[修改] 增加freeRTOS

1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
2023-05-06 16:43:01 +00:00
commit a345df017b
20944 changed files with 11094377 additions and 0 deletions

View File

@ -0,0 +1,646 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_api.h
*/
#ifndef __CELLULAR_API_H__
#define __CELLULAR_API_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* IoT Cellular data types. */
#include "cellular_types.h"
/* Hardware interface. */
#include "cellular_comm_interface.h"
/**
* @brief 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.
*
* @param[in,out] pCellularHandle the handle pointer to store the cellular handle.
* @param[in] pCommInterface Comm interface for communicating with the module.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_Init( CellularHandle_t * pCellularHandle,
const CellularCommInterface_t * pCommInterface );
/**
* @brief 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.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_Cleanup( CellularHandle_t cellularHandle );
/**
* @brief Configure the priority order in which the networks are searched.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pRatPriorities An array of RATs in priority order. For example, to
* search NB-IoT first, then Cat-M1 and then LTE, the array should contain:
* { CELLULAR_RAT_NBIOT, CELLULAR_RAT_CATM1, CELLULAR_RAT_LTE }.
* @param[in] ratPrioritiesLength Length of the pRatPriorities array.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SetRatPriority( CellularHandle_t cellularHandle,
const CellularRat_t * pRatPriorities,
uint8_t ratPrioritiesLength );
/**
* @brief Get the priority order in which the networks are searched.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pRatPriorities An array of current RATs in priority order.
* @param[in] ratPrioritiesLength Length of the pRatPriorities array.
* @param[out] pOutputRatPrioritiesLength Actual number of items filled into pRatPriorities
* by this function when it returns.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetRatPriority( CellularHandle_t cellularHandle,
CellularRat_t * pRatPriorities,
uint8_t ratPrioritiesLength,
uint8_t * pOutputRatPrioritiesLength );
/**
* @brief Turn on RF i.e. turn-off airplane mode.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RfOn( CellularHandle_t cellularHandle );
/**
* @brief Turn off RF i.e. turn-on airplane mode.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RfOff( CellularHandle_t cellularHandle );
/**
* @brief Get SIM card status (activated/Pin set etc.).
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pSimCardStatus Out parameter to provide the SIM card status.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetSimCardStatus( CellularHandle_t cellularHandle,
CellularSimCardStatus_t * pSimCardStatus );
/**
* @brief Get SIM card information (IMSI, SIM Card number etc.).
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pSimCardInfo Out parameter to provide the SIM card information.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetSimCardInfo( CellularHandle_t cellularHandle,
CellularSimCardInfo_t * pSimCardInfo );
/**
* @brief Get the information about the modem (HW version, FW version etc.).
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pModemInfo Out parameter to provide the modem information.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetModemInfo( CellularHandle_t cellularHandle,
CellularModemInfo_t * pModemInfo );
/**
* @brief Get the network on which SIM is currently registered/camped.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pNetworkInfo Out parameter to provide the network information.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetRegisteredNetwork( CellularHandle_t cellularHandle,
CellularPlmnInfo_t * pNetworkInfo );
/**
* @brief Get the network time.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pNetworkTime Out parameter to provide the network time.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetNetworkTime( CellularHandle_t cellularHandle,
CellularTime_t * pNetworkTime );
/**
* @brief Get signal information.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pSignalInfo Out parameter to provide the signal information.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetSignalInfo( CellularHandle_t cellularHandle,
CellularSignalInfo_t * pSignalInfo );
/**
* @brief Get network service status.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pServiceStatus Out parameter to provide the service status.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetServiceStatus( CellularHandle_t cellularHandle,
CellularServiceStatus_t * pServiceStatus );
/**
* @brief Set PDN config for a PDN context.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Context ID of the PDN to set the config for. Context ID value
* should be in range between CELLULAR_PDN_CONTEXT_ID_MIN and CELLULAR_PDN_CONTEXT_ID_MAX.
* The context ID with specified PDN config will be used with other CELLULAR APIs.
* @param[in] pPdnConfig PDN config to set.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SetPdnConfig( CellularHandle_t cellularHandle,
uint8_t contextId,
const CellularPdnConfig_t * pPdnConfig );
/**
* @brief Get status reports for all PDN contexts.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pPdnStatusBuffers Out parameter to provide array of PDN contexts.
* @param[in] numStatusBuffers Number of CellularPdnStatus_t buffers in the
* provided array pPdnStatusBuffers.
* @param[out] pNumStatus Out parameter to provide the number of PDN statuses
* returned.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetPdnStatus( CellularHandle_t cellularHandle,
CellularPdnStatus_t * pPdnStatusBuffers,
uint8_t numStatusBuffers,
uint8_t * pNumStatus );
/**
* @brief Activate a PDN context.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Context ID of the PDN context to activate. The same context ID
* should be used with Cellular_SetPdnConfig before calling this API.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_ActivatePdn( CellularHandle_t cellularHandle,
uint8_t contextId );
/**
* @brief Deactivate a PDN context.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Context ID of the PDN context to deactivate.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_DeactivatePdn( CellularHandle_t cellularHandle,
uint8_t contextId );
/**
* @brief Get the IP Address assigned to the module.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Context ID of the PDN context for which IP address is requested.
* @param[out] pBuffer the buffer to receive the IP address into. The returned pBuffer
* is a NULL terminated string.
* @param[in] bufferLength of the buffer pBuffer.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetIPAddress( CellularHandle_t cellularHandle,
uint8_t contextId,
char * pBuffer,
uint32_t bufferLength );
/**
* @brief Set the DNS server to use.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Context ID of the PDN context for which DNS needs to be set.
* @param[in] pDnsServerAddress The address of the DNS server to set.
* It should be a NULL terminated string.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SetDns( CellularHandle_t cellularHandle,
uint8_t contextId,
const char * pDnsServerAddress );
/**
* @brief Register/Remove callback for Network Registration URC events.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] networkRegistrationCallback The callback to register. Set to NULL
* to remove the existing callback.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RegisterUrcNetworkRegistrationEventCallback( CellularHandle_t cellularHandle,
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback,
void * pCallbackContext );
/**
* @brief Register/Remove callback for PDN related URC events.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pdnEventCallback The callback to register. Set to NULL remove the
* existing callback.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RegisterUrcPdnEventCallback( CellularHandle_t cellularHandle,
CellularUrcPdnEventCallback_t pdnEventCallback,
void * pCallbackContext );
/**
* @brief Register callback for Signal Strength changed URC events.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] signalStrengthChangedCallback The callback to register. Set to
* NULL to remove the existing callback.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RegisterUrcSignalStrengthChangedCallback( CellularHandle_t cellularHandle,
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback,
void * pCallbackContext );
/**
* @brief Register callback for all modem related events.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] modemEventCallback The callback to register. Set to NULL to remove
* the existing callback.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RegisterModemEventCallback( CellularHandle_t cellularHandle,
CellularModemEventCallback_t modemEventCallback,
void * pCallbackContext );
/**
* @brief Register generic callback for all other URC events than covered in
* above callbacks.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] genericCallback The callback to register. Set to NULL to remove
* the existing callback.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_RegisterUrcGenericCallback( CellularHandle_t cellularHandle,
CellularUrcGenericCallback_t genericCallback,
void * pCallbackContext );
/**
* @brief Get current PSM settings.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pPsmSettings Out parameter to provide the PSM settings.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetPsmSettings( CellularHandle_t cellularHandle,
CellularPsmSettings_t * pPsmSettings );
/**
* @brief Set PSM settings.
*
* Enable/disable PSM by using CellularPsmSettings_t structure.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pPsmSettings PSM settings to set.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SetPsmSettings( CellularHandle_t cellularHandle,
const CellularPsmSettings_t * pPsmSettings );
/**
* @brief Get current e-I-DRX settings.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pEidrxSettingsList Out parameter to provide the e-I-DRX settings.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetEidrxSettings( CellularHandle_t cellularHandle,
CellularEidrxSettingsList_t * pEidrxSettingsList );
/**
* @brief Set e-I-DRX settings.
*
* This API can be used to enable/disable e-I-DRX by using the mode member of
* CellularEidrxSettings_t.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pEidrxSettings e-I-DRX settings to set.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SetEidrxSettings( CellularHandle_t cellularHandle,
const CellularEidrxSettings_t * pEidrxSettings );
/**
* @brief Send the raw AT command to the module.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pATCommandPrefix The AT command response prefix. NULL if the response
* has no prefix.
* @param[in] pATCommandPayload The AT command to send. It should be a NULL terminated
* string.
* @param[in] atCommandType Type of AT command.
* @param[in] responseReceivedCallback Callback to be invoked when a response for the
* command is received.
* @param[in] pData The pData pointer will be passed in responseReceivedCallback.
* @param[in] dataLen The dataLen value will be passed in responseReceivedCallback.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_ATCommandRaw( CellularHandle_t cellularHandle,
const char * pATCommandPrefix,
const char * pATCommandPayload,
CellularATCommandType_t atCommandType,
CellularATCommandResponseReceivedCallback_t responseReceivedCallback,
void * pData,
uint16_t dataLen );
/**
* @brief Create a socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pdnContextId pdn context id on which this socket needs to be created. The pdn
* context must be previously activated by Cellular_ActivatePdn function.
* @param[in] socketDomain Socket domain.
* @param[in] socketType Socket Type.
* @param[in] socketProtocol Socket Protocol.
* @param[out] pSocketHandle Out parameter to provide the created handle.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_CreateSocket( CellularHandle_t cellularHandle,
uint8_t pdnContextId,
CellularSocketDomain_t socketDomain,
CellularSocketType_t socketType,
CellularSocketProtocol_t socketProtocol,
CellularSocketHandle_t * pSocketHandle );
/**
* @brief Connect to a remote socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[in] dataAccessMode Data access mode of the socket. Buffer, Direct Push or Transparent.
* @param[in] pRemoteSocketAddress Address (IP and Port) of the remote socket to connect to.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketConnect( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketAccessMode_t dataAccessMode,
const CellularSocketAddress_t * pRemoteSocketAddress );
/**
* @brief Send data to the connected remote socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[in] pData The buffer containing that data to be sent.
* @param[in] dataLength Length of the data in the pData buffer.
* @param[out] pSentDataLength Out parameter to provide the length of the actual
* data sent. Note that it may be less than the dataLength in case complete data
* could not be sent.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketSend( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
const uint8_t * pData,
uint32_t dataLength,
uint32_t * pSentDataLength );
/**
* @brief Receive data on a connected socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[out] pBuffer The buffer to receive the data into.
* @param[in] bufferLength Length of the buffer pBuffer.
* @param[out] pReceivedDataLength Out parameter to provide the of the actual
* data received in the buffer pBuffer. Note that it may be less than
* bufferLength.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketRecv( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
uint8_t * pBuffer,
uint32_t bufferLength,
uint32_t * pReceivedDataLength );
/**
* @brief Close the socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketClose( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle );
/**
* @brief Resolve a host name using Domain Name Service.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Context ID of the PDN context for which DNS is set.
* @param[in] pcHostName The host name to resolve.
* It should be a NULL terminated string.
* The length of the string should not exceed RFC1035 defined.
* @param[out] pResolvedAddress The output parameter to return the resolved
* address. The length of this buffer should be at least CELLULAR_IP_ADDRESS_MAX_SIZE.
* The returned buffer is a NULL terminated string.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_GetHostByName( CellularHandle_t cellularHandle,
uint8_t contextId,
const char * pcHostName,
char * pResolvedAddress );
/**
* @brief Set options for a socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[in] optionLevel Socket option level (IP or TCP/UDP).
* @param[in] option Socket option to set.
* @param[in] pOptionValue Buffer containing the socket option value.
* @param[in] optionValueLength Length of the value pointed to by pOptionValue.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketSetSockOpt( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketOptionLevel_t optionLevel,
CellularSocketOption_t option,
const uint8_t * pOptionValue,
uint32_t optionValueLength );
/**
* @brief Register Socket open callback on the socket.
*
* This callback is invoked when modem confirms that a socket is opened.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[in] socketOpenCallback The callback to register.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketRegisterSocketOpenCallback( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketOpenCallback_t socketOpenCallback,
void * pCallbackContext );
/**
* @brief Register data ready callback on the socket.
*
* This callback is invoked whenever data is ready to be read from the socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[in] dataReadyCallback The callback to register.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketRegisterDataReadyCallback( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketDataReadyCallback_t dataReadyCallback,
void * pCallbackContext );
/**
* @brief Register closed callback on the socket.
*
* This callback is invoked whenever remote end closes the connection on a
* connected socket.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
* @param[in] closedCallback The callback to register.
* @param[in] pCallbackContext The context to be passed to callback function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_SocketRegisterClosedCallback( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketClosedCallback_t closedCallback,
void * pCallbackContext );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_API_H__ */

View File

