wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1 | #include <stdint.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 4 | #include "liblog/lynq_deflog.h" |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 5 | |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 10 | #include <cfg_api.h> |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 11 | #include "sc_tel_types.h" |
| 12 | #include "sc_wifi.h" |
| 13 | #include "lynq-qser-wifi.h" |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 14 | #define WIFI_ENABLE_FLAG_TIME_OUT 10 |
| 15 | #define WIFI_ENABLE_FLAG_DEFAULT -100 |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 16 | |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 17 | static lynq_wifi_event_handle wifi_event_handle = NULL; |
| 18 | static lynq_wifi_event_handle_sta wifi_event_handle_sta = NULL; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 19 | static void *global_arg = NULL; |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 20 | static int wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT; |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 21 | static bool lynq_wifi_enable = false; |
| 22 | #define WIFI_ENABLE_JUDGE() do{ \ |
| 23 | if(lynq_wifi_enable == false) \ |
| 24 | { \ |
| 25 | LYINFLOG("[%s ] wifi not enable\n", __func__); \ |
| 26 | return -1; \ |
| 27 | } \ |
| 28 | }while (0); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 29 | |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 30 | static lynq_wifi_event_handle wifi2_event_handle = NULL; |
| 31 | static lynq_wifi_event_handle_sta wifi2_event_handle_sta = NULL; |
| 32 | static void *global_arg_2 = NULL; |
| 33 | static int wifi2_enable_flag = WIFI_ENABLE_FLAG_DEFAULT; |
| 34 | static bool lynq_wifi2_enable = false; |
| 35 | #define WIFI2_ENABLE_JUDGE() do{ \ |
| 36 | if(lynq_wifi2_enable== false) \ |
| 37 | { \ |
| 38 | LYINFLOG("[%s ] wifi 2 not enable\n", __func__); \ |
| 39 | return -1; \ |
| 40 | } \ |
| 41 | }while (0); |
| 42 | |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 43 | /******************************************************************** |
| 44 | * @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 45 | * @return :sc_wifi_auth_e, all |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 46 | * @todo: NA |
| 47 | * @see: NA |
| 48 | * @warning: NA |
| 49 | *********************************************************************/ |
| 50 | static sc_wifi_auth_e lynq_to_sc_auth_mode(lynq_wifi_auth_e auth_mode) |
| 51 | { |
| 52 | sc_wifi_auth_e type; |
| 53 | switch (auth_mode) |
| 54 | { |
| 55 | case LYNQ_WIFI_AUTH_OPEN: |
| 56 | type = SC_WIFI_AUTH_OPEN; |
| 57 | break; |
| 58 | case LYNQ_WIFI_AUTH_WPA2_PSK: |
| 59 | type = SC_WIFI_AUTH_WPA2_PSK; |
| 60 | break; |
| 61 | case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 62 | type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 63 | break; |
| 64 | case LYNQ_WIFI_AUTH_WPA3_PSK: |
| 65 | type = SC_WIFI_AUTH_WPA3_PSK; |
| 66 | break; |
| 67 | case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 68 | type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 69 | break; |
| 70 | default: |
| 71 | type = SC_WIFI_AUTH_MIN; |
| 72 | break; |
| 73 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 74 | return type; |
| 75 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 76 | |
| 77 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 78 | * @brief: sc_to_lynq_auth_mode, The wifi protocol moves from platform to api |
| 79 | * @return :lynq_wifi_auth_e, all |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 80 | * @todo: NA |
| 81 | * @see: NA |
| 82 | * @warning: NA |
| 83 | *********************************************************************/ |
| 84 | static lynq_wifi_auth_e sc_to_lynq_auth_mode(sc_wifi_auth_e auth_mode) |
| 85 | { |
| 86 | lynq_wifi_auth_e type; |
| 87 | switch (auth_mode) |
| 88 | { |
| 89 | case SC_WIFI_AUTH_OPEN: |
| 90 | type = LYNQ_WIFI_AUTH_OPEN; |
| 91 | break; |
| 92 | case SC_WIFI_AUTH_WPA2_PSK: |
| 93 | type = LYNQ_WIFI_AUTH_WPA2_PSK; |
| 94 | break; |
| 95 | case SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 96 | type = LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 97 | break; |
| 98 | case SC_WIFI_AUTH_WPA3_PSK: |
| 99 | type = LYNQ_WIFI_AUTH_WPA3_PSK; |
| 100 | break; |
| 101 | case SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 102 | type = LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 103 | break; |
| 104 | default: |
| 105 | type = LYNQ_WIFI_AUTH_MIN; |
| 106 | break; |
| 107 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 108 | return type; |
| 109 | } |
| 110 | |
| 111 | /******************************************************************** |
| 112 | * @brief: lynq_to_sc_mode, The wifi protocol is transferred from api to platform |
| 113 | * @return :sc_wifi_ap_mode_type_e, all |
| 114 | * @todo: NA |
| 115 | * @see: NA |
| 116 | * @warning: NA |
| 117 | *********************************************************************/ |
| 118 | static sc_wifi_ap_mode_type_e lynq_to_sc_mode(lynq_wifi_mode_type_e mode) |
| 119 | { |
| 120 | sc_wifi_ap_mode_type_e type; |
| 121 | switch (mode) |
| 122 | { |
| 123 | case LYNQ_WIFI_MODE_80211BGN: |
| 124 | type = SC_WIFI_AP_MODE_80211BGN; |
| 125 | break; |
| 126 | case LYNQ_WIFI_MODE_80211BGNAX_2G: |
| 127 | type = SC_WIFI_AP_MODE_80211BGNAX_2G; |
| 128 | break; |
| 129 | case LYNQ_WIFI_MODE_80211AN: |
| 130 | type = SC_WIFI_AP_MODE_80211AN; |
| 131 | break; |
| 132 | case LYNQ_WIFI_MODE_80211ANAC: |
| 133 | type = SC_WIFI_AP_MODE_80211ANAC; |
| 134 | break; |
| 135 | case LYNQ_WIFI_MODE_80211ANACAX_5G: |
| 136 | type = SC_WIFI_AP_MODE_80211ANACAX_5G; |
| 137 | break; |
| 138 | default: |
| 139 | type = SC_WIFI_AP_MODE_MIN; |
| 140 | break; |
| 141 | } |
| 142 | return type; |
| 143 | } |
| 144 | |
| 145 | /******************************************************************** |
| 146 | * @brief: sc_to_lynq_mode, The encryption mode of wifi is changed from platform to api |
| 147 | * @return :lynq_wifi_mode_type_e, all |
| 148 | * @todo: NA |
| 149 | * @see: NA |
| 150 | * @warning: NA |
| 151 | *********************************************************************/ |
| 152 | static lynq_wifi_mode_type_e sc_to_lynq_mode(sc_wifi_ap_mode_type_e mode) |
| 153 | { |
| 154 | lynq_wifi_mode_type_e type; |
| 155 | switch (mode) |
| 156 | { |
| 157 | case SC_WIFI_AP_MODE_80211BGN: |
| 158 | type = LYNQ_WIFI_MODE_80211BGN; |
| 159 | break; |
| 160 | case SC_WIFI_AP_MODE_80211BGNAX_2G: |
| 161 | type = LYNQ_WIFI_MODE_80211BGNAX_2G; |
| 162 | break; |
| 163 | case SC_WIFI_AP_MODE_80211AN: |
| 164 | type = LYNQ_WIFI_MODE_80211AN; |
| 165 | break; |
| 166 | case SC_WIFI_AP_MODE_80211ANAC: |
| 167 | type = LYNQ_WIFI_MODE_80211ANAC; |
| 168 | break; |
| 169 | case SC_WIFI_AP_MODE_80211ANACAX_5G: |
| 170 | type = LYNQ_WIFI_MODE_80211ANACAX_5G; |
| 171 | break; |
| 172 | default: |
| 173 | type = LYNQ_WIFI_MODE_MIN; |
| 174 | break; |
| 175 | } |
| 176 | return type; |
| 177 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 178 | |
| 179 | /******************************************************************** |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 180 | * @brief: sc_to_lynq_sta_status, sc_wifi_sta_status_t to lynq_wifi_sta_status_t |
| 181 | * @return :int, all |
| 182 | * @todo: NA |
| 183 | * @see: NA |
| 184 | * @warning: NA |
| 185 | *********************************************************************/ |
| 186 | static int sc_to_lynq_sta_status(sc_wifi_sta_status_t *stat, lynq_wifi_sta_status_t *status_stat) |
| 187 | { |
| 188 | status_stat->status = (lynq_wifi_sta_status_e)stat->status; |
| 189 | status_stat->signal_level = stat->signal_level; |
| 190 | status_stat->has_addr = stat->has_addr; |
| 191 | status_stat->has_addr6 = stat->has_addr6; |
| 192 | status_stat->reason_code = (lynq_wifi_reason_code_e)stat->reason_code; |
| 193 | strncpy(status_stat->ifname, stat->ifname, sizeof(stat->ifname) - 1); |
| 194 | strncpy(status_stat->ap_bssid, stat->ap_bssid, sizeof(stat->ap_bssid) - 1); |
| 195 | if (status_stat->has_addr == 1) |
| 196 | { |
| 197 | strncpy(status_stat->addr.addr, stat->addr.addr, sizeof(status_stat->addr.addr) - 1); |
| 198 | strncpy(status_stat->addr.netmask, stat->addr.netmask, sizeof(status_stat->addr.netmask) - 1); |
| 199 | status_stat->addr.subnet_bits = stat->addr.subnet_bits; |
| 200 | strncpy(status_stat->addr.gateway, stat->addr.gateway, sizeof(status_stat->addr.gateway) - 1); |
| 201 | strncpy(status_stat->addr.dnsp, stat->addr.dnsp, sizeof(status_stat->addr.dnsp) - 1); |
| 202 | strncpy(status_stat->addr.dnss, stat->addr.dnss, sizeof(status_stat->addr.dnss) - 1); |
| 203 | } |
| 204 | if (status_stat->has_addr6 == 1) |
| 205 | { |
| 206 | strncpy(status_stat->addr6.addr, stat->addr6.addr, sizeof(status_stat->addr6.addr) - 1); |
| 207 | strncpy(status_stat->addr6.prefix, stat->addr6.prefix, sizeof(status_stat->addr6.prefix) - 1); |
| 208 | status_stat->addr6.prefix_bits = stat->addr6.prefix_bits; |
| 209 | strncpy(status_stat->addr6.gateway, stat->addr6.gateway, sizeof(status_stat->addr6.gateway) - 1); |
| 210 | strncpy(status_stat->addr6.dnsp, stat->addr6.dnsp, sizeof(status_stat->addr6.dnsp) - 1); |
| 211 | strncpy(status_stat->addr6.dnss, stat->addr6.dnss, sizeof(status_stat->addr6.dnss) - 1); |
| 212 | } |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | /******************************************************************** |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 217 | * @brief: lynq_user_status, wifi startup callback |
| 218 | * @return : NA |
| 219 | * @todo: NA |
| 220 | * @see: NA |
| 221 | * @warning: NA |
| 222 | *********************************************************************/ |
| 223 | static void lynq_user_status(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status) |
| 224 | { |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 225 | wifi_enable_flag = status; |
| 226 | LYINFLOG("%s:%d,%d wifi_enable_flag:%d\n", __func__, pre_status, status, wifi_enable_flag); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 227 | } |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 228 | static void lynq_user2_status(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status) |
| 229 | { |
| 230 | wifi2_enable_flag = status; |
| 231 | LYINFLOG("%s:%d,%d wifi2_enable_flag:%d\n", __func__, pre_status, status, wifi2_enable_flag); |
| 232 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 233 | |
| 234 | /******************************************************************** |
| 235 | * @brief: lynq_user_wifi_service_error, wifi service status callback |
| 236 | * @return : NA |
| 237 | * @todo: NA |
| 238 | * @see: NA |
| 239 | * @warning: NA |
| 240 | *********************************************************************/ |
| 241 | static void lynq_user_wifi_service_error(int error) |
| 242 | { |
| 243 | LYINFLOG("%s: %d\n", __func__, error); |
| 244 | } |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 245 | static void lynq_user2_wifi_service_error(int error) |
| 246 | { |
| 247 | LYINFLOG("%s: %d\n", __func__, error); |
| 248 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 249 | |
| 250 | /******************************************************************** |
| 251 | * @brief: lynq_user_ap_status, wifi Obtains the ap status callback |
| 252 | * @return : NA |
| 253 | * @todo: NA |
| 254 | * @see: NA |
| 255 | * @warning: NA |
| 256 | *********************************************************************/ |
| 257 | static void lynq_user_ap_status(sc_wifi_ap_index_e index, sc_wifi_ap_status_e pre_status, sc_wifi_ap_status_t *p_msg) |
| 258 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 259 | lynq_wifi_event_s event; |
| 260 | if (wifi_event_handle != NULL && global_arg != NULL) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 261 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 262 | if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 263 | { |
| 264 | return; |
| 265 | } |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 266 | LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 267 | event.id = LYNQ_WIFI_EVENT_AP_STATION; |
zw.wang | f6fbbc0 | 2024-09-02 11:43:46 +0800 | [diff] [blame] | 268 | event.status = (lynq_wifi_status_e)p_msg->status; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 269 | wifi_event_handle(&event, global_arg); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 270 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 271 | else |
| 272 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 273 | LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status); |
| 274 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 275 | } |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 276 | static void lynq_user2_ap_status(sc_wifi_ap_index_e index, sc_wifi_ap_status_e pre_status, sc_wifi_ap_status_t *p_msg) |
| 277 | { |
| 278 | lynq_wifi_event_s event; |
| 279 | if (wifi2_event_handle != NULL && global_arg_2 != NULL) |
| 280 | { |
| 281 | if (*(int *)global_arg_2 == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 282 | { |
| 283 | return; |
| 284 | } |
| 285 | LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status); |
| 286 | event.id = LYNQ_WIFI_EVENT_AP_STATION; |
| 287 | event.status = (lynq_wifi_status_e)p_msg->status; |
| 288 | wifi2_event_handle(&event, global_arg_2); |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status); |
| 293 | } |
| 294 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 295 | |
| 296 | /******************************************************************** |
| 297 | * @brief: lynq_user_ap_sta_conn_status, wifi as ap is sta information callback |
| 298 | * @return : NA |
| 299 | * @todo: NA |
| 300 | * @see: NA |
| 301 | * @warning: NA |
| 302 | *********************************************************************/ |
| 303 | static void lynq_user_ap_sta_conn_status(sc_wifi_ap_index_e index, sc_wifi_sta_connect_status_t *p_msg) |
| 304 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 305 | char hostname[32] = {0}; |
| 306 | lynq_wifi_event_s event; |
| 307 | int ret = sc_wifi_get_hostname_by_mac(p_msg->macaddr, hostname, sizeof(hostname)); |
| 308 | if (ret == 0) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 309 | { |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 310 | LYINFLOG("sta ip not assigned, try again later!\n"); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 311 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 312 | if (wifi_event_handle != NULL && global_arg != NULL) |
| 313 | { |
| 314 | if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 315 | { |
| 316 | return; |
| 317 | } |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 318 | LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname); |
| 319 | event.id = LYNQ_WIFI_EVENT_AP_STA_STATUS; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 320 | event.ap_sta_info.connected = p_msg->is_connected; |
| 321 | strncpy(event.ap_sta_info.mac, p_msg->macaddr, |
| 322 | sizeof(event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(event.ap_sta_info.mac) : sizeof(p_msg->macaddr)); |
| 323 | strncpy(event.ap_sta_info.hostname, hostname, sizeof(hostname)); |
| 324 | wifi_event_handle(&event, global_arg); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 325 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 326 | else |
| 327 | { |
| 328 | LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname); |
| 329 | } |
| 330 | } |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 331 | static void lynq_user2_ap_sta_conn_status(sc_wifi_ap_index_e index, sc_wifi_sta_connect_status_t *p_msg) |
| 332 | { |
| 333 | char hostname[32] = {0}; |
| 334 | lynq_wifi_event_s event; |
| 335 | int ret = sc_wifi_get_hostname_by_mac_ext(1, p_msg->macaddr, hostname, sizeof(hostname)); |
| 336 | if (ret == 0) |
| 337 | { |
| 338 | LYINFLOG("sta ip not assigned, try again later!\n"); |
| 339 | } |
| 340 | if (wifi2_event_handle != NULL && global_arg_2 != NULL) |
| 341 | { |
| 342 | if (*(int *)global_arg_2 == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 343 | { |
| 344 | return; |
| 345 | } |
| 346 | LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname); |
| 347 | event.id = LYNQ_WIFI_EVENT_AP_STA_STATUS; |
| 348 | event.ap_sta_info.connected = p_msg->is_connected; |
| 349 | strncpy(event.ap_sta_info.mac, p_msg->macaddr, |
| 350 | sizeof(event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(event.ap_sta_info.mac) : sizeof(p_msg->macaddr)); |
| 351 | strncpy(event.ap_sta_info.hostname, hostname, sizeof(hostname)); |
| 352 | wifi2_event_handle(&event, global_arg_2); |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname); |
| 357 | } |
| 358 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 359 | /******************************************************************** |
| 360 | * @brief: print_sta_status, wifi gets the status callback in sta mode |
| 361 | * @return : NA |
| 362 | * @todo: NA |
| 363 | * @see: NA |
| 364 | * @warning: NA |
| 365 | *********************************************************************/ |
| 366 | static void print_sta_status(sc_wifi_sta_status_t *p_msg) |
| 367 | { |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 368 | LYINFLOG("%s: %d, %s, %s, %d, %d\n", __func__, p_msg->status, p_msg->ifname, p_msg->ap_bssid, |
| 369 | p_msg->signal_level, p_msg->reason_code); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 370 | |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 371 | if (p_msg->has_addr == 1) |
| 372 | { |
| 373 | LYINFLOG("[%s]addr ip:%s, netmask:%s, subnet_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n", __func__, |
| 374 | p_msg->addr.addr, p_msg->addr.netmask, p_msg->addr.subnet_bits, |
| 375 | p_msg->addr.gateway, p_msg->addr.dnsp, p_msg->addr.dnss); |
| 376 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 377 | |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 378 | if (p_msg->has_addr6 == 1) |
| 379 | { |
| 380 | LYINFLOG("[%s]addr6 ip:%s, prefix:%s, prefix_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n", __func__, |
| 381 | p_msg->addr6.addr, p_msg->addr6.prefix, p_msg->addr6.prefix_bits, |
| 382 | p_msg->addr6.gateway, p_msg->addr6.dnsp, p_msg->addr6.dnss); |
| 383 | } |
| 384 | LYINFLOG("%s : sta_status end\n", __func__); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /******************************************************************** |
| 388 | * @brief: lynq_user_sta_status_ind, wifi gets the status callback in sta mode |
| 389 | * @return : NA |
| 390 | * @todo: NA |
| 391 | * @see: NA |
| 392 | * @warning: NA |
| 393 | *********************************************************************/ |
| 394 | static void lynq_user_sta_status_ind(sc_wifi_sta_status_e pre_status, |
| 395 | sc_wifi_sta_status_t *p_msg) |
| 396 | { |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 397 | if (wifi_event_handle != NULL && global_arg != NULL) |
| 398 | { |
| 399 | lynq_wifi_event_s event; |
| 400 | if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 401 | { |
| 402 | return; |
| 403 | } |
| 404 | LYINFLOG("%s : user_sta_status_ind_cb pre:%d, cur:%d\n", __func__, pre_status, p_msg->status); |
| 405 | event.id = LYNQ_WIFI_EVENT_STA_STATUS; |
| 406 | if(p_msg->status == SC_WIFI_STA_STATUS_CONNECTED) |
| 407 | event.sta_status = LYNQ_WIFI_STATION_CONNECTED; |
| 408 | else if(p_msg->status == SC_WIFI_STA_STATUS_DISCONNECTED) |
| 409 | event.sta_status = LYNQ_WIFI_STATION_DISCONNECTED; |
| 410 | else |
| 411 | event.sta_status = LYNQ_WIFI_STATION_DISABLE; |
| 412 | sc_to_lynq_sta_status(p_msg, &event.sta_status_all); |
| 413 | event.sta_status_all.sta_status = event.sta_status; |
| 414 | wifi_event_handle(&event, global_arg); |
| 415 | } |
| 416 | else |
| 417 | { |
| 418 | print_sta_status(p_msg); |
| 419 | } |
| 420 | |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 421 | } |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 422 | static void lynq_user2_sta_status_ind(sc_wifi_sta_status_e pre_status, |
| 423 | sc_wifi_sta_status_t *p_msg) |
| 424 | { |
| 425 | if (wifi2_event_handle != NULL && global_arg_2 != NULL) |
| 426 | { |
| 427 | lynq_wifi_event_s event; |
| 428 | if (*(int *)global_arg_2 == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 429 | { |
| 430 | return; |
| 431 | } |
| 432 | LYINFLOG("%s : user_sta_status_ind_cb pre:%d, cur:%d\n", __func__, pre_status, p_msg->status); |
| 433 | event.id = LYNQ_WIFI_EVENT_STA_STATUS; |
| 434 | if(p_msg->status == SC_WIFI_STA_STATUS_CONNECTED) |
| 435 | event.sta_status = LYNQ_WIFI_STATION_CONNECTED; |
| 436 | else if(p_msg->status == SC_WIFI_STA_STATUS_DISCONNECTED) |
| 437 | event.sta_status = LYNQ_WIFI_STATION_DISCONNECTED; |
| 438 | else |
| 439 | event.sta_status = LYNQ_WIFI_STATION_DISABLE; |
| 440 | sc_to_lynq_sta_status(p_msg, &event.sta_status_all); |
| 441 | event.sta_status_all.sta_status = event.sta_status; |
| 442 | wifi2_event_handle(&event, global_arg_2); |
| 443 | } |
| 444 | else |
| 445 | { |
| 446 | print_sta_status(p_msg); |
| 447 | } |
| 448 | |
| 449 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 450 | /******************************************************************** |
| 451 | * @brief: lynq_user_sta_scan_result_ind, wifi gets the callback of sta mode traversing the hotspot |
| 452 | * @return : NA |
| 453 | * @todo: NA |
| 454 | * @see: NA |
| 455 | * @warning: NA |
| 456 | *********************************************************************/ |
| 457 | static void lynq_user_sta_scan_result_ind(sc_wifi_sta_scan_list_t *p_msg) |
| 458 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 459 | int i = 0; |
| 460 | LYINFLOG("%s : user_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt); |
| 461 | if (p_msg->cnt <= 0) |
| 462 | { |
| 463 | return; |
| 464 | } |
| 465 | if (wifi_event_handle_sta != NULL) |
| 466 | { |
| 467 | lynq_wifi_sta_scan_list_t event; |
| 468 | event.cnt = p_msg->cnt; |
| 469 | for (i = 0; i < event.cnt; i++) |
| 470 | { |
| 471 | strncpy(event.info[i].essid, p_msg->info[i].essid, sizeof(p_msg->info[i].essid)); |
| 472 | strncpy(event.info[i].bssid, p_msg->info[i].bssid, sizeof(p_msg->info[i].bssid)); |
| 473 | event.info[i].auth = sc_to_lynq_auth_mode(p_msg->info[i].auth); |
| 474 | event.info[i].cipher = (lynq_wifi_auth_wpa_psk_e)p_msg->info[i].cipher; |
| 475 | event.info[i].channel = p_msg->info[i].channel; |
| 476 | event.info[i].signal_level = p_msg->info[i].signal_level; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 477 | event.info[i].frequency = p_msg->info[i].frequency; |
| 478 | event.info[i].signal = p_msg->info[i].signal; |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 479 | } |
| 480 | wifi_event_handle_sta(&event); |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | for (i = 0; i < p_msg->cnt; i++) |
| 485 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 486 | LYINFLOG("%s : ap[%d]:%s,%d,%d,%d,%s,%d,%d,%d\n", __func__, i, p_msg->info[i].essid, sc_to_lynq_auth_mode(p_msg->info[i].auth), |
| 487 | p_msg->info[i].cipher, p_msg->info[i].channel, p_msg->info[i].bssid, p_msg->info[i].signal_level,p_msg->info[i].frequency,p_msg->info[i].signal); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | } |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 491 | static void lynq_user2_sta_scan_result_ind(sc_wifi_sta_scan_list_t *p_msg) |
| 492 | { |
| 493 | int i = 0; |
| 494 | LYINFLOG("%s : user2_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt); |
| 495 | if (p_msg->cnt <= 0) |
| 496 | { |
| 497 | return; |
| 498 | } |
| 499 | if (wifi2_event_handle_sta != NULL) |
| 500 | { |
| 501 | lynq_wifi_sta_scan_list_t event; |
| 502 | event.cnt = p_msg->cnt; |
| 503 | for (i = 0; i < event.cnt; i++) |
| 504 | { |
| 505 | strncpy(event.info[i].essid, p_msg->info[i].essid, sizeof(p_msg->info[i].essid)); |
| 506 | strncpy(event.info[i].bssid, p_msg->info[i].bssid, sizeof(p_msg->info[i].bssid)); |
| 507 | event.info[i].auth = sc_to_lynq_auth_mode(p_msg->info[i].auth); |
| 508 | event.info[i].cipher = (lynq_wifi_auth_wpa_psk_e)p_msg->info[i].cipher; |
| 509 | event.info[i].channel = p_msg->info[i].channel; |
| 510 | event.info[i].signal_level = p_msg->info[i].signal_level; |
| 511 | event.info[i].frequency = p_msg->info[i].frequency; |
| 512 | event.info[i].signal = p_msg->info[i].signal; |
| 513 | } |
| 514 | wifi2_event_handle_sta(&event); |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | for (i = 0; i < p_msg->cnt; i++) |
| 519 | { |
| 520 | LYINFLOG("%s : ap[%d]:%s,%d,%d,%d,%s,%d,%d,%d\n", __func__, i, p_msg->info[i].essid, sc_to_lynq_auth_mode(p_msg->info[i].auth), |
| 521 | p_msg->info[i].cipher, p_msg->info[i].channel, p_msg->info[i].bssid, p_msg->info[i].signal_level,p_msg->info[i].frequency,p_msg->info[i].signal); |
| 522 | } |
| 523 | } |
| 524 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 525 | /******************************************************************** |
| 526 | * @brief: qser_wifi_work_mode_set, 2.4g or 5g working mode Settings |
| 527 | * @param type [IN]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Settings |
| 528 | * @return : int, If equal to 0 succeeds, others fail |
| 529 | * @todo: NA |
| 530 | * @see: NA |
| 531 | * @warning: NA |
| 532 | *********************************************************************/ |
| 533 | int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type) |
| 534 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 535 | WIFI_ENABLE_JUDGE(); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 536 | int ret = -1; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 537 | sc_wifi_work_mode_e mode; |
| 538 | ret = sc_wifi_work_mode_get(&mode); |
| 539 | if (0 != ret) |
| 540 | { |
| 541 | LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret); |
| 542 | return ret; |
| 543 | } |
| 544 | if(mode == (sc_wifi_work_mode_e)type) //The same value is returned |
| 545 | { |
| 546 | return 0; |
| 547 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 548 | ret = sc_wifi_work_mode_set((sc_wifi_work_mode_e)type); |
| 549 | if (0 != ret) |
| 550 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 551 | LYERRLOG("[%s ] work_mode set ret = %d\n", __func__,ret); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 552 | return ret; |
| 553 | } |
| 554 | LYINFLOG("[%s ]\n", __func__); |
| 555 | return 0; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | /******************************************************************** |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 559 | * @brief: qser_wifi_work_mode_get, 2.4g or 5g working mode Gettings |
| 560 | * @param type [OUT]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Gettings |
| 561 | * @return : int, If equal to 0 succeeds, others fail |
| 562 | * @todo: NA |
| 563 | * @see: NA |
| 564 | * @warning: NA |
| 565 | *********************************************************************/ |
| 566 | int qser_wifi_work_mode_get(lynq_wifi_work_mode_e *type) |
| 567 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 568 | WIFI_ENABLE_JUDGE(); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 569 | int ret = -1; |
| 570 | sc_wifi_work_mode_e mode; |
| 571 | ret = sc_wifi_work_mode_get(&mode); |
| 572 | if (0 != ret) |
| 573 | { |
| 574 | LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret); |
| 575 | return ret; |
| 576 | } |
| 577 | *type = (lynq_wifi_work_mode_e)mode; |
| 578 | LYINFLOG("[%s ]\n", __func__); |
| 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | /******************************************************************** |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 583 | * @brief: qser_wifi_register_handle, Register callback functions |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 584 | * @param event_handle [IN]: lynq_wifi_event_handle, Register the ap event callback function |
| 585 | * @param event_handle_sta [IN]: Register sta's event callback function |
| 586 | * @param arg [IN]: void *, Not currently used, but cannot pass a null pointer |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 587 | * @return :int, If equal to 0 succeeds, others fail |
| 588 | * @todo: NA |
| 589 | * @see: NA |
| 590 | * @warning: NA |
| 591 | *********************************************************************/ |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 592 | int qser_wifi_register_handle(lynq_wifi_event_handle event_handle, lynq_wifi_event_handle_sta event_handle_sta, void *arg) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 593 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 594 | if((event_handle == NULL && event_handle_sta == NULL) || arg == NULL) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 595 | { |
| 596 | LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg); |
| 597 | return -1; |
| 598 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 599 | if(*(int *)arg <= LYNQ_WIFI_EVENT_MIN || *(int *)arg >= LYNQ_WIFI_EVENT_MAX) |
| 600 | { |
| 601 | LYERRLOG("[%s ] The value of arg can only be an integer ranging from 0 to 3p, arg = %d\n", __func__, arg); |
| 602 | return -1; |
| 603 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 604 | wifi_event_handle_sta = event_handle_sta; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 605 | wifi_event_handle = event_handle; |
| 606 | global_arg = arg; |
| 607 | return 0; |
| 608 | } |
| 609 | |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 610 | /******************************************************************** |
| 611 | * @brief: qser_wifi_enable, Enable WiFi function |
| 612 | * @return : int, If equal to 0 succeeds, others fail |
| 613 | * @todo: NA |
| 614 | * @see: NA |
| 615 | * @warning: NA |
| 616 | *********************************************************************/ |
| 617 | int qser_wifi_enable(void) |
| 618 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 619 | if(lynq_wifi_enable) |
| 620 | { |
| 621 | LYERRLOG("[%s ] The wifi is enabled\n", __func__); |
| 622 | return -1; |
| 623 | } |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 624 | wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT; |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 625 | char wifiAvailable[8] = {0}; |
| 626 | sc_cfg_get("wifiAvailable", wifiAvailable, sizeof(wifiAvailable)); |
| 627 | if (!strcmp(wifiAvailable, "0")) |
| 628 | { |
| 629 | LYERRLOG("[%s ] wifiAvailable has been set to 0. If WiFi is used, set 1 to enable it\n", __func__); |
| 630 | return -1; |
| 631 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 632 | int ret = -1; |
| 633 | ret = sc_wifi_init(); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 634 | if (0 != ret) |
| 635 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 636 | LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret); |
| 637 | return ret; |
| 638 | } |
| 639 | |
| 640 | //wifi |
| 641 | ret = sc_wifi_set_enable_status_ind_cb(lynq_user_status); |
| 642 | if (0 != ret) |
| 643 | { |
| 644 | LYERRLOG("[%s ] Request lynq_user_status ret = %d fail\n", __func__,ret); |
| 645 | return ret; |
| 646 | } |
| 647 | |
| 648 | //ap |
| 649 | ret = sc_wifi_ap_set_status_ind_cb(lynq_user_ap_status); |
| 650 | if (0 != ret) |
| 651 | { |
| 652 | LYERRLOG("[%s ] Request lynq_user_ap_status ret = %d fail\n", __func__,ret); |
| 653 | return ret; |
| 654 | } |
| 655 | ret = sc_wifi_set_ap_sta_connect_ind_cb(lynq_user_ap_sta_conn_status); |
| 656 | if (0 != ret) |
| 657 | { |
| 658 | LYERRLOG("[%s ] Request lynq_user_ap_sta_conn_status ret = %d fail\n", __func__,ret); |
| 659 | return ret; |
| 660 | } |
| 661 | |
| 662 | //sta |
| 663 | ret = sc_wifi_sta_set_status_ind_cb(lynq_user_sta_status_ind); |
| 664 | if (0 != ret) |
| 665 | { |
| 666 | LYERRLOG("[%s ] Request lynq_user_sta_status_ind ret = %d fail\n", __func__,ret); |
| 667 | return ret; |
| 668 | } |
| 669 | ret = sc_wifi_sta_set_scan_result_ind_cb(lynq_user_sta_scan_result_ind); |
| 670 | if (0 != ret) |
| 671 | { |
| 672 | LYERRLOG("[%s ] Request lynq_user_sta_scan_result_ind ret = %d fail\n", __func__,ret); |
| 673 | return ret; |
| 674 | } |
| 675 | //proxy |
| 676 | ret = sc_wifi_set_service_error_cb(lynq_user_wifi_service_error); |
| 677 | if (0 != ret) |
| 678 | { |
| 679 | LYERRLOG("[%s ] Request lynq_user_wifi_service_error ret = %d fail\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 680 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 681 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 682 | |
| 683 | ret = sc_wifi_enable(); |
| 684 | if (0 != ret) |
| 685 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 686 | LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 687 | return ret; |
| 688 | } |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 689 | for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++) |
| 690 | { |
| 691 | if(wifi_enable_flag == WIFI_ENABLE_FLAG_DEFAULT) |
| 692 | sleep(1); |
| 693 | else |
| 694 | break; |
| 695 | } |
| 696 | switch (wifi_enable_flag) |
| 697 | { |
| 698 | case SC_WIFI_STATUS_DISABLED: |
| 699 | ret = 1; |
| 700 | break; |
| 701 | case SC_WIFI_STATUS_ENABLED: |
| 702 | ret = 0; |
| 703 | break; |
| 704 | case SC_WIFI_STATUS_INVALID_MAC: |
| 705 | ret = 7; |
| 706 | break; |
| 707 | case SC_WIFI_STATUS_DEV_INIT_FAIL: |
| 708 | ret = 6; |
| 709 | break; |
| 710 | case SC_WIFI_STATUS_FIRMWARE_CRASH: |
| 711 | ret = 12; |
| 712 | break; |
| 713 | default: |
| 714 | ret = -1; |
| 715 | break; |
| 716 | } |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 717 | LYINFLOG("[%s ] ret = %d\n", __func__,ret); |
| 718 | if(ret != 0) |
| 719 | { |
| 720 | int ret_uninit = sc_wifi_uninit(); |
| 721 | if (0 != ret_uninit) |
| 722 | { |
| 723 | LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret_uninit); |
| 724 | } |
| 725 | } |
| 726 | else |
| 727 | lynq_wifi_enable = true; |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 728 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | /******************************************************************** |
| 732 | * @brief: qser_wifi_disable, Turn off WiFi |
| 733 | * @return : int, If equal to 0 succeeds, others fail |
| 734 | * @todo: NA |
| 735 | * @see: NA |
| 736 | * @warning: NA |
| 737 | *********************************************************************/ |
| 738 | int qser_wifi_disable(void) |
| 739 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 740 | int ret = -1; |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 741 | wifi_enable_flag = WIFI_ENABLE_FLAG_DEFAULT; |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 742 | if(lynq_wifi_enable == false) |
| 743 | { |
| 744 | LYERRLOG("[%s ] WiFi not turned on\n", __func__); |
| 745 | return -1; |
| 746 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 747 | ret = sc_wifi_disable(); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 748 | if (0 != ret) |
| 749 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 750 | LYERRLOG("[%s ] disable ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 751 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 752 | } |
zw.wang | f4578ce | 2024-08-14 10:58:38 +0800 | [diff] [blame] | 753 | for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++) |
| 754 | { |
| 755 | if(wifi_enable_flag == WIFI_ENABLE_FLAG_DEFAULT) |
| 756 | sleep(1); |
| 757 | else |
| 758 | break; |
| 759 | } |
| 760 | switch (wifi_enable_flag) |
| 761 | { |
| 762 | case SC_WIFI_STATUS_DISABLED: |
| 763 | ret = 0; |
| 764 | break; |
| 765 | case SC_WIFI_STATUS_INVALID_MAC: |
| 766 | ret = 7; |
| 767 | break; |
| 768 | case SC_WIFI_STATUS_DEV_INIT_FAIL: |
| 769 | ret = 6; |
| 770 | break; |
| 771 | case SC_WIFI_STATUS_FIRMWARE_CRASH: |
| 772 | ret = 12; |
| 773 | break; |
| 774 | default: |
| 775 | ret = -1; |
| 776 | break; |
| 777 | } |
| 778 | if (0 != ret) |
| 779 | { |
| 780 | LYERRLOG("[%s ] disable ret = %d\n", __func__,ret); |
| 781 | return ret; |
| 782 | } |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 783 | lynq_wifi_enable = false; |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 784 | ret = sc_wifi_uninit(); |
| 785 | if (0 != ret) |
| 786 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 787 | LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 788 | return ret; |
| 789 | } |
| 790 | LYINFLOG("[%s ]\n", __func__); |
| 791 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | /******************************************************************** |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 795 | * @brief: qser_wifi_ap_get_status, Example Query ap working status |
| 796 | * @param type [OUT]: lynq_wifi_ap_status_t *, ap working status |
| 797 | * @return : int, If equal to 0 succeeds, others fail |
| 798 | * @todo: NA |
| 799 | * @see: NA |
| 800 | * @warning: NA |
| 801 | *********************************************************************/ |
| 802 | int qser_wifi_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat) |
| 803 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 804 | WIFI_ENABLE_JUDGE(); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 805 | int ret = -1; |
| 806 | sc_wifi_ap_status_t stat; |
| 807 | ret = sc_wifi_ap_get_status((sc_wifi_ap_index_e)idx, &stat); |
| 808 | if (0 != ret) |
| 809 | { |
| 810 | LYERRLOG("[%s ] wifi_ap_get ret = %d\n", __func__,ret); |
| 811 | return ret; |
| 812 | } |
| 813 | LYINFLOG("[%s ] idx = %d ifname = %s status = %d bssid = %s \n", __func__, idx, stat.ifname, stat.status, stat.bssid); |
| 814 | strncpy(ap_stat->ifname, stat.ifname, sizeof(stat.ifname) - 1); |
| 815 | ap_stat->status = (lynq_wifi_status_e)stat.status; |
| 816 | strncpy(ap_stat->bssid, stat.bssid, sizeof(stat.bssid) - 1); |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | /******************************************************************** |
| 821 | * @brief: qser_wifi_ap_acl_set, Set the WiFi2.4G or 5G whitelist |
| 822 | * @param idx [IN]: int, Set 2.4G or 5G |
| 823 | * @param acl_rule [IN]: lynq_wifi_mac_acl_rule_e, Set the blacklist and whitelist mode |
| 824 | * @param mac_list [IN]: char *, Set the mac address of the whitelist |
| 825 | * @return : int, If equal to 0 succeeds, others fail |
| 826 | * @todo: NA |
| 827 | * @see: NA |
| 828 | * @warning: NA |
| 829 | *********************************************************************/ |
| 830 | int qser_wifi_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list) |
| 831 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 832 | WIFI_ENABLE_JUDGE(); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 833 | int ret = -1; |
| 834 | if (mac_list == NULL) |
| 835 | { |
| 836 | LYERRLOG("[%s ] Null pointer mac_list = 0x%p \n", __func__, mac_list); |
| 837 | return ret; |
| 838 | } |
| 839 | if(acl_rule == LYNQ_WIFI_MAC_ACL_RULE_BLACK) |
| 840 | ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, SC_WIFI_MAC_ACL_RULE_WHITE, mac_list); |
| 841 | ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, (sc_wifi_mac_acl_rule_e)acl_rule, mac_list); |
| 842 | if (0 != ret) |
| 843 | { |
| 844 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 845 | return ret; |
| 846 | } |
| 847 | LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, acl_rule, mac_list); |
| 848 | return 0; |
| 849 | } |
| 850 | |
| 851 | /******************************************************************** |
| 852 | * @brief: qser_wifi_ap_acl_get, Get the WiFi2.4G or 5G whitelist |
| 853 | * @param idx [IN]: int, Set 2.4G or 5G |
| 854 | * @param acl_rule [OUT]: lynq_wifi_mac_acl_rule_e *, Get the blacklist and whitelist mode |
| 855 | * @param mac_list [OUT]: char *, Get the mac address of the whitelist |
| 856 | * @return : int, If equal to 0 succeeds, others fail |
| 857 | * @todo: NA |
| 858 | * @see: NA |
| 859 | * @warning: NA |
| 860 | *********************************************************************/ |
| 861 | int qser_wifi_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list) |
| 862 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 863 | WIFI_ENABLE_JUDGE(); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 864 | int ret = -1; |
| 865 | sc_wifi_ap_param_t param = {0}; |
| 866 | if (mac_list == NULL || acl_rule == NULL) |
| 867 | { |
| 868 | LYERRLOG("[%s ] Null pointer acl_rule = 0x%p mac_list = 0x%p \n", __func__, acl_rule, mac_list); |
| 869 | return ret; |
| 870 | } |
| 871 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 872 | if (0 != ret) |
| 873 | { |
| 874 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 875 | return ret; |
| 876 | } |
| 877 | *acl_rule = (lynq_wifi_mac_acl_rule_e)param.acl_rule; |
| 878 | strncpy(mac_list, param.mac_list, sizeof(param.mac_list) - 1); |
| 879 | LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, param.acl_rule, param.mac_list); |
| 880 | return 0; |
| 881 | } |
| 882 | |
| 883 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 884 | * @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of 2.4G or 5G |
| 885 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 886 | * @param ssid [IN]: const char *, Set the ssid name |
| 887 | * @return : int, If equal to 0 succeeds, others fail |
| 888 | * @todo: NA |
| 889 | * @see: NA |
| 890 | * @warning: NA |
| 891 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 892 | int qser_wifi_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 893 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 894 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 895 | int ret = -1; |
| 896 | if (ssid == NULL) |
| 897 | { |
| 898 | LYERRLOG("[%s ] Null pointer ssid = 0x%p \n", __func__, ssid); |
| 899 | return ret; |
| 900 | } |
| 901 | ret = sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid); |
| 902 | if (0 != ret) |
| 903 | { |
| 904 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 905 | return ret; |
| 906 | } |
| 907 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, ssid); |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 912 | * @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of 2.4G or 5G |
| 913 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 914 | * @param ssid [OUT]: char *, Get the ssid name |
| 915 | * @return : int, If equal to 0 succeeds, others fail |
| 916 | * @todo: NA |
| 917 | * @see: NA |
| 918 | * @warning: NA |
| 919 | *********************************************************************/ |
| 920 | int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid) |
| 921 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 922 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 923 | int ret = -1; |
| 924 | sc_wifi_ap_param_t param = {0}; |
| 925 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 926 | if (0 != ret) |
| 927 | { |
| 928 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 929 | return ret; |
| 930 | } |
| 931 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, param.ssid); |
| 932 | strncpy(ssid, param.ssid, sizeof(param.ssid) - 1); |
| 933 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 937 | * @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of 2.4G or 5G is hidden |
| 938 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 939 | * @param hide [IN]: bool, Set whether the ssid is hidden |
| 940 | * @return : int, If equal to 0 succeeds, others fail |
| 941 | * @todo: NA |
| 942 | * @see: NA |
| 943 | * @warning: NA |
| 944 | *********************************************************************/ |
| 945 | int qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide) |
| 946 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 947 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 948 | int ret = -1; |
| 949 | ret = sc_wifi_ap_ssid_hidden_set((sc_wifi_ap_index_e)idx, (int)hide); |
| 950 | if (0 != ret) |
| 951 | { |
| 952 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 953 | return ret; |
| 954 | } |
| 955 | LYINFLOG("[%s ] idx = %d hide = %d \n", __func__, idx, hide); |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 960 | * @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of 2.4G or 5G is hidden |
| 961 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 962 | * @param hide [OUT]: bool *, Get whether the ssid is hidden |
| 963 | * @return : int, If equal to 0 succeeds, others fail |
| 964 | * @todo: NA |
| 965 | * @see: NA |
| 966 | * @warning: NA |
| 967 | *********************************************************************/ |
| 968 | int qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide) |
| 969 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 970 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 971 | int ret = -1; |
| 972 | sc_wifi_ap_param_t param = {0}; |
| 973 | if (hide == NULL) |
| 974 | { |
| 975 | LYERRLOG("[%s ] Null pointer hide = 0x%p \n", __func__, hide); |
| 976 | return ret; |
| 977 | } |
| 978 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 979 | if (0 != ret) |
| 980 | { |
| 981 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 982 | return ret; |
| 983 | } |
| 984 | LYINFLOG("[%s ] idx = %d ssid_hide = %d \n", __func__, idx, param.ssid_hide); |
| 985 | *hide = (bool)param.ssid_hide; |
| 986 | return 0; |
| 987 | } |
| 988 | |
| 989 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 990 | * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of 2.4G or 5G |
| 991 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 992 | * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode |
| 993 | * @return : int, If equal to 0 succeeds, others fail |
| 994 | * @todo: NA |
| 995 | * @see: NA |
| 996 | * @warning: NA |
| 997 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 998 | int qser_wifi_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 999 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1000 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1001 | int ret = -1; |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1002 | ret = sc_wifi_ap_mode_set((sc_wifi_ap_index_e)idx, lynq_to_sc_mode(mode)); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1003 | if (0 != ret) |
| 1004 | { |
| 1005 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1006 | return ret; |
| 1007 | } |
| 1008 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, mode); |
| 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1013 | * @brief: qser_wifi_ap_mode_get, Get the working protocol mode of 2.4G or 5G |
| 1014 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1015 | * @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode |
| 1016 | * @return : int, If equal to 0 succeeds, others fail |
| 1017 | * @todo: NA |
| 1018 | * @see: NA |
| 1019 | * @warning: NA |
| 1020 | *********************************************************************/ |
| 1021 | int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode) |
| 1022 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1023 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1024 | int ret = -1; |
| 1025 | sc_wifi_ap_param_t param = {0}; |
| 1026 | if (mode == NULL) |
| 1027 | { |
| 1028 | LYERRLOG("[%s ] Null pointer mode = 0x%p \n", __func__, mode); |
| 1029 | return ret; |
| 1030 | } |
| 1031 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1032 | if (0 != ret) |
| 1033 | { |
| 1034 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1035 | return ret; |
| 1036 | } |
| 1037 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, param.mode); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1038 | *mode = sc_to_lynq_mode(param.mode); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1039 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1043 | * @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of 2.4G or 5G |
| 1044 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1045 | * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth |
| 1046 | * @return : int, If equal to 0 succeeds, others fail |
| 1047 | * @todo: NA |
| 1048 | * @see: NA |
| 1049 | * @warning: NA |
| 1050 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1051 | int qser_wifi_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1052 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1053 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1054 | int ret = -1; |
| 1055 | ret = sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth); |
| 1056 | if (0 != ret) |
| 1057 | { |
| 1058 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1059 | return ret; |
| 1060 | } |
| 1061 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, bandwidth); |
| 1062 | return 0; |
| 1063 | } |
| 1064 | |
| 1065 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1066 | * @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of 2.4G or 5G |
| 1067 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1068 | * @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth |
| 1069 | * @return : int, If equal to 0 succeeds, others fail |
| 1070 | * @todo: NA |
| 1071 | * @see: NA |
| 1072 | * @warning: NA |
| 1073 | *********************************************************************/ |
| 1074 | int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth) |
| 1075 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1076 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1077 | int ret = -1; |
| 1078 | sc_wifi_ap_param_t param = {0}; |
| 1079 | if (bandwidth == NULL) |
| 1080 | { |
| 1081 | LYERRLOG("[%s ] Null pointer bandwidth = 0x%p \n", __func__, bandwidth); |
| 1082 | return ret; |
| 1083 | } |
| 1084 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1085 | if (0 != ret) |
| 1086 | { |
| 1087 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1088 | return ret; |
| 1089 | } |
| 1090 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, param.bandwidth); |
| 1091 | *bandwidth = (lynq_wifi_bandwidth_type_e)param.bandwidth; |
| 1092 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1096 | * @brief: qser_wifi_ap_channel_set, Set the channel for 2.4G or 5G |
| 1097 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1098 | * @param country_code [IN]: const char *, Set country code |
| 1099 | * @param channel [IN]: int, Set the channel |
| 1100 | * @return : int, If equal to 0 succeeds, others fail |
| 1101 | * @todo: NA |
| 1102 | * @see: NA |
| 1103 | * @warning: NA |
| 1104 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1105 | int qser_wifi_ap_channel_set(lynq_wifi_ap_index_e idx, const char *country_code, int channel) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1106 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1107 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1108 | int ret = -1; |
| 1109 | if (country_code == NULL) |
| 1110 | { |
| 1111 | LYERRLOG("[%s ] Null pointer country_code = 0x%p \n", __func__, country_code); |
| 1112 | return ret; |
| 1113 | } |
| 1114 | ret = sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel); |
| 1115 | if (0 != ret) |
| 1116 | { |
| 1117 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1118 | return ret; |
| 1119 | } |
| 1120 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, country_code, channel); |
| 1121 | return 0; |
| 1122 | } |
| 1123 | |
| 1124 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1125 | * @brief: qser_wifi_ap_channel_get, Get the channel for 2.4G or 5G |
| 1126 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1127 | * @param country_code [OUT]: char *, Get country code |
| 1128 | * @param channel [OUT]: int *, Get the channel |
| 1129 | * @return : int, If equal to 0 succeeds, others fail |
| 1130 | * @todo: NA |
| 1131 | * @see: NA |
| 1132 | * @warning: NA |
| 1133 | *********************************************************************/ |
| 1134 | int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel) |
| 1135 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1136 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1137 | int ret = -1; |
| 1138 | sc_wifi_ap_param_t param = {0}; |
| 1139 | if (country_code == NULL || channel == NULL) |
| 1140 | { |
| 1141 | LYERRLOG("[%s ] Null pointer country_code = 0x%p channel = 0x%p\n", __func__, country_code, channel); |
| 1142 | return ret; |
| 1143 | } |
| 1144 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1145 | if (0 != ret) |
| 1146 | { |
| 1147 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1148 | return ret; |
| 1149 | } |
| 1150 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, param.countrycode, param.channel); |
| 1151 | strncpy(country_code, param.countrycode, sizeof(param.countrycode) - 1); |
| 1152 | *channel = param.channel; |
| 1153 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1157 | * @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of 2.4G or 5G |
| 1158 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1159 | * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode |
| 1160 | * @param auth_passwd [IN]: const char *, Set password |
| 1161 | * @return : int, If equal to 0 succeeds, others fail |
| 1162 | * @todo: NA |
| 1163 | * @see: NA |
| 1164 | * @warning: NA |
| 1165 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1166 | int qser_wifi_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1167 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1168 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1169 | int ret = -1; |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1170 | if (auth_passwd == NULL) |
| 1171 | { |
| 1172 | LYERRLOG("[%s ] Null pointer auth_passwd = 0x%p\n", __func__, auth_passwd); |
| 1173 | return ret; |
| 1174 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1175 | |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1176 | sc_wifi_ap_auth_t auth; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1177 | auth.auth = lynq_to_sc_auth_mode(auth_mode); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1178 | strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1179 | ret = sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth); |
| 1180 | if (0 != ret) |
| 1181 | { |
| 1182 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1183 | return ret; |
| 1184 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1185 | LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s\n", __func__, idx, auth_mode, "******"); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1186 | return 0; |
| 1187 | } |
| 1188 | |
| 1189 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1190 | * @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of 2.4G or 5G |
| 1191 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1192 | * @param auth_mode [OUT]: lynq_wifi_auth_e *, Get the security authentication mode |
| 1193 | * @param auth_passwd [OUT]: char *, Get password |
| 1194 | * @return : int, If equal to 0 succeeds, others fail |
| 1195 | * @todo: NA |
| 1196 | * @see: NA |
| 1197 | * @warning: NA |
| 1198 | *********************************************************************/ |
| 1199 | int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd) |
| 1200 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1201 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1202 | int ret = -1; |
| 1203 | sc_wifi_ap_param_t param = {0}; |
| 1204 | if (auth_mode == NULL || auth_passwd == NULL) |
| 1205 | { |
| 1206 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p auth_passwd = 0x%p\n", __func__, auth_mode, auth_passwd); |
| 1207 | return ret; |
| 1208 | } |
| 1209 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1210 | if (0 != ret) |
| 1211 | { |
| 1212 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1213 | return ret; |
| 1214 | } |
| 1215 | LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s \n", __func__, idx, param.auth.auth, param.auth.passwd); |
| 1216 | strncpy(auth_passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1217 | |
| 1218 | *auth_mode = sc_to_lynq_auth_mode(param.auth.auth); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1219 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | /******************************************************************** |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1223 | * @brief: qser_wifi_ap_auth_get_s, Get the security authentication mode , password group_rekey and pairwise of 2.4G or 5G |
| 1224 | * @param idx [IN]: int, Set 2.4G or 5G |
| 1225 | * @param auth_mode [OUT]: lynq_wifi_ap_auth_t *, Get the security authentication mode |
| 1226 | * @return : int, If equal to 0 succeeds, others fail |
| 1227 | * @todo: NA |
| 1228 | * @see: NA |
| 1229 | * @warning: NA |
| 1230 | *********************************************************************/ |
| 1231 | int qser_wifi_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode) |
| 1232 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1233 | WIFI_ENABLE_JUDGE(); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1234 | int ret = -1; |
| 1235 | sc_wifi_ap_param_t param = {0}; |
| 1236 | if (auth_mode == NULL) |
| 1237 | { |
| 1238 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p\n", __func__, auth_mode); |
| 1239 | return ret; |
| 1240 | } |
| 1241 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1242 | if (0 != ret) |
| 1243 | { |
| 1244 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1245 | return ret; |
| 1246 | } |
| 1247 | LYINFLOG("[%s ] idx = %d auth = %d passwd = %s group_rekey = %d pairwise = %d\n", __func__, idx, param.auth.auth, param.auth.passwd, param.auth.group_rekey, param.auth.pairwise); |
| 1248 | strncpy(auth_mode->passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
| 1249 | auth_mode->group_rekey = param.auth.group_rekey; |
| 1250 | auth_mode->pairwise = (lynq_wifi_auth_wpa_psk_e)param.auth.pairwise; |
| 1251 | auth_mode->auth = sc_to_lynq_auth_mode(param.auth.auth); |
| 1252 | return 0; |
| 1253 | } |
| 1254 | |
| 1255 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1256 | * @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for 2.4G or 5G |
| 1257 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1258 | * @param max_sta_num [IN]: int, Set the maximum number |
| 1259 | * @return : int, If equal to 0 succeeds, others fail |
| 1260 | * @todo: NA |
| 1261 | * @see: NA |
| 1262 | * @warning: NA |
| 1263 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1264 | int qser_wifi_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1265 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1266 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1267 | int ret = -1; |
zw.wang | 48647fb | 2024-10-11 10:47:36 +0800 | [diff] [blame] | 1268 | if(max_sta_num >= 32) |
| 1269 | { |
| 1270 | LYERRLOG("[%s ] fail max_sta_num = %d\n", __func__,max_sta_num); |
| 1271 | return -1; |
| 1272 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1273 | ret = sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num); |
| 1274 | if (0 != ret) |
| 1275 | { |
| 1276 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1277 | return ret; |
| 1278 | } |
| 1279 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, max_sta_num); |
| 1280 | return 0; |
| 1281 | } |
| 1282 | |
| 1283 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1284 | * @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for 2.4G or 5G |
| 1285 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1286 | * @param max_sta_num [OUT]: int *, Get the maximum number |
| 1287 | * @return : int, If equal to 0 succeeds, others fail |
| 1288 | * @todo: NA |
| 1289 | * @see: NA |
| 1290 | * @warning: NA |
| 1291 | *********************************************************************/ |
| 1292 | int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num) |
| 1293 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1294 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1295 | int ret = -1; |
| 1296 | sc_wifi_ap_param_t param = {0}; |
| 1297 | if (max_sta_num == NULL) |
| 1298 | { |
| 1299 | LYERRLOG("[%s ] Null pointer max_sta_num = 0x%p\n", __func__,max_sta_num); |
| 1300 | return ret; |
| 1301 | } |
| 1302 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1303 | if (0 != ret) |
| 1304 | { |
| 1305 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1306 | return ret; |
| 1307 | } |
| 1308 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, param.max_sta_num); |
| 1309 | *max_sta_num = param.max_sta_num; |
| 1310 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1311 | } |
| 1312 | |
| 1313 | /******************************************************************** |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1314 | * @brief: qser_wifi_lanhost_get_list, Get sta device information received as an ap for 2.4G or 5G |
| 1315 | * @param lynq_arrays [OUT]: lynq_lanhost_ts *, Get sta device information received as an ap |
| 1316 | * @return : int, If equal to 0 succeeds, others fail |
| 1317 | * @todo: NA |
| 1318 | * @see: NA |
| 1319 | * @warning: NA |
| 1320 | *********************************************************************/ |
| 1321 | int qser_wifi_lanhost_get_list(lynq_lanhost_ts *lynq_arrays) |
| 1322 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1323 | WIFI_ENABLE_JUDGE(); |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1324 | int ret = -1; |
| 1325 | int i = 0; |
| 1326 | sc_lanhost_t array[32] = {0}; |
| 1327 | if (lynq_arrays == NULL) |
| 1328 | { |
| 1329 | LYERRLOG("[%s ] Null pointer lynq_arrays = 0x%p\n", __func__, lynq_arrays); |
| 1330 | return ret; |
| 1331 | } |
| 1332 | lynq_arrays->array_len = 32; |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 1333 | ret = sc_wifi_lanhost_get_list(array, &lynq_arrays->array_len); |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1334 | if (0 != ret) |
| 1335 | { |
| 1336 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 1337 | return ret; |
| 1338 | } |
| 1339 | LYINFLOG("[%s]ap_lanhost len[%d]\n", __func__, lynq_arrays->array_len); |
| 1340 | for (i = 0; i < lynq_arrays->array_len; i++) |
| 1341 | { |
| 1342 | LYINFLOG("[%s]Element : [%d] ifname = %s macaddr = %s addr = %s name = %s uptime = %d\n", __func__, i, |
| 1343 | array[i].ifname, array[i].macaddr, array[i].addr, array[i].name, array[i].uptime); |
| 1344 | strncpy(lynq_arrays->array[i].ifname, array[i].ifname, sizeof(lynq_arrays->array[i].ifname) - 1); |
| 1345 | strncpy(lynq_arrays->array[i].macaddr, array[i].macaddr, sizeof(lynq_arrays->array[i].macaddr) - 1); |
| 1346 | strncpy(lynq_arrays->array[i].addr, array[i].addr, sizeof(lynq_arrays->array[i].addr) - 1); |
| 1347 | strncpy(lynq_arrays->array[i].name, array[i].name, sizeof(lynq_arrays->array[i].name) - 1); |
| 1348 | lynq_arrays->array[i].uptime = array[i].uptime; |
| 1349 | } |
| 1350 | return 0; |
| 1351 | } |
| 1352 | |
| 1353 | /******************************************************************** |
| 1354 | * @brief: qser_wifi_get_ap_pkt_stats, Obtain data packets sent and received by ap for 2.4G or 5G |
| 1355 | * @param idx [IN]: int, Set 2.4G or 5G |
| 1356 | * @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by ap |
| 1357 | * @return : int, If equal to 0 succeeds, others fail |
| 1358 | * @todo: NA |
| 1359 | * @see: NA |
| 1360 | * @warning: NA |
| 1361 | *********************************************************************/ |
| 1362 | int qser_wifi_get_ap_pkt_stats(lynq_wifi_ap_index_e idx, lynq_wifi_pkt_stats_t *pkt_stat) |
| 1363 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1364 | WIFI_ENABLE_JUDGE(); |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1365 | int ret = -1; |
| 1366 | sc_wifi_pkt_stats_t stat = {0}; |
| 1367 | if (pkt_stat == NULL) |
| 1368 | { |
| 1369 | LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat); |
| 1370 | return ret; |
| 1371 | } |
| 1372 | idx = LYNQ_WIFI_AP_INDEX_AP0; |
| 1373 | ret = sc_wifi_get_ap_pkt_stats((sc_wifi_ap_index_e)idx, &stat); |
| 1374 | if (0 != ret) |
| 1375 | { |
| 1376 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 1377 | return ret; |
| 1378 | } |
| 1379 | LYINFLOG("[%s ]ap_pkt_get[%d] rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__, idx, |
| 1380 | stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped, |
| 1381 | stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped); |
| 1382 | pkt_stat->rx_packets = stat.rx_packets; |
| 1383 | pkt_stat->rx_bytes = stat.rx_bytes; |
| 1384 | pkt_stat->rx_errors = stat.rx_errors; |
| 1385 | pkt_stat->rx_dropped = stat.rx_dropped; |
| 1386 | pkt_stat->tx_packets = stat.tx_packets; |
| 1387 | pkt_stat->tx_bytes = stat.tx_bytes; |
| 1388 | pkt_stat->tx_errors = stat.tx_errors; |
| 1389 | pkt_stat->tx_dropped = stat.tx_dropped; |
| 1390 | return 0; |
| 1391 | } |
| 1392 | |
| 1393 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1394 | * @brief: qser_wifi_ap_start, Set the ap mode of 2.4G or 5G to enable |
| 1395 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1396 | * @return : int, If equal to 0 succeeds, others fail |
| 1397 | * @todo: NA |
| 1398 | * @see: NA |
| 1399 | * @warning: NA |
| 1400 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1401 | int qser_wifi_ap_start(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1402 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1403 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1404 | int ret = -1; |
| 1405 | ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 1406 | if (0 != ret) |
| 1407 | { |
| 1408 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1409 | return ret; |
| 1410 | } |
| 1411 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 1412 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1416 | * @brief: qser_wifi_ap_stop, Disable ap mode for 2.4G or 5G |
| 1417 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1418 | * @return : int, If equal to 0 succeeds, others fail |
| 1419 | * @todo: NA |
| 1420 | * @see: NA |
| 1421 | * @warning: NA |
| 1422 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1423 | int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1424 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1425 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1426 | int ret = -1; |
| 1427 | ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| 1428 | if (0 != ret) |
| 1429 | { |
| 1430 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1431 | return ret; |
| 1432 | } |
| 1433 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 1434 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1438 | * @brief: qser_wifi_ap_restart, Set the ap mode of 2.4G or 5G to restart |
| 1439 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1440 | * @return : int, If equal to 0 succeeds, others fail |
| 1441 | * @todo: NA |
| 1442 | * @see: NA |
| 1443 | * @warning: NA |
| 1444 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1445 | int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1446 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1447 | WIFI_ENABLE_JUDGE(); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1448 | int ret = -1; |
| 1449 | ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1450 | if (0 != ret) |
| 1451 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1452 | LYERRLOG("[%s ] stop ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1453 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1454 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1455 | ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 1456 | if (0 != ret) |
| 1457 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1458 | LYERRLOG("[%s ] start ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1459 | return ret; |
| 1460 | } |
| 1461 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 1462 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1463 | } |
| 1464 | |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1465 | /******************************************************************** |
| 1466 | * @brief: qser_wifi_sta_param_set, Set the ssid and password that you need to connect to the access point |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1467 | * @param param_stat [IN]: sc_wifi_sta_param_t *, Set parameters such as ssid and password that you want to connect to the access point |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1468 | * @return : int, If equal to 0 succeeds, others fail |
| 1469 | * @todo: NA |
| 1470 | * @see: NA |
| 1471 | * @warning: NA |
| 1472 | *********************************************************************/ |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1473 | int qser_wifi_sta_param_set(lynq_wifi_sta_param_t *param_stat) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1474 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1475 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1476 | int ret = -1; |
| 1477 | sc_wifi_sta_param_t stat = {0}; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1478 | stat.auth = lynq_to_sc_auth_mode(param_stat->auth); |
| 1479 | stat.pairwise = (sc_wifi_auth_wpa_psk_e )param_stat->pairwise; |
| 1480 | strncpy(stat.ssid, param_stat->ssid, sizeof(stat.ssid) - 1); |
| 1481 | strncpy(stat.passwd, param_stat->passwd, sizeof(stat.passwd) - 1); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1482 | ret = sc_wifi_sta_param_set(&stat); |
| 1483 | if (0 != ret) |
| 1484 | { |
| 1485 | LYERRLOG("[%s ] sta_param_set ret = %d\n", __func__,ret); |
| 1486 | return ret; |
| 1487 | } |
| 1488 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1489 | return 0; |
| 1490 | } |
| 1491 | |
| 1492 | /******************************************************************** |
| 1493 | * @brief: qser_wifi_sta_param_get, Get the ssid and password that you need to connect to the access point |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1494 | * @param param_stat [OUT]: sc_wifi_sta_param_t *, Get parameters such as ssid and password that you want to connect to the access point |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1495 | * @return : int, If equal to 0 succeeds, others fail |
| 1496 | * @todo: NA |
| 1497 | * @see: NA |
| 1498 | * @warning: NA |
| 1499 | *********************************************************************/ |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1500 | int qser_wifi_sta_param_get(lynq_wifi_sta_param_t *param_stat) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1501 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1502 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1503 | int ret = -1; |
| 1504 | sc_wifi_sta_param_t stat = {0}; |
| 1505 | ret = sc_wifi_sta_param_get(&stat); |
| 1506 | if (0 != ret) |
| 1507 | { |
| 1508 | LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__,ret); |
| 1509 | return ret; |
| 1510 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1511 | param_stat->auth = sc_to_lynq_auth_mode(stat.auth); |
| 1512 | param_stat->pairwise = (lynq_wifi_auth_wpa_psk_e )stat.pairwise; |
| 1513 | strncpy(param_stat->ssid, stat.ssid, sizeof(stat.ssid) - 1); |
| 1514 | strncpy(param_stat->passwd, stat.passwd, sizeof(stat.passwd) -1); |
| 1515 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1516 | return 0; |
| 1517 | } |
| 1518 | |
| 1519 | /******************************************************************** |
| 1520 | * @brief: qser_wifi_sta_get_status, Gets the status value associated with sta |
| 1521 | * @param status_stat [OUT]: lynq_wifi_sta_status_t *, Gets the status value associated with sta |
| 1522 | * @return : int, If equal to 0 succeeds, others fail |
| 1523 | * @todo: NA |
| 1524 | * @see: NA |
| 1525 | * @warning: NA |
| 1526 | *********************************************************************/ |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1527 | int qser_wifi_sta_get_status(lynq_wifi_sta_status_t *status_stat) |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1528 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1529 | WIFI_ENABLE_JUDGE(); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1530 | int ret = -1; |
| 1531 | sc_wifi_sta_status_t stat; |
| 1532 | ret = sc_wifi_sta_get_status(&stat); |
| 1533 | if (0 != ret) |
| 1534 | { |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1535 | LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__, ret); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1536 | return ret; |
| 1537 | } |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1538 | print_sta_status(&stat); |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame] | 1539 | sc_to_lynq_sta_status(&stat, status_stat); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1540 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1541 | return 0; |
| 1542 | } |
| 1543 | |
| 1544 | /******************************************************************** |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1545 | * @brief: qser_wifi_get_sta_pkt_stats, Obtain data packets sent and received by sta for 2.4G or 5G |
| 1546 | * @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by sta |
| 1547 | * @return : int, If equal to 0 succeeds, others fail |
| 1548 | * @todo: NA |
| 1549 | * @see: NA |
| 1550 | * @warning: NA |
| 1551 | *********************************************************************/ |
| 1552 | int qser_wifi_get_sta_pkt_stats(lynq_wifi_pkt_stats_t *pkt_stat) |
| 1553 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1554 | WIFI_ENABLE_JUDGE(); |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1555 | int ret = -1; |
| 1556 | sc_wifi_pkt_stats_t stat = {0}; |
| 1557 | if (pkt_stat == NULL) |
| 1558 | { |
| 1559 | LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat); |
| 1560 | return ret; |
| 1561 | } |
| 1562 | ret = sc_wifi_get_sta_pkt_stats(&stat); |
| 1563 | if (0 != ret) |
| 1564 | { |
| 1565 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 1566 | return ret; |
| 1567 | } |
| 1568 | LYINFLOG("[%s ]sta_pkt_get rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__, |
| 1569 | stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped, |
| 1570 | stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped); |
| 1571 | pkt_stat->rx_packets = stat.rx_packets; |
| 1572 | pkt_stat->rx_bytes = stat.rx_bytes; |
| 1573 | pkt_stat->rx_errors = stat.rx_errors; |
| 1574 | pkt_stat->rx_dropped = stat.rx_dropped; |
| 1575 | pkt_stat->tx_packets = stat.tx_packets; |
| 1576 | pkt_stat->tx_bytes = stat.tx_bytes; |
| 1577 | pkt_stat->tx_errors = stat.tx_errors; |
| 1578 | pkt_stat->tx_dropped = stat.tx_dropped; |
| 1579 | return 0; |
| 1580 | } |
| 1581 | |
| 1582 | /******************************************************************** |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1583 | * @brief: qser_wifi_sta_start_scan, Scan for ap nodes and return them through callback |
| 1584 | * @return : int, If equal to 0 succeeds, others fail |
| 1585 | * @todo: NA |
| 1586 | * @see: NA |
| 1587 | * @warning: NA |
| 1588 | *********************************************************************/ |
| 1589 | int qser_wifi_sta_start_scan(void) |
| 1590 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1591 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1592 | int ret = -1; |
| 1593 | ret = sc_wifi_sta_start_scan(); |
| 1594 | if (0 != ret) |
| 1595 | { |
| 1596 | LYERRLOG("[%s ] scan ret = %d\n", __func__,ret); |
| 1597 | return ret; |
| 1598 | } |
| 1599 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1600 | return 0; |
| 1601 | } |
| 1602 | |
| 1603 | /******************************************************************** |
| 1604 | * @brief: qser_wifi_sta_start, To enable sta mode, you need to enable ap mode first |
| 1605 | * @return : int, If equal to 0 succeeds, others fail |
| 1606 | * @todo: NA |
| 1607 | * @see: NA |
| 1608 | * @warning: NA |
| 1609 | *********************************************************************/ |
| 1610 | int qser_wifi_sta_start(void) |
| 1611 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1612 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1613 | int ret = -1; |
| 1614 | ret = sc_wifi_sta_start(); |
| 1615 | if (0 != ret) |
| 1616 | { |
| 1617 | LYERRLOG("[%s ] sta_start ret = %d\n", __func__,ret); |
| 1618 | return ret; |
| 1619 | } |
| 1620 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1621 | return 0; |
| 1622 | } |
| 1623 | |
| 1624 | /******************************************************************** |
| 1625 | * @brief: qser_wifi_sta_stop, To disable sta mode. |
| 1626 | * @return : int, If equal to 0 succeeds, others fail |
| 1627 | * @todo: NA |
| 1628 | * @see: NA |
| 1629 | * @warning: NA |
| 1630 | *********************************************************************/ |
| 1631 | int qser_wifi_sta_stop(void) |
| 1632 | { |
zw.wang | b8e9b0c | 2024-09-05 13:53:33 +0800 | [diff] [blame] | 1633 | WIFI_ENABLE_JUDGE(); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1634 | int ret = -1; |
| 1635 | ret = sc_wifi_sta_stop(); |
| 1636 | if (0 != ret) |
| 1637 | { |
| 1638 | LYERRLOG("[%s ] sta_stop ret = %d\n", __func__,ret); |
| 1639 | return ret; |
| 1640 | } |
| 1641 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1642 | return 0; |
| 1643 | } |
| 1644 | |
you.chen | 154c191 | 2025-06-25 17:12:30 +0800 | [diff] [blame] | 1645 | |
| 1646 | //wifi2 |
| 1647 | |
| 1648 | /******************************************************************** |
| 1649 | * @brief: qser_wifi_work_mode_set, 2.4g or 5g working mode Settings |
| 1650 | * @param type [IN]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Settings |
| 1651 | * @return : int, If equal to 0 succeeds, others fail |
| 1652 | * @todo: NA |
| 1653 | * @see: NA |
| 1654 | * @warning: NA |
| 1655 | *********************************************************************/ |
| 1656 | int qser_wifi2_work_mode_set(lynq_wifi_work_mode_e type) |
| 1657 | { |
| 1658 | WIFI2_ENABLE_JUDGE(); |
| 1659 | int ret = -1; |
| 1660 | sc_wifi_work_mode_e mode; |
| 1661 | ret = sc_wifi_work_mode_get_ext(1, &mode); |
| 1662 | if (0 != ret) |
| 1663 | { |
| 1664 | LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret); |
| 1665 | return ret; |
| 1666 | } |
| 1667 | if(mode == (sc_wifi_work_mode_e)type) //The same value is returned |
| 1668 | { |
| 1669 | return 0; |
| 1670 | } |
| 1671 | ret = sc_wifi_work_mode_set_ext(1, (sc_wifi_work_mode_e)type); |
| 1672 | if (0 != ret) |
| 1673 | { |
| 1674 | LYERRLOG("[%s ] work_mode set ret = %d\n", __func__,ret); |
| 1675 | return ret; |
| 1676 | } |
| 1677 | LYINFLOG("[%s ]\n", __func__); |
| 1678 | return 0; |
| 1679 | } |
| 1680 | |
| 1681 | /******************************************************************** |
| 1682 | * @brief: qser_wifi_work_mode_get, 2.4g or 5g working mode Gettings |
| 1683 | * @param type [OUT]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Gettings |
| 1684 | * @return : int, If equal to 0 succeeds, others fail |
| 1685 | * @todo: NA |
| 1686 | * @see: NA |
| 1687 | * @warning: NA |
| 1688 | *********************************************************************/ |
| 1689 | int qser_wifi2_work_mode_get(lynq_wifi_work_mode_e *type) |
| 1690 | { |
| 1691 | WIFI2_ENABLE_JUDGE(); |
| 1692 | int ret = -1; |
| 1693 | sc_wifi_work_mode_e mode; |
| 1694 | ret = sc_wifi_work_mode_get_ext(1, &mode); |
| 1695 | if (0 != ret) |
| 1696 | { |
| 1697 | LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret); |
| 1698 | return ret; |
| 1699 | } |
| 1700 | *type = (lynq_wifi_work_mode_e)mode; |
| 1701 | LYINFLOG("[%s ]\n", __func__); |
| 1702 | return 0; |
| 1703 | } |
| 1704 | |
| 1705 | /******************************************************************** |
| 1706 | * @brief: qser_wifi_register_handle, Register callback functions |
| 1707 | * @param event_handle [IN]: lynq_wifi_event_handle, Register the ap event callback function |
| 1708 | * @param event_handle_sta [IN]: Register sta's event callback function |
| 1709 | * @param arg [IN]: void *, Not currently used, but cannot pass a null pointer |
| 1710 | * @return :int, If equal to 0 succeeds, others fail |
| 1711 | * @todo: NA |
| 1712 | * @see: NA |
| 1713 | * @warning: NA |
| 1714 | *********************************************************************/ |
| 1715 | int qser_wifi2_register_handle(lynq_wifi_event_handle event_handle, lynq_wifi_event_handle_sta event_handle_sta, void *arg) |
| 1716 | { |
| 1717 | if((event_handle == NULL && event_handle_sta == NULL) || arg == NULL) |
| 1718 | { |
| 1719 | LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg); |
| 1720 | return -1; |
| 1721 | } |
| 1722 | if(*(int *)arg <= LYNQ_WIFI_EVENT_MIN || *(int *)arg >= LYNQ_WIFI_EVENT_MAX) |
| 1723 | { |
| 1724 | LYERRLOG("[%s ] The value of arg can only be an integer ranging from 0 to 3p, arg = %d\n", __func__, arg); |
| 1725 | return -1; |
| 1726 | } |
| 1727 | wifi2_event_handle_sta = event_handle_sta; |
| 1728 | wifi2_event_handle = event_handle; |
| 1729 | global_arg_2 = arg; |
| 1730 | return 0; |
| 1731 | } |
| 1732 | |
| 1733 | /******************************************************************** |
| 1734 | * @brief: qser_wifi_enable, Enable WiFi function |
| 1735 | * @return : int, If equal to 0 succeeds, others fail |
| 1736 | * @todo: NA |
| 1737 | * @see: NA |
| 1738 | * @warning: NA |
| 1739 | *********************************************************************/ |
| 1740 | int qser_wifi2_enable(void) |
| 1741 | { |
| 1742 | if(lynq_wifi2_enable) |
| 1743 | { |
| 1744 | LYERRLOG("[%s ] The wifi is enabled\n", __func__); |
| 1745 | return -1; |
| 1746 | } |
| 1747 | wifi2_enable_flag = WIFI_ENABLE_FLAG_DEFAULT; |
| 1748 | char wifiAvailable[8] = {0}; |
| 1749 | sc_cfg_get("wifiAvailable", wifiAvailable, sizeof(wifiAvailable)); |
| 1750 | if (!strcmp(wifiAvailable, "0")) |
| 1751 | { |
| 1752 | LYERRLOG("[%s ] wifiAvailable has been set to 0. If WiFi is used, set 1 to enable it\n", __func__); |
| 1753 | return -1; |
| 1754 | } |
| 1755 | int ret = -1; |
| 1756 | ret = sc_wifi_init(); |
| 1757 | if (0 != ret) |
| 1758 | { |
| 1759 | LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret); |
| 1760 | return ret; |
| 1761 | } |
| 1762 | //wifi |
| 1763 | ret = sc_wifi_set_enable_status_ind_cb_ext(1, lynq_user2_status); |
| 1764 | if (0 != ret) |
| 1765 | { |
| 1766 | LYERRLOG("[%s ] Request lynq_user_status ret = %d fail\n", __func__,ret); |
| 1767 | return ret; |
| 1768 | } |
| 1769 | |
| 1770 | //ap |
| 1771 | ret = sc_wifi_ap_set_status_ind_cb_ext(1, lynq_user2_ap_status); |
| 1772 | if (0 != ret) |
| 1773 | { |
| 1774 | LYERRLOG("[%s ] Request lynq_user_ap_status ret = %d fail\n", __func__,ret); |
| 1775 | return ret; |
| 1776 | } |
| 1777 | ret = sc_wifi_set_ap_sta_connect_ind_cb_ext(1, lynq_user2_ap_sta_conn_status); |
| 1778 | if (0 != ret) |
| 1779 | { |
| 1780 | LYERRLOG("[%s ] Request lynq_user_ap_sta_conn_status ret = %d fail\n", __func__,ret); |
| 1781 | return ret; |
| 1782 | } |
| 1783 | |
| 1784 | //sta |
| 1785 | ret = sc_wifi_sta_set_status_ind_cb_ext(1, lynq_user2_sta_status_ind); |
| 1786 | if (0 != ret) |
| 1787 | { |
| 1788 | LYERRLOG("[%s ] Request lynq_user_sta_status_ind ret = %d fail\n", __func__,ret); |
| 1789 | return ret; |
| 1790 | } |
| 1791 | ret = sc_wifi_sta_set_scan_result_ind_cb_ext(1, lynq_user2_sta_scan_result_ind); |
| 1792 | if (0 != ret) |
| 1793 | { |
| 1794 | LYERRLOG("[%s ] Request lynq_user_sta_scan_result_ind ret = %d fail\n", __func__,ret); |
| 1795 | return ret; |
| 1796 | } |
| 1797 | //proxy |
| 1798 | ret = sc_wifi_set_service_error_cb(lynq_user2_wifi_service_error); |
| 1799 | if (0 != ret) |
| 1800 | { |
| 1801 | LYERRLOG("[%s ] Request lynq_user_wifi_service_error ret = %d fail\n", __func__,ret); |
| 1802 | return ret; |
| 1803 | } |
| 1804 | |
| 1805 | ret = sc_wifi_enable_ext(1); |
| 1806 | if (0 != ret) |
| 1807 | { |
| 1808 | LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret); |
| 1809 | return ret; |
| 1810 | } |
| 1811 | for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++) |
| 1812 | { |
| 1813 | if(wifi2_enable_flag == WIFI_ENABLE_FLAG_DEFAULT) |
| 1814 | sleep(1); |
| 1815 | else |
| 1816 | break; |
| 1817 | } |
| 1818 | switch (wifi2_enable_flag) |
| 1819 | { |
| 1820 | case SC_WIFI_STATUS_DISABLED: |
| 1821 | ret = 1; |
| 1822 | break; |
| 1823 | case SC_WIFI_STATUS_ENABLED: |
| 1824 | ret = 0; |
| 1825 | break; |
| 1826 | case SC_WIFI_STATUS_INVALID_MAC: |
| 1827 | ret = 7; |
| 1828 | break; |
| 1829 | case SC_WIFI_STATUS_DEV_INIT_FAIL: |
| 1830 | ret = 6; |
| 1831 | break; |
| 1832 | case SC_WIFI_STATUS_FIRMWARE_CRASH: |
| 1833 | ret = 12; |
| 1834 | break; |
| 1835 | default: |
| 1836 | ret = -1; |
| 1837 | break; |
| 1838 | } |
| 1839 | LYINFLOG("[%s ] ret = %d\n", __func__,ret); |
| 1840 | if(ret == 0) |
| 1841 | lynq_wifi2_enable = true; |
| 1842 | return ret; |
| 1843 | } |
| 1844 | |
| 1845 | /******************************************************************** |
| 1846 | * @brief: qser_wifi_disable, Turn off WiFi |
| 1847 | * @return : int, If equal to 0 succeeds, others fail |
| 1848 | * @todo: NA |
| 1849 | * @see: NA |
| 1850 | * @warning: NA |
| 1851 | *********************************************************************/ |
| 1852 | int qser_wifi2_disable(void) |
| 1853 | { |
| 1854 | int ret = -1; |
| 1855 | wifi2_enable_flag = WIFI_ENABLE_FLAG_DEFAULT; |
| 1856 | if(lynq_wifi2_enable == false) |
| 1857 | { |
| 1858 | LYERRLOG("[%s ] WiFi not turned on\n", __func__); |
| 1859 | return -1; |
| 1860 | } |
| 1861 | ret = sc_wifi_disable_ext(1); |
| 1862 | if (0 != ret) |
| 1863 | { |
| 1864 | LYERRLOG("[%s ] disable ret = %d\n", __func__,ret); |
| 1865 | return ret; |
| 1866 | } |
| 1867 | for(int i = 0; i < WIFI_ENABLE_FLAG_TIME_OUT; i++) |
| 1868 | { |
| 1869 | if(wifi2_enable_flag == WIFI_ENABLE_FLAG_DEFAULT) |
| 1870 | sleep(1); |
| 1871 | else |
| 1872 | break; |
| 1873 | } |
| 1874 | switch (wifi2_enable_flag) |
| 1875 | { |
| 1876 | case SC_WIFI_STATUS_DISABLED: |
| 1877 | ret = 0; |
| 1878 | break; |
| 1879 | case SC_WIFI_STATUS_INVALID_MAC: |
| 1880 | ret = 7; |
| 1881 | break; |
| 1882 | case SC_WIFI_STATUS_DEV_INIT_FAIL: |
| 1883 | ret = 6; |
| 1884 | break; |
| 1885 | case SC_WIFI_STATUS_FIRMWARE_CRASH: |
| 1886 | ret = 12; |
| 1887 | break; |
| 1888 | default: |
| 1889 | ret = -1; |
| 1890 | break; |
| 1891 | } |
| 1892 | if (0 != ret) |
| 1893 | { |
| 1894 | LYERRLOG("[%s ] disable ret = %d\n", __func__,ret); |
| 1895 | return ret; |
| 1896 | } |
| 1897 | lynq_wifi2_enable = false; |
| 1898 | ret = sc_wifi_uninit(); |
| 1899 | if (0 != ret) |
| 1900 | { |
| 1901 | LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret); |
| 1902 | return ret; |
| 1903 | } |
| 1904 | LYINFLOG("[%s ]\n", __func__); |
| 1905 | return 0; |
| 1906 | } |
| 1907 | |
| 1908 | /******************************************************************** |
| 1909 | * @brief: qser_wifi_ap_get_status, Example Query ap working status |
| 1910 | * @param type [OUT]: lynq_wifi_ap_status_t *, ap working status |
| 1911 | * @return : int, If equal to 0 succeeds, others fail |
| 1912 | * @todo: NA |
| 1913 | * @see: NA |
| 1914 | * @warning: NA |
| 1915 | *********************************************************************/ |
| 1916 | int qser_wifi2_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat) |
| 1917 | { |
| 1918 | WIFI2_ENABLE_JUDGE(); |
| 1919 | int ret = -1; |
| 1920 | sc_wifi_ap_status_t stat; |
| 1921 | ret = sc_wifi_ap_get_status_ext(1, (sc_wifi_ap_index_e)idx, &stat); |
| 1922 | if (0 != ret) |
| 1923 | { |
| 1924 | LYERRLOG("[%s ] wifi_ap_get ret = %d\n", __func__,ret); |
| 1925 | return ret; |
| 1926 | } |
| 1927 | LYINFLOG("[%s ] idx = %d ifname = %s status = %d bssid = %s \n", __func__, idx, stat.ifname, stat.status, stat.bssid); |
| 1928 | strncpy(ap_stat->ifname, stat.ifname, sizeof(stat.ifname) - 1); |
| 1929 | ap_stat->status = (lynq_wifi_status_e)stat.status; |
| 1930 | strncpy(ap_stat->bssid, stat.bssid, sizeof(stat.bssid) - 1); |
| 1931 | return 0; |
| 1932 | } |
| 1933 | |
| 1934 | /******************************************************************** |
| 1935 | * @brief: qser_wifi_ap_acl_set, Set the WiFi2.4G or 5G whitelist |
| 1936 | * @param idx [IN]: int, Set 2.4G or 5G |
| 1937 | * @param acl_rule [IN]: lynq_wifi_mac_acl_rule_e, Set the blacklist and whitelist mode |
| 1938 | * @param mac_list [IN]: char *, Set the mac address of the whitelist |
| 1939 | * @return : int, If equal to 0 succeeds, others fail |
| 1940 | * @todo: NA |
| 1941 | * @see: NA |
| 1942 | * @warning: NA |
| 1943 | *********************************************************************/ |
| 1944 | int qser_wifi2_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list) |
| 1945 | { |
| 1946 | WIFI2_ENABLE_JUDGE(); |
| 1947 | int ret = -1; |
| 1948 | if (mac_list == NULL) |
| 1949 | { |
| 1950 | LYERRLOG("[%s ] Null pointer mac_list = 0x%p \n", __func__, mac_list); |
| 1951 | return ret; |
| 1952 | } |
| 1953 | if(acl_rule == LYNQ_WIFI_MAC_ACL_RULE_BLACK) |
| 1954 | ret = sc_wifi_ap_acl_set_ext(1, (sc_wifi_ap_index_e)idx, SC_WIFI_MAC_ACL_RULE_WHITE, mac_list); |
| 1955 | ret = sc_wifi_ap_acl_set_ext(1, (sc_wifi_ap_index_e)idx, (sc_wifi_mac_acl_rule_e)acl_rule, mac_list); |
| 1956 | if (0 != ret) |
| 1957 | { |
| 1958 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1959 | return ret; |
| 1960 | } |
| 1961 | LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, acl_rule, mac_list); |
| 1962 | return 0; |
| 1963 | } |
| 1964 | |
| 1965 | /******************************************************************** |
| 1966 | * @brief: qser_wifi_ap_acl_get, Get the WiFi2.4G or 5G whitelist |
| 1967 | * @param idx [IN]: int, Set 2.4G or 5G |
| 1968 | * @param acl_rule [OUT]: lynq_wifi_mac_acl_rule_e *, Get the blacklist and whitelist mode |
| 1969 | * @param mac_list [OUT]: char *, Get the mac address of the whitelist |
| 1970 | * @return : int, If equal to 0 succeeds, others fail |
| 1971 | * @todo: NA |
| 1972 | * @see: NA |
| 1973 | * @warning: NA |
| 1974 | *********************************************************************/ |
| 1975 | int qser_wifi2_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list) |
| 1976 | { |
| 1977 | WIFI2_ENABLE_JUDGE(); |
| 1978 | int ret = -1; |
| 1979 | sc_wifi_ap_param_t param = {0}; |
| 1980 | if (mac_list == NULL || acl_rule == NULL) |
| 1981 | { |
| 1982 | LYERRLOG("[%s ] Null pointer acl_rule = 0x%p mac_list = 0x%p \n", __func__, acl_rule, mac_list); |
| 1983 | return ret; |
| 1984 | } |
| 1985 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 1986 | if (0 != ret) |
| 1987 | { |
| 1988 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1989 | return ret; |
| 1990 | } |
| 1991 | *acl_rule = (lynq_wifi_mac_acl_rule_e)param.acl_rule; |
| 1992 | strncpy(mac_list, param.mac_list, sizeof(param.mac_list) - 1); |
| 1993 | LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, param.acl_rule, param.mac_list); |
| 1994 | return 0; |
| 1995 | } |
| 1996 | |
| 1997 | /******************************************************************** |
| 1998 | * @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of 2.4G or 5G |
| 1999 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2000 | * @param ssid [IN]: const char *, Set the ssid name |
| 2001 | * @return : int, If equal to 0 succeeds, others fail |
| 2002 | * @todo: NA |
| 2003 | * @see: NA |
| 2004 | * @warning: NA |
| 2005 | *********************************************************************/ |
| 2006 | int qser_wifi2_ap_ssid_set(lynq_wifi_ap_index_e idx, const char *ssid) |
| 2007 | { |
| 2008 | WIFI2_ENABLE_JUDGE(); |
| 2009 | int ret = -1; |
| 2010 | if (ssid == NULL) |
| 2011 | { |
| 2012 | LYERRLOG("[%s ] Null pointer ssid = 0x%p \n", __func__, ssid); |
| 2013 | return ret; |
| 2014 | } |
| 2015 | ret = sc_wifi_ap_ssid_set_ext(1, (sc_wifi_ap_index_e)idx, ssid); |
| 2016 | if (0 != ret) |
| 2017 | { |
| 2018 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2019 | return ret; |
| 2020 | } |
| 2021 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, ssid); |
| 2022 | return 0; |
| 2023 | } |
| 2024 | |
| 2025 | /******************************************************************** |
| 2026 | * @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of 2.4G or 5G |
| 2027 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2028 | * @param ssid [OUT]: char *, Get the ssid name |
| 2029 | * @return : int, If equal to 0 succeeds, others fail |
| 2030 | * @todo: NA |
| 2031 | * @see: NA |
| 2032 | * @warning: NA |
| 2033 | *********************************************************************/ |
| 2034 | int qser_wifi2_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid) |
| 2035 | { |
| 2036 | WIFI2_ENABLE_JUDGE(); |
| 2037 | int ret = -1; |
| 2038 | sc_wifi_ap_param_t param = {0}; |
| 2039 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2040 | if (0 != ret) |
| 2041 | { |
| 2042 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2043 | return ret; |
| 2044 | } |
| 2045 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, param.ssid); |
| 2046 | strncpy(ssid, param.ssid, sizeof(param.ssid) - 1); |
| 2047 | return 0; |
| 2048 | } |
| 2049 | |
| 2050 | /******************************************************************** |
| 2051 | * @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of 2.4G or 5G is hidden |
| 2052 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2053 | * @param hide [IN]: bool, Set whether the ssid is hidden |
| 2054 | * @return : int, If equal to 0 succeeds, others fail |
| 2055 | * @todo: NA |
| 2056 | * @see: NA |
| 2057 | * @warning: NA |
| 2058 | *********************************************************************/ |
| 2059 | int qser_wifi2_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide) |
| 2060 | { |
| 2061 | WIFI2_ENABLE_JUDGE(); |
| 2062 | int ret = -1; |
| 2063 | ret = sc_wifi_ap_ssid_hidden_set_ext(1, (sc_wifi_ap_index_e)idx, (int)hide); |
| 2064 | if (0 != ret) |
| 2065 | { |
| 2066 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2067 | return ret; |
| 2068 | } |
| 2069 | LYINFLOG("[%s ] idx = %d hide = %d \n", __func__, idx, hide); |
| 2070 | return 0; |
| 2071 | } |
| 2072 | |
| 2073 | /******************************************************************** |
| 2074 | * @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of 2.4G or 5G is hidden |
| 2075 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2076 | * @param hide [OUT]: bool *, Get whether the ssid is hidden |
| 2077 | * @return : int, If equal to 0 succeeds, others fail |
| 2078 | * @todo: NA |
| 2079 | * @see: NA |
| 2080 | * @warning: NA |
| 2081 | *********************************************************************/ |
| 2082 | int qser_wifi2_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide) |
| 2083 | { |
| 2084 | WIFI2_ENABLE_JUDGE(); |
| 2085 | int ret = -1; |
| 2086 | sc_wifi_ap_param_t param = {0}; |
| 2087 | if (hide == NULL) |
| 2088 | { |
| 2089 | LYERRLOG("[%s ] Null pointer hide = 0x%p \n", __func__, hide); |
| 2090 | return ret; |
| 2091 | } |
| 2092 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2093 | if (0 != ret) |
| 2094 | { |
| 2095 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2096 | return ret; |
| 2097 | } |
| 2098 | LYINFLOG("[%s ] idx = %d ssid_hide = %d \n", __func__, idx, param.ssid_hide); |
| 2099 | *hide = (bool)param.ssid_hide; |
| 2100 | return 0; |
| 2101 | } |
| 2102 | |
| 2103 | /******************************************************************** |
| 2104 | * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of 2.4G or 5G |
| 2105 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2106 | * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode |
| 2107 | * @return : int, If equal to 0 succeeds, others fail |
| 2108 | * @todo: NA |
| 2109 | * @see: NA |
| 2110 | * @warning: NA |
| 2111 | *********************************************************************/ |
| 2112 | int qser_wifi2_ap_mode_set(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e mode) |
| 2113 | { |
| 2114 | WIFI2_ENABLE_JUDGE(); |
| 2115 | int ret = -1; |
| 2116 | ret = sc_wifi_ap_mode_set_ext(1, (sc_wifi_ap_index_e)idx, lynq_to_sc_mode(mode)); |
| 2117 | if (0 != ret) |
| 2118 | { |
| 2119 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2120 | return ret; |
| 2121 | } |
| 2122 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, mode); |
| 2123 | return 0; |
| 2124 | } |
| 2125 | |
| 2126 | /******************************************************************** |
| 2127 | * @brief: qser_wifi_ap_mode_get, Get the working protocol mode of 2.4G or 5G |
| 2128 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2129 | * @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode |
| 2130 | * @return : int, If equal to 0 succeeds, others fail |
| 2131 | * @todo: NA |
| 2132 | * @see: NA |
| 2133 | * @warning: NA |
| 2134 | *********************************************************************/ |
| 2135 | int qser_wifi2_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode) |
| 2136 | { |
| 2137 | WIFI2_ENABLE_JUDGE(); |
| 2138 | int ret = -1; |
| 2139 | sc_wifi_ap_param_t param = {0}; |
| 2140 | if (mode == NULL) |
| 2141 | { |
| 2142 | LYERRLOG("[%s ] Null pointer mode = 0x%p \n", __func__, mode); |
| 2143 | return ret; |
| 2144 | } |
| 2145 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2146 | if (0 != ret) |
| 2147 | { |
| 2148 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2149 | return ret; |
| 2150 | } |
| 2151 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, param.mode); |
| 2152 | *mode = sc_to_lynq_mode(param.mode); |
| 2153 | return 0; |
| 2154 | } |
| 2155 | |
| 2156 | /******************************************************************** |
| 2157 | * @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of 2.4G or 5G |
| 2158 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2159 | * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth |
| 2160 | * @return : int, If equal to 0 succeeds, others fail |
| 2161 | * @todo: NA |
| 2162 | * @see: NA |
| 2163 | * @warning: NA |
| 2164 | *********************************************************************/ |
| 2165 | int qser_wifi2_ap_bandwidth_set(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e bandwidth) |
| 2166 | { |
| 2167 | WIFI2_ENABLE_JUDGE(); |
| 2168 | int ret = -1; |
| 2169 | ret = sc_wifi_ap_bandwidth_set_ext(1, (sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth); |
| 2170 | if (0 != ret) |
| 2171 | { |
| 2172 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2173 | return ret; |
| 2174 | } |
| 2175 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, bandwidth); |
| 2176 | return 0; |
| 2177 | } |
| 2178 | |
| 2179 | /******************************************************************** |
| 2180 | * @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of 2.4G or 5G |
| 2181 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2182 | * @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth |
| 2183 | * @return : int, If equal to 0 succeeds, others fail |
| 2184 | * @todo: NA |
| 2185 | * @see: NA |
| 2186 | * @warning: NA |
| 2187 | *********************************************************************/ |
| 2188 | int qser_wifi2_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth) |
| 2189 | { |
| 2190 | WIFI2_ENABLE_JUDGE(); |
| 2191 | int ret = -1; |
| 2192 | sc_wifi_ap_param_t param = {0}; |
| 2193 | if (bandwidth == NULL) |
| 2194 | { |
| 2195 | LYERRLOG("[%s ] Null pointer bandwidth = 0x%p \n", __func__, bandwidth); |
| 2196 | return ret; |
| 2197 | } |
| 2198 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2199 | if (0 != ret) |
| 2200 | { |
| 2201 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2202 | return ret; |
| 2203 | } |
| 2204 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, param.bandwidth); |
| 2205 | *bandwidth = (lynq_wifi_bandwidth_type_e)param.bandwidth; |
| 2206 | return 0; |
| 2207 | } |
| 2208 | |
| 2209 | /******************************************************************** |
| 2210 | * @brief: qser_wifi_ap_channel_set, Set the channel for 2.4G or 5G |
| 2211 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2212 | * @param country_code [IN]: const char *, Set country code |
| 2213 | * @param channel [IN]: int, Set the channel |
| 2214 | * @return : int, If equal to 0 succeeds, others fail |
| 2215 | * @todo: NA |
| 2216 | * @see: NA |
| 2217 | * @warning: NA |
| 2218 | *********************************************************************/ |
| 2219 | int qser_wifi2_ap_channel_set(lynq_wifi_ap_index_e idx, const char *country_code, int channel) |
| 2220 | { |
| 2221 | WIFI2_ENABLE_JUDGE(); |
| 2222 | int ret = -1; |
| 2223 | if (country_code == NULL) |
| 2224 | { |
| 2225 | LYERRLOG("[%s ] Null pointer country_code = 0x%p \n", __func__, country_code); |
| 2226 | return ret; |
| 2227 | } |
| 2228 | ret = sc_wifi_ap_cc_ch_set_ext(1, (sc_wifi_ap_index_e)idx, country_code, channel); |
| 2229 | if (0 != ret) |
| 2230 | { |
| 2231 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2232 | return ret; |
| 2233 | } |
| 2234 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, country_code, channel); |
| 2235 | return 0; |
| 2236 | } |
| 2237 | |
| 2238 | /******************************************************************** |
| 2239 | * @brief: qser_wifi_ap_channel_get, Get the channel for 2.4G or 5G |
| 2240 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2241 | * @param country_code [OUT]: char *, Get country code |
| 2242 | * @param channel [OUT]: int *, Get the channel |
| 2243 | * @return : int, If equal to 0 succeeds, others fail |
| 2244 | * @todo: NA |
| 2245 | * @see: NA |
| 2246 | * @warning: NA |
| 2247 | *********************************************************************/ |
| 2248 | int qser_wifi2_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel) |
| 2249 | { |
| 2250 | WIFI2_ENABLE_JUDGE(); |
| 2251 | int ret = -1; |
| 2252 | sc_wifi_ap_param_t param = {0}; |
| 2253 | if (country_code == NULL || channel == NULL) |
| 2254 | { |
| 2255 | LYERRLOG("[%s ] Null pointer country_code = 0x%p channel = 0x%p\n", __func__, country_code, channel); |
| 2256 | return ret; |
| 2257 | } |
| 2258 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2259 | if (0 != ret) |
| 2260 | { |
| 2261 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2262 | return ret; |
| 2263 | } |
| 2264 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, param.countrycode, param.channel); |
| 2265 | strncpy(country_code, param.countrycode, sizeof(param.countrycode) - 1); |
| 2266 | *channel = param.channel; |
| 2267 | return 0; |
| 2268 | } |
| 2269 | |
| 2270 | /******************************************************************** |
| 2271 | * @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of 2.4G or 5G |
| 2272 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2273 | * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode |
| 2274 | * @param auth_passwd [IN]: const char *, Set password |
| 2275 | * @return : int, If equal to 0 succeeds, others fail |
| 2276 | * @todo: NA |
| 2277 | * @see: NA |
| 2278 | * @warning: NA |
| 2279 | *********************************************************************/ |
| 2280 | int qser_wifi2_ap_auth_set(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e auth_mode, const char *auth_passwd) |
| 2281 | { |
| 2282 | WIFI2_ENABLE_JUDGE(); |
| 2283 | int ret = -1; |
| 2284 | if (auth_passwd == NULL) |
| 2285 | { |
| 2286 | LYERRLOG("[%s ] Null pointer auth_passwd = 0x%p\n", __func__, auth_passwd); |
| 2287 | return ret; |
| 2288 | } |
| 2289 | |
| 2290 | sc_wifi_ap_auth_t auth; |
| 2291 | auth.auth = lynq_to_sc_auth_mode(auth_mode); |
| 2292 | strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1); |
| 2293 | ret = sc_wifi_ap_auth_set_ext(1, (sc_wifi_ap_index_e)idx, &auth); |
| 2294 | if (0 != ret) |
| 2295 | { |
| 2296 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2297 | return ret; |
| 2298 | } |
| 2299 | LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s\n", __func__, idx, auth_mode, "******"); |
| 2300 | return 0; |
| 2301 | } |
| 2302 | |
| 2303 | /******************************************************************** |
| 2304 | * @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of 2.4G or 5G |
| 2305 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2306 | * @param auth_mode [OUT]: lynq_wifi_auth_e *, Get the security authentication mode |
| 2307 | * @param auth_passwd [OUT]: char *, Get password |
| 2308 | * @return : int, If equal to 0 succeeds, others fail |
| 2309 | * @todo: NA |
| 2310 | * @see: NA |
| 2311 | * @warning: NA |
| 2312 | *********************************************************************/ |
| 2313 | int qser_wifi2_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd) |
| 2314 | { |
| 2315 | WIFI2_ENABLE_JUDGE(); |
| 2316 | int ret = -1; |
| 2317 | sc_wifi_ap_param_t param = {0}; |
| 2318 | if (auth_mode == NULL || auth_passwd == NULL) |
| 2319 | { |
| 2320 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p auth_passwd = 0x%p\n", __func__, auth_mode, auth_passwd); |
| 2321 | return ret; |
| 2322 | } |
| 2323 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2324 | if (0 != ret) |
| 2325 | { |
| 2326 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2327 | return ret; |
| 2328 | } |
| 2329 | LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s \n", __func__, idx, param.auth.auth, param.auth.passwd); |
| 2330 | strncpy(auth_passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
| 2331 | |
| 2332 | *auth_mode = sc_to_lynq_auth_mode(param.auth.auth); |
| 2333 | return 0; |
| 2334 | } |
| 2335 | |
| 2336 | /******************************************************************** |
| 2337 | * @brief: qser_wifi_ap_auth_get_s, Get the security authentication mode , password group_rekey and pairwise of 2.4G or 5G |
| 2338 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2339 | * @param auth_mode [OUT]: lynq_wifi_ap_auth_t *, Get the security authentication mode |
| 2340 | * @return : int, If equal to 0 succeeds, others fail |
| 2341 | * @todo: NA |
| 2342 | * @see: NA |
| 2343 | * @warning: NA |
| 2344 | *********************************************************************/ |
| 2345 | int qser_wifi2_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode) |
| 2346 | { |
| 2347 | WIFI2_ENABLE_JUDGE(); |
| 2348 | int ret = -1; |
| 2349 | sc_wifi_ap_param_t param = {0}; |
| 2350 | if (auth_mode == NULL) |
| 2351 | { |
| 2352 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p\n", __func__, auth_mode); |
| 2353 | return ret; |
| 2354 | } |
| 2355 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2356 | if (0 != ret) |
| 2357 | { |
| 2358 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2359 | return ret; |
| 2360 | } |
| 2361 | LYINFLOG("[%s ] idx = %d auth = %d passwd = %s group_rekey = %d pairwise = %d\n", __func__, idx, param.auth.auth, param.auth.passwd, param.auth.group_rekey, param.auth.pairwise); |
| 2362 | strncpy(auth_mode->passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
| 2363 | auth_mode->group_rekey = param.auth.group_rekey; |
| 2364 | auth_mode->pairwise = (lynq_wifi_auth_wpa_psk_e)param.auth.pairwise; |
| 2365 | auth_mode->auth = sc_to_lynq_auth_mode(param.auth.auth); |
| 2366 | return 0; |
| 2367 | } |
| 2368 | |
| 2369 | /******************************************************************** |
| 2370 | * @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for 2.4G or 5G |
| 2371 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2372 | * @param max_sta_num [IN]: int, Set the maximum number |
| 2373 | * @return : int, If equal to 0 succeeds, others fail |
| 2374 | * @todo: NA |
| 2375 | * @see: NA |
| 2376 | * @warning: NA |
| 2377 | *********************************************************************/ |
| 2378 | int qser_wifi2_ap_max_sta_set(lynq_wifi_ap_index_e idx, int max_sta_num) |
| 2379 | { |
| 2380 | WIFI2_ENABLE_JUDGE(); |
| 2381 | int ret = -1; |
| 2382 | if(max_sta_num >= 32) |
| 2383 | { |
| 2384 | LYERRLOG("[%s ] fail max_sta_num = %d\n", __func__,max_sta_num); |
| 2385 | return -1; |
| 2386 | } |
| 2387 | ret = sc_wifi_ap_max_sta_num_set_ext(1, (sc_wifi_ap_index_e)idx, max_sta_num); |
| 2388 | if (0 != ret) |
| 2389 | { |
| 2390 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2391 | return ret; |
| 2392 | } |
| 2393 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, max_sta_num); |
| 2394 | return 0; |
| 2395 | } |
| 2396 | |
| 2397 | /******************************************************************** |
| 2398 | * @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for 2.4G or 5G |
| 2399 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2400 | * @param max_sta_num [OUT]: int *, Get the maximum number |
| 2401 | * @return : int, If equal to 0 succeeds, others fail |
| 2402 | * @todo: NA |
| 2403 | * @see: NA |
| 2404 | * @warning: NA |
| 2405 | *********************************************************************/ |
| 2406 | int qser_wifi2_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num) |
| 2407 | { |
| 2408 | WIFI2_ENABLE_JUDGE(); |
| 2409 | int ret = -1; |
| 2410 | sc_wifi_ap_param_t param = {0}; |
| 2411 | if (max_sta_num == NULL) |
| 2412 | { |
| 2413 | LYERRLOG("[%s ] Null pointer max_sta_num = 0x%p\n", __func__,max_sta_num); |
| 2414 | return ret; |
| 2415 | } |
| 2416 | ret = sc_wifi_ap_param_get_ext(1, (sc_wifi_ap_index_e)idx, ¶m); |
| 2417 | if (0 != ret) |
| 2418 | { |
| 2419 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2420 | return ret; |
| 2421 | } |
| 2422 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, param.max_sta_num); |
| 2423 | *max_sta_num = param.max_sta_num; |
| 2424 | return 0; |
| 2425 | } |
| 2426 | |
| 2427 | /******************************************************************** |
| 2428 | * @brief: qser_wifi_lanhost_get_list, Get sta device information received as an ap for 2.4G or 5G |
| 2429 | * @param lynq_arrays [OUT]: lynq_lanhost_ts *, Get sta device information received as an ap |
| 2430 | * @return : int, If equal to 0 succeeds, others fail |
| 2431 | * @todo: NA |
| 2432 | * @see: NA |
| 2433 | * @warning: NA |
| 2434 | *********************************************************************/ |
| 2435 | int qser_wifi2_lanhost_get_list(lynq_lanhost_ts *lynq_arrays) |
| 2436 | { |
| 2437 | WIFI2_ENABLE_JUDGE(); |
| 2438 | int ret = -1; |
| 2439 | int i = 0; |
| 2440 | sc_lanhost_t array[32] = {0}; |
| 2441 | if (lynq_arrays == NULL) |
| 2442 | { |
| 2443 | LYERRLOG("[%s ] Null pointer lynq_arrays = 0x%p\n", __func__, lynq_arrays); |
| 2444 | return ret; |
| 2445 | } |
| 2446 | lynq_arrays->array_len = 32; |
| 2447 | ret = sc_wifi_lanhost_get_list_ext(1, array, &lynq_arrays->array_len); |
| 2448 | if (0 != ret) |
| 2449 | { |
| 2450 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 2451 | return ret; |
| 2452 | } |
| 2453 | LYINFLOG("[%s]ap_lanhost len[%d]\n", __func__, lynq_arrays->array_len); |
| 2454 | for (i = 0; i < lynq_arrays->array_len; i++) |
| 2455 | { |
| 2456 | LYINFLOG("[%s]Element : [%d] ifname = %s macaddr = %s addr = %s name = %s uptime = %d\n", __func__, i, |
| 2457 | array[i].ifname, array[i].macaddr, array[i].addr, array[i].name, array[i].uptime); |
| 2458 | strncpy(lynq_arrays->array[i].ifname, array[i].ifname, sizeof(lynq_arrays->array[i].ifname) - 1); |
| 2459 | strncpy(lynq_arrays->array[i].macaddr, array[i].macaddr, sizeof(lynq_arrays->array[i].macaddr) - 1); |
| 2460 | strncpy(lynq_arrays->array[i].addr, array[i].addr, sizeof(lynq_arrays->array[i].addr) - 1); |
| 2461 | strncpy(lynq_arrays->array[i].name, array[i].name, sizeof(lynq_arrays->array[i].name) - 1); |
| 2462 | lynq_arrays->array[i].uptime = array[i].uptime; |
| 2463 | } |
| 2464 | return 0; |
| 2465 | } |
| 2466 | |
| 2467 | /******************************************************************** |
| 2468 | * @brief: qser_wifi_get_ap_pkt_stats, Obtain data packets sent and received by ap for 2.4G or 5G |
| 2469 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2470 | * @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by ap |
| 2471 | * @return : int, If equal to 0 succeeds, others fail |
| 2472 | * @todo: NA |
| 2473 | * @see: NA |
| 2474 | * @warning: NA |
| 2475 | *********************************************************************/ |
| 2476 | int qser_wifi2_get_ap_pkt_stats(lynq_wifi_ap_index_e idx, lynq_wifi_pkt_stats_t *pkt_stat) |
| 2477 | { |
| 2478 | WIFI2_ENABLE_JUDGE(); |
| 2479 | int ret = -1; |
| 2480 | sc_wifi_pkt_stats_t stat = {0}; |
| 2481 | if (pkt_stat == NULL) |
| 2482 | { |
| 2483 | LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat); |
| 2484 | return ret; |
| 2485 | } |
| 2486 | idx = LYNQ_WIFI_AP_INDEX_AP0; |
| 2487 | ret = sc_wifi_get_ap_pkt_stats_ext(1, (sc_wifi_ap_index_e)idx, &stat); |
| 2488 | if (0 != ret) |
| 2489 | { |
| 2490 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 2491 | return ret; |
| 2492 | } |
| 2493 | LYINFLOG("[%s ]ap_pkt_get[%d] rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__, idx, |
| 2494 | stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped, |
| 2495 | stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped); |
| 2496 | pkt_stat->rx_packets = stat.rx_packets; |
| 2497 | pkt_stat->rx_bytes = stat.rx_bytes; |
| 2498 | pkt_stat->rx_errors = stat.rx_errors; |
| 2499 | pkt_stat->rx_dropped = stat.rx_dropped; |
| 2500 | pkt_stat->tx_packets = stat.tx_packets; |
| 2501 | pkt_stat->tx_bytes = stat.tx_bytes; |
| 2502 | pkt_stat->tx_errors = stat.tx_errors; |
| 2503 | pkt_stat->tx_dropped = stat.tx_dropped; |
| 2504 | return 0; |
| 2505 | } |
| 2506 | |
| 2507 | /******************************************************************** |
| 2508 | * @brief: qser_wifi_ap_start, Set the ap mode of 2.4G or 5G to enable |
| 2509 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2510 | * @return : int, If equal to 0 succeeds, others fail |
| 2511 | * @todo: NA |
| 2512 | * @see: NA |
| 2513 | * @warning: NA |
| 2514 | *********************************************************************/ |
| 2515 | int qser_wifi2_ap_start(lynq_wifi_ap_index_e idx) |
| 2516 | { |
| 2517 | WIFI2_ENABLE_JUDGE(); |
| 2518 | int ret = -1; |
| 2519 | ret = sc_wifi_ap_start_ext(1, (sc_wifi_ap_index_e)idx); |
| 2520 | if (0 != ret) |
| 2521 | { |
| 2522 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2523 | return ret; |
| 2524 | } |
| 2525 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 2526 | return 0; |
| 2527 | } |
| 2528 | |
| 2529 | /******************************************************************** |
| 2530 | * @brief: qser_wifi_ap_stop, Disable ap mode for 2.4G or 5G |
| 2531 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2532 | * @return : int, If equal to 0 succeeds, others fail |
| 2533 | * @todo: NA |
| 2534 | * @see: NA |
| 2535 | * @warning: NA |
| 2536 | *********************************************************************/ |
| 2537 | int qser_wifi2_ap_stop(lynq_wifi_ap_index_e idx) |
| 2538 | { |
| 2539 | WIFI2_ENABLE_JUDGE(); |
| 2540 | int ret = -1; |
| 2541 | ret = sc_wifi_ap_stop_ext(1, (sc_wifi_ap_index_e)idx); |
| 2542 | if (0 != ret) |
| 2543 | { |
| 2544 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 2545 | return ret; |
| 2546 | } |
| 2547 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 2548 | return 0; |
| 2549 | } |
| 2550 | |
| 2551 | /******************************************************************** |
| 2552 | * @brief: qser_wifi_ap_restart, Set the ap mode of 2.4G or 5G to restart |
| 2553 | * @param idx [IN]: int, Set 2.4G or 5G |
| 2554 | * @return : int, If equal to 0 succeeds, others fail |
| 2555 | * @todo: NA |
| 2556 | * @see: NA |
| 2557 | * @warning: NA |
| 2558 | *********************************************************************/ |
| 2559 | int qser_wifi2_ap_restart(lynq_wifi_ap_index_e idx) |
| 2560 | { |
| 2561 | WIFI2_ENABLE_JUDGE(); |
| 2562 | int ret = -1; |
| 2563 | ret = sc_wifi_ap_stop_ext(1, (sc_wifi_ap_index_e)idx); |
| 2564 | if (0 != ret) |
| 2565 | { |
| 2566 | LYERRLOG("[%s ] stop ret = %d\n", __func__,ret); |
| 2567 | return ret; |
| 2568 | } |
| 2569 | ret = sc_wifi_ap_start_ext(1, (sc_wifi_ap_index_e)idx); |
| 2570 | if (0 != ret) |
| 2571 | { |
| 2572 | LYERRLOG("[%s ] start ret = %d\n", __func__,ret); |
| 2573 | return ret; |
| 2574 | } |
| 2575 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 2576 | return 0; |
| 2577 | } |
| 2578 | |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 2579 | DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 2580 | |
| 2581 | #ifdef __cplusplus |
| 2582 | } |
| 2583 | #endif |