quec_usbnet.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /** @file
  2. quec_usbnet.h
  3. @brief
  4. This file is used to define version information for different Quectel Project.
  5. */
  6. /*================================================================
  7. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  8. Quectel Wireless Solution Proprietary and Confidential.
  9. =================================================================*/
  10. /*=================================================================
  11. EDIT HISTORY FOR MODULE
  12. This section contains comments describing changes made to the module.
  13. Notice that changes are listed in reverse chronological order.
  14. WHEN WHO WHAT, WHERE, WHY
  15. ------------ ------- -------------------------------------------------------------------------------
  16. =================================================================*/
  17. #ifndef QUEC_USBNET_H
  18. #define QUEC_USBNET_H
  19. #include "quec_modem_interface.h"
  20. #include "quec_common.h"
  21. #include "ql_api_usbnet.h"
  22. #include "quec_at_engine.h"
  23. #include "ql_api_osi.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #ifdef CONFIG_QUEC_PROJECT_FEATURE_USBNET
  28. #define QUEC_USBNET_DEBUG 0
  29. /*========================================================================
  30. * Macro Definition
  31. *========================================================================*/
  32. #define QUEC_USBNET_TIMER_PERIOD_MIN 2
  33. #define QUEC_USBNET_TIMER_PERIOD_MAX 300
  34. /*========================================================================
  35. * Enumeration Definition
  36. *========================================================================*/
  37. typedef enum
  38. {
  39. QUEC_USB_NET_CONNECT_DISABLE = 0,
  40. QUEC_USB_NET_CONNECT_MANAUAL = 1,
  41. QUEC_USB_NET_CONNECT_AUTO = 3,
  42. QUEC_USB_NET_CONNECT_MAX,
  43. }quec_usb_net_connect_e;
  44. typedef enum
  45. {
  46. QUEC_USB_NET_MSG_NONE = 0,
  47. QUEC_USB_NET_MSG_AUTO_TIMER_START,
  48. QUEC_USB_NET_MSG_AUTO_TIMER_STOP,
  49. QUEC_USB_NET_MSG_ENABLE,//enable usbnet by at cmd
  50. QUEC_USB_NET_MSG_DISABLE,//disable usbnet by at cmd
  51. QUEC_USB_NET_MSG_UP,
  52. QUEC_USB_NET_MSG_DOWN,
  53. QUEC_USB_NET_MSG_PORT_CONNECT,
  54. QUEC_USB_NET_MSG_PORT_DISCONNECT,
  55. QUEC_USB_NET_MSG_NETIF_SET,
  56. QUEC_USB_NET_MSG_PS_ATTACH,
  57. QUEC_USB_NET_MSG_MAX,
  58. }quec_usb_net_msg_e;
  59. /*========================================================================
  60. * Type Definition
  61. *========================================================================*/
  62. typedef struct
  63. {
  64. quec_usb_net_connect_e connect_type;
  65. uint8_t connect_sim_cid;
  66. quec_enable_e connect_urc;
  67. }quec_usb_net_dev_cfg_s;
  68. typedef enum
  69. {
  70. QUEC_USB_STATE_NONE = 0,
  71. QUEC_USB_STATE_DISCONNECT,
  72. QUEC_USB_STATE_CONNECT,
  73. QUEC_USB_STATE_MAX,
  74. }quec_usb_state_e;
  75. typedef struct
  76. {
  77. quec_usb_net_dev_cfg_s usbnetdevcfg;
  78. ql_usbnet_state_e connect_state;
  79. quec_usb_state_e usb_state;
  80. quec_netif *connect_netif;
  81. quec_netif *connect_wan_netif;
  82. uint16_t timer_period;//unit: s
  83. uint32_t retry_cnt;
  84. }quec_usb_net_connect_ctx_s;
  85. typedef struct
  86. {
  87. uint32_t id;
  88. uint32_t nMsg;
  89. uint32_t nParam1;
  90. uint8_t nParam2;
  91. uint8_t nParam3;
  92. uint16_t nParam4;
  93. }quec_usbnet_event_s;
  94. typedef struct
  95. {
  96. uint32_t ind_type;
  97. int err_code;
  98. }quec_usb_net_event_ctx_s;
  99. typedef struct
  100. {
  101. ql_usbnet_callback event_cb;
  102. void *ctx;
  103. }quec_usb_net_cb_context_s;
  104. /*========================================================================
  105. * Variable Definition
  106. *========================================================================*/
  107. extern quec_usb_net_connect_ctx_s q_usbnet_connect_ctx;
  108. /*========================================================================
  109. * Utilities Definition
  110. *========================================================================*/
  111. /*========================================================================
  112. * function Definition
  113. *========================================================================*/
  114. void quectel_exec_qcfg_usbnet_cmd(ql_at_cmd_t *cmd);
  115. void quectel_exec_qdbgcfg_usbnet_cmd(ql_at_cmd_t *cmd);
  116. void quec_usbnet_try_lock(void);
  117. void quec_usbnet_unlock(void);
  118. void ql_usbnet_set_status(ql_usbnet_state_e status);
  119. void quec_netdev_init(void);
  120. quec_netif *quec_usbnet_connect_netif_get(void);
  121. quec_netif *quec_usbnet_wan_netif_get(void);
  122. bool quec_usbnet_sendevent(uint32_t nMsg, uint32_t nParam1, uint8_t nParam2, uint8_t nParam3, uint16_t nParam4);
  123. bool quec_usbnet_send_osi_event_set_if(quec_netif *net_if, quec_netif *wan_if);
  124. void quec_usbnet_connect_ctx_init(void);
  125. void quec_usbnet_retry_or_reinit(void *ctx);
  126. int8_t quec_usbnet_connect_enable_with_cid(const uint8_t nSim, const uint8_t cid);
  127. ql_task_t quec_get_usbnet_threadID(void);
  128. int8_t quec_netdevctl_cfg_save(uint8_t usbnet_op, uint8_t usbnet_cid, uint8_t usbnet_urc);
  129. ql_usbnet_errcode_e ql_usbnet_active_up(void);
  130. #endif
  131. #ifdef __cplusplus
  132. } /*"C" */
  133. #endif
  134. #endif /* QUEC_USBNET_H */