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
| void SendConstATCmd(void(*fptr2UARTx_Write_Text)(char *), char *pPtr2gUartBuffer, const char *pAtCmd, const char *pAtResponse,
const char *pAtErr, char *pCopyConst2RamBuffer, unsigned int pTimeOutSec,
unsigned int *pPtr2gUartBufferIndex, unsigned char *pPtr2gAttemptFlag, unsigned char pClearBuffersFlag) {
unsigned char lCounter = 0, lAttemptCounter = 0, lAttempt = 0, lClearBuffersFlag = 0;
lClearBuffersFlag = pClearBuffersFlag;
while(strstr(pPtr2gUartBuffer, CopyConst2Ram(pCopyConst2RamBuffer, pAtResponse)) == 0) {
(*fptr2UARTx_Write_Text)(CopyConst2Ram(pCopyConst2RamBuffer, pAtCmd));
while(lCounter < pTimeOutSec) {
Delay_ms(1000);
++lCounter;
}
*pPtr2gUartBufferIndex = 0;
lCounter = 0;
if((++lAttemptCounter > 5) || (strstr(pPtr2gUartBuffer, CopyConst2Ram(pCopyConst2RamBuffer, pAtErr)) != 0)) {
GSM_RST = 0;
Delay_ms(500);
GSM_RST = 1;
Delay_ms(4000);
lAttemptCounter = 0;
++lAttempt;
Set_Buffer(pPtr2gUartBuffer, gNullChar);
Set_Buffer(pCopyConst2RamBuffer, gNullChar);
}
if(lAttempt == 2){ *pPtr2gAttemptFlag = 1; break; }
}
if(lClearBuffersFlag) {
Set_Buffer(pPtr2gUartBuffer, gNullChar);
Set_Buffer(pCopyConst2RamBuffer, gNullChar);
}
*pPtr2gUartBufferIndex = 0;
} |