FreeRTOS: FreeRTOS Cellular Library v1.4.0
FreeRTOS Cellular Library
 
Loading...
Searching...
No Matches
cellular_common_internal.h
1/*
2 * FreeRTOS-Cellular-Interface v1.4.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
26 */
27
28#ifndef __CELLULAR_COMMON_INTERNAL_H__
29#define __CELLULAR_COMMON_INTERNAL_H__
30
31/* *INDENT-OFF* */
32#ifdef __cplusplus
33 extern "C" {
34#endif
35/* *INDENT-ON* */
36
37/* Cellular includes. */
38
39#include "cellular_platform.h"
40#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
41 /* Include custom config file before other headers. */
42 #include "cellular_config.h"
43#endif
45#include "cellular_pkthandler_internal.h"
46#include "cellular_at_core.h"
47#include "cellular_pktio_internal.h"
48
49/*-----------------------------------------------------------*/
50
51#define PKTIO_READ_BUFFER_SIZE ( CELLULAR_CONFIG_PKTIO_READ_BUFFER_SIZE )
52#define PKTIO_WRITE_BUFFER_SIZE ( CELLULAR_AT_CMD_MAX_SIZE )
53
54/*-----------------------------------------------------------*/
55
60typedef enum CellularNetworkRegType
61{
68
73typedef struct _callbackEvents
74{
86
91typedef struct cellularAtData
92{
96 uint8_t csRejectType;
97 uint8_t csRejCause;
98 uint8_t psRejectType;
99 uint8_t psRejCause;
100 uint32_t cellId;
101 uint16_t lac;
102 uint16_t rac;
103 uint16_t tac;
105
111{
114 /* Common library. */
118 PlatformMutex_t libStatusMutex;
119 PlatformMutex_t libAtDataMutex;
125 /* Packet handler. */
126 PlatformMutex_t pktRequestMutex;
127 PlatformMutex_t PktRespMutex;
128 PlatformQueueHandle_t pktRespQueue;
134 void * pPktUsrData;
135 uint16_t PktUsrDataLen;
136 const char * pCurrentCmd;
138 /* Packet IO. */
139 bool bPktioUp;
141 PlatformEventGroupHandle_t pPktioCommEvent;
142 _pPktioShutdownCallback_t pPktioShutdownCB;
143 _pPktioHandlePacketCallback_t pPktioHandlepktCB;
144 char pktioSendBuf[ PKTIO_WRITE_BUFFER_SIZE + 1 ];
145 char pktioReadBuf[ PKTIO_READ_BUFFER_SIZE + 1 ];
147 const char * pRespPrefix;
150 _atRespType_t recvdMsgType;
157 /* PktIo data handling. */
158 uint32_t dataLength;
164};
165
166/*-----------------------------------------------------------*/
167
182CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,
183 char * pRegPayload,
184 bool isUrc,
185 CellularNetworkRegType_t regType );
186
198void _Cellular_InitAtData( CellularContext_t * pContext,
199 uint32_t mode );
200
208bool _Cellular_CreateAtDataMutex( CellularContext_t * pContext );
209
218void _Cellular_DestroyAtDataMutex( CellularContext_t * pContext );
219
220
228void _Cellular_LockAtDataMutex( CellularContext_t * pContext );
229
237void _Cellular_UnlockAtDataMutex( CellularContext_t * pContext );
238
239/* *INDENT-OFF* */
240#ifdef __cplusplus
241 }
242#endif
243/* *INDENT-ON* */
244
245#endif /* ifndef __CELLULAR_COMMON_INTERNAL_H__ */
struct CellularCommInterfaceContext * CellularCommInterfaceHandle_t
Opaque handle to comm interface.
Definition: cellular_comm_interface.h:65
CellularPktStatus_t(* CellularUndefinedRespCallback_t)(void *pCallbackContext, const char *pLine)
Undefined response callback function.
Definition: cellular_common.h:223
CellularPktStatus_t(* CellularInputBufferCallback_t)(void *pInputBufferCallbackContext, char *pBuffer, uint32_t bufferLength, uint32_t *pBufferLengthHandled)
Callback used to process input buffer.
Definition: cellular_common.h:240
CellularPktStatus_t(* CellularATCommandDataPrefixCallback_t)(void *pCallbackContext, char *pLine, uint32_t lineLength, char **pDataStart, uint32_t *pDataLength)
Callback used to inform pktio the data start and the length of the data.
Definition: cellular_common.h:192
CellularPktStatus_t(* CellularATCommandDataSendPrefixCallback_t)(void *pCallbackContext, char *pLine, uint32_t *pBytesRead)
Callback used to fix the stream before the send data.
Definition: cellular_common.h:209
This represents the default values for the configuration macros for the Cellular library.
#define CELLULAR_NUM_SOCKET_MAX
Cellular module number of socket max size.
Definition: cellular_config_defaults.h:213
#define CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH
Cellular AT command response prefix string length.
Definition: cellular_config_defaults.h:401
CellularNetworkRegistrationStatus_t
Represents network registration status. Reference 3GPP TS 27.007 network registration status.
Definition: cellular_types.h:181
CellularPktStatus_t
packet Status Names.
Definition: cellular_types.h:338
CellularATCommandType_t
Represents AT Command type.
Definition: cellular_types.h:360
CellularRat_t
Enums representing Radio Access Technologies (RATs). Reference 3GPP TS 27.007 PLMN selection +COPS.
Definition: cellular_types.h:111
CellularNetworkRegType_t
Cellular network register URC type.
Definition: cellular_common_internal.h:61
@ CELLULAR_REG_TYPE_CEREG
Definition: cellular_common_internal.h:64
@ CELLULAR_REG_TYPE_MAX
Definition: cellular_common_internal.h:65
@ CELLULAR_REG_TYPE_CREG
Definition: cellular_common_internal.h:62
@ CELLULAR_REG_TYPE_UNKNOWN
Definition: cellular_common_internal.h:66
@ CELLULAR_REG_TYPE_CGREG
Definition: cellular_common_internal.h:63
void(* CellularModemEventCallback_t)(CellularModemEvent_t modemEvent, void *pCallbackContext)
Callback used to inform about modem events.
Definition: cellular_types.h:789
void(* CellularUrcSignalStrengthChangedCallback_t)(CellularUrcEvent_t urcEvent, const CellularSignalInfo_t *pSignalInfo, void *pCallbackContext)
Callback used to inform about signal strength changed URC event.
Definition: cellular_types.h:766
void(* CellularUrcPdnEventCallback_t)(CellularUrcEvent_t urcEvent, uint8_t contextId, void *pCallbackContext)
Callback used to inform about PDN URC events.
Definition: cellular_types.h:753
void(* CellularUrcNetworkRegistrationCallback_t)(CellularUrcEvent_t urcEvent, const CellularServiceStatus_t *pServiceStatus, void *pCallbackContext)
Callback used to inform about a Network Registration URC event.
Definition: cellular_types.h:740
CellularPktStatus_t(* CellularATCommandResponseReceivedCallback_t)(CellularHandle_t cellularHandle, const CellularATCommandResponse_t *pAtResp, void *pData, uint16_t dataLen)
Callback used to inform about the response of an AT command sent using Cellular_ATCommandRaw API.
Definition: cellular_types.h:726
void(* CellularUrcGenericCallback_t)(const char *pRawData, void *pCallbackContext)
Generic callback used to inform all other URC events.
Definition: cellular_types.h:778
Represents different URC event callback registration function.
Definition: cellular_common_internal.h:74
CellularUrcNetworkRegistrationCallback_t networkRegistrationCallback
Definition: cellular_common_internal.h:75
void * pPdnEventCallbackContext
Definition: cellular_common_internal.h:78
void * pModemEventCallbackContext
Definition: cellular_common_internal.h:84
CellularUrcGenericCallback_t genericCallback
Definition: cellular_common_internal.h:81
CellularModemEventCallback_t modemEventCallback
Definition: cellular_common_internal.h:83
void * pGenericCallbackContext
Definition: cellular_common_internal.h:82
CellularUrcPdnEventCallback_t pdnEventCallback
Definition: cellular_common_internal.h:77
void * pNetworkRegistrationCallbackContext
Definition: cellular_common_internal.h:76
void * pSignalStrengthChangedCallbackContext
Definition: cellular_common_internal.h:80
CellularUrcSignalStrengthChangedCallback_t signalStrengthChangedCallback
Definition: cellular_common_internal.h:79
Represents AT Command response.
Definition: cellular_types.h:483
Represents the functions of a comm interface.
Definition: cellular_comm_interface.h:160
Parameters involved in maintaining the context for the modem.
Definition: cellular_common_internal.h:111
uint32_t partialDataRcvdLen
Definition: cellular_common_internal.h:159
CellularATCommandDataSendPrefixCallback_t pktDataSendPrefixCB
Definition: cellular_common_internal.h:132
bool bLibOpened
Definition: cellular_common_internal.h:115
PlatformEventGroupHandle_t pPktioCommEvent
Definition: cellular_common_internal.h:141
CellularATCommandResponseReceivedCallback_t pktRespCB
Definition: cellular_common_internal.h:129
const char * pRespPrefix
Definition: cellular_common_internal.h:147
char pktRespPrefixBuf[CELLULAR_CONFIG_MAX_PREFIX_STRING_LENGTH]
Definition: cellular_common_internal.h:148
bool bLibClosing
Definition: cellular_common_internal.h:117
char pktioReadBuf[PKTIO_READ_BUFFER_SIZE+1]
Definition: cellular_common_internal.h:145
uint32_t dataLength
Definition: cellular_common_internal.h:158
_callbackEvents_t cbEvents
Definition: cellular_common_internal.h:120
const CellularCommInterface_t * pCommIntf
Definition: cellular_common_internal.h:112
CellularUndefinedRespCallback_t undefinedRespCallback
Definition: cellular_common_internal.h:151
PlatformQueueHandle_t pktRespQueue
Definition: cellular_common_internal.h:128
CellularSocketContext_t * pSocketData[CELLULAR_NUM_SOCKET_MAX]
Definition: cellular_common_internal.h:161
void * pDataSendPrefixCBContext
Definition: cellular_common_internal.h:133
void * pModuleContext
Definition: cellular_common_internal.h:163
_pPktioShutdownCallback_t pPktioShutdownCB
Definition: cellular_common_internal.h:142
PlatformMutex_t pktRequestMutex
Definition: cellular_common_internal.h:126
void * pInputBufferCallbackContext
Definition: cellular_common_internal.h:154
void * pPktUsrData
Definition: cellular_common_internal.h:134
CellularATCommandDataPrefixCallback_t pktDataPrefixCB
Definition: cellular_common_internal.h:130
CellularATCommandType_t PktioAtCmdType
Definition: cellular_common_internal.h:149
CellularInputBufferCallback_t inputBufferCallback
Definition: cellular_common_internal.h:153
bool bPktioUp
Definition: cellular_common_internal.h:139
_pPktioHandlePacketCallback_t pPktioHandlepktCB
Definition: cellular_common_internal.h:143
_atRespType_t recvdMsgType
Definition: cellular_common_internal.h:150
cellularAtData_t libAtData
Definition: cellular_common_internal.h:121
CellularATCommandResponse_t * pAtCmdResp
Definition: cellular_common_internal.h:155
CellularCommInterfaceHandle_t hPktioCommIntf
Definition: cellular_common_internal.h:140
uint16_t PktUsrDataLen
Definition: cellular_common_internal.h:135
void * pUndefinedRespCBContext
Definition: cellular_common_internal.h:152
char * pPktioReadPtr
Definition: cellular_common_internal.h:146
void * pDataPrefixCBContext
Definition: cellular_common_internal.h:131
const char * pCurrentCmd
Definition: cellular_common_internal.h:136
PlatformMutex_t PktRespMutex
Definition: cellular_common_internal.h:127
PlatformMutex_t libStatusMutex
Definition: cellular_common_internal.h:118
char pktioSendBuf[PKTIO_WRITE_BUFFER_SIZE+1]
Definition: cellular_common_internal.h:144
bool bLibShutdown
Definition: cellular_common_internal.h:116
PlatformMutex_t libAtDataMutex
Definition: cellular_common_internal.h:119
CellularTokenTable_t tokenTable
Definition: cellular_common_internal.h:123
Parameters involved in sending/receiving data through sockets.
Definition: cellular_common.h:123
Parameters to setup pktio and pkthandler token tables.
Definition: cellular_common.h:158
Structure containing all the control plane parameters of Modem.
Definition: cellular_common_internal.h:92
uint8_t csRejCause
Definition: cellular_common_internal.h:97
CellularNetworkRegistrationStatus_t psRegStatus
Definition: cellular_common_internal.h:95
uint16_t rac
Definition: cellular_common_internal.h:102
uint16_t lac
Definition: cellular_common_internal.h:101
CellularRat_t rat
Definition: cellular_common_internal.h:93
uint16_t tac
Definition: cellular_common_internal.h:103
uint8_t psRejectType
Definition: cellular_common_internal.h:98
uint8_t csRejectType
Definition: cellular_common_internal.h:96
uint32_t cellId
Definition: cellular_common_internal.h:100
CellularNetworkRegistrationStatus_t csRegStatus
Definition: cellular_common_internal.h:94
uint8_t psRejCause
Definition: cellular_common_internal.h:99