ql_api_usbnet.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*============================================================================
  2. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  3. Quectel Wireless Solution 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. #ifndef QL_API_USBNET_H
  13. #define QL_API_USBNET_H
  14. #include "ql_api_common.h"
  15. #include "ql_api_datacall.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /*===========================================================================
  20. * Macro Definition
  21. ===========================================================================*/
  22. #define QL_USBNET_ERRCODE_BASE (QL_COMPONENT_NETWORK_USBNET<<16)
  23. /*===========================================================================
  24. * Enum
  25. ===========================================================================*/
  26. typedef enum
  27. {
  28. QL_USBNET_SUCCESS = 0,
  29. QL_USBNET_EXECUTE_ERR = 1 | QL_USBNET_ERRCODE_BASE,
  30. QL_USBNET_MEM_ADDR_NULL_ERR,
  31. QL_USBNET_INVALID_PARAM_ERR,
  32. QL_USBNET_USB_NOT_CONNECT_ERR,
  33. QL_USBNET_PDP_ACTIVE_ERR = 5 | QL_USBNET_ERRCODE_BASE,
  34. QL_USBNET_REPEAT_CONNECT_ERR,
  35. QL_USBNET_REPEAT_DISCONNECT_ERR,
  36. }ql_usbnet_errcode_e;
  37. //support ECM and RNDIS
  38. typedef enum
  39. {
  40. QL_USBNET_NONE = 0,
  41. QL_USBNET_ECM,
  42. QL_USBNET_MBIM,
  43. QL_USBNET_RNDIS,
  44. QL_USBNET_MAX
  45. }ql_usbnet_type_e;
  46. typedef enum
  47. {
  48. QL_USBNET_STATE_NONE = 0, //usbnet initialization state
  49. QL_USBNET_STATE_START, //usbnet connecting
  50. QL_USBNET_STATE_CONNECT, //usbnet connected
  51. QL_USBNET_STATE_PORT_DISCONNECT, //usb port disconnect
  52. QL_USBNET_STATE_MAX,
  53. }ql_usbnet_state_e;
  54. /*===========================================================================
  55. * STRUCT
  56. ===========================================================================*/
  57. typedef struct
  58. {
  59. uint8_t *data;
  60. int data_len;
  61. }ql_usbnet_uplink_s;
  62. /*===========================================================================
  63. * function
  64. ===========================================================================*/
  65. /*****************************************************************
  66. * Description: usbnet callback
  67. *
  68. * Parameters:
  69. * ind_type [in] Event Notification Type
  70. * errcode [in] error code, 0 indicates that the execution result was correct
  71. * ctx [in] reserved for callback
  72. *
  73. * Retuen:
  74. * None
  75. *****************************************************************/
  76. typedef void (*ql_usbnet_callback)(unsigned int ind_type, ql_usbnet_errcode_e errcode, void *ctx);
  77. /*****************************************************************
  78. * Description: usbnet datalink callback
  79. *
  80. * Parameters:
  81. * uplink_data [in] usbnet data
  82. *
  83. * Retuen:
  84. * None
  85. *****************************************************************/
  86. typedef bool (*ql_usbnet_datalink_callback)(ql_usbnet_uplink_s *uplink_data);
  87. /*****************************************************************
  88. * Description: set usbnet type and reboot to take effect
  89. *
  90. * Parameters:
  91. * usbnet_type [in] usbnet type, only support QL_USBNET_ECM and QL_USBNET_RNDIS
  92. *
  93. * Return:
  94. * 0: success
  95. * other: error code
  96. *****************************************************************/
  97. ql_usbnet_errcode_e ql_usbnet_set_type(ql_usbnet_type_e usbnet_type);
  98. /*****************************************************************
  99. * Description: get usbnet type that has been set
  100. *
  101. * Parameters:
  102. * usbnet_type [out] usbnet type that has been saved
  103. *
  104. * Return:
  105. * 0: success
  106. * other: error code
  107. *****************************************************************/
  108. ql_usbnet_errcode_e ql_usbnet_get_type(ql_usbnet_type_e *usbnet_type);
  109. /*****************************************************************
  110. * Description: start usbnet connect
  111. *
  112. * Parameters:
  113. * nSim [in] sim index,range: 0-1
  114. * profile_idx [in] pdp index, range: 1-7
  115. * config [in] pdp context configuration info, If set to NULL, the default parameters are used
  116. *
  117. * Return:
  118. * 0: success
  119. * other: error code
  120. *****************************************************************/
  121. ql_usbnet_errcode_e ql_usbnet_start(uint8_t nSim, int profile_idx, ql_data_call_conf_s *config);
  122. /*****************************************************************
  123. * Description: stop usbnet connect
  124. *
  125. * Parameters:
  126. * None
  127. *
  128. * Return:
  129. * 0: success
  130. * other: error code
  131. *****************************************************************/
  132. ql_usbnet_errcode_e ql_usbnet_stop(void);
  133. /*****************************************************************
  134. * Description: get usbnet status
  135. *
  136. * Parameters:
  137. * status [out] usbnet status, Refer to the enumeration of ql_usbnet_state_e
  138. *
  139. * Return:
  140. * 0: success
  141. * other: error code
  142. *****************************************************************/
  143. ql_usbnet_errcode_e ql_usbnet_get_status(ql_usbnet_state_e *status);
  144. /*****************************************************************
  145. * Description: register usbnet callback
  146. *
  147. * Parameters:
  148. * usbnet_cb [in] usbnet callback
  149. * ctx [in] reserved for callback
  150. *
  151. * Return:
  152. * 0: success
  153. * other: error code
  154. *****************************************************************/
  155. ql_usbnet_errcode_e ql_usbnet_register_cb(ql_usbnet_callback usbnet_cb, void *ctx);
  156. ql_usbnet_errcode_e ql_usbnet_register_uplink_cb(ql_usbnet_datalink_callback uplink_cb);
  157. /*****************************************************************
  158. * Description: send data to usbnet
  159. *
  160. * Parameters:
  161. * data [in] data address, must be 4-byte aligned
  162. * size [in] size of data send
  163. *
  164. * Return:
  165. * 0: success
  166. * other: error code
  167. *****************************************************************/
  168. ql_usbnet_errcode_e ql_usbnet_send_data_to_usb(uint8_t *data, uint16_t size);
  169. #ifdef __cplusplus
  170. } /*"C" */
  171. #endif
  172. #endif /* QL_API_USBNET_H */