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

Add module defined prefix char check function #55

Merged
merged 17 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 13 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
1 change: 1 addition & 0 deletions lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ inet
ingroup
inidcate
init
inputchar
inputline
int
interdelayms
Expand Down
6 changes: 5 additions & 1 deletion source/cellular_at_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@

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

#define CHECK_IS_PREFIX_CHAR( inputChar ) \
#if ( CELLULAR_CONFIG_MODULE_CHECK_PFREFIX_CHAR == 0 )
#define CHECK_IS_PREFIX_CHAR( inputChar ) \
( ( ( ( int32_t ) isalpha( ( ( int8_t ) ( inputChar ) ) ) ) == 0 ) && \
( ( ( int32_t ) isdigit( ( ( int8_t ) ( inputChar ) ) ) ) == 0 ) && \
( ( inputChar ) != '+' ) && ( ( inputChar ) != '_' ) )
#else
#define CHECK_IS_PREFIX_CHAR( inputChar ) Cellular_ModuleCheckInvalidPrefixChar( inputChar )
#endif

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

Expand Down
14 changes: 14 additions & 0 deletions source/include/cellular_config_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,20 @@
#define CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION ( 0 )
#endif

/**
* @brief Use module check prefix char function.<br>
*
* Enable this macro to use module defined prefix char function.
* Cellular_ModuleCheckIsPrefixChar function should be provided in cellular module
* porting.
*
* <b>Possible values:</b>`0 or 1`<br>
* <b>Default value (if undefined):</b> 0
*/
#ifndef CELLULAR_CONFIG_MODULE_CHECK_PFREFIX_CHAR
#define CELLULAR_CONFIG_MODULE_CHECK_PFREFIX_CHAR ( 0 )
#endif

/**
* @brief Macro that is called in the cellular library for logging "Error" level
* messages.
Expand Down
13 changes: 13 additions & 0 deletions source/include/common/cellular_common_portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@ CellularError_t Cellular_ModuleEnableUE( CellularContext_t * pContext );
*/
CellularError_t Cellular_ModuleEnableUrc( CellularContext_t * pContext );

/**
* @brief Cellular module check prefix char function.
*
* This function check if the input char is valid in AT command prefix. To enable
* the module specific check function, set CELLULAR_CONFIG_MODULE_CHECK_PFREFIX_CHAR
* to 1 in "cellular_config.h".
*
* @param[in] inputChar character in prefix to be checked.
*
* @return true if this is valid prefix char. Otherwise, return false.
*/
bool Cellular_ModuleCheckInvalidPrefixChar( char inputChar );

/* *INDENT-OFF* */
#ifdef __cplusplus
}
Expand Down