quec_atresp.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. #ifndef _QUEC_AT_RESPONSE_H_
  6. #define _QUEC_AT_RESPONSE_H_
  7. #include "ql_api_common.h"
  8. #include "ql_uart_internal.h"
  9. #include "quec_at_param.h"
  10. /*========================================================================
  11. * Macro Definition
  12. *========================================================================*/
  13. #define QUEC_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
  14. #define QUEC_DO_WHILE0(expr) \
  15. do \
  16. { \
  17. expr \
  18. } while (0)
  19. #define quec_at_resp_error(engine) quec_atCmdResp(engine, ATCI_RESULT_CODE_ERROR, CMD_RC_ERROR)
  20. #define quec_at_resp_ok(engine) quec_atCmdResp(engine, ATCI_RESULT_CODE_OK, CMD_RC_OK)
  21. #define quec_at_resp_cms_error(engine,errcode) quec_atCmdResp(engine, ATCI_RESULT_CODE_CMS_ERROR, errcode)
  22. #define quec_at_resp_cme_error(engine,errcode) quec_atCmdResp(engine, ATCI_RESULT_CODE_CME_ERROR, errcode)
  23. #define QUEC_RETURN_CME_ERR(engine, err) {quec_at_resp_cme_error(engine, err); return;}
  24. #define QUEC_RETURN_CMS_ERR(engine, err) {quec_at_resp_cms_error(engine, err); return;}
  25. #define QUEC_RETURN_OK(engine) {quec_at_resp_ok(engine); return;}
  26. #define QUEC_RETURN_ERROR(engine) {quec_at_resp_error(engine); return;}
  27. #define QUEC_RETURN_FOR_ASYNC() {return;}
  28. #define QUEC_ATRESP_TEXT(engine,text) quec_atCmdRespInfoNText(engine, text, strlen(text), 1)
  29. #define QUEC_ATRESP_NTEXT(engine,text,len) quec_atCmdRespInfoNText(engine, text, len, 1)
  30. /*========================================================================
  31. * Enum Definition
  32. *========================================================================*/
  33. typedef enum
  34. {
  35. QL_AT_CB_TYPE_TIMEOUT,
  36. QL_AT_CB_TYPE_MAX
  37. }QL_AT_CB_TYPE_E;
  38. /*========================================================================
  39. * Struct Definition
  40. *========================================================================*/
  41. typedef int (*resp_cb)(ql_dispatch_t *engine, _AtciResultCode resultCode, int code);
  42. typedef int (*finish_cb)(ql_dispatch_t *engine);
  43. typedef struct
  44. {
  45. ql_dispatch_t *engine;
  46. int32_t resultCode;
  47. int32_t code;
  48. resp_cb cb;
  49. void *param;
  50. } quec_at_result_resp_t;
  51. typedef struct
  52. {
  53. ql_dispatch_t *engine;
  54. finish_cb cb;
  55. } quec_at_finish_resp_t;
  56. typedef struct
  57. {
  58. quec_dev_e dev;
  59. ql_dispatch_t *dispatch;
  60. ql_timer_t timer;
  61. ql_at_cmd_t *cmd;
  62. quec_at_timeout_cb_t cb;
  63. uint value;
  64. } quec_at_timeout_t;
  65. typedef struct
  66. {
  67. QL_AT_CB_TYPE_E type;
  68. quec_at_timeout_t *timeout;//超时触发类回调函数
  69. } quec_at_callback_t;
  70. bool quec_atc_is_parsing(ql_dispatch_t *engine);
  71. ql_task_t quec_at_get_engine_id(void);
  72. ql_at_cmd_t *quec_at_get_cmd_table(ql_dispatch_t *dispatch);
  73. void quec_at_output_promt(ql_dispatch_t *engine, int formatcfg);
  74. uint quec_at_get_count(void);
  75. const ql_at_desc_t *quec_at_get_table(size_t n);
  76. void quec_at_set_first_info(ql_dispatch_t *engine, bool is_first);
  77. bool quec_at_get_first_info(ql_dispatch_t *engine);
  78. void quec_at_resp_interm_code(ql_dispatch_t *engine, int code);
  79. void quec_at_set_error_flag(ql_dispatch_t *engine);
  80. void quec_atCmdResp(ql_dispatch_t *engine, _AtciResultCode resultCode, uint report_code);
  81. int quec_atCmdRespInfoNText(ql_dispatch_t *engine, const char *text, size_t length, unsigned char padding);
  82. int quec_at_finish(ql_dispatch_t *engine);
  83. int quec_at_get_attach_cnt(ql_dispatch_t *engine);
  84. bool quec_at_set_timeout_cb(ql_dispatch_t *dispatch, uint timeout, quec_at_timeout_cb_t handler);
  85. void quec_atCmdRespOutputPrompt(ql_dispatch_t *engine, int formatcfg);
  86. void quec_at_async_param_free(ql_at_cmd_t *cmd);
  87. void quec_at_worker_call(ql_dispatch_t *th, quec_at_cb_t cb, void *ctx);
  88. const char *quec_at_get_code_txt(int code);
  89. int quec_at_list_deinit(ql_dispatch_t *dispatch);
  90. const char *quec_at_get_code_txt_ds(int code);
  91. /**********************************************************************************************************************
  92. resultCode: ATCI_RESULT_CODE_OK ATCI_RESULT_CODE_ERROR ATCI_RESULT_CODE_CME_ERROR ATCI_RESULT_CODE_CMS_ERROR
  93. report_code: CMD_RC_OK, CMD_RC_ERROR, CMD_RC_CONNECT, CMD_RC_BUSY ......
  94. rsp_buffer: the buffer to be send out , if no buffer to send , input NULL
  95. padding : if need add \r\n at the begin and/or end of the string, the begin padding is effected by atv
  96. 0: no add s3,s4, 1: auto detect s3,s4 and add to begain and end, 2: force add s3,s4 at the begin and end,
  97. 3: force add s3,s4 at the begin, 4: force add s3,s4 at the end, and 1 is default
  98. ***********************************************************************************************************************/
  99. void quec_atResp(ql_dispatch_t *engine, _AtciResultCode resultCode, uint report_code, char *rsp_buffer , unsigned char padding);
  100. void quec_atCmdRespOutputPrompt(ql_dispatch_t *engine, int formatcfg);
  101. #endif