Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HL7802 delay after reboot #80

Merged
merged 24 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
210a55c
Update cellular library to MIT license
chinglee-iot Mar 29, 2021
298ae4c
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jun 30, 2021
21ea9bc
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jul 16, 2021
6690f3b
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jul 23, 2021
4a58d89
Merge branch 'FreeRTOS:main' into main
chinglee-iot Aug 24, 2021
955ebc0
Merge branch 'FreeRTOS:main' into main
chinglee-iot Oct 25, 2021
bba8adf
Merge branch 'FreeRTOS:main' into main
chinglee-iot Nov 4, 2021
440bec9
Merge branch 'FreeRTOS:main' into main
chinglee-iot Nov 9, 2021
a0fb7c7
Merge branch 'FreeRTOS:main' into main
chinglee-iot Nov 16, 2021
b28ed63
Merge branch 'FreeRTOS:main' into main
chinglee-iot Nov 24, 2021
b40cb10
Merge branch 'FreeRTOS:main' into main
chinglee-iot Dec 1, 2021
ca024c6
Merge branch 'FreeRTOS:main' into main
chinglee-iot Dec 1, 2021
277d8b7
Merge branch 'FreeRTOS:main' into main
chinglee-iot Dec 15, 2021
06402e9
Merge branch 'FreeRTOS:main' into main
chinglee-iot Dec 21, 2021
a993410
Merge branch 'FreeRTOS:main' into main
chinglee-iot Dec 21, 2021
45b9bcd
Merge branch 'FreeRTOS:main' into main
chinglee-iot Dec 27, 2021
cacbf87
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jan 6, 2022
128407c
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jan 7, 2022
b1e3e46
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jan 10, 2022
70e76c4
Merge branch 'FreeRTOS:main' into main
chinglee-iot Jan 11, 2022
befec26
Use ATE0 to wait for modem after reboot
chinglee-iot Jan 11, 2022
b445c02
Update AT+CFUN timeout
chinglee-iot Jan 11, 2022
f3717c6
Make CELLULAR_HL7802_RESET_DELAY_MS configurable
chinglee-iot Jan 11, 2022
b6ede34
Fix HL7802 format
chinglee-iot Jan 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions modules/hl7802/cellular_hl7802.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

/*-----------------------------------------------------------*/

#define ENBABLE_MODULE_UE_RETRY_COUNT ( 3U )
#define ENBABLE_MODULE_UE_RETRY_COUNT ( 6U )
#define HL7802_MAX_BAND_CFG ( 21U )

/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -303,6 +303,7 @@ CellularError_t Cellular_ModuleCleanUp( const CellularContext_t * pContext )
CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
{
CellularError_t cellularStatus = CELLULAR_SUCCESS;
CellularPktStatus_t pktStatus = CELLULAR_PKT_STATUS_OK;
CellularAtReq_t atReqGetNoResult =
{
NULL,
Expand All @@ -312,38 +313,31 @@ CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
NULL,
0
};
CellularAtReq_t atReqGetWithResult =
{
NULL,
CELLULAR_AT_MULTI_WO_PREFIX,
NULL,
NULL,
NULL,
0
};
Hl7802BandConfig_t bandCfg = { 0 };

if( pContext != NULL )
{
/* Disable echo. */
atReqGetWithResult.pAtCmd = "ATE0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetWithResult,
atReqGetNoResult.pAtCmd = "ATE0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );

if( cellularStatus == CELLULAR_SUCCESS )
{
/* Disable DTR function. */
atReqGetNoResult.pAtCmd = "AT&D0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}

if( cellularStatus == CELLULAR_SUCCESS )
{
/* Enable RTS/CTS hardware flow control. */
atReqGetNoResult.pAtCmd = "AT+IFC=2,2";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}

/* Set Radio Access Technology. */
Expand All @@ -354,8 +348,9 @@ CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
* in the PRL if cell coverage is lost. If the PRL is empty, switch to
* CAT-M1. To set the PRL, see AT+KSELACQ. */
atReqGetNoResult.pAtCmd = "AT+KSRAT=0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}

/* Set Default Radio Access Technology. */
Expand All @@ -379,8 +374,9 @@ CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
break;
}

cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_KSELACQ_TIMEOUT_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_KSELACQ_TIMEOUT_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}

/* Set Configured LTE Band. */
Expand All @@ -396,8 +392,9 @@ CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
LogInfo( ( "Cellular_ModuleEnableUE : CAT-M1 band desired %s actual %s",
CELLULAR_CONFIG_HL7802_CATM1_BAND, bandCfg.catm1BandCfg ) );
atReqGetNoResult.pAtCmd = "AT+KBNDCFG=0,"CELLULAR_CONFIG_HL7802_CATM1_BAND;
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}
}

Expand All @@ -408,34 +405,36 @@ CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext )
LogInfo( ( "Cellular_ModuleEnableUE : NBIOT band desired %s actual %s",
CELLULAR_CONFIG_HL7802_NBIOT_BAND, bandCfg.nbiotBandCfg ) );
atReqGetNoResult.pAtCmd = "AT+KBNDCFG=1,"CELLULAR_CONFIG_HL7802_NBIOT_BAND;
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}
}

/* Disable standalone sleep mode. */
if( cellularStatus == CELLULAR_SUCCESS )
{
atReqGetNoResult.pAtCmd = "AT+KSLEEP=2";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}

/* Force initialization of radio to consider new configured bands. */
if( cellularStatus == CELLULAR_SUCCESS )
{
atReqGetNoResult.pAtCmd = "AT+CFUN=1,1";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_30_SECONDS_MS );
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext, atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_30_SECONDS_MS );
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
}

Platform_Delay( CELLULAR_HL7802_RESET_DELAY_MS );

/* Disable echo after reboot device. */
if( cellularStatus == CELLULAR_SUCCESS )
{
atReqGetWithResult.pAtCmd = "ATE0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetWithResult,
Platform_Delay( CELLULAR_HL7802_RESET_DELAY_MS );
atReqGetNoResult.pAtCmd = "ATE0";
cellularStatus = sendAtCommandWithRetryTimeout( pContext, &atReqGetNoResult,
CELLULAR_HL7802_AT_TIMEOUT_2_SECONDS_MS );
}
}
Expand Down
14 changes: 8 additions & 6 deletions modules/hl7802/cellular_hl7802.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@
#endif
/* *INDENT-ON* */

#define MIN_TCP_SESSION_ID ( 1U )
#define MAX_TCP_SESSION_ID ( 6U )
#define TCP_SESSION_TABLE_LEGNTH ( MAX_TCP_SESSION_ID + 1 )
#define MIN_TCP_SESSION_ID ( 1U )
#define MAX_TCP_SESSION_ID ( 6U )
#define TCP_SESSION_TABLE_LEGNTH ( MAX_TCP_SESSION_ID + 1 )

#define INVALID_SOCKET_INDEX ( UINT32_MAX )
#define INVALID_SESSION_ID ( UINT32_MAX )
#define INVALID_SOCKET_INDEX ( UINT32_MAX )
#define INVALID_SESSION_ID ( UINT32_MAX )

/* Delay after AT+CFUN=1,1 commands. */
#define CELLULAR_HL7802_RESET_DELAY_MS ( 3000U )
#ifndef CELLULAR_HL7802_RESET_DELAY_MS
#define CELLULAR_HL7802_RESET_DELAY_MS ( 3000U )
#endif

/* AT command recommended timeout value for HL7802. Reference HL7802 AT Commands
* Interface Guide to setup the timeout value for each AT commands. */
Expand Down