liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /** |
| 2 | @file |
| 3 | ql_nw.h |
| 4 | |
| 5 | @brief |
| 6 | This file provides the definitions for nw, 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 | |
| 18 | This section contains comments describing changes made to the module. |
| 19 | Notice that changes are listed in reverse chronological order. |
| 20 | |
| 21 | |
| 22 | WHEN WHO WHAT, WHERE, WHY |
| 23 | ---------- ------------ ---------------------------------------------------- |
| 24 | 14/08/2019 Nebula.li create |
| 25 | =============================================================================*/ |
| 26 | |
| 27 | #ifndef __QL_NW_H__ |
| 28 | #define __QL_NW_H__ |
| 29 | |
| 30 | #include <stdlib.h> |
| 31 | #include <stdint.h> |
| 32 | #include <string.h> |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
| 38 | #define QL_NW_IND_VOICE_REG_EVENT_FLAG (1 << 0) //VOICE注册事件 |
| 39 | #define QL_NW_IND_DATA_REG_EVENT_FLAG (1 << 1) //DATA注册事件 |
| 40 | #define QL_NW_IND_SIGNAL_STRENGTH_EVENT_FLAG (1 << 2) //信号强度事件 |
| 41 | #define QL_NW_IND_NITZ_TIME_UPDATE_EVENT_FLAG (1 << 3) //时间跟新事件 |
| 42 | //START baron-2020.02.29: add for ims register state indication |
| 43 | #define QL_NW_IND_IMS_NETWORK_STATE_CHANGED_FLAG (1 << 4) //ims register state change |
| 44 | //END |
| 45 | #define CELL_MAX_NUM 20 |
| 46 | |
| 47 | typedef enum |
| 48 | { |
| 49 | QL_NW_SUCCESS, |
| 50 | QL_NW_GENERIC_FAILURE, |
| 51 | QL_NW_RADIO_NOT_AVAILABLE, |
| 52 | }QL_NW_ERROR_CODE; |
| 53 | |
| 54 | typedef enum { |
| 55 | QL_NW_PREF_NET_TYPE_GSM_WCDMA = 0, |
| 56 | QL_NW_PREF_NET_TYPE_GSM_ONLY = 1, |
| 57 | QL_NW_PREF_NET_TYPE_WCDMA = 2, |
| 58 | QL_NW_PREF_NET_TYPE_GSM_WCDMA_AUTO = 3, //根据 PRL自动选择GSM、WCDMA |
| 59 | QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA = 9, //自动选择LTE、GSM、WCDMA |
| 60 | QL_NW_PREF_NET_TYPE_LTE_ONLY = 11, |
| 61 | QL_NW_PREF_NET_TYPE_LTE_WCDMA = 12, |
| 62 | QL_NW_PREF_NET_TYPE_LTE_GSM_GSM_PREF = 13, //优先GSM |
| 63 | QL_NW_PREF_NET_TYPE_LTE_GSM_LTE_PREF = 14, //优先LTE |
| 64 | QL_NW_PREF_NET_TYPE_LTE_GSM = 15, |
| 65 | QL_NW_PREF_NET_TYPE_LTE_WCDMA_WCDMA_PREF = 16, |
| 66 | QL_NW_PREF_NET_TYPE_LTE_WCDMA_LTE_PREF = 17, |
| 67 | QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_GSM_PREF = 19, |
| 68 | QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_WCDMA_PREF = 20, |
| 69 | QL_NW_PREF_NET_TYPE_LTE_GSM_WCDMA_LTE_PREF = 21, |
| 70 | } QL_NW_PREFERRED_NETWORK_TYPE; |
| 71 | |
| 72 | typedef struct |
| 73 | { |
| 74 | QL_NW_PREFERRED_NETWORK_TYPE preferred_nw_mode; //首选的网络制式,见QL_NW_PREFERRED_NETWORK_TYPE |
| 75 | int roaming_pref; //漫游开关。 0 关; 1 开 |
| 76 | }QL_NW_CONFIG_INFO_T; |
| 77 | |
| 78 | typedef struct |
| 79 | { |
| 80 | char nitz_time[32]; //格式:format: YY/MM/DD HH:MM:SS '+/-'TZ daylight, 18/09/19 07:40:18 +32 00. |
| 81 | unsigned long abs_time; //0表示不可用 |
| 82 | unsigned char leap_sec; //0表示不可用 |
| 83 | }QL_NW_NITZ_TIME_INFO_T; |
| 84 | |
| 85 | typedef struct |
| 86 | { |
| 87 | char long_eons[128]; |
| 88 | char short_eons[128]; |
| 89 | char mcc[4]; |
| 90 | char mnc[4]; |
| 91 | }QL_NW_OPERATOR_INFO_T; |
| 92 | |
| 93 | //START baron-2020.02.29: add for ims register state |
| 94 | typedef struct __volte_state |
| 95 | { |
| 96 | int reg_state; /*0: not registered, 1: registered*/ |
| 97 | }VOLTE_STATE; |
| 98 | //END |
| 99 | |
| 100 | typedef enum |
| 101 | { |
| 102 | QL_NW_ACCESS_TECH_GSM = 0, |
| 103 | QL_NW_ACCESS_TECH_GSM_COMPACT = 1, |
| 104 | QL_NW_ACCESS_TECH_UTRAN = 2, |
| 105 | QL_NW_ACCESS_TECH_GSM_wEGPRS = 3, |
| 106 | QL_NW_ACCESS_TECH_UTRAN_wHSDPA = 4, |
| 107 | QL_NW_ACCESS_TECH_UTRAN_wHSUPA = 5, |
| 108 | QL_NW_ACCESS_TECH_UTRAN_wHSDPA_HSUPA = 6, |
| 109 | QL_NW_ACCESS_TECH_E_UTRAN = 7, |
| 110 | QL_NW_ACCESS_TECH_UTRAN_HSPAP = 8, |
| 111 | QL_NW_ACCESS_TECH_E_UTRAN_CA = 9, |
| 112 | QL_NW_ACCESS_TECH_NONE = 10, |
| 113 | }QL_NW_ACCESS_TECHNOLOGY; |
| 114 | |
| 115 | typedef struct |
| 116 | { |
| 117 | int status; //0:未知的网络;1:可用的网络;2:当前的网络;3:禁止使用的网络 |
| 118 | QL_NW_OPERATOR_INFO_T operator_name; //运营商信息,见QL_NW_OPERATOR_INFO_T。 |
| 119 | QL_NW_ACCESS_TECHNOLOGY act; //注网制式,见QL_NW_RADIO_TECH_TYPE_T。 |
| 120 | }QL_NW_SCAN_ENTRY_INFO_T; |
| 121 | |
| 122 | typedef struct |
| 123 | { |
| 124 | int entry_len; //可用网络的个数 |
| 125 | QL_NW_SCAN_ENTRY_INFO_T entry[40]; //可用网络的列表,见QL_NW_SCAN_ENTRY_INFO_T。 |
| 126 | }QL_NW_SCAN_RESULT_LIST_INFO_T; |
| 127 | |
| 128 | |
| 129 | typedef enum { |
| 130 | QL_NW_RADIO_TECH_UNKNOWN = 0, |
| 131 | QL_NW_RADIO_TECH_GPRS = 1, |
| 132 | QL_NW_RADIO_TECH_EDGE = 2, |
| 133 | QL_NW_RADIO_TECH_UMTS = 3, |
| 134 | QL_NW_RADIO_TECH_IS95A = 4, |
| 135 | QL_NW_RADIO_TECH_IS95B = 5, |
| 136 | QL_NW_RADIO_TECH_1xRTT = 6, |
| 137 | QL_NW_RADIO_TECH_HSDPA = 9, |
| 138 | QL_NW_RADIO_TECH_HSUPA = 10, |
| 139 | QL_NW_RADIO_TECH_HSPA = 11, |
| 140 | QL_NW_RADIO_TECH_EHRPD = 13, |
| 141 | QL_NW_RADIO_TECH_LTE = 14, |
| 142 | QL_NW_RADIO_TECH_HSPAP = 15, // HSPA+ |
| 143 | QL_NW_RADIO_TECH_GSM = 16, |
| 144 | QL_NW_RADIO_TECH_TD_SCDMA = 17, |
| 145 | QL_NW_RADIO_TECH_IWLAN = 18, |
| 146 | QL_NW_RADIO_TECH_LTEP = 19, |
| 147 | QL_NW_RADIO_TECH_DC_HSPA = 20 |
| 148 | } QL_NW_RADIO_TECHNOLOGY; |
| 149 | |
| 150 | typedef enum { |
| 151 | QL_NW_REG_STATE_NOT_REGISTERED=0, //not registered, MT is not currently searching an operator to register to |
| 152 | QL_NW_REG_STATE_HOME_NETWORK=1, //registered, home network |
| 153 | QL_NW_REG_STATE_TRYING_ATTACH_OR_SEARCHING=2, //not registered, but MT is currently trying to attach or searching an operator to register to |
| 154 | QL_NW_REG_STATE_DENIED=3, //registration denied |
| 155 | QL_NW_REG_STATE_UNKNOWN=4, //unknown |
| 156 | QL_NW_REG_STATE_ROAMING=5, //registered, roaming |
| 157 | QL_NW_REG_STATE_HOME_NETWORK_SMS_ONLY=6, //registered for “SMS only”, home network (not applicable) |
| 158 | QL_NW_REG_STATE_ROAMING_SMS_ONLY=7,// registered for “SMS only”, roaming (not applicable) |
| 159 | QL_NW_REG_STATE_ATTACHED_EMERGENCY_ONLY=8, //attached for emergency bearer services only |
| 160 | QL_NW_REG_STATE_HOME_NETWORK_CSFB_NOT_PREFERRED=9, //registered for “CSFB not preferred”, home network (not applicable) |
| 161 | QL_NW_REG_STATE_ROAMING_CSFB_NOT_PREFERRED=10,//registered for “CSFB not preferred”, roaming (not applicable) |
| 162 | QL_NW_REG_STATE_EMERGENCY_ONLY=11,//emergency bearer services only |
| 163 | }QL_NW_REG_STATE; |
| 164 | |
| 165 | typedef struct |
| 166 | { |
| 167 | QL_NW_REG_STATE state; //注册状态 |
| 168 | int lac; |
| 169 | int cid; |
| 170 | QL_NW_RADIO_TECHNOLOGY rat; |
| 171 | int rejectCause; //注册被拒绝的原因 |
| 172 | int psc; //Primary Scrambling Code |
| 173 | } QL_NW_COMMON_REG_STATUS_INFO_T; |
| 174 | |
| 175 | typedef struct |
| 176 | { |
| 177 | QL_NW_COMMON_REG_STATUS_INFO_T voice_reg; //VOICE注册信息,见QL_NW_COMMON_REG_STATUS_INFO_T |
| 178 | QL_NW_COMMON_REG_STATUS_INFO_T data_reg; //DATA注册信息。 |
| 179 | }QL_NW_REG_STATUS_INFO_T; |
| 180 | |
| 181 | typedef struct |
| 182 | { |
| 183 | int nw_selection_mode; //0 自动;1手动 |
| 184 | char mcc[4]; |
| 185 | char mnc[4]; |
| 186 | QL_NW_ACCESS_TECHNOLOGY act; //selection 制式,见QL_NW_ACCESS_TECHNOLOGY。 |
| 187 | }QL_NW_SELECTION_INFO_T; |
| 188 | |
| 189 | typedef struct { |
| 190 | int rssi; |
| 191 | int bitErrorRate; |
| 192 | int rscp; |
| 193 | int ecio; |
| 194 | } QL_NW_GW_SIGNAL_STRENGTH_INFO_T; |
| 195 | |
| 196 | typedef struct { |
| 197 | int rssi; |
| 198 | int rsrp; |
| 199 | int rsrq; |
| 200 | int rssnr; |
| 201 | int cqi; |
| 202 | } QL_NW_LTE_SIGNAL_STRENGTH_INFO_T; |
| 203 | |
| 204 | typedef struct { |
| 205 | QL_NW_GW_SIGNAL_STRENGTH_INFO_T GW_SignalStrength; |
| 206 | QL_NW_LTE_SIGNAL_STRENGTH_INFO_T LTE_SignalStrength; |
| 207 | }QL_NW_SIGNAL_STRENGTH_INFO_T; |
| 208 | |
| 209 | /* CSQ: just get rssi and ber */ |
| 210 | typedef struct { |
| 211 | int rssi; |
| 212 | int bitErrorRate; |
| 213 | } QL_NW_CSQ_SIGNAL_STRENGTH_INFO_T; |
| 214 | |
| 215 | typedef struct |
| 216 | { |
| 217 | int flag; /**Cell type, 0:present,1:neighbor.*/ |
| 218 | int cid; /**Cell ID, (0 indicates information is not represent).*/ |
| 219 | int mcc; /**This field should be ignored when cid is not present*/ |
| 220 | int mnc; /**This field should be ignored when cid is not present*/ |
| 221 | int lac; /**Location area code.(This field should be ignord when cid is not present). */ |
| 222 | int arfcn; /**Absolute RF channel number. */ |
| 223 | char bsic; /**Base station identity code. (0 indicates information is not present). */ |
| 224 | int lenOfMnc; /**Length of MNC, value range (2,3) */ |
| 225 | }QL_MCM_NW_GSM_CELL_INFO_T; |
| 226 | |
| 227 | typedef struct |
| 228 | { |
| 229 | int flag; /**Cell type, 0:present,1:inter,2:intra.*/ |
| 230 | int cid; /**Cell ID, (0 indicates information is not represent).*/ |
| 231 | int lcid; /**UTRAN Cell ID (0 indicates information is not present). */ |
| 232 | int mcc; /**This field should be ignored when cid is not present*/ |
| 233 | int mnc; /**This field should be ignored when cid is not present*/ |
| 234 | int lac; /**Location area code. (This field should be ignored when cid is not present). */ |
| 235 | int uarfcn; /**UTRA absolute RF channel number. */ |
| 236 | int psc; /**Primary scrambling code. */ |
| 237 | int lenOfMnc; /**Length of MNC, value range (2,3) */ |
| 238 | }QL_MCM_NW_UMTS_CELL_INFO_T; |
| 239 | |
| 240 | typedef struct |
| 241 | { |
| 242 | int flag; /**Cell type, 0:present,1:inter,2:intra.*/ |
| 243 | int cid; /**<Cell ID, (0 indicates information is not represent).*/ |
| 244 | int mcc; /**This field should be ignored when cid is not present*/ |
| 245 | int mnc; /**This field should be ignored when cid is not present*/ |
| 246 | int tac; /**Tracing area code (This field should be ignored when cid is not present). */ |
| 247 | int pci; /**Physical cell ID. Range: 0 to 503. */ |
| 248 | int earfcn; /**E-UTRA absolute radio frequency channel number of the cell. RANGE: 0 TO 65535. */ |
| 249 | int lenOfMnc; /**Length of MNC, value range (2,3) */ |
| 250 | int rsrp; |
| 251 | int rsrq; |
| 252 | }QL_MCM_NW_LTE_CELL_INFO_T; |
| 253 | |
| 254 | /** Gets cell information. */ |
| 255 | typedef struct |
| 256 | { |
| 257 | int gsm_info_valid; /**< Must be set to TRUE if gsm_info is being passed. */ |
| 258 | int gsm_info_num; /**< Must be set to the number of elements in entry*/ |
| 259 | QL_MCM_NW_GSM_CELL_INFO_T gsm_info[CELL_MAX_NUM]; /**< GSM cell information (Serving and neighbor. */ |
| 260 | int umts_info_valid; /**< Must be set to TRUE if umts_info is being passed. */ |
| 261 | int umts_info_num; /**< Must be set to the number of elements in entry*/ |
| 262 | QL_MCM_NW_UMTS_CELL_INFO_T umts_info[CELL_MAX_NUM];/**< UMTS cell information (Serving and neighbor). */ |
| 263 | int lte_info_valid; /**< Must be set to TRUE if lte_info is being passed. */ |
| 264 | int lte_info_num; /**< Must be set to the number of elements in entry*/ |
| 265 | QL_MCM_NW_LTE_CELL_INFO_T lte_info[CELL_MAX_NUM]; /**< LTE cell information (Serving and neighbor). */ |
| 266 | }QL_NW_CELL_INFO_T; |
| 267 | |
| 268 | |
| 269 | typedef void (*QL_NW_EventHandlerFunc_t)(unsigned int ind_flag, void *ind_msg_buf, unsigned int ind_msg_len, void *contextPtr); |
| 270 | |
| 271 | QL_NW_ERROR_CODE ql_nw_init (); |
| 272 | QL_NW_ERROR_CODE ql_nw_release(); |
| 273 | QL_NW_ERROR_CODE ql_nw_set_config(QL_NW_CONFIG_INFO_T *pt_info); |
| 274 | QL_NW_ERROR_CODE ql_nw_get_config(QL_NW_CONFIG_INFO_T *pt_info); |
| 275 | QL_NW_ERROR_CODE ql_nw_get_nitz_time_info(QL_NW_NITZ_TIME_INFO_T *pt_info); |
| 276 | QL_NW_ERROR_CODE ql_nw_event_register(unsigned int bitmask); |
| 277 | QL_NW_ERROR_CODE ql_nw_get_operator_name(QL_NW_OPERATOR_INFO_T *pt_info); |
| 278 | QL_NW_ERROR_CODE ql_nw_perform_scan(QL_NW_SCAN_RESULT_LIST_INFO_T *pt_info); |
| 279 | QL_NW_ERROR_CODE ql_nw_get_reg_status(QL_NW_REG_STATUS_INFO_T *pt_info); |
| 280 | QL_NW_ERROR_CODE ql_nw_set_selection(QL_NW_SELECTION_INFO_T *pt_info); |
| 281 | QL_NW_ERROR_CODE ql_nw_get_selection(QL_NW_SELECTION_INFO_T *pt_info); |
| 282 | QL_NW_ERROR_CODE ql_nw_get_signal_strength(QL_NW_SIGNAL_STRENGTH_INFO_T *pt_info); |
| 283 | QL_NW_ERROR_CODE ql_nw_get_cell_info(QL_NW_CELL_INFO_T *pt_info); |
| 284 | QL_NW_ERROR_CODE ql_nw_add_event_handler(QL_NW_EventHandlerFunc_t handlerPtr, void* contextPtr); |
| 285 | QL_NW_ERROR_CODE ql_nw_get_volte_state(VOLTE_STATE *state); |
| 286 | /* CSQ: just get rssi and ber */ |
| 287 | QL_NW_ERROR_CODE ql_nw_csq_get_signal_strength(QL_NW_CSQ_SIGNAL_STRENGTH_INFO_T *pt_info); |
| 288 | #ifdef __cplusplus |
| 289 | } |
| 290 | #endif |
| 291 | |
| 292 | #endif |