@ -0,0 +1,480 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_config_defaults.h
* @brief This represents the default values for the configuration macros
* for the Cellular library.
*
* @note This file SHOULD NOT be modified. If custom values are needed for
* any configuration macro, a cellular_config.h file should be provided to
* the Cellular library to override the default values defined in this file.
* To use the custom config file, the CELLULAR_DO_NOT_USE_CUSTOM_CONFIG preprocessor
* macro SHOULD NOT be set.
*/
#ifndef __CELLULAR_CONFIG_DEFAULTS_H__
#define __CELLULAR_CONFIG_DEFAULTS_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* The macro definition for CELLULAR_DO_NOT_USE_CUSTOM_CONFIG is for Doxygen
* documentation only. */
/**
* @brief Define this macro to build the Cellular library without the custom config
* file cellular_config.h.
*
* Without the custom config, the Cellular library builds with
* default values of config macros defined in cellular_config_defaults.h file.
*
* If a custom config is provided, then CELLULAR_DO_NOT_USE_CUSTOM_CONFIG should not
* be defined.
*/
#ifdef DOXYGEN
#define CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
#endif
/**
* @brief Mobile country code max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 3
*/
#ifndef CELLULAR_MCC_MAX_SIZE
#define CELLULAR_MCC_MAX_SIZE ( 3U )
#endif
/**
* @brief Mobile network code max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 3
*/
#ifndef CELLULAR_MNC_MAX_SIZE
#define CELLULAR_MNC_MAX_SIZE ( 3U )
#endif
/**
* @brief Integrate circuit card identity max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 20
*/
#ifndef CELLULAR_ICCID_MAX_SIZE
#define CELLULAR_ICCID_MAX_SIZE ( 20U )
#endif
/**
* @brief International Mobile Subscriber Identity max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 15
*/
#ifndef CELLULAR_IMSI_MAX_SIZE
#define CELLULAR_IMSI_MAX_SIZE ( 15U )
#endif
/**
* @brief Cellular module firmware version max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 32
*/
#ifndef CELLULAR_FW_VERSION_MAX_SIZE
#define CELLULAR_FW_VERSION_MAX_SIZE ( 32U )
#endif
/**
* @brief Cellular module hardware version max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 12
*/
#ifndef CELLULAR_HW_VERSION_MAX_SIZE
#define CELLULAR_HW_VERSION_MAX_SIZE ( 12U )
#endif
/**
* @brief Cellular module serial number max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 12
*/
#ifndef CELLULAR_SERIAL_NUM_MAX_SIZE
#define CELLULAR_SERIAL_NUM_MAX_SIZE ( 12U )
#endif
/**
* @brief International Mobile Equipment Identity number max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 15
*/
#ifndef CELLULAR_IMEI_MAX_SIZE
#define CELLULAR_IMEI_MAX_SIZE ( 15U )
#endif
/**
* @brief Registered network operator name max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 32
*/
#ifndef CELLULAR_NETWORK_NAME_MAX_SIZE
#define CELLULAR_NETWORK_NAME_MAX_SIZE ( 32U )
#endif
/**
* @brief Access point name max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 32
*/
#ifndef CELLULAR_APN_MAX_SIZE
#define CELLULAR_APN_MAX_SIZE ( 64U )
#endif
/**
* @brief Packet data network username max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 32
*/
#ifndef CELLULAR_PDN_USERNAME_MAX_SIZE
#define CELLULAR_PDN_USERNAME_MAX_SIZE ( 32U )
#endif
/**
* @brief Packet data network password max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 32
*/
#ifndef CELLULAR_PDN_PASSWORD_MAX_SIZE
#define CELLULAR_PDN_PASSWORD_MAX_SIZE ( 32u )
#endif
/**
* @brief Cellular data network IP address max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 40
*/
#ifndef CELLULAR_IP_ADDRESS_MAX_SIZE
#define CELLULAR_IP_ADDRESS_MAX_SIZE ( 40U )
#endif
/**
* @brief Cellular AT command max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 200
*/
#ifndef CELLULAR_AT_CMD_MAX_SIZE
#define CELLULAR_AT_CMD_MAX_SIZE ( 200U )
#endif
/**
* @brief Cellular module number of socket max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 12
*/
#ifndef CELLULAR_NUM_SOCKET_MAX
#define CELLULAR_NUM_SOCKET_MAX ( 12U )
#endif
/**
* @brief Cellular module manufacture ID max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 20
*/
#ifndef CELLULAR_MANUFACTURE_ID_MAX_SIZE
#define CELLULAR_MANUFACTURE_ID_MAX_SIZE ( 20U )
#endif
/**
* @brief Cellular module ID max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 10
*/
#ifndef CELLULAR_MODEL_ID_MAX_SIZE
#define CELLULAR_MODEL_ID_MAX_SIZE ( 10U )
#endif
/**
* @brief Cellular EDRX list max size.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 4
*/
#ifndef CELLULAR_EDRX_LIST_MAX_SIZE
#define CELLULAR_EDRX_LIST_MAX_SIZE ( 4U )
#endif
/**
* @brief Cellular PDN context ID min value.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1
*/
#ifndef CELLULAR_PDN_CONTEXT_ID_MIN
#define CELLULAR_PDN_CONTEXT_ID_MIN ( 1U )
#endif
/**
* @brief Cellular PDN context ID max value.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1
*/
#ifndef CELLULAR_PDN_CONTEXT_ID_MAX
#define CELLULAR_PDN_CONTEXT_ID_MAX ( 16U )
#endif
/**
* @brief Cellular RAT ( radio access technology ) priority count.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1
*/
#ifndef CELLULAR_MAX_RAT_PRIORITY_COUNT
#define CELLULAR_MAX_RAT_PRIORITY_COUNT ( 3U )
#endif
/**
* @brief Cellular socket max send data length.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1460
*/
#ifndef CELLULAR_MAX_SEND_DATA_LEN
#define CELLULAR_MAX_SEND_DATA_LEN ( 1460U )
#endif
/**
* @brief Cellular socket max receive data length.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1500
*/
#ifndef CELLULAR_MAX_RECV_DATA_LEN
#define CELLULAR_MAX_RECV_DATA_LEN ( 1500U )
#endif
/**
* @brief Cellular module support getHostByName.<br>
*
* <b>Possible values:</b>`0 or 1`<br>
* <b>Default value (if undefined):</b> 1
*/
#ifndef CELLULAR_SUPPORT_GETHOSTBYNAME
#define CELLULAR_SUPPORT_GETHOSTBYNAME ( 1U )
#endif
/**
* @brief Cellular comm interface send timeout in MS.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1000
*/
#ifndef CELLULAR_COMM_IF_SEND_TIMEOUT_MS
#define CELLULAR_COMM_IF_SEND_TIMEOUT_MS ( 1000U )
#endif
/**
* @brief Cellular comm interface receive timeout in MS.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 1000
*/
#ifndef CELLULAR_COMM_IF_RECV_TIMEOUT_MS
#define CELLULAR_COMM_IF_RECV_TIMEOUT_MS ( 1000U )
#endif
/**
* @brief FreeRTOS Cellular Library use static context.<br>
*
* <b>Possible values:</b>`0 or 1`<br>
* <b>Default value (if undefined):</b> 0
*/
#ifndef CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT
#define CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT ( 0U )
#endif
/**
* @brief Cellular comm interface use static context.<br>
*
* <b>Possible values:</b>`0 or 1`<br>
* <b>Default value (if undefined):</b> 0
*/
#ifndef CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION
#define CELLULAR_CONFIG_STATIC_COMM_CONTEXT_ALLOCATION ( 0U )
#endif
/**
* @brief Default radio access technoloyg.<br>
*
* <b>Possible values:</b>`Any value before CELLULAR_RAT_MAX` ( Reference : @ref CellularRat_t )<br>
* <b>Default value (if undefined):</b> CELLULAR_RAT_CATM1
*/
#ifndef CELLULAR_CONFIG_DEFAULT_RAT
#define CELLULAR_CONFIG_DEFAULT_RAT ( 8 ) /* Set default RAT to CELLULAR_RAT_CATM1 @ref CellularRat_t. */
#endif
/**
* @brief Cellular comm interface use static socket context.<br>
*
* <b>Possible values:</b>`0 or 1`<br>
* <b>Default value (if undefined):</b> 0
*/
#ifndef CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION
#define CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION ( 0 )
#endif
/**
* @brief Cellular common AT command timeout.<br>
*
* The timeout value for Cellular_Common prefix APIs. The timeout value should be
* set according to spec. It should be long enough for AT command used in cellular
* common APIs.
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 5000
*/
#ifndef CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS
#define CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS ( 5000U )
#endif
/**
* @brief Cellular AT command raw timeout.<br>
*
* The timeout value for Cellular_ATCommandRaw API.
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 5000
*/
#ifndef CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS
#define CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS ( 5000U )
#endif
/**
* @brief Cellular AT command response prefix string length.<br>
*
* The maximum length of AT command response prefix string.
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 32
*/
#ifndef CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH
#define CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH ( 32U )
#endif
/**
* @brief Macro that is called in the cellular library for logging "Error" level
* messages.
*
* To enable error level logging in the cellular library, this macro should be mapped to the
* application-specific logging implementation that supports error logging.
*
* @note This logging macro is called in the cellular library with parameters wrapped in
* double parentheses to be ISO C89/C90 standard compliant. For a reference
* POSIX implementation of the logging macros, refer to cellular_config.h files.
*
* <b>Default value</b>: Error logging is turned off, and no code is generated for calls
* to the macro in the cellular library on compilation.
*/
#ifndef LogError
#define LogError( message )
#endif
/**
* @brief Macro that is called in the cellular library for logging "Warning" level
* messages.
*
* To enable warning level logging in the cellular library, this macro should be mapped to the
* application-specific logging implementation that supports warning logging.
*
* @note This logging macro is called in the cellular library with parameters wrapped in
* double parentheses to be ISO C89/C90 standard compliant. For a reference
* POSIX implementation of the logging macros, refer to cellular_config.h files.
*
* <b>Default value</b>: Warning logs are turned off, and no code is generated for calls
* to the macro in the cellular library on compilation.
*/
#ifndef LogWarn
#define LogWarn( message )
#endif
/**
* @brief Macro that is called in the cellular library for logging "Info" level
* messages.
*
* To enable info level logging in the cellular library, this macro should be mapped to the
* application-specific logging implementation that supports info logging.
*
* @note This logging macro is called in the cellular library with parameters wrapped in
* double parentheses to be ISO C89/C90 standard compliant. For a reference
* POSIX implementation of the logging macros, refer to cellular_config.h files.
*
* <b>Default value</b>: Info logging is turned off, and no code is generated for calls
* to the macro in the cellular library on compilation.
*/
#ifndef LogInfo
#define LogInfo( message )
#endif
/**
* @brief Macro that is called in the cellular library for logging "Debug" level
* messages.
*
* To enable debug level logging from cellular library, this macro should be mapped to the
* application-specific logging implementation that supports debug logging.
*
* @note This logging macro is called in the cellular library with parameters wrapped in
* double parentheses to be ISO C89/C90 standard compliant. For a reference
* POSIX implementation of the logging macros, refer to cellular_config.h files.
*
* <b>Default value</b>: Debug logging is turned off, and no code is generated for calls
* to the macro in the cellular library on compilation.
*/
#ifndef LogDebug
#define LogDebug( message )
#endif
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_CONFIG_DEFAULTS_H__ */

View File

