#include <stdbool.h>
#include "cellular_config.h"
#include "cellular_config_defaults.h"
#include "cellular_platform.h"
#include "cellular_comm_interface.h"
#include "cellular_types.h"
#include "cellular_at_core.h"
Go to the source code of this file.
Data Structures | |
struct | CellularAtReq_t |
The AT command request structure. More... | |
struct | CellularAtDataReq_t |
The data command request structure. More... | |
struct | CellularAtParseTokenMap_t |
the URC token and URC handler mapping structure used by pkthandler. More... | |
struct | CellularSocketContext_t |
Parameters involved in sending/receiving data through sockets. More... | |
struct | CellularTokenTable_t |
Parameters to setup pktio and pkthandler token tables. More... | |
Typedefs | |
typedef void(* | CellularAtParseTokenHandler_t) (CellularContext_t *pContext, char *pInputStr) |
URC handler function. | |
typedef CellularPktStatus_t(* | CellularATCommandDataPrefixCallback_t) (void *pCallbackContext, char *pLine, uint32_t lineLength, char **pDataStart, uint32_t *pDataLength) |
Callback used to inform pktio the data start and the length of the data. | |
typedef CellularPktStatus_t(* | CellularATCommandDataSendPrefixCallback_t) (void *pCallbackContext, char *pLine, uint32_t *pBytesRead) |
Callback used to fix the stream before the send data. | |
typedef CellularPktStatus_t(* | CellularUndefinedRespCallback_t) (void *pCallbackContext, const char *pLine) |
Undefined response callback function. | |
typedef CellularPktStatus_t(* | CellularInputBufferCallback_t) (void *pInputBufferCallbackContext, char *pBuffer, uint32_t bufferLength, uint32_t *pBufferLengthHandled) |
Callback used to process input buffer. | |
Enumerations | |
enum | CellularSocketState_t { SOCKETSTATE_ALLOCATED = 0 , SOCKETSTATE_CONNECTING , SOCKETSTATE_CONNECTED , SOCKETSTATE_DISCONNECTED } |
enum representing different Socket State. More... | |
Functions | |
CellularError_t | _Cellular_LibInit (CellularHandle_t *pCellularHandle, const CellularCommInterface_t *pCommInterface, const CellularTokenTable_t *pTokenTable) |
One time initialization function. | |
CellularError_t | _Cellular_LibCleanup (CellularHandle_t cellularHandle) |
One time deinitialization function. | |
void | _Cellular_NetworkRegistrationCallback (const CellularContext_t *pContext, CellularUrcEvent_t urcEvent, const CellularServiceStatus_t *pServiceStatus) |
Call the network registration callback if the callback is previously set by Cellular_CommonRegisterUrcNetworkRegistrationEventCallback. | |
void | _Cellular_PdnEventCallback (const CellularContext_t *pContext, CellularUrcEvent_t urcEvent, uint8_t contextId) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcPdnEventCallback. | |
void | _Cellular_SignalStrengthChangedCallback (const CellularContext_t *pContext, CellularUrcEvent_t urcEvent, const CellularSignalInfo_t *pSignalInfo) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcSignalStrengthChangedCallback. | |
void | _Cellular_GenericCallback (const CellularContext_t *pContext, const char *pRawData) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcGenericCallback. | |
void | _Cellular_ModemEventCallback (const CellularContext_t *pContext, CellularModemEvent_t modemEvent) |
Call the network registration callback if the callback is previously set by Cellular_RegisterModemEventCallback. | |
CellularError_t | _Cellular_CheckLibraryStatus (CellularContext_t *pContext) |
Check Library Status. | |
CellularError_t | _Cellular_TranslatePktStatus (CellularPktStatus_t status) |
Translate error code packet status to cellular Status. | |
CellularPktStatus_t | _Cellular_TranslateAtCoreStatus (CellularATError_t status) |
Translate Error Code AT Core status to Packet Status. | |
CellularError_t | _Cellular_CreateSocketData (CellularContext_t *pContext, uint8_t contextId, CellularSocketDomain_t socketDomain, CellularSocketType_t socketType, CellularSocketProtocol_t socketProtocol, CellularSocketHandle_t *pSocketHandle) |
Create a socket. | |
CellularError_t | _Cellular_RemoveSocketData (CellularContext_t *pContext, CellularSocketHandle_t socketHandle) |
Remove the socket. | |
CellularError_t | _Cellular_IsValidSocket (const CellularContext_t *pContext, uint32_t sockIndex) |
Check socket index validity. | |
CellularSocketContext_t * | _Cellular_GetSocketData (const CellularContext_t *pContext, uint32_t sockIndex) |
Get the socket data structure with socket index. | |
CellularError_t | _Cellular_IsValidPdn (uint8_t contextId) |
Check PDN context index validity. | |
CellularError_t | _Cellular_ConvertCsqSignalRssi (int16_t csqRssi, int16_t *pRssiValue) |
Convert CSQ command returned RSSI value. | |
CellularError_t | _Cellular_ConvertCsqSignalBer (int16_t csqBer, int16_t *pBerValue) |
Convert CSQ command returned BER value. | |
CellularError_t | _Cellular_GetModuleContext (const CellularContext_t *pContext, void **ppModuleContext) |
Get the socket data structure with socket index. | |
CellularError_t | _Cellular_ComputeSignalBars (CellularRat_t rat, CellularSignalInfo_t *pSignalInfo) |
Convert the signal to bar. | |
CellularError_t | _Cellular_GetCurrentRat (CellularContext_t *pContext, CellularRat_t *pRat) |
Return the current RAT if previously received with 3GPP AT command. | |
CellularPktStatus_t | _Cellular_AtcmdRequestWithCallback (CellularContext_t *pContext, CellularAtReq_t atReq) |
Send the AT command to cellular modem with default timeout. | |
CellularPktStatus_t | _Cellular_TimeoutAtcmdRequestWithCallback (CellularContext_t *pContext, CellularAtReq_t atReq, uint32_t timeoutMS) |
Send the AT command to cellular modem. | |
CellularPktStatus_t | _Cellular_AtcmdRequestSuccessToken (CellularContext_t *pContext, CellularAtReq_t atReq, uint32_t atTimeoutMS, const char **pCellularSrcTokenSuccessTable, uint32_t cellularSrcTokenSuccessTableSize) |
Send the AT command to cellular modem with extra success token table. | |
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. | |
CellularPktStatus_t | _Cellular_TimeoutAtcmdDataSendRequestWithCallback (CellularContext_t *pContext, CellularAtReq_t atReq, CellularAtDataReq_t dataReq, uint32_t atTimeoutMS, uint32_t dataTimeoutMS) |
Send the AT command to cellular modem with send data. | |
CellularPktStatus_t | _Cellular_AtcmdDataSend (CellularContext_t *pContext, CellularAtReq_t atReq, CellularAtDataReq_t dataReq, CellularATCommandDataSendPrefixCallback_t pktDataSendPrefixCallback, void *pCallbackContext, uint32_t atTimeoutMS, uint32_t dataTimeoutMS, uint32_t interDelayMS) |
Send the AT command to cellular modem with send data. | |
CellularPktStatus_t | _Cellular_TimeoutAtcmdDataSendSuccessToken (CellularContext_t *pContext, CellularAtReq_t atReq, CellularAtDataReq_t dataReq, uint32_t atTimeoutMS, uint32_t dataTimeoutMS, const char **pCellularSrcTokenSuccessTable, uint32_t cellularSrcTokenSuccessTableSize) |
Send the AT command to cellular modem with send data and extra success token table. | |
CellularError_t | _Cellular_RegisterUndefinedRespCallback (CellularContext_t *pContext, CellularUndefinedRespCallback_t undefinedRespCallback, void *pCallbackContext) |
Register undefined response callback. | |
CellularError_t | _Cellular_RegisterInputBufferCallback (CellularContext_t *pContext, CellularInputBufferCallback_t inputBufferCallback, void *pInputBufferCallbackContext) |
Register input buffer callback. | |
typedef void(* CellularAtParseTokenHandler_t) (CellularContext_t *pContext, char *pInputStr) |
URC handler function.
typedef CellularPktStatus_t(* CellularATCommandDataPrefixCallback_t) (void *pCallbackContext, char *pLine, uint32_t lineLength, char **pDataStart, uint32_t *pDataLength) |
Callback used to inform pktio the data start and the length of the data.
[in] | pCallbackContext | The pCallbackContext in _Cellular_TimeoutAtcmdDataRecvRequestWithCallback. |
[in] | pLine | The input line form cellular modem. |
[in] | lineLength | The length of the input line from cellular modem. |
[out] | pDataStart | Is the start of of data in pLine. |
[out] | pDataLength | Is the data length. |
typedef CellularPktStatus_t(* CellularATCommandDataSendPrefixCallback_t) (void *pCallbackContext, char *pLine, uint32_t *pBytesRead) |
Callback used to fix the stream before the send data.
[in] | pCallbackContext | The pCallbackContext in CellularATCommandDataSendPrefixCallback_t. |
[in,out] | pLine | The input line form cellular modem. |
[in,out] | pBytesRead | The length of the input line from cellular modem. |
typedef CellularPktStatus_t(* CellularUndefinedRespCallback_t) (void *pCallbackContext, const char *pLine) |
Undefined response callback function.
[in] | pCallbackContext | The pCallbackContext parameter in _Cellular_RegisterUndefinedRespCallback. |
[in] | pLine | The input line form cellular modem. |
typedef CellularPktStatus_t(* CellularInputBufferCallback_t) (void *pInputBufferCallbackContext, char *pBuffer, uint32_t bufferLength, uint32_t *pBufferLengthHandled) |
Callback used to process input buffer.
[in] | pInputBufferCallbackContext | The pCallbackContext in CellularInputBufferCallback_t. |
[in] | pBuffer | The data buffer with modem response data. |
[in] | bufferLength | The length of the input buffer. |
[out] | pBufferLengthHandled | The length of the handled input buffer in pBuffer. |
CellularError_t _Cellular_LibInit | ( | CellularHandle_t * | pCellularHandle, |
const CellularCommInterface_t * | pCommInterface, | ||
const CellularTokenTable_t * | pTokenTable | ||
) |
One time initialization function.
This function initializes and returns the supplied context. It must be called once (and only once) before calling any other function of this library.
[in,out] | pCellularHandle | The handle pointer to store the cellular handle. |
[in] | pCommInterface | Comm interface for communicating with the module. |
[in] | pTokenTable | Token tables for pkthandler and pktio. |
CellularError_t _Cellular_LibCleanup | ( | CellularHandle_t | cellularHandle | ) |
One time deinitialization function.
This function frees resources taken in Cellular_Init. After this function returns, Cellular_Init must be called again before calling any other function of this library.
[in] | cellularHandle | The opaque cellular context pointer created by Cellular_Init. |
void _Cellular_NetworkRegistrationCallback | ( | const CellularContext_t * | pContext, |
CellularUrcEvent_t | urcEvent, | ||
const CellularServiceStatus_t * | pServiceStatus | ||
) |
Call the network registration callback if the callback is previously set by Cellular_CommonRegisterUrcNetworkRegistrationEventCallback.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | urcEvent | URC Event that happened. |
[in] | pServiceStatus | The status of the network service. |
void _Cellular_PdnEventCallback | ( | const CellularContext_t * | pContext, |
CellularUrcEvent_t | urcEvent, | ||
uint8_t | contextId | ||
) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcPdnEventCallback.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | urcEvent | URC Event that happened. |
[in] | contextId | Context ID of the PDN context. |
void _Cellular_SignalStrengthChangedCallback | ( | const CellularContext_t * | pContext, |
CellularUrcEvent_t | urcEvent, | ||
const CellularSignalInfo_t * | pSignalInfo | ||
) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcSignalStrengthChangedCallback.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | urcEvent | URC Event that happened. |
[in] | pSignalInfo | The new signal information. |
void _Cellular_GenericCallback | ( | const CellularContext_t * | pContext, |
const char * | pRawData | ||
) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcGenericCallback.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | pRawData | Raw data received in the URC event. |
void _Cellular_ModemEventCallback | ( | const CellularContext_t * | pContext, |
CellularModemEvent_t | modemEvent | ||
) |
Call the network registration callback if the callback is previously set by Cellular_RegisterModemEventCallback.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | modemEvent | The modem event. |
CellularError_t _Cellular_CheckLibraryStatus | ( | CellularContext_t * | pContext | ) |
Check Library Status.
This Functions checks if the FreeRTOS Cellular Library is already opened and set up for cellular modem operation for control and data plane function.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
CellularError_t _Cellular_TranslatePktStatus | ( | CellularPktStatus_t | status | ) |
Translate error code packet status to cellular Status.
This Functions translates packet status to cellular Status.
[in] | status | The packet status to translate. |
CellularPktStatus_t _Cellular_TranslateAtCoreStatus | ( | CellularATError_t | status | ) |
Translate Error Code AT Core status to Packet Status.
This Functions translates AT Core status to Packet Status.
[in] | status | The AT Core status to translate. |
CellularError_t _Cellular_CreateSocketData | ( | CellularContext_t * | pContext, |
uint8_t | contextId, | ||
CellularSocketDomain_t | socketDomain, | ||
CellularSocketType_t | socketType, | ||
CellularSocketProtocol_t | socketProtocol, | ||
CellularSocketHandle_t * | pSocketHandle | ||
) |
Create a socket.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | contextId | Pdn context id on which this socket needs to be created. |
[in] | socketDomain | Socket domain. |
[in] | socketType | Socket Type. |
[in] | socketProtocol | Socket Protocol. |
[out] | pSocketHandle | Out parameter to provide the created handle. |
CellularError_t _Cellular_RemoveSocketData | ( | CellularContext_t * | pContext, |
CellularSocketHandle_t | socketHandle | ||
) |
Remove the socket.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | socketHandle | Socket handle returned from the Cellular_CreateSocket call. |
CellularError_t _Cellular_IsValidSocket | ( | const CellularContext_t * | pContext, |
uint32_t | sockIndex | ||
) |
Check socket index validity.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | sockIndex | Socket index returned from cellular modem. |
CellularSocketContext_t * _Cellular_GetSocketData | ( | const CellularContext_t * | pContext, |
uint32_t | sockIndex | ||
) |
Get the socket data structure with socket index.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | sockIndex | Socket index returned from cellular modem. |
CellularError_t _Cellular_IsValidPdn | ( | uint8_t | contextId | ) |
Check PDN context index validity.
[in] | contextId | The PDN context index to check. |
CellularError_t _Cellular_ConvertCsqSignalRssi | ( | int16_t | csqRssi, |
int16_t * | pRssiValue | ||
) |
Convert CSQ command returned RSSI value.
[in] | csqRssi | The CSQ command returned RSSI index. |
[out] | pRssiValue | The output parameter to return the converted RSSI value in dBm. |
CellularError_t _Cellular_ConvertCsqSignalBer | ( | int16_t | csqBer, |
int16_t * | pBerValue | ||
) |
Convert CSQ command returned BER value.
[in] | csqBer | The CSQ command returned BER index. |
[out] | pBerValue | The output parameter to return the converted BER value in 0.01%. |
CellularError_t _Cellular_GetModuleContext | ( | const CellularContext_t * | pContext, |
void ** | ppModuleContext | ||
) |
Get the socket data structure with socket index.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[out] | ppModuleContext | The module context set in Cellular_ModuleInit function. |
CellularError_t _Cellular_ComputeSignalBars | ( | CellularRat_t | rat, |
CellularSignalInfo_t * | pSignalInfo | ||
) |
Convert the signal to bar.
[in] | rat | Current RAT of the registered network. |
[in,out] | pSignalInfo | The signal value of current RAT. The result bar value is assigned in this structure. |
CellularError_t _Cellular_GetCurrentRat | ( | CellularContext_t * | pContext, |
CellularRat_t * | pRat | ||
) |
Return the current RAT if previously received with 3GPP AT command.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[out] | pRat | Current RAT of the registered network. |
CellularPktStatus_t _Cellular_AtcmdRequestWithCallback | ( | CellularContext_t * | pContext, |
CellularAtReq_t | atReq | ||
) |
Send the AT command to cellular modem with default timeout.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
CellularPktStatus_t _Cellular_TimeoutAtcmdRequestWithCallback | ( | CellularContext_t * | pContext, |
CellularAtReq_t | atReq, | ||
uint32_t | timeoutMS | ||
) |
Send the AT command to cellular modem.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
[in] | timeoutMS | The timeout value to wait for the response from cellular modem. |
CellularPktStatus_t _Cellular_AtcmdRequestSuccessToken | ( | CellularContext_t * | pContext, |
CellularAtReq_t | atReq, | ||
uint32_t | atTimeoutMS, | ||
const char ** | pCellularSrcTokenSuccessTable, | ||
uint32_t | cellularSrcTokenSuccessTableSize | ||
) |
Send the AT command to cellular modem with extra success token table.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
[in] | atTimeoutMS | The timeout value to wait for the AT command response from cellular modem. |
[in] | pCellularSrcTokenSuccessTable | The extra success token table to indicate the send AT command success. |
[in] | cellularSrcTokenSuccessTableSize | The size of extra success token table. |
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.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
[in] | timeoutMS | The timeout value to wait for the response from cellular modem. |
[in] | pktDataPrefixCallback | The callback function to indicate the start of data and the length of data. |
[in] | pCallbackContext | The pCallbackContext passed to the pktDataPrefixCallback callback function. |
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendRequestWithCallback | ( | CellularContext_t * | pContext, |
CellularAtReq_t | atReq, | ||
CellularAtDataReq_t | dataReq, | ||
uint32_t | atTimeoutMS, | ||
uint32_t | dataTimeoutMS | ||
) |
Send the AT command to cellular modem with send data.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
[in] | dataReq | The following data request after the at request. |
[in] | atTimeoutMS | The timeout value to wait for the AT command response from cellular modem. |
[in] | dataTimeoutMS | The timeout value to wait for the data command response from cellular modem. |
CellularPktStatus_t _Cellular_AtcmdDataSend | ( | CellularContext_t * | pContext, |
CellularAtReq_t | atReq, | ||
CellularAtDataReq_t | dataReq, | ||
CellularATCommandDataSendPrefixCallback_t | pktDataSendPrefixCallback, | ||
void * | pCallbackContext, | ||
uint32_t | atTimeoutMS, | ||
uint32_t | dataTimeoutMS, | ||
uint32_t | interDelayMS | ||
) |
Send the AT command to cellular modem with send data.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
[in] | dataReq | The following data request after the at request. |
[in] | pktDataSendPrefixCallback | The callback function to indicate the data sending start. |
[in] | pCallbackContext | The callback context pass to pktDataSendPrefixCallback function. |
[in] | atTimeoutMS | The timeout value to wait for the AT command response from cellular modem. |
[in] | dataTimeoutMS | The timeout value to wait for the data command response from cellular modem. |
[in] | interDelayMS | The delay between AT command and data send. |
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendSuccessToken | ( | CellularContext_t * | pContext, |
CellularAtReq_t | atReq, | ||
CellularAtDataReq_t | dataReq, | ||
uint32_t | atTimeoutMS, | ||
uint32_t | dataTimeoutMS, | ||
const char ** | pCellularSrcTokenSuccessTable, | ||
uint32_t | cellularSrcTokenSuccessTableSize | ||
) |
Send the AT command to cellular modem with send data and extra success token table.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | atReq | The AT command data structure with send command response callback. |
[in] | dataReq | The following data request after the at request. |
[in] | atTimeoutMS | The timeout value to wait for the AT command response from cellular modem. |
[in] | dataTimeoutMS | The timeout value to wait for the data command response from cellular modem. |
[in] | pCellularSrcTokenSuccessTable | The extra success token table to indicate the send AT command success. |
[in] | cellularSrcTokenSuccessTableSize | The size of extra success token table. |
CellularError_t _Cellular_RegisterUndefinedRespCallback | ( | CellularContext_t * | pContext, |
CellularUndefinedRespCallback_t | undefinedRespCallback, | ||
void * | pCallbackContext | ||
) |
Register undefined response callback.
Cellular module can register the callback function to handle AT_UNDEFINED response through this function.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | undefinedRespCallback | The callback function to handle the undefined response. |
[in] | pCallbackContext | The pCallbackContext passed to the undefinedRespCallback callback function if undefinedRespCallback is not NULL. |
CellularError_t _Cellular_RegisterInputBufferCallback | ( | CellularContext_t * | pContext, |
CellularInputBufferCallback_t | inputBufferCallback, | ||
void * | pInputBufferCallbackContext | ||
) |
Register input buffer callback.
Cellular module can register the callback function to handler the input buffer before pktio continue to process the line in the buffer.
[in] | pContext | The opaque cellular context pointer created by Cellular_Init. |
[in] | inputBufferCallback | The callback function to handle the URC data. |
[in] | pInputBufferCallbackContext | The pInputBufferCallbackContext passed to the inputBufferCallback callback function if inputBufferCallback is not NULL. |