#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 pkthanlder. 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. More... | |
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. More... | |
typedef CellularPktStatus_t(* | CellularATCommandDataSendPrefixCallback_t) (void *pCallbackContext, char *pLine, uint32_t *pBytesRead) |
Callback used to fix the stream before the send data. More... | |
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. More... | |
CellularError_t | _Cellular_LibCleanup (CellularHandle_t cellularHandle) |
One time deinitialization function. More... | |
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. More... | |
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. More... | |
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. More... | |
void | _Cellular_GenericCallback (const CellularContext_t *pContext, const char *pRawData) |
Call the network registration callback if the callback is previously set by Cellular_RegisterUrcGenericCallback. More... | |
void | _Cellular_ModemEventCallback (const CellularContext_t *pContext, CellularModemEvent_t modemEvent) |
Call the network registration callback if the callback is previously set by Cellular_RegisterModemEventCallback. More... | |
CellularError_t | _Cellular_CheckLibraryStatus (CellularContext_t *pContext) |
Check Library Status. More... | |
CellularError_t | _Cellular_TranslatePktStatus (CellularPktStatus_t status) |
Translate error code packet status to cellular Status. More... | |
CellularPktStatus_t | _Cellular_TranslateAtCoreStatus (CellularATError_t status) |
Translate Error Code AT Core status to Packet Status. More... | |
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. More... | |
CellularError_t | _Cellular_RemoveSocketData (CellularContext_t *pContext, CellularSocketHandle_t socketHandle) |
Remove the socket. More... | |
CellularError_t | _Cellular_IsValidSocket (const CellularContext_t *pContext, uint32_t sockIndex) |
Check socket index validity. More... | |
CellularSocketContext_t * | _Cellular_GetSocketData (const CellularContext_t *pContext, uint32_t sockIndex) |
Get the socket data structure with socket index. More... | |
CellularError_t | _Cellular_IsValidPdn (uint8_t contextId) |
Check PDN context index validity. More... | |
CellularError_t | _Cellular_ConvertCsqSignalRssi (int16_t csqRssi, int16_t *pRssiValue) |
Convert CSQ command returned RSSI value. More... | |
CellularError_t | _Cellular_ConvertCsqSignalBer (int16_t csqBer, int16_t *pBerValue) |
Convert CSQ command retruned BER value. More... | |
CellularError_t | _Cellular_GetModuleContext (const CellularContext_t *pContext, void **ppModuleContext) |
Get the socket data structure with socket index. More... | |
CellularError_t | _Cellular_ComputeSignalBars (CellularRat_t rat, CellularSignalInfo_t *pSignalInfo) |
Convert the signal to bar. More... | |
CellularError_t | _Cellular_GetCurrentRat (CellularContext_t *pContext, CellularRat_t *pRat) |
Return the current RAT if previously received with 3GPP AT command. More... | |
CellularPktStatus_t | _Cellular_AtcmdRequestWithCallback (CellularContext_t *pContext, CellularAtReq_t atReq) |
Send the AT command to cellular modem with default timeout. More... | |
CellularPktStatus_t | _Cellular_TimeoutAtcmdRequestWithCallback (CellularContext_t *pContext, CellularAtReq_t atReq, uint32_t timeoutMS) |
Send the AT command to cellular modem. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 retruned 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_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 inidcate 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. |