Skip to content

Make CELLULAR_AT_MAX_STRING_SIZE configurable #140

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

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions source/include/cellular_config_defaults.h
Original file line number Diff line number Diff line change
@@ -440,6 +440,18 @@
( !( CELLULAR_CHECK_IS_PREFIX_LEADING_CHAR( inputChar ) ) ) )
#endif

/**
* @brief Cellular AT string length.<br>
*
* The maximum length of an AT string.<br>
*
* <b>Possible values:</b>`Any positive integer`<br>
* <b>Default value (if undefined):</b> 256
*/
#ifndef CELLULAR_AT_MAX_STRING_SIZE
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
#endif

/**
* @brief Macro that is called in the cellular library for logging "Error" level
* messages.
17 changes: 7 additions & 10 deletions source/include/common/cellular_at_core.h
Original file line number Diff line number Diff line change
@@ -45,17 +45,14 @@
/* Standard includes. */
#include <stdint.h>

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

/**
* @brief Maximum size of an AT string.
*/
#define CELLULAR_AT_MAX_STRING_SIZE ( 256U )
/* Cellular includes. */
#ifndef CELLULAR_DO_NOT_USE_CUSTOM_CONFIG
/* Include custom config file before other headers. */
#include "cellular_config.h"
#endif
#include "cellular_config_defaults.h"

/**
* @brief Maximum size of an AT prefix.
*/
#define CELLULAR_AT_MAX_PREFIX_SIZE ( 32 )
/*-----------------------------------------------------------*/

/**
* @brief The array size of an array.
14 changes: 14 additions & 0 deletions test/unit-test/cellular_at_core_utest.c
Original file line number Diff line number Diff line change
@@ -888,6 +888,20 @@ void test_Cellular_ATStrStartWith_Empty_Prefix( void )
TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus );
}

/**
* @brief Test the long string case for Cellular_ATStrStartWith to return CELLULAR_AT_BAD_PARAMETER.
*/
void test_Cellular_ATStrStartWith_ATStringTooLong( void )
{
CellularATError_t cellularStatus = CELLULAR_AT_SUCCESS;
bool result;
char * pPrefix = "";
char pStringSuccess[] = CELLULAR_SAMPLE_PREFIX_STRING_LARGE_INPUT;

cellularStatus = Cellular_ATStrStartWith( pStringSuccess, pPrefix, &result );
TEST_ASSERT_EQUAL( CELLULAR_AT_BAD_PARAMETER, cellularStatus );
}

/**
* @brief Test that any NULL parameter causes Cellular_ATStrtoi to return CELLULAR_AT_BAD_PARAMETER.
*/