@ -0,0 +1,831 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_types.h
*/
#ifndef __CELLULAR_TYPES_H__
#define __CELLULAR_TYPES_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* Includes for standard bool and int. */
#include <stdbool.h>
#include <stdint.h>
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Invalid signal value.
*/
#define CELLULAR_INVALID_SIGNAL_VALUE ( -32768 )
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Invalid signal bar value.
*/
#define CELLULAR_INVALID_SIGNAL_BAR_VALUE ( 0xFFU )
/**
* @ingroup cellular_datatypes_handles
* @brief Opaque Cellular context structure.
*/
struct CellularContext;
/**
* @ingroup cellular_datatypes_handles
* @brief Opaque Cellular context structure type.
*/
typedef struct CellularContext CellularContext_t;
/**
* @ingroup cellular_datatypes_handles
* @brief Opaque Cellular handle.
*/
typedef struct CellularContext * CellularHandle_t;
struct CellularSocketContext;
/**
* @ingroup cellular_datatypes_handles
* @brief Opaque socket handle.
*/
typedef struct CellularSocketContext * CellularSocketHandle_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Status code returns from APIs.
*/
typedef enum CellularError
{
CELLULAR_SUCCESS = 0, /**< The operation was successful. */
CELLULAR_INVALID_HANDLE, /**< Invalid handle. */
CELLULAR_MODEM_NOT_READY, /**< The modem is not ready yet. */
CELLULAR_LIBRARY_NOT_OPEN, /**< The cellular library is not open yet. */
CELLULAR_LIBRARY_ALREADY_OPEN, /**< The cellular library is already open. */
CELLULAR_BAD_PARAMETER, /**< One or more of the input parameters is not valid. */
CELLULAR_NO_MEMORY, /**< Memory allocation failure. */
CELLULAR_TIMEOUT, /**< The operation timed out. */
CELLULAR_SOCKET_CLOSED, /**< The supplied socket is already closed. */
CELLULAR_SOCKET_NOT_CONNECTED, /**< The supplied socket is not connected. */
CELLULAR_INTERNAL_FAILURE, /**< The Cellular library internal failure. */
CELLULAR_RESOURCE_CREATION_FAIL, /**< Resource creation for Cellular library failed. */
CELLULAR_UNSUPPORTED, /**< The operation is not supported. */
CELLULAR_NOT_ALLOWED, /**< The operation is not allowed. */
CELLULAR_UNKNOWN /**< Any other error other than the above mentioned ones. */
} CellularError_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Enums representing Radio Access Technologies (RATs). Reference 3GPP TS 27.007 PLMN selection +COPS.
*/
typedef enum CellularRat
{
CELLULAR_RAT_GSM = 0, /**< The GSM RATs network. */
CELLULAR_RAT_WCDMA = 2, /**< The WCDMA RATs network. */
CELLULAR_RAT_EDGE = 3, /**< The EDGE RATs network. */
CELLULAR_RAT_HSDPA = 4, /**< The HSDPA RATs network. */
CELLULAR_RAT_HSUPA = 5, /**< The HSUPA RATs network. */
CELLULAR_RAT_HSDPAHSUPA = 6, /**< The HSDPAHSUPA RATs network. */
CELLULAR_RAT_LTE = 7, /**< The LTE RATs network. */
CELLULAR_RAT_CATM1 = 8, /**< The CAT M1 RATs network. */
CELLULAR_RAT_NBIOT = 9, /**< The NBIOT RATs network. */
CELLULAR_RAT_MAX, /**< The max supported number for RATs network. */
CELLULAR_RAT_INVALID = 0xFF /**< Any other error other than the above mentioned ones. */
} CellularRat_t;
/**
* @ingroup cellular_datatypes_enums
* @brief SIM card state codes.
*/
typedef enum CellularSimCardState
{
CELLULAR_SIM_CARD_REMOVED = 0, /**< The state stands for cellular sim card removed. */
CELLULAR_SIM_CARD_INSERTED, /**< The state stands for cellular sim card inserted. */
CELLULAR_SIM_CARD_STATUS_MAX, /**< The number of supported sim card status. */
CELLULAR_SIM_CARD_UNKNOWN /**< The state stands for unknown cellular sim card. */
} CellularSimCardState_t;
/**
* @ingroup cellular_datatypes_enums
* @brief SIM card lock state codes. Reference 3GPP TS 27.007 Enter PIN +CPIN.
*/
typedef enum CellularSimCardLockState
{
CELLULAR_SIM_CARD_READY = 0, /**< The cellular sim card in a lock state of ready. */
CELLULAR_SIM_CARD_PIN, /**< The cellular sim card in a lock state of pin(personal identification number). */
CELLULAR_SIM_CARD_PUK, /**< The cellular sim card in a lock state of puk(personal unlocking key). */
CELLULAR_SIM_CARD_PIN2, /**< The cellular sim card in a lock state of pin2. */
CELLULAR_SIM_CARD_PUK2, /**< The cellular sim card in a lock state of puk2. */
CELLULAR_SIM_CARD_PH_NET_PIN, /**< The cellular sim card in a lock state of ph-net pin. */
CELLULAR_SIM_CARD_PH_NET_PUK, /**< The cellular sim card in a lock state of ph-net puk. */
CELLULAR_SIM_CARD_PH_NETSUB_PIN, /**< The cellular sim card in a lock state of ph-netsub pin. */
CELLULAR_SIM_CARD_PH_NETSUB_PUK, /**< The cellular sim card in a lock state of ph-netsub puk. */
CELLULAR_SIM_CARD_SP_PIN, /**< The cellular sim card in a lock state of ph-sp pin. */
CELLULAR_SIM_CARD_SP_PUK, /**< The cellular sim card in a lock state of ph-sp puk. */
CELLULAR_SIM_CARD_CORP_PIN, /**< The cellular sim card in a lock state of ph-corp pin. */
CELLULAR_SIM_CARD_CORP_PUK, /**< The cellular sim card in a lock state of ph-sp puk. */
CELLULAR_SIM_CARD_IMSI_PIN, /**< The cellular sim card in a lock state of imsi pin. */
CELLULAR_SIM_CARD_IMSI_PUK, /**< The cellular sim card in a lock state of imsi puk. */
CELLULAR_SIM_CARD_INVALID, /**< The cellular sim card in a lock state of invalid. */
CELLULAR_SIM_CARD_LOCK_UNKNOWN /**< The cellular sim card in a lock state of unknown. */
} CellularSimCardLockState_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents network registration mode. Reference 3GPP TS 27.007 PLMN selection +COPS.
*/
typedef enum CellularNetworkRegistrationMode
{
REGISTRATION_MODE_AUTO = 0, /**< Auto network registration mode. */
REGISTRATION_MODE_MANUAL = 1, /**< Manual network registration mode. */
REGISTRATION_MODE_DEREGISTER = 2, /**< Deregister network registration mode. */
REGISTRATION_MODE_MANUAL_THEN_AUTO = 4, /**< Manual then auto network registration mode. */
REGISTRATION_MODE_MAX, /**< The number of supported registration mode. */
REGISTRATION_MODE_UNKNOWN /**< Unknown network registration mode. */
} CellularNetworkRegistrationMode_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents network registration status. Reference 3GPP TS 27.007 network registration status.
*/
typedef enum CellularNetworkRegistrationStatus
{
REGISTRATION_STATUS_NO_REGISTERED_SEARCHING = 0, /**< No registered searching network registration status. */
REGISTRATION_STATUS_REGISTERED_HOME = 1, /**< Registered home network registration status. */
REGISTRATION_STATUS_NOT_REGISTERED_SEARCHING = 2, /**< Not registered searching network registration status. */
REGISTRATION_STATUS_REGISTRATION_DENIED = 3, /**< Registration denied network registration status. */
REGISTRATION_STATUS_UNKNOWN = 4, /**< Unknown network registration status. */
REGISTRATION_STATUS_ROAMING_REGISTERED = 5, /**< Roaming registered network registration status. */
REGISTRATION_STATUS_HOME_SMS_ONLY_REGISTERED = 6, /**< Home SMS only registered network registration status. */
REGISTRATION_STATUS_SMS_ONLY_ROAMING_REGISTERED = 7, /**< SMS only roaming registered network registration status. */
REGISTRATION_STATUS_ATTACHED_EMERG_SERVICES_ONLY = 8, /**< Attached emergency service only network registration status. */
REGISTRATION_STATUS_MAX /**< The max supported number for registration status. */
} CellularNetworkRegistrationStatus_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents operator name format.
*/
typedef enum CellularOperatorNameFormat
{
OPERATOR_NAME_FORMAT_LONG = 0, /**< Long operator name format. */
OPERATOR_NAME_FORMAT_SHORT = 1, /**< Short operator name format. */
OPERATOR_NAME_FORMAT_NUMERIC = 2, /**< Numeric operator name format. */
OPERATOR_NAME_FORMAT_NOT_PRESENT = 9, /**< Not present operator name format. */
OPERATOR_NAME_FORMAT_MAX /**< The max supported number for operator name format. */
} CellularOperatorNameFormat_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents URC events.
*/
typedef enum CellularUrcEvent
{
CELLULAR_URC_EVENT_NETWORK_CS_REGISTRATION, /**< Network CS registration URC event. */
CELLULAR_URC_EVENT_NETWORK_PS_REGISTRATION, /**< Network PS registration URC event. */
CELLULAR_URC_EVENT_PDN_ACTIVATED, /**< PDN activated registration URC event. */
CELLULAR_URC_EVENT_PDN_DEACTIVATED, /**< PDN deactivated registration URC event. */
CELLULAR_URC_EVENT_SIGNAL_CHANGED, /**< Signal changed registration URC event. */
CELLULAR_URC_SOCKET_OPENED, /**< Socket opened registration URC event. */
CELLULAR_URC_SOCKET_OPEN_FAILED, /**< Socket open failed registration URC event. */
CELLULAR_URC_EVENT_OTHER /**< Any URC event other than above. */
} CellularUrcEvent_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents Modem events.
*/
typedef enum CellularModemEvent
{
CELLULAR_MODEM_EVENT_BOOTUP_OR_REBOOT, /**< Bootup or reboot modem event. */
CELLULAR_MODEM_EVENT_POWERED_DOWN, /**< Power down modem event. */
CELLULAR_MODEM_EVENT_PSM_ENTER /**< PSM enter modem event. */
} CellularModemEvent_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents PDN context type.
*/
typedef enum CellularPdnContextType
{
CELLULAR_PDN_CONTEXT_IPV4 = 1, /**< IPV4 PDN CONTEXT. */
CELLULAR_PDN_CONTEXT_IPV6 = 2, /**< IPV6 PDN CONTEXT. */
CELLULAR_PDN_CONTEXT_IPV4V6 = 3, /**< IPV4V6 PDN CONTEXT. */
CELLULAR_PDN_CONTEXT_TYPE_MAX /**< The max number of supported PDN CONTEXT. */
} CellularPdnContextType_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents PDN authentication type.
*/
typedef enum CellularPdnAuthType
{
CELLULAR_PDN_AUTH_NONE = 0, /**< No authentication. */
CELLULAR_PDN_AUTH_PAP, /**< Password Authentication Protocol (PAP). */
CELLULAR_PDN_AUTH_CHAP, /**< Challenge Handshake Authentication Protocol (CHAP). */
CELLULAR_PDN_AUTH_PAP_OR_CHAP /**< PAP or CHAP. */
} CellularPdnAuthType_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents socket domain.
*/
typedef enum CellularSocketDomain
{
CELLULAR_SOCKET_DOMAIN_AF_INET, /**< IPv4 Internet Protocols. */
CELLULAR_SOCKET_DOMAIN_AF_INET6 /**< IPv6 Internet Protocols. */
} CellularSocketDomain_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents socket type.
*/
typedef enum CellularSocketType
{
CELLULAR_SOCKET_TYPE_DGRAM, /**< Datagram. */
CELLULAR_SOCKET_TYPE_STREAM /**< Byte-stream. */
} CellularSocketType_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents socket protocol.
*/
typedef enum CellularSocketProtocol
{
CELLULAR_SOCKET_PROTOCOL_UDP,
CELLULAR_SOCKET_PROTOCOL_TCP
} CellularSocketProtocol_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents data access modes.
*/
typedef enum CellularSocketAccessMode
{
CELLULAR_ACCESSMODE_BUFFER = 0, /* Data access buffer mode. */
CELLULAR_ACCESSMODE_DIRECT_PUSH, /* Data access direct push mode. */
CELLULAR_ACCESSMODE_TRANSPARENT, /* Data access transparent mode. */
CELLULAR_ACCESSMODE_NOT_SET /* Data access not set. */
} CellularSocketAccessMode_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents IP address.
*/
typedef enum CellularIPAddressType
{
CELLULAR_IP_ADDRESS_V4, /**< IP V4 IP address. */
CELLULAR_IP_ADDRESS_V6 /**< IP V6 IP address. */
} CellularIPAddressType_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents socket option level.
*/
typedef enum CellularSocketOptionLevel
{
CELLULAR_SOCKET_OPTION_LEVEL_IP, /**< IP layer options. */
CELLULAR_SOCKET_OPTION_LEVEL_TRANSPORT /**< Transport (TCP/UDP) layer options. */
} CellularSocketOptionLevel_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Socket option names.
*/
typedef enum CellularSocketOption
{
CELLULAR_SOCKET_OPTION_MAX_IP_PACKET_SIZE, /**< Set Max IP packet size. */
CELLULAR_SOCKET_OPTION_SEND_TIMEOUT, /**< Set send timeout (in milliseconds). */
CELLULAR_SOCKET_OPTION_RECV_TIMEOUT, /**< Set receive timeout (in milliseconds). */
CELLULAR_SOCKET_OPTION_PDN_CONTEXT_ID, /**< Set PDN Context ID to use for the socket. */
CELLULAR_SOCKET_OPTION_SET_LOCAL_PORT /**< Set local port. */
} CellularSocketOption_t;
/**
* @ingroup cellular_datatypes_enums
* @brief packet Status Names.
*/
typedef enum CellularPktStatus
{
CELLULAR_PKT_STATUS_OK = 0, /* The operation was successful. */
CELLULAR_PKT_STATUS_TIMED_OUT, /* The operation timed out. */
CELLULAR_PKT_STATUS_FAILURE, /* There was some internal failure. */
CELLULAR_PKT_STATUS_BAD_REQUEST, /* Request was not valid. */
CELLULAR_PKT_STATUS_BAD_RESPONSE, /* The response received was not valid. */
CELLULAR_PKT_STATUS_SIZE_MISMATCH, /* There is a size mismatch between the params. */
CELLULAR_PKT_STATUS_BAD_PARAM, /* One or more params is not valid. */
CELLULAR_PKT_STATUS_SEND_ERROR, /* Modem returned a send error. */
CELLULAR_PKT_STATUS_INVALID_HANDLE, /* Invalid context. */
CELLULAR_PKT_STATUS_CREATION_FAIL, /* Resource creation fail. */
CELLULAR_PKT_STATUS_PREFIX_MISMATCH, /* Invalid prefix from Modem resp. */
CELLULAR_PKT_STATUS_INVALID_DATA, /* Invalid data from Modem resp. */
CELLULAR_PKT_STATUS_PENDING_DATA, /* Pending data from Modem resp. */
CELLULAR_PKT_STATUS_PENDING_BUFFER /* Pending data from Modem resp. */
} CellularPktStatus_t;
/**
* @ingroup cellular_datatypes_enums
* @brief Represents AT Command type.
*/
typedef enum CellularATCommandType
{
CELLULAR_AT_NO_RESULT, /**< no response expected, only OK, ERROR etc. */
CELLULAR_AT_WO_PREFIX, /**< string response without a prefix. */
CELLULAR_AT_WITH_PREFIX, /**< string response with a prefix. */
CELLULAR_AT_MULTI_WITH_PREFIX, /**< multiple line response all start with a prefix. */
CELLULAR_AT_MULTI_WO_PREFIX, /**< multiple line response with or without a prefix. */
CELLULAR_AT_MULTI_DATA_WO_PREFIX, /**< multiple line data response with or without a prefix. */
CELLULAR_AT_NO_COMMAND /**< no command is waiting response. */
} CellularATCommandType_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief SIM Card status.
*/
typedef struct CellularSimCardStatus
{
CellularSimCardState_t simCardState; /**< Cellular sim card state. */
CellularSimCardLockState_t simCardLockState; /**< Cellular sim card lock state. */
} CellularSimCardStatus_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Public Land Mobile Network (PLMN) information.
*/
typedef struct CellularPlmnInfo
{
char mcc[ CELLULAR_MCC_MAX_SIZE + 1 ]; /**< Mobile Country Code (MCC). */
char mnc[ CELLULAR_MNC_MAX_SIZE + 1 ]; /**< Mobile Network Code (MNC). */
} CellularPlmnInfo_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief SIM Card information.
*/
typedef struct CellularSimCardInfo
{
char iccid[ CELLULAR_ICCID_MAX_SIZE + 1 ]; /**< Integrated Circuit Card Identifier aka SIM Card Number. */
char imsi[ CELLULAR_IMSI_MAX_SIZE + 1 ]; /**< International Mobile Subscriber Identity. */
CellularPlmnInfo_t plmn; /**< Public Land Mobile Network (PLMN) information. */
} CellularSimCardInfo_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Modem information.
*/
typedef struct CellularModemInfo
{
char hardwareVersion[ CELLULAR_HW_VERSION_MAX_SIZE + 1 ]; /**< Hardware version number. */
char firmwareVersion[ CELLULAR_FW_VERSION_MAX_SIZE + 1 ]; /**< Firmware version number. */
char serialNumber[ CELLULAR_SERIAL_NUM_MAX_SIZE + 1 ]; /**< Module serial number. */
char imei[ CELLULAR_IMEI_MAX_SIZE + 1 ]; /**< International Mobile Equipment Identity (IMEI). */
char manufactureId[ CELLULAR_MANUFACTURE_ID_MAX_SIZE + 1 ]; /**< Manufacture Identity. */
char modelId[ CELLULAR_MODEL_ID_MAX_SIZE + 1 ]; /**< Model Identity. */
} CellularModemInfo_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents time.
*/
typedef struct CellularTime
{
uint8_t month; /**< 1..12 (Jan = 1 .. Dec = 12). */
uint8_t day; /**< Day of the month 1..31. */
uint8_t hour; /**< Hour of the day 0..23. */
uint8_t minute; /**< Minute of the hour 0..59. */
uint8_t second; /**< Second of the minute 0..59. */
uint16_t year; /**< Year (like 2019). */
int32_t timeZone; /**< Timezone represented in 15 minute increments (UTC+1 will be 4 because 1 hour = 60 minutes = 4 * 15 minutes). */
uint8_t dst; /**< Daylight savings ( 0 = No adjustment for daylight savings
* 1 = +1 hour for daylight savings
* 2 = +2 hours for daylight savings ). */
} CellularTime_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents signal information.
*/
typedef struct CellularSignalInfo
{
int16_t rssi; /**< Received Signal Strength Indicator (RSSI) in dBm.*/
int16_t rsrp; /**< LTE Reference Signal Received Power (RSRP) in dBm. */
int16_t rsrq; /**< LTE Reference Signal Received Quality (RSRQ) in dB. */
int16_t sinr; /**< LTE Signal to Interference-Noise Ratio in dB. */
int16_t ber; /**< Bit Error Rate (BER) in 0.01%. */
uint8_t bars; /**< A number between 0 to 5 (both inclusive) indicating signal strength. */
} CellularSignalInfo_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents network service status.
*/
typedef struct CellularServiceStatus
{
CellularRat_t rat; /**< Radio Access Technology (RAT). */
CellularNetworkRegistrationMode_t networkRegistrationMode; /**< Network registration mode (auto/manual etc.) currently selected. */
CellularNetworkRegistrationStatus_t csRegistrationStatus; /**< CS (Circuit Switched) registration status (registered/searching/roaming etc.). */
CellularNetworkRegistrationStatus_t psRegistrationStatus; /**< PS (Packet Switched) registration status (registered/searching/roaming etc.). */
CellularPlmnInfo_t plmnInfo; /**< Registered MCC and MNC information. */
CellularOperatorNameFormat_t operatorNameFormat; /**< Format of registered network operator name. */
char operatorName[ CELLULAR_NETWORK_NAME_MAX_SIZE + 1 ]; /**< Registered network operator name. */
uint8_t csRejectionType; /**< CS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
uint8_t csRejectionCause; /**< Reason why the CS (Circuit Switched) registration attempt was rejected. */
uint8_t psRejectionType; /**< PS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
uint8_t psRejectionCause; /**< Reason why the PS (Packet Switched) registration attempt was rejected. */
} CellularServiceStatus_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents A singly-lined list of intermediate AT responses.
*/
typedef struct CellularATCommandLine
{
struct CellularATCommandLine * pNext; /**< The CellularATCommandLine structure pointer points to the next element of the liniked list. */
char * pLine; /**< The content of the at command. */
} CellularATCommandLine_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents AT Command response.
*/
typedef struct CellularATCommandResponse
{
bool status; /**< true: modem returns Success, false: Error. */
CellularATCommandLine_t * pItm; /**< Any intermediate responses. */
} CellularATCommandResponse_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents PSM settings.
*/
typedef struct CellularPsmSettings
{
/*
* 0 = PSM Disable
* 1 = PSM Enable.
*/
uint8_t mode; /**< PSM mode value (as shown above). */
/*
* Bits 5 to 1 represent the binary coded timer value
* Bits 6 to 8 define the timer value unit as follows:
* Bits
* 8 7 6
* 0 0 0 value is incremented in multiples of 10 minutes
* 0 0 1 value is incremented in multiples of 1 hour
* 0 1 0 value is incremented in multiples of 10 hours
* 0 1 1 value is incremented in multiples of 2 seconds
* 1 0 0 value is incremented in multiples of 30 seconds
* 1 0 1 value is incremented in multiples of 1 minute
*
* e.g. "00001010" equals to 100 minutes.
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
*/
uint32_t periodicTauValue; /**< TAU (T3412) value encoded as per spec (as shown above). */
/*
* Bits 5 to 1 represent the binary coded timer value
* Bits 6 to 8 define the timer value unit as follows:
* Bits
* 8 7 6
* 0 0 0 value is incremented in multiples of 10 minutes
* 0 0 1 value is incremented in multiples of 1 hour
* 0 1 0 value is incremented in multiples of 10 hours
* 0 1 1 value is incremented in multiples of 2 seconds
* 1 0 0 value is incremented in multiples of 30 seconds
* 1 0 1 value is incremented in multiples of 1 minute
*
* e.g. "00001010" equals to 100 minutes.
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
*/
uint32_t periodicRauValue; /**< RAU (T3312) value encoded as per Spec (as shown above). */
/*
* Bits 5 to 1 represent the binary coded timer value
* Bits 6 to 8 define the timer value unit as follows:
* Bits
* 8 7 6
* 0 0 0 value is incremented in multiples of 10 minutes
* 0 0 1 value is incremented in multiples of 1 hour
* 0 1 0 value is incremented in multiples of 10 hours
* 0 1 1 value is incremented in multiples of 2 seconds
* 1 0 0 value is incremented in multiples of 30 seconds
* 1 0 1 value is incremented in multiples of 1 minute
*
* e.g. "00001010" equals to 100 minutes.
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
*/
uint32_t gprsReadyTimer; /**< GPRS Ready timer (T3314) value encoded as per Spec. */
/*
* Bits 5 to 1 represent the binary coded timer value.
* Bits 6 to 8 define the timer value unit as follows:
* Bits
* 8 7 6
* 0 0 0 value is incremented in multiples of 2 seconds
* 0 0 1 value is incremented in multiples of 1 minute
* 0 1 0 value is incremented in multiples of decihours
* 1 1 1 value indicates that the timer is deactivated.
*
* "00001111" equals to 30 seconds.
* first uint8_t is used for PSM set, whole uint32_t is used for PSM get.
*/
uint32_t activeTimeValue; /**< Active Time (T3324) value encoded as per spec (as shown above). */
} CellularPsmSettings_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents e-I-DRX settings.
*/
typedef struct CellularEidrxSettings
{
/*
* 0 Disable the use of e-I-DRX
* 1 Enable the use of e-I-DRX
* 2 Enable the use of e-I-DRX and enable the unsolicited result code
* 3 Disable the use of e-I-DRX and discard all parameters for e-I-DRX or,
* if available, reset to the manufacturer specific default values.
*/
uint8_t mode; /**< e-I-DRX mode (as shown above). */
/*
* 2 GSM
* 3 UTRAN
* 4 LTE Cat M1
* 5 LTE Cat NB1
*/
uint8_t rat; /**< Radio Access Technology (as shown above). */
/*
* String type. Half a byte in a 4 bit format.
* bit
* 4 3 2 1 E-UTRAN e-I-DRX cycle length duration
* 0 0 0 0 5.12 seconds
* 0 0 0 1 10.24 seconds
* 0 0 1 0 20.48 seconds
* 0 0 1 1 40.96 seconds
* 0 1 0 0 61.44 seconds
* 0 1 0 1 81.92 seconds
* 0 1 1 0 102.4 seconds
* 0 1 1 1 122.88 seconds
* 1 0 0 0 143.36 seconds
* 1 0 0 1 163.84 seconds
* 1 0 1 0 327.68 seconds
* 1 0 1 1 655,36 seconds
* 1 1 0 0 1310.72 seconds
* 1 1 0 1 2621.44 seconds
* 1 1 1 0 5242.88 seconds
* 1 1 1 1 10485.76 seconds
*/
uint8_t requestedEdrxVaue; /**< Requested eDRX value encoded as per spec (as shown above). */
uint8_t nwProvidedEdrxVaue; /**< Network provided eDRX value encoded as per spec (as shown above). Only applicable in URC. */
/*
* LTE Cat M1 mode
* bit
* 4 3 2 1 Paging Time Window length
* 0 0 0 0 1.28 seconds
* 0 0 0 1 2.56 seconds
* 0 0 1 0 3.84 seconds
* 0 0 1 1 5.12 seconds
* 0 1 0 0 6.4 seconds
* 0 1 0 1 7.68 seconds
* 0 1 1 0 8.96 seconds
* 0 1 1 1 10.24 seconds
* 1 0 0 0 11.52 seconds
* 1 0 0 1 12.8 seconds
* 1 0 1 0 14.08 seconds
* 1 0 1 1 15.36 seconds
* 1 1 0 0 16.64 seconds
* 1 1 0 1 17.92 seconds
* 1 1 1 0 19.20 seconds
* 1 1 1 1 20.48 seconds
*
* LTE Cat NB1 mode
* bit
* 4 3 2 1 Paging Time Window length
* 0 0 0 0 2.56 seconds
* 0 0 0 1 5.12 seconds
* 0 0 1 0 7.68 seconds
* 0 0 1 1 10.24 seconds
* 0 1 0 0 12.8 seconds
* 0 1 0 1 15.36 seconds
* 0 1 1 0 17.92 seconds
* 0 1 1 1 20.48 seconds
* 1 0 0 0 23.04 seconds
* 1 0 0 1 25.6 seconds
* 1 0 1 0 28.16 seconds
* 1 0 1 1 30.72 seconds
* 1 1 0 0 33.28 seconds
* 1 1 0 1 35.84 seconds
* 1 1 1 0 38.4 seconds
* 1 1 1 1 40.96 seconds
*/
uint8_t pagingTimeWindow; /**< Paging time window encoded as per spec (as shown above). Only applicable in URC. */
} CellularEidrxSettings_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Cellular Represents e-I-DRX settings Lists.
*/
typedef struct CellularEidrxSettingsList
{
CellularEidrxSettings_t eidrxList[ CELLULAR_EDRX_LIST_MAX_SIZE ]; /**< Cellular e-I-DRX settings list. */
uint8_t count; /**< Cellular e-I-DRX settings list number. */
} CellularEidrxSettingsList_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents IP Address.
*/
typedef struct CellularIPAddress
{
CellularIPAddressType_t ipAddressType; /**< Type of IP address (IPv4/IPv6). */
char ipAddress[ CELLULAR_IP_ADDRESS_MAX_SIZE + 1 ]; /**< IP Address. NULL terminated. */
} CellularIPAddress_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents a PDN config.
*/
typedef struct CellularPdnConfig
{
CellularPdnContextType_t pdnContextType; /**< PDN Context type. */
CellularPdnAuthType_t pdnAuthType; /**< PDN Authentication type. */
const char apnName[ CELLULAR_APN_MAX_SIZE + 1 ]; /**< APN name. */
const char username[ CELLULAR_PDN_USERNAME_MAX_SIZE + 1 ]; /**< Username. */
const char password[ CELLULAR_PDN_PASSWORD_MAX_SIZE + 1 ]; /**< Password. */
} CellularPdnConfig_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents status of a PDN context.
*/
typedef struct CellularPdnStatus
{
uint8_t contextId; /**< 1-16 are valid values. */
uint8_t state; /**< 0 = Deactivated, 1 = Activated. */
CellularPdnContextType_t pdnContextType; /**< PDN Context type. */
CellularIPAddress_t ipAddress; /**< Local IP address after the context is activated. */
} CellularPdnStatus_t;
/**
* @ingroup cellular_datatypes_paramstructs
* @brief Represents socket address.
*/
typedef struct CellularSocketAddress
{
CellularIPAddress_t ipAddress; /**< IP address. */
uint16_t port; /**< Port number. */
} CellularSocketAddress_t;
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform about the response of an AT command sent
* using Cellular_ATCommandRaw API.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[in] pAtResp The response received for the AT command.
* @param[in] pData is pATCommandPayload pointer in Cellular_ATCommandRaw parameters.
* @param[in] dataLen is the string length of pATCommandPayloadin in Cellular_ATCommandRaw parameters.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
typedef CellularPktStatus_t ( * CellularATCommandResponseReceivedCallback_t ) ( CellularHandle_t cellularHandle,
const CellularATCommandResponse_t * pAtResp,
void * pData,
uint16_t dataLen );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform about a Network Registration URC event.
*
* @param[in] urcEvent URC Event that happened.
* @param[in] pServiceStatus The status of the network service.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_RegisterUrcNetworkRegistrationEventCallback function.
*/
typedef void ( * CellularUrcNetworkRegistrationCallback_t )( CellularUrcEvent_t urcEvent,
const CellularServiceStatus_t * pServiceStatus,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform about PDN URC events.
*
* @param[in] urcEvent URC Event that happened.
* @param[in] contextId Context ID of the PDN context
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_RegisterUrcPdnEventCallback function.
*/
typedef void ( * CellularUrcPdnEventCallback_t )( CellularUrcEvent_t urcEvent,
uint8_t contextId,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform about signal strength changed URC event.
*
* @param[in] urcEvent URC Event that happened.
* @param[in] pSignalInfo The new signal information.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_RegisterUrcSignalStrengthChangedCallback function.
*/
typedef void ( * CellularUrcSignalStrengthChangedCallback_t )( CellularUrcEvent_t urcEvent,
const CellularSignalInfo_t * pSignalInfo,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Generic callback used to inform all other URC events.
*
* @param[in] pRawData Raw data received in the URC event.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_RegisterUrcGenericCallback function.
*/
typedef void ( * CellularUrcGenericCallback_t )( const char * pRawData,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform about modem events.
*
* @param[in] modemEvent The modem event.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_RegisterModemEventCallback function.
*/
typedef void ( * CellularModemEventCallback_t )( CellularModemEvent_t modemEvent,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform about the status of socket open.
*
* @param[in] urcEvent URC Event that happened.
* @param[in] socketHandle Socket handle for which data is ready.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_SocketRegisterSocketOpenCallback function.
*/
typedef void ( * CellularSocketOpenCallback_t )( CellularUrcEvent_t urcEvent,
CellularSocketHandle_t socketHandle,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform that data is ready for reading on a socket.
*
* @param[in] socketHandle Socket handle for which data is ready.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_SocketRegisterDataReadyCallback function.
*/
typedef void ( * CellularSocketDataReadyCallback_t )( CellularSocketHandle_t socketHandle,
void * pCallbackContext );
/**
* @ingroup cellular_datatypes_functionpointers
* @brief Callback used to inform that remote end closed the connection for a
* connected socket.
*
* @param[in] socketHandle Socket handle for which remote end closed the
* connection.
* @param[in] pCallbackContext pCallbackContext parameter in
* Cellular_SocketRegisterClosedCallback function.
*/
typedef void ( * CellularSocketClosedCallback_t )( CellularSocketHandle_t socketHandle,
void * pCallbackContext );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_TYPES_H__ */

View File

@ -0,0 +1,411 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_at_core.h
*/
#ifndef __CELLULAR_AT_CORE_H__
#define __CELLULAR_AT_CORE_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* Standard includes */
#include <stdbool.h>
#include <string.h>
/* Standard includes. */
#include <stdint.h>
/*-----------------------------------------------------------*/
/**
* @brief Maximum size of an AT string.
*/
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
/**
* @brief Maximum size of an AT prefix.
*/
#define CELLULAR_AT_MAX_PREFIX_SIZE ( 32 )
/**
* @brief The array size of an array.
*/
#define ARRY_SIZE( x ) ( sizeof( x ) / sizeof( x[ 0 ] ) )
/*-----------------------------------------------------------*/
/**
* @brief Represents error codes returned from AT Core APIs.
*/
typedef enum CellularATError
{
CELLULAR_AT_SUCCESS = 0, /**< The operation was successful. */
CELLULAR_AT_BAD_PARAMETER, /**< One or more of the input parameters is not valid. */
CELLULAR_AT_NO_MEMORY, /**< Memory allocation failure. */
CELLULAR_AT_UNSUPPORTED, /**< The operation is not supported. */
CELLULAR_AT_MODEM_ERROR, /**< Error in modem response. */
CELLULAR_AT_ERROR, /**< Generic Error or boolean false. */
CELLULAR_AT_UNKNOWN /**< Any other error other than the above mentioned ones. */
} CellularATError_t;
/*-----------------------------------------------------------*/
/**
* @brief Remove prefix from a string
*
* Many AT responses contain prefix of the form +XXXX. This function removes the
* prefix by moving the pointer after the prefix. For example:
*
* Input:
* +---+---+---+---+---+---+---+---+---+---+---+
* | + | C | P | I | N | : | R | E | A | D | Y |
* +---+---+---+---+---+---+---+---+---+---+---+
* ^
* |
* *ppString
*
* Output:
* +---+---+---+---+---+---+---+---+---+---+---+
* | + | C | P | I | N | : | R | E | A | D | Y |
* +---+---+---+---+---+---+---+---+---+---+---+
* ^
* |
* *ppString
*
* Note that a prefix is always followed by colon (':') and this function
* removes colon as well.
*
* @param[in,out] ppString The AT response to remove the prefix from. In
* case of success, the pointer is updated to move past the prefix.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATRemovePrefix( char ** ppString );
/**
* @brief Remove all leading white spaces from an AT response.
*
* Leading white spaces are removed by updating the pointer to the first
* non-white space character. For example:
*
* Input:
* +--+--+--+---+---+---+---+---+---+---+---+------+
* | | | | r | e | s | p | o | n | s | e | '\0' |
* +--+--+--+---+---+---+---+---+---+---+---+------+
* ^
* |
* *ppString
*
* Output:
* +--+--+--+---+---+---+---+---+---+---+---+------+
* | | | | r | e | s | p | o | n | s | e | '\0' |
* +--+--+--+---+---+---+---+---+---+---+---+------+
* ^
* |
* *ppString
*
* @param[in,out] ppString The AT response to remove the leading white spaces
* from. In case of success, the pointer is updated to the first non white space
* character.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATRemoveLeadingWhiteSpaces( char ** ppString );
/**
* @brief Remove all trailing white spaces from an AT response.
*
* Trailing spaces are removed by making the character next to the last
* non white space character NULL ('\0'). For example:
*
* Input:
* +---+---+---+---+---+---+---+---+--+--+--+------+
* | r | e | s | p | o | n | s | e | | | | '\0' |
* +---+---+---+---+---+---+---+---+--+--+--+------+
*
* Output:
* +---+---+---+---+---+---+---+---+------+--+--+------+
* | r | e | s | p | o | n | s | e | '\0' | | | '\0' |
* +---+---+---+---+---+---+---+---+------+--+--+------+
*
* @param[in,out] pString The AT response to remove the trailing white
* spaces from.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATRemoveTrailingWhiteSpaces( char * pString );
/**
* @brief Remove all white spaces from an AT response.
*
* White spaces are removed by copying the non-white space characters to the
* beginning. The character next to the last non-white space character is set
* to the null character ('\0'). For example:
*
* Input:
* +--+--+--+---+---+---+---+---+---+---+-- +---+------+
* | | | | r | e | s | p | | o | n | s | e | '\0' |
* +--+--+--+---+---+---+---+---+---+---+---+---+------+
*
* Output:
* +---+---+---+---+---+---+---+---+------+------+
* | r | e | s | p | o | n | s | e | '\0' | '\0' |
* +---+---+---+---+---+---+---+---+------+------+
*
* @param[in,out] pString The AT response to remove the white spaces from.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATRemoveAllWhiteSpaces( char * pString );
/**
* @brief Remove outermost double quotes from an AT response.
*
* If the first character is double quote, it is removed by updating the pointer
* to point to the next character. If the last character is double quote, it
* is removed by making it the null character. Nothing else is done in any other
* case. For example:
*
* Input:
* +---+---+---+---+---+---+---+---+---+---+------+
* | " | r | e | s | p | o | n | s | e | " | '\0' |
* +---+---+---+---+---+---+---+---+---+---+------+
* ^
* |
* *ppString
*
* Output:
* +---+---+---+---+---+---+---+---+---+------+------+
* | " | r | e | s | p | o | n | s | e | '\0' | '\0' |
* +---+---+---+---+---+---+---+---+---+------+------+
* ^
* |
* *ppString
*
* @param[in,out] ppString The AT response to remove the double quotes
* from.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATRemoveOutermostDoubleQuote( char ** ppString );
/**
* @brief Remove all double quotes from an AT response.
*
* Double quotes are removed by copying all the other characters to the
* beginning. The character next to the last character is set to the null
* character ('\0'). For example:
*
* Input:
* +---+---+---+---+---+---+---+---+---+---+---+---+------+
* | " | r | e | s | " | p | " | o | n | s | e | " | '\0' |
* +---+---+---+---+---+---+---+---+---+---+---+---+------+
*
* Output:
* +---+---+---+---+---+---+---+---+------+---+---+---+------+
* | r | e | s | p | o | n | s | e | '\0' | s | e | " | '\0' |
* +---+---+---+---+---+---+---+---+------+---+---+---+------+
*
* @param[in,out] pString The AT response to remove the double quotes
* from.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATRemoveAllDoubleQuote( char * pString );
/**
* @brief Extract the next token based on comma (',') as delimiter.
*
* @param[in,out] ppString The AT response to extract the token from.
* @param[in,out] ppTokOutput The output parameter to return the location of the
* token.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATGetNextTok( char ** ppString,
char ** ppTokOutput );
/**
* @brief Extract the next token based on the provided delimiter.
*
* This function uses *ppATResponse as the starting location to scan for tokens
* which are sequences of contiguous characters separated by delimiters. When it
* finds a token, *ppOutToken is updated to point to starting location of the
* token and *ppATResponse is updated to point to the next character after the
* token. This ensures that the next call to this function will extract the next
* occurrence of the token.
*
* @param[in,out] ppString The AT response to extract the token from.
* @param[in] pDelimiter The delimiter string.
* @param[in,out] ppTokOutput The output parameter to return the location of the
* token.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATGetSpecificNextTok( char ** ppString,
const char * pDelimiter,
char ** ppTokOutput );
/**
* @brief Convert HEX string to HEX.
*
* This function requires the provided string to be of even length and returns
* CELLULAR_AT_BAD_PARAMETER if it is not. It also requires the output buffer to be
* of exactly half the length of the given hex string to ensure that it exactly
* fits the converted data.
*
* It reads two characters and constructs a HEX byte by treating them upper and
* lower nibble of the byte. For example:
*
* Input:
* +---+---+---+---+------+
* | 1 | 0 | A | B | '\0' |
* +---+---+---+---+------+
*
* Output:
* +----+-----+------+
* | 16 | 171 | '\0' |
* +----+-----+------+
*
* Decimal 16 is 0x10 and decimal 171 is 0xAB.
*
* @param[in] pString The hex string to convert to HEX.
* @param[out] pHexData The buffer to return the converted HEX data into.
* @param[in] hexDataLen The length of the buffer.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATHexStrToHex( const char * pString,
uint8_t * pHexData,
uint16_t hexDataLen );
/**
* @brief Check if a string is numeric.
*
* A string is numeric if all the characters in it are digits. For example,
* "1234" is numeric but "123YD" is not because 'Y' and 'D' are not digits.
*
* @param[in] pString The input string to check.
* @param[out] pResult The bool output parameter to return whether or not the
* string is numeric.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATIsStrDigit( const char * pString,
bool * pResult );
/**
* @brief check if a string as prefix present by determine present of ':'
*
* @param[in] pString input string
* @param[out] pResult The bool output parameter to return whether or not the
* string is numeric.
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATIsPrefixPresent( const char * pString,
bool * pResult );
/**
* @brief duplicate string from pSrc to ppDst, malloc is use to allocate mem space for ppDst
*
* @param[in] pSrc: input string to be copied
* @param[out] ppDst: destination pointer
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATStrDup( char ** ppDst,
const char * pSrc );
/**
* @brief check if a string starts with certain prefix
*
* @param[in] pString input string
* @param[in] pPrefix input prefix
* @param[out] pResult return true if prefix is at start of pString, else false
*
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATStrStartWith( const char * pString,
const char * pPrefix,
bool * pResult );
/**
* @brief check if certain success code/error code present in the input buffer
*
* @param[in] pInputBuf: the haystack buffer
* @param[in] ppKeyList: list of keys
* @param[in] keyListLen: size of the keyList array
* @param[out] pResult: return true if any of Keys in ppKeyList is found in is at start of pString, else false
* *
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATcheckErrorCode( const char * pInputBuf,
const char * const * const ppKeyList,
size_t keyListLen,
bool * pResult );
/**
* @brief Convert string to int32_t.
*
* @param[in] pStr: the input string buffer.
* @param[in] base: Numerical base (radix) of pStr.
* Input string should not contain leading space or zero.
* @param[out] pResult: converted int32_t result.
* *
* @return CELLULAR_AT_SUCCESS if the operation is successful, otherwise an
* error code indicating the cause of the error.
*/
CellularATError_t Cellular_ATStrtoi( const char * pStr,
int32_t base,
int32_t * pResult );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_AT_CORE_H__ */

View File

@ -0,0 +1,630 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_common.h
*/
#ifndef __CELLULAR_COMMON_H__
#define __CELLULAR_COMMON_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* Standard includes. */
#include <stdbool.h>
/* Cellular includes. */
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
/* Include custom config file before other headers. */
#include "cellular_config.h"
#endif
#include "cellular_config_defaults.h"
#include "cellular_platform.h"
#include "cellular_comm_interface.h"
#include "cellular_types.h"
#include "cellular_at_core.h"
/*-----------------------------------------------------------*/
/**
* @ingroup cellular_common_datatypes_paramstructs
* @brief The AT command request structure.
*/
typedef struct CellularAtReq
{
const char * pAtCmd; /**< The At command string used for at command request. */
CellularATCommandType_t atCmdType; /**< The At command type. */
const char * pAtRspPrefix; /**< The prefix of at command response. */
CellularATCommandResponseReceivedCallback_t respCallback; /**< The callback function #CellularATCommandResponseReceivedCallback_t. */
void * pData; /**< The data pointer to the data. */
uint16_t dataLen; /**< The length of the data pointer . */
} CellularAtReq_t;
/**
* @ingroup cellular_common_datatypes_paramstructs
* @brief The data command request structure.
*/
typedef struct CellularAtDataReq
{
const uint8_t * pData; /**< Data to send. */
uint32_t dataLen; /**< Data length to send. */
uint32_t * pSentDataLength; /**< Data actually sent. */
const uint8_t * pEndPattern; /**< End pattern after pData is sent completely.
* Set NULL if not required. Cellular modem uses
* end pattern instead of length in AT command
* can make use of this variable. */
uint32_t endPatternLen; /**< End pattern length. */
} CellularAtDataReq_t;
/**
* @ingroup cellular_common_datatypes_functionpointers
* @brief URC handler function.
*
* @return Void.
*/
typedef void ( * CellularAtParseTokenHandler_t )( CellularContext_t * pContext,
char * pInputStr );
/**
* @ingroup cellular_common_datatypes_paramstructs
* @brief the URC token and URC handler mapping structure used by pkthanlder.
*/
typedef struct CellularAtParseTokenMap
{
const char * pStrValue; /**< The URC token string. */
CellularAtParseTokenHandler_t parserFunc; /**< The function pointer points to #CellularAtParseTokenHandler_t. */
} CellularAtParseTokenMap_t;
/**
* @ingroup cellular_common_datatypes_enums
* @brief enum representing different Socket State.
*/
typedef enum CellularSocketState
{
SOCKETSTATE_ALLOCATED = 0, /**< Socket is created. */
SOCKETSTATE_CONNECTING, /**< Socket is connecting in progress with remote peer. */
SOCKETSTATE_CONNECTED, /**< Socket is connected. */
SOCKETSTATE_DISCONNECTED /**< Socket is disconnected by remote peer or due to network error. */
} CellularSocketState_t;
/**
* @ingroup cellular_common_datatypes_paramstructs
* @brief Parameters involved in sending/receiving data through sockets.
*/
typedef struct CellularSocketContext
{
uint8_t contextId; /**< PDN context ID on which this socket exists. */
uint32_t socketId; /**< Socket ID of this socket. */
CellularSocketState_t socketState; /**< State of the socket, Allocated, Free etc. */
CellularSocketType_t socketType; /**< Type of socket, DGRAM or STREAM. */
CellularSocketDomain_t socketDomain; /**< Socket domain, IPV4 or V6. */
CellularSocketProtocol_t socketProtocol; /**< Socket transport protocol, TCP or UDP. */
CellularIPAddress_t localIpAddress; /**< IP address assigned to the device. */
uint16_t localPort; /**< Local Port. */
CellularSocketAccessMode_t dataMode; /**< Data Access mode enabled for this socket. */
/* Set using socket options. */
uint32_t sendTimeoutMs; /**< Send timeout value in milliseconds. */
uint32_t recvTimeoutMs; /**< Receive timeout value in milliseconds. */
/* Set during socket connect. */
CellularSocketAddress_t remoteSocketAddress; /**< Remote IP address and port. */
/* Callback functions. */
CellularSocketDataReadyCallback_t dataReadyCallback; /**< Informs data on this socket. */
void * pDataReadyCallbackContext; /**< Data ready callback context. */
CellularSocketOpenCallback_t openCallback; /**< Informs the socket open status. */
void * pOpenCallbackContext; /**< socket open callback context. */
CellularSocketClosedCallback_t closedCallback; /**< Informs the socket is closed. */
void * pClosedCallbackContext; /**< socket closed callback context. */
/* Modem data. */
void * pModemData; /**< Modem specific data. */
} CellularSocketContext_t;
/**
* @ingroup cellular_common_datatypes_paramstructs
* @brief Parameters to setup pktio and pkthandler token tables.
*/
typedef struct CellularTokenTable
{
/* URC handler mapping table. */
CellularAtParseTokenMap_t * pCellularUrcHandlerTable; /**< URC handler table. */
uint32_t cellularPrefixToParserMapSize; /**< URC handler table size. */
/* Table to decide AT command respone status. */
const char ** pCellularSrcTokenErrorTable; /**< Solicited error token table. */
uint32_t cellularSrcTokenErrorTableSize; /**< Solicited error token table size. */
const char ** pCellularSrcTokenSuccessTable; /**< Solicited success token table. */
uint32_t cellularSrcTokenSuccessTableSize; /**< Solicited success token table size. */
/* Table to URC with prefix Token. */
const char ** pCellularUrcTokenWoPrefixTable; /**< URC token without prefix table. */
uint32_t cellularUrcTokenWoPrefixTableSize; /**< URC token without prefix table size. */
/* Extra success token for specific AT command. */
const char ** pCellularSrcExtraTokenSuccessTable; /**< Extra token success table. */
uint32_t cellularSrcExtraTokenSuccessTableSize; /**< Extra token success table size. */
} CellularTokenTable_t;
/**
* @ingroup cellular_common_datatypes_functionpointers
* @brief Callback used to inform pktio the data start and the length of the data.
*
* @param[in] pCallbackContext The pCallbackContext in _Cellular_TimeoutAtcmdDataRecvRequestWithCallback.
* @param[in] pLine The input line form cellular modem.
* @param[in] lineLength The length of the input line from cellular modem.
* @param[out] pDataStart Is the start of of data in pLine.
* @param[out] pDataLength Is the data length.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful.
* CELLULAR_PKT_STATUS_SIZE_MISMATCH if more data is required.
* Otherwise an error code indicating the cause of the error.
*/
typedef CellularPktStatus_t ( * CellularATCommandDataPrefixCallback_t ) ( void * pCallbackContext,
char * pLine,
uint32_t lineLength,
char ** pDataStart,
uint32_t * pDataLength );
/**
* @ingroup cellular_common_datatypes_functionpointers
* @brief Callback used to fix the stream before the send data.
*
* @param[in] pCallbackContext The pCallbackContext in CellularATCommandDataSendPrefixCallback_t.
* @param[in,out] pLine The input line form cellular modem.
* @param[in,out] pBytesRead The length of the input line from cellular modem.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
typedef CellularPktStatus_t ( * CellularATCommandDataSendPrefixCallback_t ) ( void * pCallbackContext,
char * pLine,
uint32_t * pBytesRead );
/**
* @ingroup cellular_common_datatypes_functionpointers
* @brief Undefined response callback function.
*
* @param[in] pCallbackContext The pCallbackContext parameter in _Cellular_RegisterUndefinedRespCallback.
* @param[in] pLine The input line form cellular modem.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
typedef CellularPktStatus_t ( * CellularUndefinedRespCallback_t )( void * pCallbackContext,
const char * pLine );
/*-----------------------------------------------------------*/
/**
* @brief 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.
*
* @param[in,out] pCellularHandle The handle pointer to store the cellular handle.
* @param[in] pCommInterface Comm interface for communicating with the module.
* @param[in] pTokenTable Token tables for pkthandler and pktio.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
const CellularCommInterface_t * pCommInterface,
const CellularTokenTable_t * pTokenTable );
/**
* @brief 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.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_LibCleanup( CellularHandle_t cellularHandle );
/**
* @brief Call the network registration callback if the callback is previously set by
* Cellular_CommonRegisterUrcNetworkRegistrationEventCallback.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] urcEvent URC Event that happened.
* @param[in] pServiceStatus The status of the network service.
*/
void _Cellular_NetworkRegistrationCallback( const CellularContext_t * pContext,
CellularUrcEvent_t urcEvent,
const CellularServiceStatus_t * pServiceStatus );
/**
* @brief Call the network registration callback if the callback is previously set by
* Cellular_RegisterUrcPdnEventCallback.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] urcEvent URC Event that happened.
* @param[in] contextId Context ID of the PDN context.
*/
void _Cellular_PdnEventCallback( const CellularContext_t * pContext,
CellularUrcEvent_t urcEvent,
uint8_t contextId );
/**
* @brief Call the network registration callback if the callback is previously set by
* Cellular_RegisterUrcSignalStrengthChangedCallback.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] urcEvent URC Event that happened.
* @param[in] pSignalInfo The new signal information.
*/
void _Cellular_SignalStrengthChangedCallback( const CellularContext_t * pContext,
CellularUrcEvent_t urcEvent,
const CellularSignalInfo_t * pSignalInfo );
/**
* @brief Call the network registration callback if the callback is previously set by
* Cellular_RegisterUrcGenericCallback.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] pRawData Raw data received in the URC event.
*/
void _Cellular_GenericCallback( const CellularContext_t * pContext,
const char * pRawData );
/**
* @brief Call the network registration callback if the callback is previously set by
* Cellular_RegisterModemEventCallback.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] modemEvent The modem event.
*/
void _Cellular_ModemEventCallback( const CellularContext_t * pContext,
CellularModemEvent_t modemEvent );
/**
* @brief 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.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful , otherwise return error code.
*/
CellularError_t _Cellular_CheckLibraryStatus( CellularContext_t * pContext );
/**
* @brief Translate error code packet status to cellular Status.
*
* This Functions translates packet status to cellular Status.
*
* @param[in] status The packet status to translate.
*
* @return The corresponding CellularError_t.
*/
CellularError_t _Cellular_TranslatePktStatus( CellularPktStatus_t status );
/**
* @brief Translate Error Code AT Core status to Packet Status.
*
* This Functions translates AT Core status to Packet Status.
*
* @param[in] status The AT Core status to translate.
*
* @return The corresponding CellularPktStatus_t.
*/
CellularPktStatus_t _Cellular_TranslateAtCoreStatus( CellularATError_t status );
/**
* @brief Create a socket.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] contextId Pdn context id on which this socket needs to be created.
* @param[in] socketDomain Socket domain.
* @param[in] socketType Socket Type.
* @param[in] socketProtocol Socket Protocol.
* @param[out] pSocketHandle Out parameter to provide the created handle.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_CreateSocketData( CellularContext_t * pContext,
uint8_t contextId,
CellularSocketDomain_t socketDomain,
CellularSocketType_t socketType,
CellularSocketProtocol_t socketProtocol,
CellularSocketHandle_t * pSocketHandle );
/**
* @brief Remove the socket.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] socketHandle Socket handle returned from the Cellular_CreateSocket call.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_RemoveSocketData( CellularContext_t * pContext,
CellularSocketHandle_t socketHandle );
/**
* @brief Check socket index validity.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] sockIndex Socket index returned from cellular modem.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_IsValidSocket( const CellularContext_t * pContext,
uint32_t sockIndex );
/**
* @brief Get the socket data structure with socket index.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] sockIndex Socket index returned from cellular modem.
*
* @return The socket data pointer if the socket index is valid, otherwise NULL is returned.
*/
CellularSocketContext_t * _Cellular_GetSocketData( const CellularContext_t * pContext,
uint32_t sockIndex );
/**
* @brief Check PDN context index validity.
*
* @param[in] contextId The PDN context index to check.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_IsValidPdn( uint8_t contextId );
/**
* @brief Convert CSQ command returned RSSI value.
*
* @param[in] csqRssi The CSQ command returned RSSI index.
* @param[out] pRssiValue The output parameter to return the converted
* RSSI value in dBm.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_ConvertCsqSignalRssi( int16_t csqRssi,
int16_t * pRssiValue );
/**
* @brief Convert CSQ command retruned BER value.
*
* @param[in] csqBer The CSQ command returned BER index.
* @param[out] pBerValue The output parameter to return the converted
* BER value in 0.01%.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_ConvertCsqSignalBer( int16_t csqBer,
int16_t * pBerValue );
/**
* @brief Get the socket data structure with socket index.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[out] ppModuleContext The module context set in Cellular_ModuleInit function.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_GetModuleContext( const CellularContext_t * pContext,
void ** ppModuleContext );
/**
* @brief Convert the signal to bar.
*
* @param[in] rat Current RAT of the registered network.
* @param[in,out] pSignalInfo The signal value of current RAT. The result bar
* value is assigned in this structure.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_ComputeSignalBars( CellularRat_t rat,
CellularSignalInfo_t * pSignalInfo );
/**
* @brief Return the current RAT if previously received with 3GPP AT command.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[out] pRat Current RAT of the registered network.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t _Cellular_GetCurrentRat( CellularContext_t * pContext,
CellularRat_t * pRat );
/**
* @brief Send the AT command to cellular modem with default timeout.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_AtcmdRequestWithCallback( CellularContext_t * pContext,
CellularAtReq_t atReq );
/**
* @brief Send the AT command to cellular modem.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] timeoutMS The timeout value to wait for the response from cellular modem.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_TimeoutAtcmdRequestWithCallback( CellularContext_t * pContext,
CellularAtReq_t atReq,
uint32_t timeoutMS );
/**
* @brief Send the AT command to cellular modem with extra success token table.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
* @param[in] pCellularSrcTokenSuccessTable The extra success token table to indicate the send AT command success.
* @param[in] cellularSrcTokenSuccessTableSize The size of extra success token table.
*
* @note AT command request makes use of cellularSrcTokenSuccessTableSize to obtain
* the response status. Some AT commands don't have fixed success token. This function
* make use of a temporary table, pCellularSrcTokenSuccessTable, to obtain the response
* status.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_AtcmdRequestSuccessToken( CellularContext_t * pContext,
CellularAtReq_t atReq,
uint32_t atTimeoutMS,
const char ** pCellularSrcTokenSuccessTable,
uint32_t cellularSrcTokenSuccessTableSize );
/**
* @brief Send the AT command to cellular modem with data buffer response.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] timeoutMS The timeout value to wait for the response from cellular modem.
* @param[in] pktDataPrefixCallback The callback function to indicate the start of data and the length of data.
* @param[in] pCallbackContext The pCallbackContext passed to the pktDataPrefixCallback callback function.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_TimeoutAtcmdDataRecvRequestWithCallback( CellularContext_t * pContext,
CellularAtReq_t atReq,
uint32_t timeoutMS,
CellularATCommandDataPrefixCallback_t pktDataPrefixCallback,
void * pCallbackContext );
/**
* @brief Send the AT command to cellular modem with send data.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] dataReq The following data request after the at request.
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
* @param[in] dataTimeoutMS The timeout value to wait for the data command response from cellular modem.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_TimeoutAtcmdDataSendRequestWithCallback( CellularContext_t * pContext,
CellularAtReq_t atReq,
CellularAtDataReq_t dataReq,
uint32_t atTimeoutMS,
uint32_t dataTimeoutMS );
/**
* @brief Send the AT command to cellular modem with send data.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] dataReq The following data request after the at request.
* @param[in] pktDataSendPrefixCallback The callback function to inidcate the data sending start.
* @param[in] pCallbackContext The callback context pass to pktDataSendPrefixCallback function.
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
* @param[in] dataTimeoutMS The timeout value to wait for the data command response from cellular modem.
* @param[in] interDelayMS The delay between AT command and data send.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
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 );
/**
* @brief Send the AT command to cellular modem with send data and extra success token table
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] dataReq The following data request after the at request.
* @param[in] atTimeoutMS The timeout value to wait for the AT command response from cellular modem.
* @param[in] dataTimeoutMS The timeout value to wait for the data command response from cellular modem.
* @param[in] pCellularSrcTokenSuccessTable The extra success token table to indicate the send AT command success.
* @param[in] cellularSrcTokenSuccessTableSize The size of extra success token table.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
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 );
/**
* @brief Register undefined response callback.
*
* Cellular module can register the callback function to handle AT_UNDEFINED response
* through this function.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] undefinedRespCallback The callback function to handle the undefined response.
* @param[in] pCallbackContext The pCallbackContext passed to the undefinedRespCallback
* callback function if undefinedRespCallback is not NULL.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error code
* indicating the cause of the error.
*/
CellularError_t _Cellular_RegisterUndefinedRespCallback( CellularContext_t * pContext,
CellularUndefinedRespCallback_t undefinedRespCallback,
void * pCallbackContext );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_COMMON_H__ */

View File

@ -0,0 +1,312 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_common_api.h
*/
#ifndef __CELLULAR_COMMON_API_H__
#define __CELLULAR_COMMON_API_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
#include "cellular_types.h"
#include "cellular_common.h"
#include "cellular_comm_interface.h"
/*-----------------------------------------------------------*/
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_Init in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonInit( CellularHandle_t * pCellularHandle,
const CellularCommInterface_t * pCommInterface,
const CellularTokenTable_t * pTokenTable );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_Cleanup in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonCleanup( CellularHandle_t cellularHandle );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RegisterUrcNetworkRegistrationEventCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRegisterUrcNetworkRegistrationEventCallback( CellularHandle_t cellularHandle,
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RegisterUrcPdnEventCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRegisterUrcPdnEventCallback( CellularHandle_t cellularHandle,
CellularUrcPdnEventCallback_t pdnEventCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RegisterUrcSignalStrengthChangedCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRegisterUrcSignalStrengthChangedCallback( CellularHandle_t cellularHandle,
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RegisterUrcGenericCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRegisterUrcGenericCallback( CellularHandle_t cellularHandle,
CellularUrcGenericCallback_t genericCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RegisterModemEventCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRegisterModemEventCallback( CellularHandle_t cellularHandle,
CellularModemEventCallback_t modemEventCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_ATCommandRaw in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonATCommandRaw( CellularHandle_t cellularHandle,
const char * pATCommandPrefix,
const char * pATCommandPayload,
CellularATCommandType_t atCommandType,
CellularATCommandResponseReceivedCallback_t responseReceivedCallback,
void * pData,
uint16_t dataLen );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_CreateSocket in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonCreateSocket( CellularHandle_t cellularHandle,
uint8_t pdnContextId,
CellularSocketDomain_t socketDomain,
CellularSocketType_t socketType,
CellularSocketProtocol_t socketProtocol,
CellularSocketHandle_t * pSocketHandle );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_SocketSetSockOpt in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSocketSetSockOpt( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketOptionLevel_t optionLevel,
CellularSocketOption_t option,
const uint8_t * pOptionValue,
uint32_t optionValueLength );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_SocketRegisterDataReadyCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSocketRegisterDataReadyCallback( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketDataReadyCallback_t dataReadyCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_SocketRegisterSocketOpenCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSocketRegisterSocketOpenCallback( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketOpenCallback_t socketOpenCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_SocketRegisterClosedCallback in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSocketRegisterClosedCallback( CellularHandle_t cellularHandle,
CellularSocketHandle_t socketHandle,
CellularSocketClosedCallback_t closedCallback,
void * pCallbackContext );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RfOn in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRfOn( CellularHandle_t cellularHandle );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_RfOff in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonRfOff( CellularHandle_t cellularHandle );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetIPAddress in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetIPAddress( CellularHandle_t cellularHandle,
uint8_t contextId,
char * pBuffer,
uint32_t bufferLength );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetModemInfo in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetModemInfo( CellularHandle_t cellularHandle,
CellularModemInfo_t * pModemInfo );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetEidrxSettings in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetEidrxSettings( CellularHandle_t cellularHandle,
CellularEidrxSettingsList_t * pEidrxSettingsList );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_SetEidrxSettings in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSetEidrxSettings( CellularHandle_t cellularHandle,
const CellularEidrxSettings_t * pEidrxSettings );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetRegisteredNetwork in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetRegisteredNetwork( CellularHandle_t cellularHandle,
CellularPlmnInfo_t * pNetworkInfo );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetNetworkTime in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetNetworkTime( CellularHandle_t cellularHandle,
CellularTime_t * pNetworkTime );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetServiceStatus( CellularHandle_t cellularHandle,
CellularServiceStatus_t * pServiceStatus );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSetPdnConfig( CellularHandle_t cellularHandle,
uint8_t contextId,
const CellularPdnConfig_t * pPdnConfig );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetPsmSettings( CellularHandle_t cellularHandle,
CellularPsmSettings_t * pPsmSettings );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonSetPsmSettings( CellularHandle_t cellularHandle,
const CellularPsmSettings_t * pPsmSettings );
/**
* @brief This function is the common implementation of FreeRTOS Cellular Library API.
* Reference Cellular_GetServiceStatus in cellular_api.h for definition.
*/
CellularError_t Cellular_CommonGetSimCardInfo( CellularHandle_t cellularHandle,
CellularSimCardInfo_t * pSimCardInfo );
/**
* @brief Get SIM card lock status.
*
* @param[in] cellularHandle The opaque cellular context pointer created by Cellular_Init.
* @param[out] pSimCardStatus Out parameter to provide the SIM card status.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_CommonGetSimCardLockStatus( CellularHandle_t cellularHandle,
CellularSimCardStatus_t * pSimCardStatus );
/**
* @brief 3GPP URC AT+CEREG handler for FreeRTOS Cellular Library.
*
* This function handles the incoming URC and callback function.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
* @param[in] pInputLine the input URC string.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t Cellular_CommonUrcProcessCereg( CellularContext_t * pContext,
char * pInputLine );
/**
* @brief 3GPP URC AT+CGREG handler for FreeRTOS Cellular Library.
*
* This function handles the incoming URC and callback function.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
* @param[in] pInputLine the input URC string.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t Cellular_CommonUrcProcessCgreg( CellularContext_t * pContext,
char * pInputLine );
/**
* @brief 3GPP URC AT+CREG handler for FreeRTOS Cellular Library.
*
* This function handles the incoming URC and callback function.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
* @param[in] pInputLine the input URC string.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t Cellular_CommonUrcProcessCreg( CellularContext_t * pContext,
char * pInputLine );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_COMMON_API_H__ */

View File

@ -0,0 +1,100 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
/**
* @file cellular_common_portable.h
*/
#ifndef __CELLULAR_COMMON_PORTABLE_H__
#define __CELLULAR_COMMON_PORTABLE_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
#include <stdint.h>
#include "cellular_common.h"
/*-----------------------------------------------------------*/
/**
* @brief Cellular module init function.
*
* This function is called in Cellular_CommonInit to setup cellular module context.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
* @param[in] ppModuleContext Cellular module context can be obtained with _Cellular_GetModuleContext.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_ModuleInit( const CellularContext_t * pContext,
void ** ppModuleContext );
/**
* @brief Cellular module cleanup function.
*
* This function cleans up the module context.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_ModuleCleanUp( const CellularContext_t * pContext );
/**
* @brief Cellular module user equipment setup function.
*
* This function setups the user equipment of the cellular module.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext );
/**
* @brief Cellular module URC enable function.
*
* This function enable the unsolicited result code of the cellular module.
*
* @param[in,out] pContext FreeRTOS Cellular Library context created in Cellular_Init.
*
* @return CELLULAR_SUCCESS if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularError_t Cellular_ModuleEnableUrc( CellularContext_t * pContext );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* End of __CELLULAR_COMMON_PORTABLE_H__. */

View File

@ -0,0 +1,234 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
#ifndef __CELLULAR_COMMON_INTERNAL_H__
#define __CELLULAR_COMMON_INTERNAL_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
/* Cellular includes. */
#include "cellular_platform.h"
#include "cellular_pkthandler_internal.h"
#include "cellular_at_core.h"
#include "cellular_pktio_internal.h"
/*-----------------------------------------------------------*/
#define PKTIO_READ_BUFFER_SIZE ( 1600U ) /* This should be larger than TCP packet size. */
#define PKTIO_WRITE_BUFFER_SIZE ( CELLULAR_AT_CMD_MAX_SIZE )
/*-----------------------------------------------------------*/
/**
* @brief Cellular network register URC type.
*/
typedef enum CellularNetworkRegType
{
CELLULAR_REG_TYPE_CREG = 0,
CELLULAR_REG_TYPE_CGREG,
CELLULAR_REG_TYPE_CEREG,
CELLULAR_REG_TYPE_MAX,
CELLULAR_REG_TYPE_UNKNOWN
} CellularNetworkRegType_t;
/**
* @brief Represents different URC event callback registration function.
*/
typedef struct _callbackEvents
{
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback;
void * pNetworkRegistrationCallbackContext;
CellularUrcPdnEventCallback_t pdnEventCallback;
void * pPdnEventCallbackContext;
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback;
void * pSignalStrengthChangedCallbackContext;
CellularUrcGenericCallback_t genericCallback;
void * pGenericCallbackContext;
CellularModemEventCallback_t modemEventCallback;
void * pModemEventCallbackContext;
} _callbackEvents_t;
/**
* @brief Structure containing all the control plane parameters of Modem.
*/
typedef struct cellularAtData
{
CellularRat_t rat; /* Device registered Radio Access Technology (Cat-M, Cat-NB, GPRS etc). */
CellularNetworkRegistrationStatus_t csRegStatus; /* CS (Circuit Switched) registration status (registered/searching/roaming etc.). */
CellularNetworkRegistrationStatus_t psRegStatus; /* PS (Packet Switched) registration status (registered/searching/roaming etc.). */
uint8_t csRejectType; /* CS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
uint8_t csRejCause; /* Circuit Switch Reject cause. */
uint8_t psRejectType; /* PS Reject Type. 0 - 3GPP specific Reject Cause. 1 - Manufacture specific. */
uint8_t psRejCause; /* Packet Switch Reject cause. */
uint32_t cellId; /* Registered network operator cell Id. */
uint16_t lac; /* Registered network operator Location Area Code. */
uint16_t rac; /* Registered network operator Routing Area Code. */
uint16_t tac; /* Registered network operator Tracking Area Code. */
} cellularAtData_t;
/**
* @brief Parameters involved in maintaining the context for the modem.
*/
struct CellularContext
{
/* Communication interface for target specific. */
const CellularCommInterface_t * pCommIntf;
/* Common library. */
bool bLibOpened; /* CellularLib is currently open */
bool bLibShutdown; /* CellularLib prematurely shut down */
bool bLibClosing; /* Graceful shutdown in progress */
PlatformMutex_t libStatusMutex;
PlatformMutex_t libAtDataMutex;
_callbackEvents_t cbEvents; /* Call back functions registered to report events. */
cellularAtData_t libAtData; /* Global variables. */
/* Token table to config pkthandler and pktio. */
CellularTokenTable_t tokenTable;
/* Packet handler. */
PlatformMutex_t pktRequestMutex; /* The mutex for sending request. */
PlatformMutex_t PktRespMutex; /* The mutex for parsing the response from modem. */
QueueHandle_t pktRespQueue;
CellularATCommandResponseReceivedCallback_t pktRespCB;
CellularATCommandDataPrefixCallback_t pktDataPrefixCB; /* Data prefix callback function for socket receive function. */
void * pDataPrefixCBContext; /* The pCallbackContext passed to CellularATCommandDataPrefixCallback_t. */
CellularATCommandDataSendPrefixCallback_t pktDataSendPrefixCB; /* Data prefix callback function for socket send function. */
void * pDataSendPrefixCBContext; /* The pCallbackContext passed to CellularATCommandDataSendPrefixCallback_t. */
void * pPktUsrData; /* The pData passed to CellularATCommandResponseReceivedCallback_t. */
uint16_t PktUsrDataLen; /* The dataLen passed to CellularATCommandResponseReceivedCallback_t. */
const char * pCurrentCmd; /* Debug purpose. */
/* Packet IO. */
bool bPktioUp;
CellularCommInterfaceHandle_t hPktioCommIntf;
PlatformEventGroupHandle_t pPktioCommEvent;
_pPktioShutdownCallback_t pPktioShutdownCB;
_pPktioHandlePacketCallback_t pPktioHandlepktCB;
char pktioSendBuf[ PKTIO_WRITE_BUFFER_SIZE + 1 ];
char pktioReadBuf[ PKTIO_READ_BUFFER_SIZE + 1 ];
char * pPktioReadPtr;
const char * pRespPrefix;
char pktRespPrefixBuf[ CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH ];
CellularATCommandType_t PktioAtCmdType;
_atRespType_t recvdMsgType;
CellularUndefinedRespCallback_t undefinedRespCallback;
void * pUndefinedRespCBContext;
/* PktIo data handling. */
uint32_t dataLength;
uint32_t partialDataRcvdLen;
/* Socket. */
CellularSocketContext_t * pSocketData[ CELLULAR_NUM_SOCKET_MAX ]; /* All socket related information. */
/* Module Context. */
void * pModueContext;
};
/*-----------------------------------------------------------*/
/**
* @brief Netwrok registration respone parsing function.
*
* Parse the network registration response from AT command response or URC.
* The result is stored in the pContext.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] pRegPayload The input string from AT command respnose or URC.
* @param[in] isUrc The input string source type.
* @param[in] regType The network registration type.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,
char * pRegPayload,
bool isUrc,
CellularNetworkRegType_t regType );
/**
* @brief Initializes the AT data structures.
*
* Function is invokes to initialize the AT data structure during
* very first initialization, upon deregistration and upon receiving
* network reject during registration.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] mode Parameter that identifies which elements in Data Structure
* to be initialized.
*/
void _Cellular_InitAtData( CellularContext_t * pContext,
uint32_t mode );
/**
* @brief Create the AT data mutex.
*
* Create the mutex for AT data in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
bool _Cellular_CreateAtDataMutex( CellularContext_t * pContext );
/**
* @brief Destroy the AT data mutex.
*
* Destroy the mutex for AT data in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*
*/
void _Cellular_DestroyAtDataMutex( CellularContext_t * pContext );
/**
* @brief Lock the AT data mutex.
*
* Lock the mutex for AT data in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
void _Cellular_LockAtDataMutex( CellularContext_t * pContext );
/**
* @brief Unlock the AT data mutex.
*
* Unlock the mutex for AT data in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
void _Cellular_UnlockAtDataMutex( CellularContext_t * pContext );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* ifndef __CELLULAR_COMMON_INTERNAL_H__ */

View File

@ -0,0 +1,43 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
#ifndef __CELLULAR_INTERNAL_H__
#define __CELLULAR_INTERNAL_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
#include "cellular_platform.h"
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_INTERNAL_H__ */

View File

@ -0,0 +1,157 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
#ifndef __CELLULAR_PKTHANDLER_INTERNAL_H__
#define __CELLULAR_PKTHANDLER_INTERNAL_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
/* Include custom config file before other headers. */
#include "cellular_config.h"
#endif
#include "cellular_config_defaults.h"
#include "cellular_types.h"
#include "cellular_common.h"
#include "cellular_pktio_internal.h"
/*-----------------------------------------------------------*/
/* AT Command timeout for general AT commands. */
#define PACKET_REQ_TIMEOUT_MS CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS
/*-----------------------------------------------------------*/
/**
* @brief Create the packet request mutex.
*
* Create the mutex for packet rquest in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
bool _Cellular_CreatePktRequestMutex( CellularContext_t * pContext );
/**
* @brief Destroy the packet request mutex.
*
* Destroy the mutex for packet rquest in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
void _Cellular_DestroyPktRequestMutex( CellularContext_t * pContext );
/**
* @brief Create the packet response mutex.
*
* Create the mutex for packet response in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
bool _Cellular_CreatePktResponseMutex( CellularContext_t * pContext );
/**
* @brief Destroy the packet response mutex.
*
* Destroy the mutex for packet response in cellular context.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
void _Cellular_DestroyPktResponseMutex( CellularContext_t * pContext );
/**
* @brief Packet handler init function.
*
* This function init the packet handler in FreeRTOS Cellular Library common.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_PktHandlerInit( CellularContext_t * pContext );
/**
* @brief Packet handler cleanup function.
*
* This function cleanup the pakcet handler in FreeRTOS Cellular Library common.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
void _Cellular_PktHandlerCleanup( CellularContext_t * pContext );
/**
* @brief Packet handler function.
*
* This function is the callback function of packet handler. It is called by packet IO thread.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atRespType The AT response type from packet IO.
* @param[in] pBuf The input data buffer from packet IO.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_HandlePacket( CellularContext_t * pContext,
_atRespType_t atRespType,
const void * pBuf );
/**
* @brief The URC handler init function.
*
* This function setup the URC handler table query function.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_AtParseInit( const CellularContext_t * pContext );
/**
* @brief Wrapper for sending the AT command to cellular modem.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atReq The AT command data structure with send command response callback.
* @param[in] timeoutMS The timeout value to wait for the response from cellular modem.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_PktHandler_AtcmdRequestWithCallback( CellularContext_t * pContext,
CellularAtReq_t atReq,
uint32_t timeoutMS );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_PKTHANDLER_INTERNAL_H__ */

View File

@ -0,0 +1,142 @@
/*
* FreeRTOS-Cellular-Interface v1.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*/
#ifndef __CELLULAR_PKTIO_INTERNAL_H__
#define __CELLULAR_PKTIO_INTERNAL_H__
/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C" {
#endif
/* *INDENT-ON* */
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
/* Include custom config file before other headers. */
#include "cellular_config.h"
#endif
#include "cellular_config_defaults.h"
#include "cellular_types.h"
/*-----------------------------------------------------------*/
/**
* @brief The received AT response type.
*/
typedef enum _atRespType
{
AT_SOLICITED = 0,
AT_UNSOLICITED,
AT_UNDEFINED
} _atRespType_t;
/**
* @brief Callback used to inform packet received.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] atRespType The received packet type.
* @param[in] pBuf The input data buffer from packet IO.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
typedef CellularPktStatus_t ( * _pPktioHandlePacketCallback_t ) ( CellularContext_t * pContext,
_atRespType_t atRespType,
const void * pBuffer );
/**
* @brief Callback used to inform packet IO thread shutdown.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
typedef void ( * _pPktioShutdownCallback_t ) ( CellularContext_t * pContext );
/*-----------------------------------------------------------*/
/**
* @brief Packet IO init function.
*
* This function init the packet IO in FreeRTOS Cellular Library common.
* Packet IO thread is created in this function.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] handlePacketCb The callback function to handle the packet received.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_PktioInit( CellularContext_t * pContext,
_pPktioHandlePacketCallback_t handlePacketCb );
/**
* @brief Packet IO shutdown function.
*
* This function shutdown the packet IO in FreeRTOS Cellular Library common.
* Packet IO thread is shutdown in this function.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
*/
void _Cellular_PktioShutdown( CellularContext_t * pContext );
/**
* @brief Send AT command function.
*
* This function setup the internal data of pktio and send the AT command through comm interface.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] pAtCmd The AT command to send.
* @param[in] atType The AT command type.
* @param[in] pAtRspPrefix The AT command response prefix.
*
* @return CELLULAR_PKT_STATUS_OK if the operation is successful, otherwise an error
* code indicating the cause of the error.
*/
CellularPktStatus_t _Cellular_PktioSendAtCmd( CellularContext_t * pContext,
const char * pAtCmd,
CellularATCommandType_t atType,
const char * pAtRspPrefix );
/**
* @brief Send data command function.
*
* This function setup the internal data of pktio and send the data through comm interface.
*
* @param[in] pContext The opaque cellular context pointer created by Cellular_Init.
* @param[in] pData The data to send.
* @param[in] dataLen The data length of pData.
*
* @return The data actually send to the comm interface.
*/
uint32_t _Cellular_PktioSendData( CellularContext_t * pContext,
const uint8_t * pData,
uint32_t dataLen );
/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */
#endif /* __CELLULAR_PKTIO_INTERNAL_H__ */