[修改] 增加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,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__. */