blob: 427c88bae42a4fa94ee6e160927d2d53de420123 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_net_usb_dev.h
4 @brief USB net device API
5*/
6/*-----------------------------------------------------------------------------------------------*/
7
8/*-------------------------------------------------------------------------------------------------
9 Copyright (c) 2018 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
10 Quectel Wireless Solution Proprietary and Confidential.
11-------------------------------------------------------------------------------------------------*/
12
13/*-------------------------------------------------------------------------------------------------
14 EDIT HISTORY
15 This section contains comments describing changes made to the file.
16 Notice that changes are listed in reverse chronological order.
17 $Header: $
18 when who what, where, why
19 -------- --- ----------------------------------------------------------
20 20190709 tyler.kuang Created .
21-------------------------------------------------------------------------------------------------*/
22
23#ifndef __QL_NET_USB_DEV_H__
24#define __QL_NET_USB_DEV_H__
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29#include "ql_net_common.h"
30
31
32typedef void (*ql_net_usb_dev_ind_cb_f)(const char *device,
33 QL_NET_USB_DEV_STATUS_E pre_status,
34 ql_net_usb_dev_t *p_dev);
35
36typedef void (*ql_net_usb_dev_service_error_cb_f)(int error);
37
38/*-----------------------------------------------------------------------------------------------*/
39/**
40 @brief Initialize the USB net device service
41 @return
42 QL_ERR_OK - successful
43 QL_ERR_INVALID_ARG - as defined
44 QL_ERR_UNKNOWN - unknown error, failed to connect to service
45 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
46 Other - error code defined by ql_type.h
47 */
48/*-----------------------------------------------------------------------------------------------*/
49int ql_net_usb_dev_init(void);
50
51/*-----------------------------------------------------------------------------------------------*/
52/**
53 @brief Get USB network device status
54 @param[in] device Device name, such as ecm0, rndis0..
55 @param[out] p_dev Return device status information
56 @return
57 QL_ERR_OK - successful
58 QL_ERR_INVALID_ARG - as defined
59 QL_ERR_UNKNOWN - unknown error, failed to connect to service
60 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
61 QL_ERR_INTERFACE_NOT_FOUND - device does not exist
62 Other - error code defined by ql_type.h
63 */
64/*-----------------------------------------------------------------------------------------------*/
65int ql_net_usb_dev_get_status(const char *device, ql_net_usb_dev_t *p_dev);
66
67/*-----------------------------------------------------------------------------------------------*/
68/**
69 @brief Get all USB network device list
70 @param[out] list USB network device array
71 @param[in,out] list_len, in-> array size, out->current instance number
72 @return
73 QL_ERR_OK - successful
74 QL_ERR_INVALID_ARG - as defined
75 QL_ERR_UNKNOWN - unknown error, failed to connect to service
76 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
77 Other - error code defined by ql_type.h
78 */
79/*-----------------------------------------------------------------------------------------------*/
80int ql_net_usb_dev_get_list(ql_net_usb_dev_t *list, int *list_len);
81
82/*-----------------------------------------------------------------------------------------------*/
83/**
84 @brief Set USB network device MTU. If it does not currently exist, then set it after the device
85 appears.
86 @param[in] device Device name, such as ecm0, rndis0..
87 @param[in] mtu MTU
88 @return
89 QL_ERR_OK - successful
90 QL_ERR_INVALID_ARG - as defined
91 QL_ERR_UNKNOWN - unknown error, failed to connect to service
92 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
93 Other - error code defined by ql_type.h
94 */
95/*-----------------------------------------------------------------------------------------------*/
96int ql_net_usb_dev_set_mtu(const char *device, int mtu);
97
98/*-----------------------------------------------------------------------------------------------*/
99/**
100 @brief Get USB network device MTU
101 @param[in] device Device name, such as ecm0, rndis0..
102 @param[out] p_mtu Reutn device MTU
103 @return
104 QL_ERR_OK - successful
105 QL_ERR_INVALID_ARG - as defined
106 QL_ERR_UNKNOWN - unknown error, failed to connect to service
107 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
108 QL_ERR_INTERFACE_NOT_FOUND - device does not exist
109 Other - error code defined by ql_type.h
110 */
111/*-----------------------------------------------------------------------------------------------*/
112int ql_net_usb_dev_get_mtu(const char *device, int *p_mtu);
113
114/*-----------------------------------------------------------------------------------------------*/
115/**
116 @brief Set USB network device MAC address. If it does not currently exist, then set it after the device
117 appears.
118 @param[in] device Device name, such as ecm0, rndis0..
119 @param[in] macaddr MAC address, format: XX:XX:XX:XX:XX:XX
120 @return
121 QL_ERR_OK - successful
122 QL_ERR_INVALID_ARG - as defined
123 QL_ERR_UNKNOWN - unknown error, failed to connect to service
124 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
125 QL_ERR_INTERFACE_NOT_FOUND - device does not exist
126 Other - error code defined by ql_type.h
127 */
128/*-----------------------------------------------------------------------------------------------*/
129int ql_net_usb_dev_set_macaddr(const char *device, const char *macaddr);
130
131/*-----------------------------------------------------------------------------------------------*/
132/**
133 @brief Get USB network device MAC address
134 @param[in] device Device name, such as ecm0, rndis0..
135 @param[out] macaddr_buf Return MAC address
136 @param[in] buf_len Buffer size
137 @return
138 QL_ERR_OK - successful
139 QL_ERR_INVALID_ARG - as defined
140 QL_ERR_UNKNOWN - unknown error, failed to connect to service
141 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
142 QL_ERR_INTERFACE_NOT_FOUND - device does not exist
143 Other - error code defined by ql_type.h
144 */
145/*-----------------------------------------------------------------------------------------------*/
146int ql_net_usb_dev_get_macaddr(const char *device, char *macaddr_buf, int buf_len);
147
148/*-----------------------------------------------------------------------------------------------*/
149/**
150 @brief Register USB network device status change event
151 @param[in] cb
152 @return
153 QL_ERR_OK - successful
154 QL_ERR_NOT_INIT - uninitialized
155 QL_ERR_SERVICE_NOT_READY - service is not ready
156 QL_ERR_INVALID_ARG - Invalid arguments
157 Other - error code defined by ql_type.h
158 */
159/*-----------------------------------------------------------------------------------------------*/
160int ql_net_usb_dev_set_ind_cb(ql_net_usb_dev_ind_cb_f cb);
161
162
163/*-----------------------------------------------------------------------------------------------*/
164/**
165 @brief Registration server error callback. Currently, only if the server exits abnormally,
166 the callback function will be executed, and the error code is QL_ERR_ABORTED;
167 @param[in] cb Callback function
168 @return
169 QL_ERR_OK - successful
170 Other - error code defined by ql_type.h
171 */
172/*-----------------------------------------------------------------------------------------------*/
173int ql_net_usb_dev_set_service_error_cb(ql_net_usb_dev_service_error_cb_f cb);
174
175/*-----------------------------------------------------------------------------------------------*/
176/**
177 @brief Deinitialize the USB net device service
178 @return
179 QL_ERR_OK - successful
180 Other - error code defined by ql_type.h
181 */
182/*-----------------------------------------------------------------------------------------------*/
183int ql_net_usb_dev_deinit(void);
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif
190