-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
DEV.cpp
97 lines (86 loc) · 1.6 KB
/
DEV.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "DEV.h"
void DeviceClass::getImsi(char *buffer, uint32_t size)
{
if (buffer && size > 15)
{
memset(buffer, 0, size);
api_getIMSI(buffer);
}
}
void DeviceClass::getImsi(String &s)
{
char buffer[16];
memset(buffer, 0, 16);
api_getIMSI(buffer);
s = buffer;
}
void DeviceClass::getImei(char *buffer, uint32_t size)
{
if (buffer && size > 15)
{
memset(buffer, 0, size);
api_getIMEI(buffer);
}
}
void DeviceClass::getImei(String &s)
{
char buffer[16];
memset(buffer, 0, 16);
api_getIMEI(buffer);
s = buffer;
}
int DeviceClass::getSimStatus()
{
return api_getSimStatus(); // 0 = READY,
}
void DeviceClass::enterPin(const char *pin)
{
int res;
if (pin)
{
Dev.ril.sendf("AP+CPIN =\"%s\"", pin);
if (ril.waitForResponse() == 1)
return;
}
TRACE("[PIN] ERROR\n");
while (true)
Ql_Sleep(1000);
}
void DeviceClass::waitSimReady(const char *pin)
{
int status;
do
{
delayEx(100);
status = api_getSimStatus();
if (status == -666) // TODO status enum
enterPin(pin);
} while (0 != status);
}
void DeviceClass::waitCreg()
{
while (1)
{
int res = getCreg();
if (res == 5 || res == 1)
break;
delayEx(100);
}
}
void DeviceClass::waitCgreg()
{
while (1)
{
int res = getCgreg();
if (res == 5 || res == 1)
break;
delayEx(100);
}
}
void DeviceClass::waitCereg(){
waitCreg();
delay(200);
waitCgreg();
delay(200);
}
DeviceClass Dev;