Skip to content

Commit 066cf4c

Browse files
authored
Add Cellular common AT command timeout config (#101)
* Update cellular library to MIT license * Add cellular common AT command timeout config * Add CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS config to set timeout value for Cellular_Common prefix APIs. * Add CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS config to set timeout value for Cellular_ATCommandRaw API. * Update Cellular_CommonATCommandRaw unit test
1 parent bcec1f9 commit 066cf4c

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

source/cellular_common_api.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ CellularError_t Cellular_CommonATCommandRaw( CellularHandle_t cellularHandle,
344344
atReqGetResult.dataLen = dataLen;
345345
atReqGetResult.respCallback = responseReceivedCallback;
346346

347-
pktStatus = _Cellular_AtcmdRequestWithCallback( pContext, atReqGetResult );
347+
pktStatus = _Cellular_TimeoutAtcmdRequestWithCallback( pContext,
348+
atReqGetResult,
349+
CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS );
348350
cellularStatus = _Cellular_TranslatePktStatus( pktStatus );
349351
}
350352

source/include/cellular_config_defaults.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,32 @@
361361
#define CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION ( 0 )
362362
#endif
363363

364+
/**
365+
* @brief Cellular common AT command timeout.<br>
366+
*
367+
* The timeout value for Cellular_Common prefix APIs. The timeout value should be
368+
* set according to spec. It should be long enough for AT command used in cellular
369+
* common APIs.
370+
*
371+
* <b>Possible values:</b>`Any positive integer`<br>
372+
* <b>Default value (if undefined):</b> 5000
373+
*/
374+
#ifndef CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS
375+
#define CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS ( 5000U )
376+
#endif
377+
378+
/**
379+
* @brief Cellular AT command raw timeout.<br>
380+
*
381+
* The timeout value for Cellular_ATCommandRaw API.
382+
*
383+
* <b>Possible values:</b>`Any positive integer`<br>
384+
* <b>Default value (if undefined):</b> 5000
385+
*/
386+
#ifndef CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS
387+
#define CELLULAR_AT_COMMAND_RAW_TIMEOUT_MS ( 5000U )
388+
#endif
389+
364390
/**
365391
* @brief Macro that is called in the cellular library for logging "Error" level
366392
* messages.

source/include/private/cellular_pkthandler_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
/*-----------------------------------------------------------*/
4545

4646
/* AT Command timeout for general AT commands. */
47-
#define PACKET_REQ_TIMEOUT_MS ( 5000UL )
47+
#define PACKET_REQ_TIMEOUT_MS CELLULAR_COMMON_AT_COMMAND_TIMEOUT_MS
4848

4949
/*-----------------------------------------------------------*/
5050

test/unit-test/cellular_common_api_utest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ void test_Cellular_CommonATCommandRaw_AtCmd_Bad_Request( void )
536536
char pData[] = "Test Data";
537537

538538
_Cellular_CheckLibraryStatus_IgnoreAndReturn( CELLULAR_SUCCESS );
539-
_Cellular_AtcmdRequestWithCallback_IgnoreAndReturn( CELLULAR_PKT_STATUS_BAD_REQUEST );
539+
_Cellular_TimeoutAtcmdRequestWithCallback_IgnoreAndReturn( CELLULAR_PKT_STATUS_BAD_REQUEST );
540540
_Cellular_TranslatePktStatus_IgnoreAndReturn( CELLULAR_INTERNAL_FAILURE );
541541

542542
cellularStatus = Cellular_CommonATCommandRaw( &context, pPrefix, pData, 0, NULL, NULL, 0 );
@@ -557,7 +557,7 @@ void test_Cellular_CommonATCommandRaw_Happy_Path( void )
557557
char pData[] = "Test Data";
558558

559559
_Cellular_CheckLibraryStatus_IgnoreAndReturn( CELLULAR_SUCCESS );
560-
_Cellular_AtcmdRequestWithCallback_IgnoreAndReturn( CELLULAR_PKT_STATUS_OK );
560+
_Cellular_TimeoutAtcmdRequestWithCallback_IgnoreAndReturn( CELLULAR_PKT_STATUS_OK );
561561
_Cellular_TranslatePktStatus_IgnoreAndReturn( CELLULAR_SUCCESS );
562562

563563
cellularStatus = Cellular_CommonATCommandRaw( &context, pPrefix, pData, 0, NULL, NULL, 0 );

0 commit comments

Comments
 (0)