-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcall.c
39 lines (37 loc) · 1.21 KB
/
call.c
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
#include "gsm.h"
#if (_GSM_CALL_ENABLE == 1)
//#############################################################################################
bool gsm_call_answer(void)
{
if (gsm_at_sendCommand("ATA\r\n", 1000 , NULL, 0, 2, "\r\nOK\r\n", "\r\nERROR\r\n") != 1)
return false;
gsm.call.busy = 1;
return true;
}
//#############################################################################################
bool gsm_call_dial(const char* number, uint8_t waitSecond)
{
char str[32];
sprintf(str,"ATD%s;\r\n", number);
uint8_t ans = gsm_at_sendCommand(str, waitSecond * 1000 , NULL, 0, 5, "\r\nNO DIALTONE\r\n", "\r\nBUSY\r\n", "\r\nNO CARRIER\r\n", "\r\nNO ANSWER\r\n", "\r\nOK\r\n");
if (ans == 5)
{
gsm.call.busy = 1;
return true;
}
else
{
gsm_call_end();
return false;
}
}
//#############################################################################################
bool gsm_call_end(void)
{
if (gsm_at_sendCommand("ATH\r\n", 20000 , NULL, 0, 2, "\r\nOK\r\n", "\r\nERROR\r\n") != 1)
return false;
gsm.call.busy = 0;
return true;
}
//#############################################################################################
#endif