Receive binary data command relies on the port to indicate start and length of the binary data in the input stream.
Take the socket receive command of reference port BG96 for example:
AT+QIRD=11,1500
+QIRD: 4
test
OK
The binary data "test" should not be parsed by cellular interface. The port needs to indicate the start of binary data and the length in data prefix callback function.
_Cellular_TimeoutAtcmdDataRecvRequestWithCallback is cellular common API to receive binary data from modem. BG96 port make use of this API to receive binary data with the following parameters:
char * pLine,
uint32_t lineLength,
char ** ppDataStart,
uint32_t * pDataLength );
void * pData,
uint16_t dataLen );
{
.pAtRspPrefix = "+QIRD",
.respCallback = _Cellular_RecvFuncData,
.pData = ( void * ) &dataRecv,
.dataLen = bufferLength
};
atReqSocketRecv,
recvTimeout,
socketRecvDataPrefix,
NULL );
CellularPktStatus_t _Cellular_TimeoutAtcmdDataRecvRequestWithCallback(CellularContext_t *pContext, CellularAtReq_t atReq, uint32_t timeoutMS, CellularATCommandDataPrefixCallback_t pktDataPrefixCallback, void *pCallbackContext)
Send the AT command to cellular modem with data buffer response.
Definition: cellular_pkthandler.c:629
CellularPktStatus_t
packet Status Names.
Definition: cellular_types.h:338
@ CELLULAR_AT_MULTI_DATA_WO_PREFIX
Definition: cellular_types.h:366
Represents AT Command response.
Definition: cellular_types.h:483
The AT command request structure.
Definition: cellular_common.h:62
const char * pAtCmd
Definition: cellular_common.h:63
The data receive callback CellularATCommandDataPrefixCallback_t, socketRecvDataPrefix in this example, can return the following value to cellular interface library:
- CELLULAR_PKT_STATUS_OK : Cellular interface libary should keep process the input buffer. The following data in the input buffer will be regarded as binary data when ppDataStart and pDataLength is set in the function.
pLine |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
+ | Q | I | R | D | : | | 4 | \r | \n | t | e | s | t | \r | \n | O | K | \r | \n |
| ^ ppDataStart point to this address in pLine
with pDataLength is set to 4. |
The binary data will be stored in the response and passed to the AT command response callback function.
- CELLULAR_PKT_STATUS_SIZE_MISMATCH : The callback function needs more data to decide the start and length of the binary data.
- Other error : Indicate that the moden returns unexpected response.
Cellular interface library calls the response callback function, _Cellular_RecvFuncData in this example, when it successfully receives the binary data from cellular modem. The CellularATCommandResponse_t pAtResp parameter of _Cellular_RecvFuncData contains the following list in this example:
Name | pAtResp pAtResp->pItm pAtResp->
pNext->pItm
-------------| --------------------------- ------------------------- -------------------------
Member | pItm -> pNext -> pNext
| pLine = "+QIRD: 4" pLine = "test"
Represents A singly-lined list of intermediate AT responses.
Definition: cellular_types.h:473
struct CellularATCommandLine * pNext
Definition: cellular_types.h:474