-
Notifications
You must be signed in to change notification settings - Fork 0
/
u_cx.c
71 lines (58 loc) · 2.31 KB
/
u_cx.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
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
/** @file
* @brief 2nd gen uConnectXpress API
*/
#include <stddef.h> // NULL, size_t etc.
#include <stdbool.h>
#include <string.h> // memcpy(), strcmp(), strcspn(), strspm()
#include <stdio.h>
#include "u_cx_log.h"
#include "u_cx.h"
/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* TYPES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* STATIC PROTOTYPES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* STATIC VARIABLES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* STATIC FUNCTIONS
* -------------------------------------------------------------- */
static void urcCallback(struct uCxAtClient *pClient, void *pTag, char *pLine, size_t lineLength,
uint8_t *pBinaryData, size_t binaryDataLen)
{
uCxHandle_t *puCxHandle = (uCxHandle_t *)pTag;
char *pParams = pLine;
size_t paramLen = lineLength;
// Start by checking where params starts. All URCs that have params will have a ':' before params
while (pParams < pLine + lineLength) {
if (*pParams == ':') {
*pParams = 0;
pParams++;
paramLen--;
break;
}
pParams++;
paramLen--;
}
U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Received URC '%s', params: '%s'", pLine, pParams);
extern int32_t uCxUrcParse(uCxHandle_t * puCxHandle, const char * pUrcName, char * pParams, size_t paramsLength);
uCxUrcParse(puCxHandle, pLine, pParams, paramLen);
}
/* ----------------------------------------------------------------
* PUBLIC FUNCTIONS
* -------------------------------------------------------------- */
void uCxInit(uCxAtClient_t *pClient, uCxHandle_t *puCxHandle)
{
memset(puCxHandle, 0, sizeof(uCxHandle_t));
puCxHandle->pAtClient = pClient;
uCxAtClientSetUrcCallback(pClient, urcCallback, puCxHandle);
}
int32_t uCxEnd(uCxHandle_t *puCxHandle)
{
return uCxAtClientCmdEnd(puCxHandle->pAtClient);
}