FreeRTOS / FreeRTOS-Cellular-Interface

FreeRTOS Cellular Interface implementation of the 3GPP TS v27.007 standard.
MIT License
85 stars 59 forks source link

[Enhancement] Raw data receive prefix parser should pass info to command callback #127

Closed tpecar-ltek closed 1 year ago

tpecar-ltek commented 1 year ago

A common idiom across all modem ports seems to be that receiving raw data via

_Cellular_TimeoutAtcmdDataRecvRequestWithCallback(), currently mostly used in Cellular_SocketRecv()

requires duplication of the prefix parsing in the actual prefix handler, example from BG96

https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Quectel-BG96/blob/c33a3628e015f88df24b21160ba9dbdabc781da1/source/cellular_bg96_api.c#L1690-L1774

and then in the callback itself, since the callback usually refers to information and / or performs checks based on info found in prefix

https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface-Reference-Quectel-BG96/blob/c33a3628e015f88df24b21160ba9dbdabc781da1/source/cellular_bg96_api.c#L1277-L1342

The prefix handler context is set by caller via pCallbackContext argument, but most ports don't make use of it.

tpecar-ltek commented 1 year ago

Upon further study, I've determined that I can use the current interface as it is.

_Cellular_TimeoutAtcmdDataRecvRequestWithCallback() sets up the pDataPrefixCBContext, which is provided to prefix handler.

One can set up the pCallbackContext (prefix handler context) and atReq->pData (parser user data) to point to same object and use that to pass info between them.