blob: e8eba55d96a7ef540826c1c77e1b5f43a8385dff [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001/*-----------------------------------------------------------------------------------------------*/
2/**
3 @file ql_data_call.h
4 @brief Data service 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 20181024 tyler.kuang Created .
21-------------------------------------------------------------------------------------------------*/
22
23#ifndef __QL_DATA_CALL_H__
24#define __QL_DATA_CALL_H__
25#include <sys/socket.h>
26#include <netinet/in.h>
27#include <arpa/inet.h>
28#include "ql_net_common.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34typedef void ql_data_call_param_t;
35
l.yange4f94f42025-04-29 18:08:39 -070036typedef enum
37{
38 QL_SIM_SLOT_INVALID = 0x000, /**< Invalid slot. */
39 QL_SIM_SLOT_1 = 0xB01, /**< Identify card in slot 1. */
40 QL_SIM_SLOT_2 = 0xB02, /**< Identify card in slot 2. */
41} QL_SIM_SLOT_E;
42
b.liud440f9f2025-04-18 10:44:31 +080043typedef struct
44{
45 int call_id;
46 char call_name[QL_NET_MAX_NAME_LEN + 1];
47 QL_NET_IP_VER_E ip_ver;
48 QL_NET_DATA_CALL_STATUS_E call_status;
49 char device[QL_NET_MAX_NAME_LEN + 1];
50 uint8_t has_addr; /**< Valid when data call state is connected*/
51 ql_net_addr_t addr;
52 uint8_t has_addr6; /**< Valid when data call state is connected*/
53 ql_net_addr6_t addr6;
54 int call_end_reason_type; /**< Last data call disconnect reason type */
55 int call_end_reason_code; /**< Last data call disconnect reason code */
56} ql_data_call_status_t;
57
58typedef struct
59{
60 int call_id;
61 char call_name[QL_NET_MAX_NAME_LEN + 1];
62} ql_data_call_item_t;
63
64typedef struct
65{
66 QL_NET_IP_VER_E ip_ver;
67 QL_NET_AUTH_PREF_E auth_pref;
68 char apn_name[QL_NET_MAX_APN_NAME_LEN + 1];
69 char username[QL_NET_MAX_APN_USERNAME_LEN + 1];
70 char password[QL_NET_MAX_APN_PASSWORD_LEN + 1];
71} ql_data_call_apn_config_t;
72
73typedef struct
74{
75 uint64_t tx_pkts;
76 uint64_t tx_bytes;
77 uint64_t tx_dropped_pkts;
78 uint64_t rx_pkts;
79 uint64_t rx_bytes;
80 uint64_t rx_dropped_pkts;
81}ql_data_call_pkt_stats_t;
82
83typedef void (*ql_data_call_status_ind_cb_f)(int call_id,
84 QL_NET_DATA_CALL_STATUS_E pre_call_status,
85 ql_data_call_status_t *p_msg);
86
87typedef void (*ql_data_call_service_error_cb_f)(int error);
88
89
90/*-----------------------------------------------------------------------------------------------*/
91/**
92 @brief Initialize the data call service
93 @return
94 QL_ERR_OK - successful
95 QL_ERR_INVALID_ARG - as defined
96 QL_ERR_UNKNOWN - unknown error, failed to connect to service
97 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
98 Other - error code defined by ql_type.h
99 */
100/*-----------------------------------------------------------------------------------------------*/
101int ql_data_call_init(void);
102
103/*-----------------------------------------------------------------------------------------------*/
104/**
105 @brief Create a data call instance
106 @param[in] call_id The unique identifier of the data call instance, specified by the user
107 @param[in] call_name Friendly data call name, specified by the user
108 @param[in] is_background Whether the data call status is maintained by the data call service daemon.
109 If it is 0, the data call instance will be deleted after the data call process exits.
110 @return
111 QL_ERR_OK - successful
112 QL_ERR_INVALID_ARG - as defined
113 QL_ERR_UNKNOWN - unknown error, failed to connect to service
114 QL_ERR_SERVICE_NOT_READY - service is not ready, need to retry
115 Other - error code defined by ql_type.h
116 */
117/*-----------------------------------------------------------------------------------------------*/
118int ql_data_call_create(int call_id, const char *call_name, int is_background);
119
120/*-----------------------------------------------------------------------------------------------*/
121/**
122 @brief Alloc for a data call configuration instance
123 @return
124 NULL - Not enough memory
125 Other - successful
126 */
127/*-----------------------------------------------------------------------------------------------*/
128ql_data_call_param_t *ql_data_call_param_alloc(void);
129
130/*-----------------------------------------------------------------------------------------------*/
131/**
132 @brief Initialize the data call configuration instance
133 @param[in] param Point to the data call configuration instance
134 @return
135 QL_ERR_OK - Successful
136 QL_ERR_INVALID_ARG - Invalid arguments
137 */
138/*-----------------------------------------------------------------------------------------------*/
139int ql_data_call_param_init(ql_data_call_param_t *param);
140
141/*-----------------------------------------------------------------------------------------------*/
142/**
143 @brief Release the data call configuration instance
144 @param[in] param Point to the data call configuration instance
145 @return
146 QL_ERR_OK - Successful
147 QL_ERR_INVALID_ARG - Invalid arguments
148 */
149/*-----------------------------------------------------------------------------------------------*/
150int ql_data_call_param_free(ql_data_call_param_t *param);
151
152
153/*-----------------------------------------------------------------------------------------------*/
154/**
155 @brief Bind APN ID, range:1-16
156 @param[in] param Point to the data call configuration instance
157 @param[in] apn_id APN ID, range:1-16
158 @return
159 QL_ERR_OK - Successful
160 QL_ERR_INVALID_ARG - Invalid arguments
161 */
162/*-----------------------------------------------------------------------------------------------*/
163int ql_data_call_param_set_apn_id(ql_data_call_param_t *param, int apn_id);
164
165/*-----------------------------------------------------------------------------------------------*/
166/**
167 @brief Get APN name from configuration instance
168 @param[in] param Point to the data call configuration instance
169 @param[out] buf APN ID
170 @return
171 QL_ERR_OK - Successful
172 QL_ERR_INVALID_ARG - Invalid arguments
173 */
174/*-----------------------------------------------------------------------------------------------*/
175int ql_data_call_param_get_apn_id(ql_data_call_param_t *param, int *apn_id);
176
177
178/*-----------------------------------------------------------------------------------------------*/
179/**
180 @brief Configure APN name
181 @param[in] param Point to the data call configuration instance
182 @param[in] apn_name APN name
183 @return
184 QL_ERR_OK - Successful
185 QL_ERR_INVALID_ARG - Invalid arguments
186 */
187/*-----------------------------------------------------------------------------------------------*/
188int ql_data_call_param_set_apn_name(ql_data_call_param_t *param, const char *apn_name);
189
190/*-----------------------------------------------------------------------------------------------*/
191/**
192 @brief Get APN name from configuration instance
193 @param[in] param Point to the data call configuration instance
194 @param[out] buf APN name buffer
195 @param[in] buf_len APN name buffer size
196 @return
197 QL_ERR_OK - Successful
198 QL_ERR_INVALID_ARG - Invalid arguments
199 */
200/*-----------------------------------------------------------------------------------------------*/
201int ql_data_call_param_get_apn_name(ql_data_call_param_t *param, char *buf, int buf_len);
202
203/*-----------------------------------------------------------------------------------------------*/
204/**
205 @brief Configure APN user name
206 @param[in] param Point to the data call configuration instance
207 @param[in] user_name APN user name
208 @return
209 QL_ERR_OK - Successful
210 QL_ERR_INVALID_ARG - Invalid arguments
211 */
212/*-----------------------------------------------------------------------------------------------*/
213int ql_data_call_param_set_user_name(ql_data_call_param_t *param, const char *user_name);
214
215/*-----------------------------------------------------------------------------------------------*/
216/**
217 @brief Get APN user name from configuration instance
218 @param[in] param Point to the data call configuration instance
219 @param[out] buf APN user name buffer
220 @param[in] buf_len APN user name buffer size
221 @return
222 QL_ERR_OK - Successful
223 QL_ERR_INVALID_ARG - Invalid arguments
224 */
225/*-----------------------------------------------------------------------------------------------*/
226int ql_data_call_param_get_user_name(ql_data_call_param_t *param, char *buf, int buf_len);
227
228/*-----------------------------------------------------------------------------------------------*/
229/**
230 @brief Configure APN user password
231 @param[in] param Point to the data call configuration instance
232 @param[in] user_password APN user password
233 @return
234 QL_ERR_OK - Not enough memory
235 QL_ERR_INVALID_ARG - Invalid arguments
236 */
237/*-----------------------------------------------------------------------------------------------*/
238int ql_data_call_param_set_user_password(ql_data_call_param_t *param, const char *user_password);
239
240/*-----------------------------------------------------------------------------------------------*/
241/**
242 @brief Get APN user password from configuration instance
243 @param[in] param Point to the data call configuration instance
244 @param[out] buf APN user password buffer
245 @param[in] buf_len APN user password buffer size
246 @return
247 QL_ERR_OK - Not enough memory
248 QL_ERR_INVALID_ARG - Invalid arguments
249 */
250/*-----------------------------------------------------------------------------------------------*/
251int ql_data_call_param_get_user_password(ql_data_call_param_t *param, char *buf, int buf_len);
252
253
254/*-----------------------------------------------------------------------------------------------*/
255/**
256 @brief Configure the data call authentication method
257 @param[in] param Point to the data call configuration instance
258 @param[in] auth_pref Defined by QL_DATA_CALL_AUTH_PREF_E
259 @return
260 QL_ERR_OK - Successful
261 QL_ERR_INVALID_ARG - Invalid arguments
262 */
263/*-----------------------------------------------------------------------------------------------*/
264int ql_data_call_param_set_auth_pref(ql_data_call_param_t *param, int auth_pref);
265
266/*-----------------------------------------------------------------------------------------------*/
267/**
268 @brief Configure the data call authentication method
269 @param[in] param Point to the data call configuration instance
270 @param[out] p_data Store return value
271 @return
272 QL_ERR_OK - Successful
273 QL_ERR_INVALID_ARG - Invalid arguments
274 */
275/*-----------------------------------------------------------------------------------------------*/
276int ql_data_call_param_get_auth_pref(ql_data_call_param_t *param, int *p_data);
277
278
279/*-----------------------------------------------------------------------------------------------*/
280/**
281 @brief Configure the data call IP version
282 @param[in] param Point to the data call configuration instance
283 @param[in] ip_ver Defined by QL_NET_IP_VER_E
284 @return
285 QL_ERR_OK - Successful
286 QL_ERR_INVALID_ARG - Invalid arguments
287 */
288/*-----------------------------------------------------------------------------------------------*/
289int ql_data_call_param_set_ip_version(ql_data_call_param_t *param, int ip_ver);
290
291/*-----------------------------------------------------------------------------------------------*/
292/**
293 @brief Get IP version from configuration instance
294 @param[in] param Point to the data call configuration instance
295 @param[out] p_ver Store return value
296 @return
297 QL_ERR_OK - Successful
298 QL_ERR_INVALID_ARG - Invalid arguments
299 */
300/*-----------------------------------------------------------------------------------------------*/
301int ql_data_call_param_get_ip_version(ql_data_call_param_t *param, int *p_ver);
302
303/*-----------------------------------------------------------------------------------------------*/
304/**
305 @brief Configure the data call auto reconnection mode
306 @param[in] param Point to the data call configuration instance
307 @param[in] mode Defined by QL_NET_DATA_CALL_RECONNECT_MODE_E
308 @return
309 QL_ERR_OK - Successful
310 QL_ERR_INVALID_ARG - Invalid arguments
311 */
312/*-----------------------------------------------------------------------------------------------*/
313int ql_data_call_param_set_reconnect_mode(ql_data_call_param_t *param, int reconnect_mode);
314
315/*-----------------------------------------------------------------------------------------------*/
316/**
317 @brief Get auto reconnection mode from configuration instance
318 @param[in] param Point to the data call configuration instance
319 @param[out] p_mode Store return value
320 @return
321 QL_ERR_OK - Successful
322 QL_ERR_INVALID_ARG - Invalid arguments
323 */
324/*-----------------------------------------------------------------------------------------------*/
325int ql_data_call_param_get_reconnect_mode(ql_data_call_param_t *param, int *p_mode);
326
327/*-----------------------------------------------------------------------------------------------*/
328/**
329 @brief Configure the data call auto reconnection interval
330 @param[in] param Point to the data call configuration instance
331 @param[in] time_list Interval time list in ms
332 @param[in] num Number of time list
333 @return
334 QL_ERR_OK - Successful
335 QL_ERR_INVALID_ARG - Invalid arguments
336 */
337/*-----------------------------------------------------------------------------------------------*/
338int ql_data_call_param_set_reconnect_interval(ql_data_call_param_t *param, int *time_list, int num);
339
340/*-----------------------------------------------------------------------------------------------*/
341/**
342 @brief Get auto reconnection interval from configuration instance
343 @param[in] param Point to the data call configuration instance
344 @param[out] time_list Store return value
345 @param[in,out] p_num
346 @return
347 QL_ERR_OK - Successful
348 QL_ERR_INVALID_ARG - Invalid arguments
349 */
350/*-----------------------------------------------------------------------------------------------*/
351int ql_data_call_param_get_reconnect_interval(ql_data_call_param_t *param, int *time_list, int *p_num);
352
353/*-----------------------------------------------------------------------------------------------*/
354/**
355 @brief Configure the specified data call instance
356 @param[in] call_id Specify a data call instance
357 @param[in] param Point to the data call configuration instance
358 @return
359 QL_ERR_OK - Successful
360 QL_ERR_INVALID_ARG - Invalid arguments
361 */
362/*-----------------------------------------------------------------------------------------------*/
363int ql_data_call_config(int call_id, ql_data_call_param_t *param);
364
365/*-----------------------------------------------------------------------------------------------*/
366/**
367 @brief Get the specified data call configuration instance
368 @param[in] call_id Specify a data call instance
369 @param[in] param Point to the data call configuration instance
370 @return
371 QL_ERR_OK - Successful
372 QL_ERR_INVALID_ARG - Invalid arguments
373 */
374/*-----------------------------------------------------------------------------------------------*/
375int ql_data_call_get_config(int call_id, ql_data_call_param_t *param);
376
377/*-----------------------------------------------------------------------------------------------*/
378/**
379 @brief Start data call
380 @param[in] call_id Specify a data call instance
381 @return
382 QL_ERR_OK - successful
383 QL_ERR_NOT_INIT - uninitialized
384 QL_ERR_SERVICE_NOT_READY - service is not ready
385 QL_ERR_INVALID_ARG - Invalid arguments
386 Other - error code defined by ql_type.h
387 */
388/*-----------------------------------------------------------------------------------------------*/
389int ql_data_call_start(int call_id);
390
391/*-----------------------------------------------------------------------------------------------*/
392/**
393 @brief Stop data call
394 @param[in] call_id Specify a data call instance
395 @return
396 QL_ERR_OK - successful
397 QL_ERR_NOT_INIT - uninitialized
398 QL_ERR_SERVICE_NOT_READY - service is not ready
399 QL_ERR_INVALID_ARG - Invalid arguments
400 Other - error code defined by ql_type.h
401 */
402/*-----------------------------------------------------------------------------------------------*/
403int ql_data_call_stop(int call_id);
404
405/*-----------------------------------------------------------------------------------------------*/
406/**
407 @brief Delete a data call instance
408 @param[in] call_id Specify a data call instance
409 @return
410 QL_ERR_OK - successful
411 QL_ERR_NOT_INIT - uninitialized
412 QL_ERR_SERVICE_NOT_READY - service is not ready
413 QL_ERR_INVALID_ARG - Invalid arguments
414 Other - error code defined by ql_type.h
415 */
416/*-----------------------------------------------------------------------------------------------*/
417int ql_data_call_delete(int call_id);
418
419/*-----------------------------------------------------------------------------------------------*/
420/**
421 @brief Get the current data call instance list
422 @param[out] list Data call instance array
423 @param[in,out] list_len, in-> Data call instance array size, out->current data call instance number
424 @return
425 QL_ERR_OK - successful
426 QL_ERR_NOT_INIT - uninitialized
427 QL_ERR_SERVICE_NOT_READY - service is not ready
428 QL_ERR_INVALID_ARG - Invalid arguments
429 Other - error code defined by ql_type.h
430 */
431/*-----------------------------------------------------------------------------------------------*/
432int ql_data_call_get_list(ql_data_call_item_t *list, int *list_len);
433
434/*-----------------------------------------------------------------------------------------------*/
435/**
436 @brief Get the data call status
437 @param[in] call_id Specify a data call instance
438 @param[out] p_sta Point to status instance
439 @return
440 QL_ERR_OK - successful
441 QL_ERR_NOT_INIT - uninitialized
442 QL_ERR_SERVICE_NOT_READY - service is not ready
443 QL_ERR_INVALID_ARG - Invalid arguments
444 Other - error code defined by ql_type.h
445 */
446/*-----------------------------------------------------------------------------------------------*/
447int ql_data_call_get_status(int call_id, ql_data_call_status_t *p_sta);
448
449/*-----------------------------------------------------------------------------------------------*/
450/**
451 @brief Register data call status change event
452 @param[in] cb
453 @return
454 QL_ERR_OK - successful
455 QL_ERR_NOT_INIT - uninitialized
456 QL_ERR_SERVICE_NOT_READY - service is not ready
457 QL_ERR_INVALID_ARG - Invalid arguments
458 Other - error code defined by ql_type.h
459 */
460/*-----------------------------------------------------------------------------------------------*/
461int ql_data_call_set_status_ind_cb(ql_data_call_status_ind_cb_f cb);
462
463/*-----------------------------------------------------------------------------------------------*/
464/**
465 @brief Set APN related configuration.If the apn does not exist, it is automatically created.
466 @param[in] apn_id APN ID, range:1-16
467 @param[in] p_info APN configuration
468 @return
469 QL_ERR_OK - successful
470 QL_ERR_NOT_INIT - uninitialized
471 QL_ERR_SERVICE_NOT_READY - service is not ready
472 QL_ERR_INVALID_ARG - Invalid arguments
473 Other - error code defined by ql_type.h
474 */
475/*-----------------------------------------------------------------------------------------------*/
476int ql_data_call_set_apn_config(int apn_id, ql_data_call_apn_config_t *p_info);
477
478/*-----------------------------------------------------------------------------------------------*/
479/**
480 @brief Set APN related configuration. If the apn does not exist, it is automatically created and
481 the default parameters are set.
482 @param[in] apn_id APN ID, range:1-16
483 @param[out] p_info APN configuration
484 @return
485 QL_ERR_OK - successful
486 QL_ERR_NOT_INIT - uninitialized
487 QL_ERR_SERVICE_NOT_READY - service is not ready
488 QL_ERR_INVALID_ARG - Invalid arguments
489 Other - error code defined by ql_type.h
490 */
491/*-----------------------------------------------------------------------------------------------*/
492int ql_data_call_get_apn_config(int apn_id, ql_data_call_apn_config_t *p_info);
493
494/*-----------------------------------------------------------------------------------------------*/
495/**
496 @brief Set APN related configuration,APN ID:1
497 @param[in] p_info APN configuration
498 @return
499 QL_ERR_OK - successful
500 QL_ERR_NOT_INIT - uninitialized
501 QL_ERR_SERVICE_NOT_READY - service is not ready
502 QL_ERR_INVALID_ARG - Invalid arguments
503 Other - error code defined by ql_type.h
504 */
505/*-----------------------------------------------------------------------------------------------*/
506int ql_data_call_set_attach_apn_config(ql_data_call_apn_config_t *p_info);
507
508/*-----------------------------------------------------------------------------------------------*/
509/**
510 @brief Registration server error callback. Currently, only if the server exits abnormally,
511 the callback function will be executed, and the error code is QL_ERR_ABORTED;
512 @param[in] cb Callback function
513 @return
514 QL_ERR_OK - successful
515 Other - error code defined by ql_type.h
516 */
517/*-----------------------------------------------------------------------------------------------*/
518int ql_data_call_set_service_error_cb(ql_data_call_service_error_cb_f cb);
519
520/*-----------------------------------------------------------------------------------------------*/
521/**
522 @brief Deinitialize the data call service
523 @return
524 QL_ERR_OK - successful
525 Other - error code defined by ql_type.h
526 */
527/*-----------------------------------------------------------------------------------------------*/
528int ql_data_call_deinit(void);
529
l.yange4f94f42025-04-29 18:08:39 -0700530
531/*-----------------------------------------------------------------------------------------------*/
532/**
533 @brief chose sim card to data call
534 @param[in] sub Subscription type.
535 @return Whether the subscription was successfully bound.
536 @retval QL_ERR_OK successful.
537 @retval QL_ERR_INVALID_ARG invalid argument.
538 @retval QL_ERR_UNKNOWN unknown error, failed to connect to service.
539 @retval QL_ERR_SERVICE_NOT_READY service is not ready, need to retry.
540 @retval Other error code defined by ql_type.h.
541 */
542/*-----------------------------------------------------------------------------------------------*/
543int ql_set_data_slot(QL_SIM_SLOT_E log_slot);
544
b.liud440f9f2025-04-18 10:44:31 +0800545#ifdef __cplusplus
546}
547#endif
548
549#endif
550