-
Notifications
You must be signed in to change notification settings - Fork 1
/
A6call.cpp
79 lines (78 loc) · 1.6 KB
/
A6call.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
#include "Arduino.h"
#include "A6Services.h"
#include "A6Call.h"
A6CALL::A6CALL(A6GPRS& a6gprs)
{
_a6gprs = &a6gprs;
}
A6CALL::~A6CALL(){}
void A6CALL::Parse(byte buffer[],unsigned length)
{
int parm;
char *start;
if (length == 1)
return; // single trailing LF
if (strncmp(buffer,"RING",4) == 0)
_a6gprs->callState = _a6gprs->CALLER_RINGING;
if (strncmp(buffer,"ERROR",5) == 0)
{
_a6gprs->callState = _a6gprs->CALLER_RINGING;
OnPhoneEvent(DISCONNECTED,0);
}
else if (strncmp(buffer,"+CIEV:",6) == 0)
{
start = strchr(buffer,'"'); // point to begining of string
if (start)
{
start++;
if (strncmp(start,"SOUNDER\",",9) == 0)
{
start += 9;
parm = atoi(start);
if (parm == 0)
_a6gprs->callState = _a6gprs->SPEAKING;
OnPhoneEvent(SOUNDER,parm);
}
else if (strncmp(start,"CALL\",",6) == 0)
{
start += 6;
parm = atoi(start);
if (parm == 0)
_a6gprs->callState = _a6gprs->IDLE;
OnPhoneEvent(CALL,parm);
}
}
}
else if (strncmp(buffer,"+CLIP:",6) == 0)
{
start = strchr(buffer,'"'); // point to begining of string
if (start)
{
start++;
char *end = strchr(start,'"'); // point to end of number
if (end)
*end = 0;
_a6gprs->callState = _a6gprs->CALLERID;
OnDialin(start);
}
}
else if (strncmp(buffer,"+CMT:",5) == 0)
{
// extract sender
start = strchr(buffer,'"');
if (start)
{
start++;
char *end = strchr(start,'"');
*end = 0;
strcpy(smsSender,start);
}
nextLineSMS = true;
}
else if (nextLineSMS)
{
strcpy(smsbuffer,buffer);
nextLineSMS = false;
OnPhoneEvent(SMS_ARRIVED,strlen(smsbuffer));
}
}