blob: 3a8029fe4c6598a6a1489226d8199bbcc1ad1d92 [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001/**
2 @file
3 DSI_ConnectManager.h
4
5 @brief
6 This file provides the definitions for dsi, and declares the
7 API functions.
8
9*/
10/*============================================================================
11 Copyright (c) 2017 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
12 Quectel Wireless Solution Proprietary and Confidential.
13 =============================================================================*/
14/*===========================================================================
15
16 EDIT HISTORY FOR MODULE
17
18This section contains comments describing changes made to the module.
19Notice that changes are listed in reverse chronological order.
20
21
22WHEN WHO WHAT, WHERE, WHY
23---------- ------------ ----------------------------------------------------
2424/07/2019 Nebula.li create
25=============================================================================*/
26
27#ifndef __DSI_CONNECTMANAGER_H__
28#define __DSI_CONNECTMANAGER_H__
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#define QL_WAN_SUCCESS (0)
35#define QL_WAN_ERROR (-1)
36#define QL_INTERFACE_NAME_LEN 16
37#define QL_IPV4_MAX_ADDR_LEN 32
38#define QL_IPV6_MAX_ADDR_LEN 128
39
40
41/**
42 * used to check network status, when timeout, start data call again.
43*/
44#define QL_WAN_NETWORK_STATUS_MAX_TIMEOUT (60)
45
46
47/**
48 * DSI event define
49 */
50typedef enum
51{
52 CONNECT_DISCON = 0x00,
53 CONNECT_CONSUCCESS,
54 CONNECT_CONNING,
55 CONNECT_REDIAL,
56 CONNECT_DIAL_IMMEDIATELY,
57 CONNECT_ROAM,
58 CONNECT_WAIT_NWCHANGE,
59 CONNECT_GET_GLOBALIP_ERR,
60 CONNECT_DEACTIVATED,
61 CONNECT_WAIT_PS_ATTACH,
62
63 FAIL_BASE_INDEX=0x10,
64 SIM_NOT_READY=FAIL_BASE_INDEX+0x01,
65 NW_NOT_READY=FAIL_BASE_INDEX+0x02,
66 PDP_OPERATOR_BARRED =FAIL_BASE_INDEX+0x08, /* no retry */
67 PDP_INSUFFICIENT_RESOURCES =FAIL_BASE_INDEX+0x1A,
68 PDP_MISSING_UKNOWN_APN = FAIL_BASE_INDEX+0x1B, /* no retry */
69 PDP_UNKNOWN_PDP_ADDRESS_TYPE = FAIL_BASE_INDEX+0x1C, /* no retry */
70 PDP_USER_AUTHENTICATION = FAIL_BASE_INDEX+0x1D, /* no retry */
71 PDP_ACTIVATION_REJECT_GGSN = FAIL_BASE_INDEX+0x1E, /* no retry */
72 PDP_ACTIVATION_REJECT_UNSPECIFIED = FAIL_BASE_INDEX+0x1F,
73 PDP_SERVICE_OPTION_NOT_SUPPORTED = FAIL_BASE_INDEX+0x20, /* no retry */
74 PDP_SERVICE_OPTION_NOT_SUBSCRIBED = FAIL_BASE_INDEX+0x21, /* no retry */
75 PDP_SERVICE_OPTION_OUT_OF_ORDER = FAIL_BASE_INDEX+0x22,
76 PDP_NSAPI_IN_USE = FAIL_BASE_INDEX+0x23, /* no retry */
77 PDP_REGULAR_DEACTIVATION = FAIL_BASE_INDEX+0x24, /* possibly restart radio,
78 based on framework config */
79 PDP_ONLY_IPV4_ALLOWED = FAIL_BASE_INDEX+0x32, /* no retry */
80 PDP_ONLY_IPV6_ALLOWED = FAIL_BASE_INDEX+0x33, /* no retry */
81 PDP_ONLY_SINGLE_BEARER_ALLOWED = FAIL_BASE_INDEX+0x34,
82 PDP_PROTOCOL_ERRORS = FAIL_BASE_INDEX+0x6F, /* no retry */
83
84 /* Not mentioned in the specification */
85 PDP_VOICE_REGISTRATION_FAIL = -1,
86 PDP_DATA_REGISTRATION_FAIL = -2,
87
88 /* reasons for data call drop - network/modem disconnect */
89 PDP_SIGNAL_LOST = -3,
90 PDP_PREF_RADIO_TECH_CHANGED = -4,/* preferred technology has changed, should retry
91 with parameters appropriate for new technology */
92 PDP_RADIO_POWER_OFF = -5, /* data call was disconnected because radio was resetting,
93 powered off - no retry */
94 PDP_TETHERED_CALL_ACTIVE = -6, /* data call was disconnected by modem because tethered
95 mode was up on same APN/data profile - no retry until
96 tethered call is off */
97 PDP_CID_EXIST_FAIL = -7, /* cid is exist already*/
98
99 PDP_NO_CCINET=-10,
100 PDP_DHCP_SERVER_ERR_PIPE=-11,
101
102 PDP_ERROR_UNSPECIFIED = 0xffff, /* retry silently */
103 QL_DSI_EVT_MAX
104} QL_DSI_NET_EVT_T;
105
106#define SIM_REMOVED SIM_NOT_READY
107
108typedef struct
109{
110 char ip[QL_IPV4_MAX_ADDR_LEN];
111 char pri_dns[QL_IPV4_MAX_ADDR_LEN];
112 char sec_dns[QL_IPV4_MAX_ADDR_LEN];
113 char name[QL_INTERFACE_NAME_LEN];
114 char gateway[QL_IPV4_MAX_ADDR_LEN];
115}v4_address_status;
116
117typedef struct
118{
119 int state; //dial status
120 v4_address_status addr; //IPv4 address information
121}v4_info;
122
123typedef struct
124{
125 char ip[QL_IPV6_MAX_ADDR_LEN];
126 char pri_dns[QL_IPV6_MAX_ADDR_LEN];
127 char sec_dns[QL_IPV6_MAX_ADDR_LEN];
128 char name[QL_INTERFACE_NAME_LEN];
129 char gateway[QL_IPV6_MAX_ADDR_LEN];
130}v6_address_status;
131
132typedef struct
133{
134 int state; //dial status
135 v6_address_status addr; //IPv6 address information
136}v6_info;
137
138typedef struct
139{
140 int profile_idx;
141 int ip_type;
142 v4_info v4;
143 v6_info v6;
144}ql_data_call_info;
145
146/**
147 * DSI auth pref define
148*/
149typedef enum
150{
151 QL_DSI_AUTH_PREF_NULL = 0,
152 QL_DSI_AUTH_PREF_ONLY_PAP,
153 QL_DSI_AUTH_PREF_ONLY_CHAP,
154 //QL_DSI_AUTH_PREF_BOTH_PAP_CHAP
155} QL_DSI_AUTH_PREF_T;
156
157/**
158 * callback function used in ql_wan_start, when data call status changed,
159 * Use callback functions for notifications, see enum QL_DSI_NET_EVT_T
160*/
161typedef void (*nw_status_cb)(int status);
162
163
164typedef void (*ex_conn_status_cb)(int cid,int iptype,int status,int cause);
165
166
167
168/*-----------------------------------------------------------------------------------------------*/
169/**
170 @brief data call init function, must call first.
171 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
172 */
173/*-----------------------------------------------------------------------------------------------*/
174int ql_wan_init();
175
176/*-----------------------------------------------------------------------------------------------*/
177/**
178 @brief data call release function, must call finally.
179 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
180 */
181/*-----------------------------------------------------------------------------------------------*/
182int ql_wan_release();
183
184
185/*-----------------------------------------------------------------------------------------------*/
186/**
187 @brief data call auto connect set, include auto status and interval(seconds).
188 @param[in] auto_status When it is 0, the network cannot be automatically reconnected
189 after disconnection; when it is 1, it can be automatically reconnected
190 @param[in] interval_sec data call status check interval
191 the max value is QL_WAN_NETWORK_STATUS_MAX_TIMEOUT
192 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
193 */
194/*-----------------------------------------------------------------------------------------------*/
195int ql_wan_set_autoconnect(int auto_status, int interval_sec);
196
197/*-----------------------------------------------------------------------------------------------*/
198/**
199 @brief start data call, must call ql_wan_init first.
200 @param[in] nw_cb this is a callback function, when data call status changed, Use callback
201 functions for notifications
202 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
203 */
204/*-----------------------------------------------------------------------------------------------*/
205int ql_wan_start(int profile_idx, int op, nw_status_cb nw_cb);
206
207/*-----------------------------------------------------------------------------------------------*/
208/**
209 @brief start data call, must call ql_wan_init first.
210 @param[in] nw_cb this is a callback function, when data call status changed, Use callback
211 functions for notifications
212 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
213 */
214/*-----------------------------------------------------------------------------------------------*/
215int ql_wan_start_ex(int profile_idx, int op, ex_conn_status_cb nw_cb);
216
217/*-----------------------------------------------------------------------------------------------*/
218/**
219 @brief data call stop function.
220 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
221 */
222/*-----------------------------------------------------------------------------------------------*/
223int ql_wan_stop(int profile_idx);
224
225
226/*-----------------------------------------------------------------------------------------------*/
227/**
228 @brief function to set apn.
229 @param[in] apn apn name want to set
230 @param[in] username user name of apn
231 @param[in] password password of apn
232 @param[in] auth auth type of apn, see enum QL_DSI_AUTH_PREF_T
233 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
234 */
235/*-----------------------------------------------------------------------------------------------*/
236int ql_wan_setapn(int profile_idx, int ip_type, const char *apn, const char *userName, const char *password, QL_DSI_AUTH_PREF_T auth);
237/*-----------------------------------------------------------------------------------------------*/
238/**
239 @brief function to get first apn infomation.
240 @param[out] apn apn name to return
241 @param[in ] apnLen apn name buffer size
242 @param[out] userName username of apn to return
243 @param[in ] userLen username buffer size
244 @param[out] password password to return
245 @param[in ] pwdLen password buffer size
246 @return if success return QL_WAN_SUCCESS, else return QL_WAN_ERROR
247 */
248/*-----------------------------------------------------------------------------------------------*/
249
250#define ql_wan_getapn(profile_idx,ip_type,apn,apnLen,userName,userLen,password,pwdLen,...) __ql_wan_getapn(profile_idx,ip_type,apn,apnLen,userName,userLen,password,pwdLen,(NULL,##__VA_ARGS__))
251
252int __ql_wan_getapn(int profile_idx, int *ip_type, char *apn, int apnLen, char *userName, int userLen, char *password, int pwdLen,int* auth);
253int ql_get_data_call_info(int profile_idx, ql_data_call_info *info);
254
255#ifdef __cplusplus
256}
257#endif
258
259#endif