Skip to content

Commit bfe3f48

Browse files
authored
Make CELLULAR_AT_MAX_STRING_SIZE configurable (#140)
* Make CELLULAR_AT_MAX_STRING_SIZE configurable * Add large string test in Cellular_ATStrStartWith
1 parent 4bc022e commit bfe3f48

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

source/include/cellular_config_defaults.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,18 @@
440440
( !( CELLULAR_CHECK_IS_PREFIX_LEADING_CHAR( inputChar ) ) ) )
441441
#endif
442442

443+
/**
444+
* @brief Cellular AT string length.<br>
445+
*
446+
* The maximum length of an AT string.<br>
447+
*
448+
* <b>Possible values:</b>`Any positive integer`<br>
449+
* <b>Default value (if undefined):</b> 256
450+
*/
451+
#ifndef CELLULAR_AT_MAX_STRING_SIZE
452+
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
453+
#endif
454+
443455
/**
444456
* @brief Macro that is called in the cellular library for logging "Error" level
445457
* messages.

source/include/common/cellular_at_core.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,14 @@
4545
/* Standard includes. */
4646
#include <stdint.h>
4747

48-
/*-----------------------------------------------------------*/
49-
50-
/**
51-
* @brief Maximum size of an AT string.
52-
*/
53-
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
48+
/* Cellular includes. */
49+
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
50+
/* Include custom config file before other headers. */
51+
#include "cellular_config.h"
52+
#endif
53+
#include "cellular_config_defaults.h"
5454

55-
/**
56-
* @brief Maximum size of an AT prefix.
57-
*/
58-
#define CELLULAR_AT_MAX_PREFIX_SIZE ( 32 )
55+
/*-----------------------------------------------------------*/
5956

6057
/**
6158
* @brief The array size of an array.

test/unit-test/cellular_at_core_utest.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,20 @@ void test_Cellular_ATStrStartWith_Empty_Prefix( void )
888888
TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus );
889889
}
890890

891+
/**
892+
* @brief Test the long string case for Cellular_ATStrStartWith to return CELLULAR_AT_BAD_PARAMETER.
893+
*/
894+
void test_Cellular_ATStrStartWith_ATStringTooLong( void )
895+
{
896+
CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS;
897+
bool result;
898+
char * pPrefix = "";
899+
char pStringSuccess[] = CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT;
900+
901+
cellularStatus = Cellular_ATStrStartWith( pStringSuccess, pPrefix, &result );
902+
TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus );
903+
}
904+
891905
/**
892906
* @brief Test that any NULL parameter causes Cellular_ATStrtoi to return CELLULAR_AT_BAD_PARAMETER.
893907
*/

0 commit comments

Comments
 (0)