-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathztedial.cc
57 lines (46 loc) · 1.03 KB
/
ztedial.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright: (C) 2016 ESIMTEK ALL RIGHTS RESERVED
// author: Yonghua Zheng
#include "dispatchmanager.h"
#include "ztedial.h"
ZteDial::ZteDial(ZteModemManager* _manager)
: manager(_manager)
{
}
ZteDial::~ZteDial()
{
if (manager)
delete manager;
}
int ZteDial::run()
{
for (;;) {
char message[1024];
int n = DispatchManager::Get(DispatchManager::main_id, message, sizeof(message));
if (n < 0)
break;
if (!n)
continue;
char *p = message;
if (!strncmp(p, "ACTION=", 7)) {
p += 7;
if (!strncmp(p, "exit", 4))
break;
}
}
return 0;
}
bool ZteDial::dial(const char* device)
{
ZteModem* modem = ZteModem::fromDevice(device);
if (!modem)
return false;
ZteModemManager* manager = new ZteModemManager(modem);
if (!manager->ready()) {
delete modem;
return false;
}
ZteDial* dialer = new ZteDial(manager);
dialer->run();
delete dialer;
return true;
}