app_img_at_demo.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. /*=================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ------------ ------- -------------------------------------------------------------------------------
  11. =================================================================*/
  12. /*===========================================================================
  13. * include files
  14. ===========================================================================*/
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <stdlib.h>
  18. #include "ql_api_osi.h"
  19. #include "ql_log.h"
  20. #include "quec_at_engine.h"
  21. #include "quec_at_param.h"
  22. #include "quec_atresp.h"
  23. /*===========================================================================
  24. * Macro Definition
  25. ===========================================================================*/
  26. #define QL_APP_IMG_AT_LOG_LEVEL QL_LOG_LEVEL_INFO
  27. #define QL_APP_IMG_AT_LOG(msg, ...) QL_LOG(QL_APP_IMG_AT_LOG_LEVEL, "ql_app_img_at", msg, ##__VA_ARGS__)
  28. #define QL_APP_IMG_AT_LOG_PUSH(msg, ...) QL_LOG_PUSH("ql_app_img_at", msg, ##__VA_ARGS__)
  29. /*===========================================================================
  30. * Struct
  31. ===========================================================================*/
  32. /*===========================================================================
  33. * Variate
  34. ===========================================================================*/
  35. /*===========================================================================
  36. * Functions
  37. ===========================================================================*/
  38. void ql_exec_img_at_demo_cmd(ql_at_cmd_t *cmd)
  39. {
  40. if (cmd->type == AT_CMD_SET)
  41. {
  42. //how to extract parameter, please refer to at_param.h
  43. //eg:
  44. //quec_atParamUintInList: to extract uint parameter, and check in list
  45. //quec_atParamUintInRange: to extract uint parameter, and check range
  46. //quec_atParamStr: to extract string parameter
  47. //quec_atParamInt: to extract int parameter
  48. //quec_atParamDefInt: to extract optional int parameter with default value
  49. //......
  50. // ========================= parameter extract demo ==============================
  51. // bool paramok = true;
  52. // const char *data_str = quec_atParamStr(cmd->params[0], &paramok);
  53. // unsigned short major = quec_atParamUintInRange(cmd->params[1], 0, 65535, &paramok);
  54. // int temp_val =quec_atParamInt(cmd->params[2],&paramok);
  55. // int scheme = quec_atParamDefInt(cmd->params[3], 0x04, &paramok);
  56. // const uint32_t list[] = {4800, 9600, 14400, 19200, 38400, 57600, 115200, 230400, 460800, 921600};
  57. // uint32_t baud = quec_atParamUintInList(cmd->params[4], list, sizeof(list) / sizeof(list[0]), &paramok);
  58. // ......
  59. // =================================================================================
  60. bool paramok = true;
  61. const char *input_str = quec_atParamStr(cmd->params[0], &paramok);
  62. if ((cmd->param_count != 1) || !paramok)
  63. {
  64. quec_atCmdResp(cmd->engine, ATCI_RESULT_CODE_CME_ERROR, ERR_AT_CME_PARAM_INVALID);
  65. }
  66. quec_atCmdRespInfoNText(cmd->engine, input_str, strlen(input_str), 1);
  67. quec_atCmdResp(cmd->engine, ATCI_RESULT_CODE_OK, CMD_RC_OK);
  68. }
  69. else if (cmd->type == AT_CMD_READ)
  70. {
  71. quec_atResp(cmd->engine, ATCI_RESULT_CODE_OK, CMD_RC_OK, "app img at demo read resp", 1);
  72. }
  73. else if (cmd->type == AT_CMD_TEST)
  74. {
  75. quec_atCmdResp(cmd->engine, ATCI_RESULT_CODE_OK, CMD_RC_OK);
  76. }
  77. else
  78. {
  79. quec_atCmdResp(cmd->engine, ATCI_RESULT_CODE_CME_ERROR, ERR_AT_CME_OPTION_NOT_SURPORT);
  80. }
  81. }
  82. ql_at_desc_t app_img_at_desc[] = {
  83. {"+IMGATDEMO", ql_exec_img_at_demo_cmd, 0},
  84. {NULL, NULL, 0}};
  85. void ql_app_img_at_init(void)
  86. {
  87. QL_APP_IMG_AT_LOG("add app img at");
  88. quec_app_at_add((const ql_at_desc_t *)app_img_at_desc, sizeof(app_img_at_desc)/sizeof(app_img_at_desc[0]));
  89. }