mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-16 09:47:44 -04:00
Update FreeRTOS-Cellular-Interface submodule pointer (#775)
* Update cellular sub-module pointer * Add more log in cellular_setup.c to indicate error * Adjust cellular transport timeout value for demo application * Add default cellular module specific config in cellular_config.h
This commit is contained in:
parent
778ba90b96
commit
1ce4d784cc
9 changed files with 99 additions and 29 deletions
|
@ -61,6 +61,8 @@
|
||||||
|
|
||||||
#define CELLULAR_PDN_CONNECT_WAIT_INTERVAL_MS ( 1000UL )
|
#define CELLULAR_PDN_CONNECT_WAIT_INTERVAL_MS ( 1000UL )
|
||||||
|
|
||||||
|
#define CELLULAR_PDN_CONTEXT_NUM ( CELLULAR_PDN_CONTEXT_ID_MAX - CELLULAR_PDN_CONTEXT_ID_MIN + 1U )
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* the default Cellular comm interface in system. */
|
/* the default Cellular comm interface in system. */
|
||||||
|
@ -86,17 +88,23 @@ bool setupCellular( void )
|
||||||
CellularCommInterface_t * pCommIntf = &CellularCommInterface;
|
CellularCommInterface_t * pCommIntf = &CellularCommInterface;
|
||||||
uint8_t tries = 0;
|
uint8_t tries = 0;
|
||||||
CellularPdnConfig_t pdnConfig = { CELLULAR_PDN_CONTEXT_IPV4, CELLULAR_PDN_AUTH_NONE, CELLULAR_APN, "", "" };
|
CellularPdnConfig_t pdnConfig = { CELLULAR_PDN_CONTEXT_IPV4, CELLULAR_PDN_AUTH_NONE, CELLULAR_APN, "", "" };
|
||||||
CellularPdnStatus_t PdnStatusBuffers = { 0 };
|
CellularPdnStatus_t PdnStatusBuffers[ CELLULAR_PDN_CONTEXT_NUM ] = { 0 };
|
||||||
char localIP[ CELLULAR_IP_ADDRESS_MAX_SIZE ] = { '\0' };
|
char localIP[ CELLULAR_IP_ADDRESS_MAX_SIZE ] = { '\0' };
|
||||||
uint32_t timeoutCountLimit = ( CELLULAR_PDN_CONNECT_TIMEOUT / CELLULAR_PDN_CONNECT_WAIT_INTERVAL_MS ) + 1U;
|
uint32_t timeoutCountLimit = ( CELLULAR_PDN_CONNECT_TIMEOUT / CELLULAR_PDN_CONNECT_WAIT_INTERVAL_MS ) + 1U;
|
||||||
uint32_t timeoutCount = 0;
|
uint32_t timeoutCount = 0;
|
||||||
uint8_t NumStatus = 1;
|
uint8_t NumStatus = 0;
|
||||||
CellularPsmSettings_t psmSettings = { 0 };
|
CellularPsmSettings_t psmSettings = { 0 };
|
||||||
|
bool pdnStatus = false;
|
||||||
|
uint32_t i = 0U;
|
||||||
|
|
||||||
/* Initialize Cellular Comm Interface. */
|
/* Initialize Cellular Comm Interface. */
|
||||||
cellularStatus = Cellular_Init( &CellularHandle, pCommIntf );
|
cellularStatus = Cellular_Init( &CellularHandle, pCommIntf );
|
||||||
|
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_Init failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* wait until SIM is ready */
|
/* wait until SIM is ready */
|
||||||
for( tries = 0; tries < CELLULAR_MAX_SIM_RETRY; tries++ )
|
for( tries = 0; tries < CELLULAR_MAX_SIM_RETRY; tries++ )
|
||||||
|
@ -107,19 +115,7 @@ bool setupCellular( void )
|
||||||
( ( simStatus.simCardState == CELLULAR_SIM_CARD_INSERTED ) &&
|
( ( simStatus.simCardState == CELLULAR_SIM_CARD_INSERTED ) &&
|
||||||
( simStatus.simCardLockState == CELLULAR_SIM_CARD_READY ) ) )
|
( simStatus.simCardLockState == CELLULAR_SIM_CARD_READY ) ) )
|
||||||
{
|
{
|
||||||
/* Turn of PSM because this is demo to showcase MQTT instead of PSM mode. */
|
configPRINTF( ( ">>> Cellular SIM okay <<<\r\n" ) );
|
||||||
psmSettings.mode = 0;
|
|
||||||
cellularStatus = cellularStatus = Cellular_SetPsmSettings( CellularHandle, &psmSettings );
|
|
||||||
|
|
||||||
if( cellularStatus != CELLULAR_SUCCESS )
|
|
||||||
{
|
|
||||||
configPRINTF( ( ">>> Cellular_SetPsmSettings failure <<<\r\n" ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
configPRINTF( ( ">>> Cellular SIM okay <<<\r\n" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -131,27 +127,55 @@ bool setupCellular( void )
|
||||||
|
|
||||||
vTaskDelay( pdMS_TO_TICKS( CELLULAR_SIM_CARD_WAIT_INTERVAL_MS ) );
|
vTaskDelay( pdMS_TO_TICKS( CELLULAR_SIM_CARD_WAIT_INTERVAL_MS ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular SIM failure <<<\r\n" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Turn off PSM because this is demo to showcase MQTT instead of PSM mode. */
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
psmSettings.mode = 0;
|
||||||
|
cellularStatus = cellularStatus = Cellular_SetPsmSettings( CellularHandle, &psmSettings );
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_SetPsmSettings failure <<<\r\n" ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the PDN config. */
|
/* Setup the PDN config. */
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
cellularStatus = Cellular_SetPdnConfig( CellularHandle, CellularSocketPdnContextId, &pdnConfig );
|
cellularStatus = Cellular_SetPdnConfig( CellularHandle, CellularSocketPdnContextId, &pdnConfig );
|
||||||
}
|
|
||||||
else
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
configPRINTF( ( ">>> Cellular SIM failure <<<\r\n" ) );
|
configPRINTF( ( ">>> Cellular_SetPdnConfig failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rescan network. */
|
/* Rescan network. */
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
cellularStatus = Cellular_RfOff( CellularHandle );
|
cellularStatus = Cellular_RfOff( CellularHandle );
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_RfOff failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
cellularStatus = Cellular_RfOn( CellularHandle );
|
cellularStatus = Cellular_RfOn( CellularHandle );
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_RfOn failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get service status. */
|
/* Get service status. */
|
||||||
|
@ -178,8 +202,10 @@ bool setupCellular( void )
|
||||||
|
|
||||||
if( timeoutCount >= timeoutCountLimit )
|
if( timeoutCount >= timeoutCountLimit )
|
||||||
{
|
{
|
||||||
cellularStatus = CELLULAR_INVALID_HANDLE;
|
/* Return timeout to indicate network is not registered within
|
||||||
configPRINTF( ( ">>> Cellular module can't be registered <<<\r\n" ) );
|
* CELLULAR_PDN_CONNECT_TIMEOUT. */
|
||||||
|
cellularStatus = CELLULAR_TIMEOUT;
|
||||||
|
configPRINTF( ( ">>> Cellular module can't be registered within CELLULAR_PDN_CONNECT_TIMEOUT <<<\r\n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay( pdMS_TO_TICKS( CELLULAR_PDN_CONNECT_WAIT_INTERVAL_MS ) );
|
vTaskDelay( pdMS_TO_TICKS( CELLULAR_PDN_CONNECT_WAIT_INTERVAL_MS ) );
|
||||||
|
@ -189,19 +215,51 @@ bool setupCellular( void )
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
cellularStatus = Cellular_ActivatePdn( CellularHandle, CellularSocketPdnContextId );
|
cellularStatus = Cellular_ActivatePdn( CellularHandle, CellularSocketPdnContextId );
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_ActivatePdn failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
cellularStatus = Cellular_GetIPAddress( CellularHandle, CellularSocketPdnContextId, localIP, sizeof( localIP ) );
|
cellularStatus = Cellular_GetIPAddress( CellularHandle, CellularSocketPdnContextId, localIP, sizeof( localIP ) );
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_GetIPAddress failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( cellularStatus == CELLULAR_SUCCESS )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
{
|
{
|
||||||
cellularStatus = Cellular_GetPdnStatus( CellularHandle, &PdnStatusBuffers, CellularSocketPdnContextId, &NumStatus );
|
cellularStatus = Cellular_GetPdnStatus( CellularHandle, PdnStatusBuffers, CELLULAR_PDN_CONTEXT_NUM, &NumStatus );
|
||||||
|
|
||||||
|
if( cellularStatus != CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular_GetPdnStatus failure %d <<<\r\n", cellularStatus ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( cellularStatus == CELLULAR_SUCCESS ) && ( PdnStatusBuffers.state == 1 ) )
|
if( cellularStatus == CELLULAR_SUCCESS )
|
||||||
|
{
|
||||||
|
for( i = 0U; i < NumStatus; i++ )
|
||||||
|
{
|
||||||
|
if( ( PdnStatusBuffers[ i ].contextId == CellularSocketPdnContextId ) && ( PdnStatusBuffers[ i ].state == 1 ) )
|
||||||
|
{
|
||||||
|
pdnStatus = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pdnStatus == false )
|
||||||
|
{
|
||||||
|
configPRINTF( ( ">>> Cellular PDN is not activated <<<\r\n" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( cellularStatus == CELLULAR_SUCCESS ) && ( pdnStatus == true ) )
|
||||||
{
|
{
|
||||||
configPRINTF( ( ">>> Cellular module registered, IP address %s <<<\r\n", localIP ) );
|
configPRINTF( ( ">>> Cellular module registered, IP address %s <<<\r\n", localIP ) );
|
||||||
cellularRet = true;
|
cellularRet = true;
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief Transport timeout in milliseconds for transport send and receive.
|
* @brief Transport timeout in milliseconds for transport send and receive.
|
||||||
*/
|
*/
|
||||||
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 10000U )
|
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 5000U )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ALPN (Application-Layer Protocol Negotiation) protocol name for AWS IoT MQTT.
|
* @brief ALPN (Application-Layer Protocol Negotiation) protocol name for AWS IoT MQTT.
|
||||||
|
|
|
@ -105,4 +105,10 @@ extern void vLoggingPrintf( const char * pcFormatString,
|
||||||
*/
|
*/
|
||||||
#define CELLULAR_IP_ADDRESS_MAX_SIZE ( 64U )
|
#define CELLULAR_IP_ADDRESS_MAX_SIZE ( 64U )
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BG96 supports different URC port. Define this macro if "usbat" port is URC output port.
|
||||||
|
* Otherwise, "uart1" will be configured to URC output port.
|
||||||
|
*/
|
||||||
|
#define CELLULAR_BG96_URC_PORT_USBAT
|
||||||
|
|
||||||
#endif /* __CELLULAR_CONFIG_H__ */
|
#endif /* __CELLULAR_CONFIG_H__ */
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief Transport timeout in milliseconds for transport send and receive.
|
* @brief Transport timeout in milliseconds for transport send and receive.
|
||||||
*/
|
*/
|
||||||
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 10000U )
|
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 5000U )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ALPN (Application-Layer Protocol Negotiation) protocol name for AWS IoT MQTT.
|
* @brief ALPN (Application-Layer Protocol Negotiation) protocol name for AWS IoT MQTT.
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief Transport timeout in milliseconds for transport send and receive.
|
* @brief Transport timeout in milliseconds for transport send and receive.
|
||||||
*/
|
*/
|
||||||
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 10000U )
|
#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 5000U )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ALPN (Application-Layer Protocol Negotiation) protocol name for AWS IoT MQTT.
|
* @brief ALPN (Application-Layer Protocol Negotiation) protocol name for AWS IoT MQTT.
|
||||||
|
|
|
@ -149,4 +149,9 @@ extern void vLoggingPrintf( const char * pcFormatString,
|
||||||
* #define CELLULAR_CONFIG_SARA_R4_SET_MNO_PROFILE ( ...insert here... )
|
* #define CELLULAR_CONFIG_SARA_R4_SET_MNO_PROFILE ( ...insert here... )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reboot Sara R4 cellular modem in module init function.
|
||||||
|
*/
|
||||||
|
#define CELLULAR_CONFIG_SARA_R4_REBOOT_ON_INIT
|
||||||
|
|
||||||
#endif /* __CELLULAR_CONFIG_H__ */
|
#endif /* __CELLULAR_CONFIG_H__ */
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0289b787b745d0c675fb12ef002574d98d4b402e
|
Subproject commit 2bd3f79b4e5070a3e3ec500980e86b5013fdcc62
|
|
@ -2848,6 +2848,7 @@ usagefault
|
||||||
usart
|
usart
|
||||||
usarts
|
usarts
|
||||||
usb
|
usb
|
||||||
|
usbat
|
||||||
usbbus
|
usbbus
|
||||||
usbconfiguration
|
usbconfiguration
|
||||||
usbdevice
|
usbdevice
|
||||||
|
|
|
@ -130,7 +130,7 @@ dependencies:
|
||||||
path: "FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos"
|
path: "FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos"
|
||||||
|
|
||||||
- name: "FreeRTOS-Cellular-Interface"
|
- name: "FreeRTOS-Cellular-Interface"
|
||||||
version: "v1.2.0"
|
version: "2bd3f79"
|
||||||
repository:
|
repository:
|
||||||
type: "git"
|
type: "git"
|
||||||
url: "https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git"
|
url: "https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue