123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967 |
- /*================================================================
- Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
- Quectel Wireless Solutions Proprietary and Confidential.
- =================================================================*/
- #ifndef _QUEC_AT_PARAM_H_
- #define _QUEC_AT_PARAM_H_
- #include "stdio.h"
- #include "string.h"
- #include "stdlib.h"
- #include "ctype.h"
- #include "ql_api_common.h"
- #include "ql_uart_internal.h"
- #include "quec_atc_common.h"
- /*************************************************************************
- * Define
- **************************************************************************/
- #define AT_BUFFER_SIZE (3*1024)
- #define AT_NAME_LEN_MAX 24 //at名称的最大长度,如"cfun"
- #ifdef CONFIG_QUEC_PROJECT_FEATURE_HW_IOT_DEVICE_SDK_AT
- #define AT_PARMA_LEN_MAX 2048*2 //at命令的最大总长度
- #else
- #define AT_PARMA_LEN_MAX 2048 //at命令的最大总长度
- #endif
- #define AT_MAX_LEN (AT_PARMA_LEN_MAX+AT_NAME_LEN_MAX)
- #define AT_MAX_PARAM_CNT 24 //at命令的参数个数
- #define AT_LF_TIMEOUT 10 //CR后若无数据,则等 AT_LF_TIMEOUT ms
- /*************************************************************************
- * Enum
- **************************************************************************/
- typedef enum
- {
- AT_PARAM_TYPE_EMPTY,
- AT_PARAM_TYPE_RAW,
- AT_PARAM_TYPE_STRING,
- } ql_at_param_type_e;
- typedef enum
- {
- QUEC_AT_CONSTRAIN_MIN = 100,
- QUEC_AT_CONSTRAIN_CJSON,
- QUEC_AT_CONSTRAIN_MAX
- } QUEC_AT_CONSTRAIN_E;
- /*************************************************************************
- * Struct
- **************************************************************************/
- typedef struct ql_at_cmd ql_at_cmd_t;
- typedef void (*async_ctx_destory)(struct ql_at_cmd *cmd);
- typedef void (*quec_at_timeout_cb_t)(ql_at_cmd_t *cmd);
- typedef void (*quec_at_cb_t)(void *ctx);
- typedef struct ql_at_desc
- {
- char *name; ///< AT command name, such as "+IPR"
- void (*handler)(struct ql_at_cmd*); ///< At command handler
- uint32_t constrains; ///< AT command constrains
- } ql_at_desc_t;
- typedef struct
- {
- uint8_t type; ///< parameter type, used by AT engine internally
- uint16_t length; ///< value length
- char *value; ///< value, the real size is variable
- } ql_at_param_t;
- typedef struct
- {
- quec_at_cb_t cb;
- void *ctx;
- }ql_at_cb_param_t;
- typedef struct ql_at_cmd
- {
- ql_dispatch_t *engine; //当前AT端口的dispatch(等同于dev,作用为兼容8910)
- quec_dev_e dev; //当前端口的端口号
-
- uint8 param_count; //当前AT的参数个数
- atCmdType_t type; //AT命令的类型
- ql_at_desc_t *desc; //AT命令信息
- bool resp_flag; //当前AT是否已经进行过AT回复
- bool err_flag; //当前AT在执行过程中是否遇到错误
- ql_at_param_t *params[AT_MAX_PARAM_CNT]; //参数
- uint16_t uti;
- void *async_ctx;
- async_ctx_destory async_ctx_destroy;
- } ql_at_cmd_t;
- typedef struct
- {
- uint32_t minval; ///< minimal value
- uint32_t maxval; ///< maximum value
- } quec_UintRange_t;
- typedef struct
- {
- int minval; ///< minimal value
- int maxval; ///< maximum value
- } quec_IntRange_t;
- typedef struct
- {
- uint64_t minval; ///< minimal value
- uint64_t maxval; ///< maximum value
- } quec_Uint64Range_t;
- /**
- * data structure to define a signed 64bits integer range
- */
- typedef struct
- {
- int64_t minval; ///< minimal value
- int64_t maxval; ///< maximum value
- } quec_Int64Range_t;
- typedef struct
- {
- uint32_t value; ///< integer value
- const char *str; ///< string value
- } quec_ValueStrMap_t;
- /*************************************************************************
- * Function
- **************************************************************************/
- /**
- * extract uint parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- */
- uint32_t quec_atParamUint(ql_at_param_t *param, bool *paramok);
- /**
- * extract optional uint parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUint.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- */
- uint32_t quec_atParamDefUint(ql_at_param_t *param, uint32_t defval, bool *paramok);
- /**
- * extract uint parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in range
- */
- uint32_t quec_atParamUintInRange(ql_at_param_t *param, uint32_t minval, uint32_t maxval, bool *paramok);
- /**
- * extract optional uint parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInRange. The \a defval is not required in the
- * range.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in range
- */
- uint32_t quec_atParamDefUintInRange(ql_at_param_t *param, uint32_t defval, uint32_t minval, uint32_t maxval, bool *paramok);
- /**
- * extract uint parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in list
- */
- uint32_t quec_atParamUintInList(ql_at_param_t *param, const uint32_t *list, unsigned count, bool *paramok);
- /**
- * extract optional uint parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInList. The \a defval is not required in the
- * list.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in list
- */
- uint32_t quec_atParamDefUintInList(ql_at_param_t *param, uint32_t defval, const uint32_t *list, unsigned count, bool *paramok);
- /**
- * extract int parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- */
- int quec_atParamInt(ql_at_param_t *param, bool *paramok);
- /**
- * extract optional int parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUint.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- */
- int quec_atParamDefInt(ql_at_param_t *param, int defval, bool *paramok);
- /**
- * extract int parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in range
- */
- int quec_atParamIntInRange(ql_at_param_t *param, int minval, int maxval, bool *paramok);
- /**
- * extract optional int parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInRange. The \a defval is not required in the
- * range.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in range
- */
- int quec_atParamDefIntInRange(ql_at_param_t *param, int defval, int minval, int maxval, bool *paramok);
- /**
- * extract int parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in list
- */
- int quec_atParamIntInList(ql_at_param_t *param, const int *list, unsigned count, bool *paramok);
- /**
- * extract optional int parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInList. The \a defval is not required in the
- * list.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in list
- */
- int quec_atParamDefIntInList(ql_at_param_t *param, int defval, const int *list, unsigned count, bool *paramok);
- /**
- * extract uint64 parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- */
- uint64_t quec_atParamUint64(ql_at_param_t *param, bool *paramok);
- /**
- * extract optional uint64 parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUint.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- */
- uint64_t quec_atParamDefUint64(ql_at_param_t *param, uint64_t defval, bool *paramok);
- /**
- * extract uint64 parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in range
- */
- uint64_t quec_atParamUint64InRange(ql_at_param_t *param, uint64_t minval, uint64_t maxval, bool *paramok);
- /**
- * extract optional uint64 parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInRange. The \a defval is not required in the
- * range.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in range
- */
- uint64_t quec_atParamDefUint64InRange(ql_at_param_t *param, uint64_t defval, uint64_t minval, uint64_t maxval, bool *paramok);
- /**
- * extract uint64 parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in list
- */
- uint64_t quec_atParamUint64InList(ql_at_param_t *param, const uint64_t *list, unsigned count, bool *paramok);
- /**
- * extract optional uint64 parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInList. The \a defval is not required in the
- * list.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in list
- */
- uint64_t quec_atParamDefUint64InList(ql_at_param_t *param, uint64_t defval, const uint64_t *list, unsigned count, bool *paramok);
- /**
- * extract int64 parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- */
- int64_t quec_atParamInt64(ql_at_param_t *param, bool *paramok);
- /**
- * extract optional int64 parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUint.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- */
- int64_t quec_atParamDefInt64(ql_at_param_t *param, int64_t defval, bool *paramok);
- /**
- * extract int64 parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in range
- */
- int64_t quec_atParamInt64InRange(ql_at_param_t *param, int64_t minval, int64_t maxval, bool *paramok);
- /**
- * extract optional int64 parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInRange. The \a defval is not required in the
- * range.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in range
- */
- int64_t quec_atParamDefInt64InRange(ql_at_param_t *param, int64_t defval, int64_t minval, int64_t maxval, bool *paramok);
- /**
- * extract int64 parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in list
- */
- int64_t quec_atParamInt64InList(ql_at_param_t *param, const int64_t *list, unsigned count, bool *paramok);
- /**
- * extract optional int64 parameter, and check in list
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintInList. The \a defval is not required in the
- * list.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param list array of valid values
- * @param count valid value count
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - int parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is not integer number
- * - \a param is not in list
- */
- int64_t quec_atParamDefInt64InList(ql_at_param_t *param, int64_t defval, const int64_t *list, unsigned count, bool *paramok);
- /**
- * extract string parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * String parameter is parameter started and ended with double quotation.
- * The escape defined in V.250 is \\HH. For example, \30 for '0'.
- *
- * It is possible that the internal storage will be changed during this
- * function call. So, don't call other parameter APIs for the same
- * parameter after it is called. However, this function itself can be
- * called again.
- *
- * The output pointer will be valid till the parameter itself is deleted.
- *
- * The output string is ended with null byte for end of string.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not string (start and end with double quotation)
- */
- const char *quec_atParamStr(ql_at_param_t *param, bool *paramok);
- /**
- * extract hex or str parameter from raw text
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * Raw text parameter is parameter started and ended without double quotation.
- * The escape defined in V.250 is \\HH. For example, \30 for '0'.
- *
- * It is possible that the internal storage will be changed during this
- * function call. So, don't call other parameter APIs for the same
- * parameter after it is called. However, this function itself can be
- * called again.
- *
- * The output pointer will be valid till the parameter itself is deleted.
- *
- * The output string is ended with null byte for end of string.
- *
- * @param param parameter pointer
- * @param len the length of the parameter
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is string (start and end with double quotation)
- */
- const char *quec_atParamHexData(ql_at_param_t *param, uint32_t len, bool *paramok);
- /**
- * extract hex parameter from raw text
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * Raw text parameter is parameter started and ended without double quotation.
- * The escape defined in V.250 is \\HH. For example, \30 for '0'.
- *
- * It is possible that the internal storage will be changed during this
- * function call. So, don't call other parameter APIs for the same
- * parameter after it is called. However, this function itself can be
- * called again.
- *
- * The output pointer will be valid till the parameter itself is deleted.
- *
- * The output string is ended with null byte for end of string.
- *
- * @param param parameter pointer
- * @param len the length of the parameter
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is string (start and end with double quotation)
- */
- const char *quec_atParamHexRawText(ql_at_param_t *param, uint32_t len, bool *paramok);
- /**
- * extract string parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * String parameter is parameter started and ended with double quotation.
- * The escape defined in V.250 is \\HH. For example, \30 for '0'.
- *
- * It is possible that the internal storage will be changed during this
- * function call. So, don't call other parameter APIs for the same
- * parameter after it is called. However, this function itself can be
- * called again.
- *
- * The output pointer will be valid till the parameter itself is deleted.
- *
- * The output string is ended with null byte for end of string.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not string (start and end with double quotation)
- */
- const char *quec_atParamOptStr(ql_at_param_t *param, bool *paramok);
- /**
- * extract optional string parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamStr.
- *
- * It is possible that the internal storage will be changed during this
- * function call. So, don't call other parameter APIs for the same
- * parameter after it is called. However, this function itself can be
- * called again.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is not string (start and end with double quotation)
- */
- const char *quec_atParamDefStr(ql_at_param_t *param, const char *defval, bool *paramok);
- /**
- * extract raw parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * The raw parameter is not parsed. For example, the double quotation of
- * string parameter will be kept, and the escape in string parameter is
- * untouched.
- *
- * The output string is ended with null byte as end of string.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- */
- const char *quec_atParamRawText(ql_at_param_t *param, bool *paramok);
- /**
- * extract floating point parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - floating point parameter
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not double
- */
- double quec_atParamDouble(ql_at_param_t *param, bool *paramok);
- /**
- * extract DTMF parameter
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * There are 2 kinds of DTMF parameter:
- * - one DTMF character without double quotation
- * - multiple DTMF chaeacters with double quotation
- * In both case, the return value is DTMF character string with null byte
- * as the string end.
- *
- * It will not check whether DTMF characters inside the string is valid
- * DTMF character. Application should validate them.
- *
- * It is possible that the internal storage will be changed during this
- * function call. So, don't call other parameter APIs for the same
- * parameter after it is called. However, this function itself can be
- * called again.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - parsed DTMF string
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not DTMF
- */
- const char *quec_atParamDtmf(ql_at_param_t *param, bool *paramok);
- /**
- * extract string parameter and return mapped uint
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * It is just a wrapper to:
- * - extract string parameter
- * - map to uint
- *
- * @param param parameter pointer
- * @param vsmap integer/string map, ended with NULL string value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not in map
- */
- uint32_t quec_atParamUintByStrMap(ql_at_param_t *param, const quec_ValueStrMap_t *vsmap, bool *paramok);
- /**
- * extract optional string parameter and return mapped uint
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * When \a param is empty, \a defval is returned. Otherwise, it is the
- * same as \a quec_atParamUintByStrMap. The \a defval is not required in the
- * map.
- *
- * @param param parameter pointer
- * @param defval default value
- * @param vsmap integer/string map, ended with NULL string value
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is not in map
- */
- uint32_t quec_atParamDefUintByStrMap(ql_at_param_t *param, uint32_t defval, const quec_ValueStrMap_t *vsmap, bool *paramok);
- /**
- * extract uint parameter by hex string
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * The valid parameter is the output of:
- * \code{.cpp}
- * printf("\"%x\"", value)
- * \endcode
- *
- * For example, parameter "12345" will be parsed as 0x12345.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - NULL on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not the needed format
- */
- uint32_t quec_atParamHexStrUint(ql_at_param_t *param, bool *paramok);
- /**
- * trim tailing characters at the end of parameter
- *
- * This shall be called before the parameter isn't parsed. \p quec_atParamRawText
- * won't parse the parameter, so it is safe to call it after \p quec_atParamRawText.
- *
- * It will change the internal storage of parameter directly. So, only call
- * it when absolutely needed, and you know what you are doing.
- *
- * @param param parameter pointer
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - true on success
- * - false on failed
- * - \p param type is not raw text
- * - the length of parameter is shorter than \p len
- */
- bool quec_atParamTrimTail(ql_at_param_t *param, uint32_t len);
- /**
- * check whether the parameter is empty
- *
- * Both not specified and skipped parameter are empty. For example:
- * - AT+CMD=123
- * - AT+CMD=123,
- * - AT+CMD=123,,456
- *
- * In all of the above cases, params[1] is empty.
- *
- * @param param parameter pointer
- * @return
- * - true if the parameter is empty
- * - false otherwise
- */
- bool quec_atParamIsEmpty(ql_at_param_t *param);
- /**
- * extract hex int64_t parameter, and check range
- *
- * When \a *paramok is false, it will do nothing. On failure, \a *param
- * will be set to false on return.
- *
- * @param param parameter pointer
- * @param minval minimum valid value, inclusive
- * @param maxval maximum valid value, inclusive
- * @param paramok in/out parameter parsing ok flag
- * @return
- * - uint parameter
- * - 0 on failed
- * - \a *paramok is false at input
- * - \a param is empty
- * - \a param is not integer number
- * - \a param is not in range
- */
- int64_t quec_atParamHexInt64InRange(ql_at_param_t *param, int64_t minval, int64_t maxval, bool *paramok);
- #endif
|