ql_wifi_msg.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /**
  2. @file
  3. ql_wifi_msg.h
  4. @brief
  5. Quectel wifi msg api header.
  6. */
  7. /*============================================================================
  8. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  9. Quectel Wireless Solution Proprietary and Confidential.
  10. =============================================================================*/
  11. /*===========================================================================
  12. EDIT HISTORY FOR MODULE
  13. This section contains comments describing changes made to the module.
  14. Notice that changes are listed in reverse chronological order.
  15. WHEN WHO WHAT, WHERE, WHY
  16. ---------- ------------ ----------------------------------------------------
  17. =============================================================================*/
  18. #ifndef QL_WIFI_MSG_H
  19. #define QL_WIFI_MSG_H
  20. #include "ql_osi_def.h"
  21. #include "ql_api_osi.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /*========================================================================
  26. * Macro Definition
  27. *========================================================================*/
  28. #define QUEC_PROTOCOL_HEAD_MAX_SIZE 6
  29. #define QUEC_PROTOCOL_MSG_DATA_MAX_LEN 1600
  30. #define QUEC_PROTOCOL_MSG_MAX_LEN (QUEC_PROTOCOL_HEAD_MAX_SIZE + QUEC_PROTOCOL_MSG_DATA_MAX_LEN)
  31. #define QUEC_MSG_CACHE_MAX_LEN (QUEC_PROTOCOL_MSG_MAX_LEN * 4)
  32. /*========================================================================
  33. * Enumeration Definition
  34. *========================================================================*/
  35. typedef enum
  36. {
  37. QL_WIFI_MSG_SUCCESS = 0,
  38. QL_WIFI_MSG_EXECUTE_ERR = 1 | (QL_COMPONENT_LWIP_WIFI << 16),
  39. QL_WIFI_MSG_INVALID_PARAM_ERR,
  40. QL_WIFI_MSG_TASK_CREATE_ERR,
  41. QL_WIFI_MSG_MUTEX_CREATE_ERR,
  42. } ql_wifi_msg_errcode_e;
  43. typedef enum
  44. {
  45. QL_WIFI_NPTO_PARSE_RESULT_SUCC = 0,
  46. QL_WIFI_NPTO_PARSE_RESULT_NOMAGIC = 101, // No protocol header
  47. QL_WIFI_NPTO_PARSE_RESULT_TOOSMALL, // Data too small
  48. QL_WIFI_NPTO_PARSE_RESULT_ERRCRC, // CRC error
  49. QL_WIFI_NPTO_PARSE_RESULT_UNKNOWN,
  50. }ql_wifi_npto_parse_result_e;
  51. typedef enum
  52. {
  53. QL_WIFI_NPTO_802_3_STREAM = 0,
  54. QL_WIFI_NPTO_STA_IP_START_CMD = 1,
  55. QL_WIFI_NPTO_STA_IP_DOWN_CMD = 2,
  56. QL_WIFI_NPTO_UAP_IP_START_CMD = 3,
  57. QL_WIFI_NPTO_UAP_IP_DOWN_CMD = 4,
  58. QL_WIFI_NPTO_IP_ADDR_SET_CMD = 5,
  59. QL_WIFI_NPTO_WLAN_CREATE_CMD = 6,
  60. QL_WIFI_NPTO_WLAN_DESTROY_CMD = 7,
  61. QL_WIFI_NPTO_STATUS_UPDATE_CMD = 8,
  62. QL_WIFI_APP_STA_ENABLE_CMD = 20,
  63. QL_WIFI_APP_STA_DISABLE_CMD = 21,
  64. QL_WIFI_APP_AP_ENABLE_CMD = 23,
  65. QL_WIFI_APP_AP_DISABLE_CMD = 24,
  66. QL_WIFI_APP_EVENT_NOTIFY = 25,
  67. QL_WIFI_APP_SCAN_START_CMD = 26,
  68. QL_WIFI_APP_STA_STATUS_CMD = 27,
  69. QUEC_WIFI_APP_RESET_CMD = 28,
  70. QL_WIFI_SIO_TEST = 30, /* [test] */
  71. QL_WIFI_APP_CMD_MAX
  72. } ql_wifi_npto_cmd_t;
  73. /*========================================================================
  74. * Type Definition
  75. *========================================================================*/
  76. typedef void (*ql_wifi_msg_net_notify_cb)(void *ctx);
  77. typedef void (*ql_wifi_msg_app_notify_cb)(void *ctx);
  78. typedef struct
  79. {
  80. int msg_id;
  81. void *msg_info;
  82. } ql_wifi_msg_cmd_info_s;
  83. typedef struct
  84. {
  85. unsigned int data_len;
  86. unsigned int pos;
  87. char *data;
  88. } ql_wifi_msg_protocol_info_s;
  89. typedef struct
  90. {
  91. unsigned char magic0; // Must be 0xAA
  92. unsigned char magic1; // Must be 0x55
  93. unsigned short cmdlen; // Command length
  94. unsigned char command; // Command.Set bit 8 to 1 means command feedback.
  95. unsigned char checksum;
  96. unsigned char *data;
  97. } ql_wifi_msg_protocol_head_info_s;
  98. typedef struct
  99. {
  100. uint8_t *data;
  101. int data_len;
  102. int cmd;
  103. } ql_wifi_msg_output_data_info_s;
  104. /*========================================================================
  105. * function Definition
  106. *========================================================================*/
  107. /*****************************************************************
  108. * Function: ql_wifi_msg_net_notify_cb_register
  109. *
  110. * Description: Register Wi-Fi NET engine notification from MSG callback.
  111. *
  112. * Parameters:
  113. * cb [in] Wi-Fi NET engine notification from MSG callback.
  114. * Once the MSG engine parses the corresponding command,the command will be passed to NET engine.
  115. *
  116. * Return:
  117. * 0 success
  118. * other error code
  119. *
  120. *****************************************************************/
  121. ql_wifi_msg_errcode_e ql_wifi_msg_net_notify_cb_register(ql_wifi_msg_net_notify_cb cb);
  122. /*****************************************************************
  123. * Function: ql_wifi_msg_app_notify_cb_register
  124. *
  125. * Description: Register Wi-Fi APP engine notification from MSG engine callback.
  126. *
  127. * Parameters:
  128. * cb [in] Wi-Fi APP engine notification from MSG engine callback.
  129. * Once the MSG engine parses the corresponding command,the command will be passed to APP engine.
  130. *
  131. * Return:
  132. * 0 success
  133. * other error code
  134. *
  135. *****************************************************************/
  136. ql_wifi_msg_errcode_e ql_wifi_msg_app_notify_cb_register(ql_wifi_msg_app_notify_cb cb);
  137. /*****************************************************************
  138. * Function: ql_wifi_msg_init
  139. *
  140. * Description: Initialize Wi-Fi msg engine.
  141. *
  142. * Parameters:
  143. * argv [in] No defined yet.
  144. *
  145. * Return:
  146. * 0 success
  147. * other error code
  148. *
  149. *****************************************************************/
  150. ql_wifi_msg_errcode_e ql_wifi_msg_init(void *argv);
  151. /*****************************************************************
  152. * Function: ql_wifi_msg_deinit
  153. *
  154. * Description: Deinitialize Wi-Fi msg engine.
  155. *
  156. * Parameters:
  157. * argv [in] No defined yet.
  158. *
  159. * Return:
  160. * 0 success
  161. * other error code
  162. *
  163. *****************************************************************/
  164. ql_wifi_msg_errcode_e ql_wifi_msg_deinit(void *argv);
  165. #ifdef __cplusplus
  166. } /*"C" */
  167. #endif
  168. #endif