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" |
| 14 | |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 15 | static lynq_wifi_event_handle wifi_event_handle = NULL; |
| 16 | static lynq_wifi_event_handle_sta wifi_event_handle_sta = NULL; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 17 | static void *global_arg = NULL; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 18 | |
| 19 | /******************************************************************** |
| 20 | * @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] | 21 | * @return :sc_wifi_auth_e, all |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 22 | * @todo: NA |
| 23 | * @see: NA |
| 24 | * @warning: NA |
| 25 | *********************************************************************/ |
| 26 | static sc_wifi_auth_e lynq_to_sc_auth_mode(lynq_wifi_auth_e auth_mode) |
| 27 | { |
| 28 | sc_wifi_auth_e type; |
| 29 | switch (auth_mode) |
| 30 | { |
| 31 | case LYNQ_WIFI_AUTH_OPEN: |
| 32 | type = SC_WIFI_AUTH_OPEN; |
| 33 | break; |
| 34 | case LYNQ_WIFI_AUTH_WPA2_PSK: |
| 35 | type = SC_WIFI_AUTH_WPA2_PSK; |
| 36 | break; |
| 37 | case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 38 | type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 39 | break; |
| 40 | case LYNQ_WIFI_AUTH_WPA3_PSK: |
| 41 | type = SC_WIFI_AUTH_WPA3_PSK; |
| 42 | break; |
| 43 | case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 44 | type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 45 | break; |
| 46 | default: |
| 47 | type = SC_WIFI_AUTH_MIN; |
| 48 | break; |
| 49 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 50 | return type; |
| 51 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 52 | |
| 53 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 54 | * @brief: sc_to_lynq_auth_mode, The wifi protocol moves from platform to api |
| 55 | * @return :lynq_wifi_auth_e, all |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 56 | * @todo: NA |
| 57 | * @see: NA |
| 58 | * @warning: NA |
| 59 | *********************************************************************/ |
| 60 | static lynq_wifi_auth_e sc_to_lynq_auth_mode(sc_wifi_auth_e auth_mode) |
| 61 | { |
| 62 | lynq_wifi_auth_e type; |
| 63 | switch (auth_mode) |
| 64 | { |
| 65 | case SC_WIFI_AUTH_OPEN: |
| 66 | type = LYNQ_WIFI_AUTH_OPEN; |
| 67 | break; |
| 68 | case SC_WIFI_AUTH_WPA2_PSK: |
| 69 | type = LYNQ_WIFI_AUTH_WPA2_PSK; |
| 70 | break; |
| 71 | case SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 72 | type = LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 73 | break; |
| 74 | case SC_WIFI_AUTH_WPA3_PSK: |
| 75 | type = LYNQ_WIFI_AUTH_WPA3_PSK; |
| 76 | break; |
| 77 | case SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 78 | type = LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 79 | break; |
| 80 | default: |
| 81 | type = LYNQ_WIFI_AUTH_MIN; |
| 82 | break; |
| 83 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 84 | return type; |
| 85 | } |
| 86 | |
| 87 | /******************************************************************** |
| 88 | * @brief: lynq_to_sc_mode, The wifi protocol is transferred from api to platform |
| 89 | * @return :sc_wifi_ap_mode_type_e, all |
| 90 | * @todo: NA |
| 91 | * @see: NA |
| 92 | * @warning: NA |
| 93 | *********************************************************************/ |
| 94 | static sc_wifi_ap_mode_type_e lynq_to_sc_mode(lynq_wifi_mode_type_e mode) |
| 95 | { |
| 96 | sc_wifi_ap_mode_type_e type; |
| 97 | switch (mode) |
| 98 | { |
| 99 | case LYNQ_WIFI_MODE_80211BGN: |
| 100 | type = SC_WIFI_AP_MODE_80211BGN; |
| 101 | break; |
| 102 | case LYNQ_WIFI_MODE_80211BGNAX_2G: |
| 103 | type = SC_WIFI_AP_MODE_80211BGNAX_2G; |
| 104 | break; |
| 105 | case LYNQ_WIFI_MODE_80211AN: |
| 106 | type = SC_WIFI_AP_MODE_80211AN; |
| 107 | break; |
| 108 | case LYNQ_WIFI_MODE_80211ANAC: |
| 109 | type = SC_WIFI_AP_MODE_80211ANAC; |
| 110 | break; |
| 111 | case LYNQ_WIFI_MODE_80211ANACAX_5G: |
| 112 | type = SC_WIFI_AP_MODE_80211ANACAX_5G; |
| 113 | break; |
| 114 | default: |
| 115 | type = SC_WIFI_AP_MODE_MIN; |
| 116 | break; |
| 117 | } |
| 118 | return type; |
| 119 | } |
| 120 | |
| 121 | /******************************************************************** |
| 122 | * @brief: sc_to_lynq_mode, The encryption mode of wifi is changed from platform to api |
| 123 | * @return :lynq_wifi_mode_type_e, all |
| 124 | * @todo: NA |
| 125 | * @see: NA |
| 126 | * @warning: NA |
| 127 | *********************************************************************/ |
| 128 | static lynq_wifi_mode_type_e sc_to_lynq_mode(sc_wifi_ap_mode_type_e mode) |
| 129 | { |
| 130 | lynq_wifi_mode_type_e type; |
| 131 | switch (mode) |
| 132 | { |
| 133 | case SC_WIFI_AP_MODE_80211BGN: |
| 134 | type = LYNQ_WIFI_MODE_80211BGN; |
| 135 | break; |
| 136 | case SC_WIFI_AP_MODE_80211BGNAX_2G: |
| 137 | type = LYNQ_WIFI_MODE_80211BGNAX_2G; |
| 138 | break; |
| 139 | case SC_WIFI_AP_MODE_80211AN: |
| 140 | type = LYNQ_WIFI_MODE_80211AN; |
| 141 | break; |
| 142 | case SC_WIFI_AP_MODE_80211ANAC: |
| 143 | type = LYNQ_WIFI_MODE_80211ANAC; |
| 144 | break; |
| 145 | case SC_WIFI_AP_MODE_80211ANACAX_5G: |
| 146 | type = LYNQ_WIFI_MODE_80211ANACAX_5G; |
| 147 | break; |
| 148 | default: |
| 149 | type = LYNQ_WIFI_MODE_MIN; |
| 150 | break; |
| 151 | } |
| 152 | return type; |
| 153 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 154 | |
| 155 | /******************************************************************** |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 156 | * @brief: sc_to_lynq_sta_status, sc_wifi_sta_status_t to lynq_wifi_sta_status_t |
| 157 | * @return :int, all |
| 158 | * @todo: NA |
| 159 | * @see: NA |
| 160 | * @warning: NA |
| 161 | *********************************************************************/ |
| 162 | static int sc_to_lynq_sta_status(sc_wifi_sta_status_t *stat, lynq_wifi_sta_status_t *status_stat) |
| 163 | { |
| 164 | status_stat->status = (lynq_wifi_sta_status_e)stat->status; |
| 165 | status_stat->signal_level = stat->signal_level; |
| 166 | status_stat->has_addr = stat->has_addr; |
| 167 | status_stat->has_addr6 = stat->has_addr6; |
| 168 | status_stat->reason_code = (lynq_wifi_reason_code_e)stat->reason_code; |
| 169 | strncpy(status_stat->ifname, stat->ifname, sizeof(stat->ifname) - 1); |
| 170 | strncpy(status_stat->ap_bssid, stat->ap_bssid, sizeof(stat->ap_bssid) - 1); |
| 171 | if (status_stat->has_addr == 1) |
| 172 | { |
| 173 | strncpy(status_stat->addr.addr, stat->addr.addr, sizeof(status_stat->addr.addr) - 1); |
| 174 | strncpy(status_stat->addr.netmask, stat->addr.netmask, sizeof(status_stat->addr.netmask) - 1); |
| 175 | status_stat->addr.subnet_bits = stat->addr.subnet_bits; |
| 176 | strncpy(status_stat->addr.gateway, stat->addr.gateway, sizeof(status_stat->addr.gateway) - 1); |
| 177 | strncpy(status_stat->addr.dnsp, stat->addr.dnsp, sizeof(status_stat->addr.dnsp) - 1); |
| 178 | strncpy(status_stat->addr.dnss, stat->addr.dnss, sizeof(status_stat->addr.dnss) - 1); |
| 179 | } |
| 180 | if (status_stat->has_addr6 == 1) |
| 181 | { |
| 182 | strncpy(status_stat->addr6.addr, stat->addr6.addr, sizeof(status_stat->addr6.addr) - 1); |
| 183 | strncpy(status_stat->addr6.prefix, stat->addr6.prefix, sizeof(status_stat->addr6.prefix) - 1); |
| 184 | status_stat->addr6.prefix_bits = stat->addr6.prefix_bits; |
| 185 | strncpy(status_stat->addr6.gateway, stat->addr6.gateway, sizeof(status_stat->addr6.gateway) - 1); |
| 186 | strncpy(status_stat->addr6.dnsp, stat->addr6.dnsp, sizeof(status_stat->addr6.dnsp) - 1); |
| 187 | strncpy(status_stat->addr6.dnss, stat->addr6.dnss, sizeof(status_stat->addr6.dnss) - 1); |
| 188 | } |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | /******************************************************************** |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 193 | * @brief: lynq_user_status, wifi startup callback |
| 194 | * @return : NA |
| 195 | * @todo: NA |
| 196 | * @see: NA |
| 197 | * @warning: NA |
| 198 | *********************************************************************/ |
| 199 | static void lynq_user_status(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status) |
| 200 | { |
| 201 | LYINFLOG("%s:%d,%d\n", __func__, pre_status, status); |
| 202 | } |
| 203 | |
| 204 | /******************************************************************** |
| 205 | * @brief: lynq_user_wifi_service_error, wifi service status callback |
| 206 | * @return : NA |
| 207 | * @todo: NA |
| 208 | * @see: NA |
| 209 | * @warning: NA |
| 210 | *********************************************************************/ |
| 211 | static void lynq_user_wifi_service_error(int error) |
| 212 | { |
| 213 | LYINFLOG("%s: %d\n", __func__, error); |
| 214 | } |
| 215 | |
| 216 | /******************************************************************** |
| 217 | * @brief: lynq_user_ap_status, wifi Obtains the ap status callback |
| 218 | * @return : NA |
| 219 | * @todo: NA |
| 220 | * @see: NA |
| 221 | * @warning: NA |
| 222 | *********************************************************************/ |
| 223 | 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) |
| 224 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 225 | lynq_wifi_event_s event; |
| 226 | if (wifi_event_handle != NULL && global_arg != NULL) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 227 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 228 | if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 229 | { |
| 230 | return; |
| 231 | } |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 232 | 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] | 233 | event.id = LYNQ_WIFI_EVENT_AP_STATION; |
| 234 | event.status = (lynq_wifi_status_e)pre_status; |
| 235 | wifi_event_handle(&event, global_arg); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 236 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 237 | else |
| 238 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 239 | LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status); |
| 240 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | /******************************************************************** |
| 244 | * @brief: lynq_user_ap_sta_conn_status, wifi as ap is sta information callback |
| 245 | * @return : NA |
| 246 | * @todo: NA |
| 247 | * @see: NA |
| 248 | * @warning: NA |
| 249 | *********************************************************************/ |
| 250 | static void lynq_user_ap_sta_conn_status(sc_wifi_ap_index_e index, sc_wifi_sta_connect_status_t *p_msg) |
| 251 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 252 | char hostname[32] = {0}; |
| 253 | lynq_wifi_event_s event; |
| 254 | int ret = sc_wifi_get_hostname_by_mac(p_msg->macaddr, hostname, sizeof(hostname)); |
| 255 | if (ret == 0) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 256 | { |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 257 | LYINFLOG("sta ip not assigned, try again later!\n"); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 258 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 259 | if (wifi_event_handle != NULL && global_arg != NULL) |
| 260 | { |
| 261 | if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 262 | { |
| 263 | return; |
| 264 | } |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 265 | LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname); |
| 266 | event.id = LYNQ_WIFI_EVENT_AP_STA_STATUS; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 267 | event.ap_sta_info.connected = p_msg->is_connected; |
| 268 | strncpy(event.ap_sta_info.mac, p_msg->macaddr, |
| 269 | sizeof(event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(event.ap_sta_info.mac) : sizeof(p_msg->macaddr)); |
| 270 | strncpy(event.ap_sta_info.hostname, hostname, sizeof(hostname)); |
| 271 | wifi_event_handle(&event, global_arg); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 272 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 273 | else |
| 274 | { |
| 275 | LYINFLOG("%s:%d,%d,%s,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr, hostname); |
| 276 | } |
| 277 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 278 | |
| 279 | /******************************************************************** |
| 280 | * @brief: print_sta_status, wifi gets the status callback in sta mode |
| 281 | * @return : NA |
| 282 | * @todo: NA |
| 283 | * @see: NA |
| 284 | * @warning: NA |
| 285 | *********************************************************************/ |
| 286 | static void print_sta_status(sc_wifi_sta_status_t *p_msg) |
| 287 | { |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 288 | LYINFLOG("%s: %d, %s, %s, %d, %d\n", __func__, p_msg->status, p_msg->ifname, p_msg->ap_bssid, |
| 289 | p_msg->signal_level, p_msg->reason_code); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 290 | |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 291 | if (p_msg->has_addr == 1) |
| 292 | { |
| 293 | LYINFLOG("[%s]addr ip:%s, netmask:%s, subnet_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n", __func__, |
| 294 | p_msg->addr.addr, p_msg->addr.netmask, p_msg->addr.subnet_bits, |
| 295 | p_msg->addr.gateway, p_msg->addr.dnsp, p_msg->addr.dnss); |
| 296 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 297 | |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 298 | if (p_msg->has_addr6 == 1) |
| 299 | { |
| 300 | LYINFLOG("[%s]addr6 ip:%s, prefix:%s, prefix_bits:%d, gateway:%s, dnsp:%s, dnss:%s\n", __func__, |
| 301 | p_msg->addr6.addr, p_msg->addr6.prefix, p_msg->addr6.prefix_bits, |
| 302 | p_msg->addr6.gateway, p_msg->addr6.dnsp, p_msg->addr6.dnss); |
| 303 | } |
| 304 | LYINFLOG("%s : sta_status end\n", __func__); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | /******************************************************************** |
| 308 | * @brief: lynq_user_sta_status_ind, wifi gets the status callback in sta mode |
| 309 | * @return : NA |
| 310 | * @todo: NA |
| 311 | * @see: NA |
| 312 | * @warning: NA |
| 313 | *********************************************************************/ |
| 314 | static void lynq_user_sta_status_ind(sc_wifi_sta_status_e pre_status, |
| 315 | sc_wifi_sta_status_t *p_msg) |
| 316 | { |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 317 | if (wifi_event_handle != NULL && global_arg != NULL) |
| 318 | { |
| 319 | lynq_wifi_event_s event; |
| 320 | if (*(int *)global_arg == LYNQ_WIFI_EVENT_DISABLE_STATUS) |
| 321 | { |
| 322 | return; |
| 323 | } |
| 324 | LYINFLOG("%s : user_sta_status_ind_cb pre:%d, cur:%d\n", __func__, pre_status, p_msg->status); |
| 325 | event.id = LYNQ_WIFI_EVENT_STA_STATUS; |
| 326 | if(p_msg->status == SC_WIFI_STA_STATUS_CONNECTED) |
| 327 | event.sta_status = LYNQ_WIFI_STATION_CONNECTED; |
| 328 | else if(p_msg->status == SC_WIFI_STA_STATUS_DISCONNECTED) |
| 329 | event.sta_status = LYNQ_WIFI_STATION_DISCONNECTED; |
| 330 | else |
| 331 | event.sta_status = LYNQ_WIFI_STATION_DISABLE; |
| 332 | sc_to_lynq_sta_status(p_msg, &event.sta_status_all); |
| 333 | event.sta_status_all.sta_status = event.sta_status; |
| 334 | wifi_event_handle(&event, global_arg); |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | print_sta_status(p_msg); |
| 339 | } |
| 340 | |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /******************************************************************** |
| 344 | * @brief: lynq_user_sta_scan_result_ind, wifi gets the callback of sta mode traversing the hotspot |
| 345 | * @return : NA |
| 346 | * @todo: NA |
| 347 | * @see: NA |
| 348 | * @warning: NA |
| 349 | *********************************************************************/ |
| 350 | static void lynq_user_sta_scan_result_ind(sc_wifi_sta_scan_list_t *p_msg) |
| 351 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 352 | int i = 0; |
| 353 | LYINFLOG("%s : user_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt); |
| 354 | if (p_msg->cnt <= 0) |
| 355 | { |
| 356 | return; |
| 357 | } |
| 358 | if (wifi_event_handle_sta != NULL) |
| 359 | { |
| 360 | lynq_wifi_sta_scan_list_t event; |
| 361 | event.cnt = p_msg->cnt; |
| 362 | for (i = 0; i < event.cnt; i++) |
| 363 | { |
| 364 | strncpy(event.info[i].essid, p_msg->info[i].essid, sizeof(p_msg->info[i].essid)); |
| 365 | strncpy(event.info[i].bssid, p_msg->info[i].bssid, sizeof(p_msg->info[i].bssid)); |
| 366 | event.info[i].auth = sc_to_lynq_auth_mode(p_msg->info[i].auth); |
| 367 | event.info[i].cipher = (lynq_wifi_auth_wpa_psk_e)p_msg->info[i].cipher; |
| 368 | event.info[i].channel = p_msg->info[i].channel; |
| 369 | event.info[i].signal_level = p_msg->info[i].signal_level; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 370 | event.info[i].frequency = p_msg->info[i].frequency; |
| 371 | event.info[i].signal = p_msg->info[i].signal; |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 372 | } |
| 373 | wifi_event_handle_sta(&event); |
| 374 | } |
| 375 | else |
| 376 | { |
| 377 | for (i = 0; i < p_msg->cnt; i++) |
| 378 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 379 | 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), |
| 380 | 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] | 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | /******************************************************************** |
| 386 | * @brief: qser_wifi_work_mode_set, 2.4g or 5g working mode Settings |
| 387 | * @param type [IN]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Settings |
| 388 | * @return : int, If equal to 0 succeeds, others fail |
| 389 | * @todo: NA |
| 390 | * @see: NA |
| 391 | * @warning: NA |
| 392 | *********************************************************************/ |
| 393 | int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type) |
| 394 | { |
| 395 | int ret = -1; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 396 | sc_wifi_work_mode_e mode; |
| 397 | ret = sc_wifi_work_mode_get(&mode); |
| 398 | if (0 != ret) |
| 399 | { |
| 400 | LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret); |
| 401 | return ret; |
| 402 | } |
| 403 | if(mode == (sc_wifi_work_mode_e)type) //The same value is returned |
| 404 | { |
| 405 | return 0; |
| 406 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 407 | ret = sc_wifi_work_mode_set((sc_wifi_work_mode_e)type); |
| 408 | if (0 != ret) |
| 409 | { |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 410 | LYERRLOG("[%s ] work_mode set ret = %d\n", __func__,ret); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 411 | return ret; |
| 412 | } |
| 413 | LYINFLOG("[%s ]\n", __func__); |
| 414 | return 0; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | /******************************************************************** |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 418 | * @brief: qser_wifi_work_mode_get, 2.4g or 5g working mode Gettings |
| 419 | * @param type [OUT]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Gettings |
| 420 | * @return : int, If equal to 0 succeeds, others fail |
| 421 | * @todo: NA |
| 422 | * @see: NA |
| 423 | * @warning: NA |
| 424 | *********************************************************************/ |
| 425 | int qser_wifi_work_mode_get(lynq_wifi_work_mode_e *type) |
| 426 | { |
| 427 | int ret = -1; |
| 428 | sc_wifi_work_mode_e mode; |
| 429 | ret = sc_wifi_work_mode_get(&mode); |
| 430 | if (0 != ret) |
| 431 | { |
| 432 | LYERRLOG("[%s ] work_mode get ret = %d\n", __func__,ret); |
| 433 | return ret; |
| 434 | } |
| 435 | *type = (lynq_wifi_work_mode_e)mode; |
| 436 | LYINFLOG("[%s ]\n", __func__); |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | /******************************************************************** |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 441 | * @brief: qser_wifi_register_handle, Register callback functions |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 442 | * @param event_handle [IN]: lynq_wifi_event_handle, Register the ap event callback function |
| 443 | * @param event_handle_sta [IN]: Register sta's event callback function |
| 444 | * @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] | 445 | * @return :int, If equal to 0 succeeds, others fail |
| 446 | * @todo: NA |
| 447 | * @see: NA |
| 448 | * @warning: NA |
| 449 | *********************************************************************/ |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 450 | 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] | 451 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 452 | if((event_handle == NULL && event_handle_sta == NULL) || arg == NULL) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 453 | { |
| 454 | LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg); |
| 455 | return -1; |
| 456 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 457 | if(*(int *)arg <= LYNQ_WIFI_EVENT_MIN || *(int *)arg >= LYNQ_WIFI_EVENT_MAX) |
| 458 | { |
| 459 | LYERRLOG("[%s ] The value of arg can only be an integer ranging from 0 to 3p, arg = %d\n", __func__, arg); |
| 460 | return -1; |
| 461 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 462 | wifi_event_handle_sta = event_handle_sta; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 463 | wifi_event_handle = event_handle; |
| 464 | global_arg = arg; |
| 465 | return 0; |
| 466 | } |
| 467 | |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 468 | /******************************************************************** |
| 469 | * @brief: qser_wifi_enable, Enable WiFi function |
| 470 | * @return : int, If equal to 0 succeeds, others fail |
| 471 | * @todo: NA |
| 472 | * @see: NA |
| 473 | * @warning: NA |
| 474 | *********************************************************************/ |
| 475 | int qser_wifi_enable(void) |
| 476 | { |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 477 | char wifiAvailable[8] = {0}; |
| 478 | sc_cfg_get("wifiAvailable", wifiAvailable, sizeof(wifiAvailable)); |
| 479 | if (!strcmp(wifiAvailable, "0")) |
| 480 | { |
| 481 | LYERRLOG("[%s ] wifiAvailable has been set to 0. If WiFi is used, set 1 to enable it\n", __func__); |
| 482 | return -1; |
| 483 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 484 | int ret = -1; |
| 485 | ret = sc_wifi_init(); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 486 | if (0 != ret) |
| 487 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 488 | LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret); |
| 489 | return ret; |
| 490 | } |
| 491 | |
| 492 | //wifi |
| 493 | ret = sc_wifi_set_enable_status_ind_cb(lynq_user_status); |
| 494 | if (0 != ret) |
| 495 | { |
| 496 | LYERRLOG("[%s ] Request lynq_user_status ret = %d fail\n", __func__,ret); |
| 497 | return ret; |
| 498 | } |
| 499 | |
| 500 | //ap |
| 501 | ret = sc_wifi_ap_set_status_ind_cb(lynq_user_ap_status); |
| 502 | if (0 != ret) |
| 503 | { |
| 504 | LYERRLOG("[%s ] Request lynq_user_ap_status ret = %d fail\n", __func__,ret); |
| 505 | return ret; |
| 506 | } |
| 507 | ret = sc_wifi_set_ap_sta_connect_ind_cb(lynq_user_ap_sta_conn_status); |
| 508 | if (0 != ret) |
| 509 | { |
| 510 | LYERRLOG("[%s ] Request lynq_user_ap_sta_conn_status ret = %d fail\n", __func__,ret); |
| 511 | return ret; |
| 512 | } |
| 513 | |
| 514 | //sta |
| 515 | ret = sc_wifi_sta_set_status_ind_cb(lynq_user_sta_status_ind); |
| 516 | if (0 != ret) |
| 517 | { |
| 518 | LYERRLOG("[%s ] Request lynq_user_sta_status_ind ret = %d fail\n", __func__,ret); |
| 519 | return ret; |
| 520 | } |
| 521 | ret = sc_wifi_sta_set_scan_result_ind_cb(lynq_user_sta_scan_result_ind); |
| 522 | if (0 != ret) |
| 523 | { |
| 524 | LYERRLOG("[%s ] Request lynq_user_sta_scan_result_ind ret = %d fail\n", __func__,ret); |
| 525 | return ret; |
| 526 | } |
| 527 | //proxy |
| 528 | ret = sc_wifi_set_service_error_cb(lynq_user_wifi_service_error); |
| 529 | if (0 != ret) |
| 530 | { |
| 531 | 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] | 532 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 533 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 534 | |
| 535 | ret = sc_wifi_enable(); |
| 536 | if (0 != ret) |
| 537 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 538 | LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 539 | return ret; |
| 540 | } |
| 541 | LYINFLOG("[%s ]\n", __func__); |
| 542 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | /******************************************************************** |
| 546 | * @brief: qser_wifi_disable, Turn off WiFi |
| 547 | * @return : int, If equal to 0 succeeds, others fail |
| 548 | * @todo: NA |
| 549 | * @see: NA |
| 550 | * @warning: NA |
| 551 | *********************************************************************/ |
| 552 | int qser_wifi_disable(void) |
| 553 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 554 | int ret = -1; |
| 555 | ret = sc_wifi_disable(); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 556 | if (0 != ret) |
| 557 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 558 | LYERRLOG("[%s ] disable ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 559 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 560 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 561 | |
| 562 | ret = sc_wifi_uninit(); |
| 563 | if (0 != ret) |
| 564 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 565 | LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 566 | return ret; |
| 567 | } |
| 568 | LYINFLOG("[%s ]\n", __func__); |
| 569 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /******************************************************************** |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 573 | * @brief: qser_wifi_ap_get_status, Example Query ap working status |
| 574 | * @param type [OUT]: lynq_wifi_ap_status_t *, ap working status |
| 575 | * @return : int, If equal to 0 succeeds, others fail |
| 576 | * @todo: NA |
| 577 | * @see: NA |
| 578 | * @warning: NA |
| 579 | *********************************************************************/ |
| 580 | int qser_wifi_ap_get_status(lynq_wifi_ap_index_e idx, lynq_wifi_ap_status_t *ap_stat) |
| 581 | { |
| 582 | int ret = -1; |
| 583 | sc_wifi_ap_status_t stat; |
| 584 | ret = sc_wifi_ap_get_status((sc_wifi_ap_index_e)idx, &stat); |
| 585 | if (0 != ret) |
| 586 | { |
| 587 | LYERRLOG("[%s ] wifi_ap_get ret = %d\n", __func__,ret); |
| 588 | return ret; |
| 589 | } |
| 590 | LYINFLOG("[%s ] idx = %d ifname = %s status = %d bssid = %s \n", __func__, idx, stat.ifname, stat.status, stat.bssid); |
| 591 | strncpy(ap_stat->ifname, stat.ifname, sizeof(stat.ifname) - 1); |
| 592 | ap_stat->status = (lynq_wifi_status_e)stat.status; |
| 593 | strncpy(ap_stat->bssid, stat.bssid, sizeof(stat.bssid) - 1); |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | /******************************************************************** |
| 598 | * @brief: qser_wifi_ap_acl_set, Set the WiFi2.4G or 5G whitelist |
| 599 | * @param idx [IN]: int, Set 2.4G or 5G |
| 600 | * @param acl_rule [IN]: lynq_wifi_mac_acl_rule_e, Set the blacklist and whitelist mode |
| 601 | * @param mac_list [IN]: char *, Set the mac address of the whitelist |
| 602 | * @return : int, If equal to 0 succeeds, others fail |
| 603 | * @todo: NA |
| 604 | * @see: NA |
| 605 | * @warning: NA |
| 606 | *********************************************************************/ |
| 607 | int qser_wifi_ap_acl_set(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e acl_rule, char *mac_list) |
| 608 | { |
| 609 | int ret = -1; |
| 610 | if (mac_list == NULL) |
| 611 | { |
| 612 | LYERRLOG("[%s ] Null pointer mac_list = 0x%p \n", __func__, mac_list); |
| 613 | return ret; |
| 614 | } |
| 615 | if(acl_rule == LYNQ_WIFI_MAC_ACL_RULE_BLACK) |
| 616 | ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, SC_WIFI_MAC_ACL_RULE_WHITE, mac_list); |
| 617 | ret = sc_wifi_ap_acl_set((sc_wifi_ap_index_e)idx, (sc_wifi_mac_acl_rule_e)acl_rule, mac_list); |
| 618 | if (0 != ret) |
| 619 | { |
| 620 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 621 | return ret; |
| 622 | } |
| 623 | LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, acl_rule, mac_list); |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | /******************************************************************** |
| 628 | * @brief: qser_wifi_ap_acl_get, Get the WiFi2.4G or 5G whitelist |
| 629 | * @param idx [IN]: int, Set 2.4G or 5G |
| 630 | * @param acl_rule [OUT]: lynq_wifi_mac_acl_rule_e *, Get the blacklist and whitelist mode |
| 631 | * @param mac_list [OUT]: char *, Get the mac address of the whitelist |
| 632 | * @return : int, If equal to 0 succeeds, others fail |
| 633 | * @todo: NA |
| 634 | * @see: NA |
| 635 | * @warning: NA |
| 636 | *********************************************************************/ |
| 637 | int qser_wifi_ap_acl_get(lynq_wifi_ap_index_e idx, lynq_wifi_mac_acl_rule_e *acl_rule, char *mac_list) |
| 638 | { |
| 639 | int ret = -1; |
| 640 | sc_wifi_ap_param_t param = {0}; |
| 641 | if (mac_list == NULL || acl_rule == NULL) |
| 642 | { |
| 643 | LYERRLOG("[%s ] Null pointer acl_rule = 0x%p mac_list = 0x%p \n", __func__, acl_rule, mac_list); |
| 644 | return ret; |
| 645 | } |
| 646 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 647 | if (0 != ret) |
| 648 | { |
| 649 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 650 | return ret; |
| 651 | } |
| 652 | *acl_rule = (lynq_wifi_mac_acl_rule_e)param.acl_rule; |
| 653 | strncpy(mac_list, param.mac_list, sizeof(param.mac_list) - 1); |
| 654 | LYINFLOG("[%s ] idx = %d acl_rule = %d mac_list = %s \n", __func__, idx, param.acl_rule, param.mac_list); |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 659 | * @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of 2.4G or 5G |
| 660 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 661 | * @param ssid [IN]: const char *, Set the ssid name |
| 662 | * @return : int, If equal to 0 succeeds, others fail |
| 663 | * @todo: NA |
| 664 | * @see: NA |
| 665 | * @warning: NA |
| 666 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 667 | 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] | 668 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 669 | int ret = -1; |
| 670 | if (ssid == NULL) |
| 671 | { |
| 672 | LYERRLOG("[%s ] Null pointer ssid = 0x%p \n", __func__, ssid); |
| 673 | return ret; |
| 674 | } |
| 675 | ret = sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid); |
| 676 | if (0 != ret) |
| 677 | { |
| 678 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 679 | return ret; |
| 680 | } |
| 681 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, ssid); |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 686 | * @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of 2.4G or 5G |
| 687 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 688 | * @param ssid [OUT]: char *, Get the ssid name |
| 689 | * @return : int, If equal to 0 succeeds, others fail |
| 690 | * @todo: NA |
| 691 | * @see: NA |
| 692 | * @warning: NA |
| 693 | *********************************************************************/ |
| 694 | int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid) |
| 695 | { |
| 696 | int ret = -1; |
| 697 | sc_wifi_ap_param_t param = {0}; |
| 698 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 699 | if (0 != ret) |
| 700 | { |
| 701 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 702 | return ret; |
| 703 | } |
| 704 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, param.ssid); |
| 705 | strncpy(ssid, param.ssid, sizeof(param.ssid) - 1); |
| 706 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 710 | * @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of 2.4G or 5G is hidden |
| 711 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 712 | * @param hide [IN]: bool, Set whether the ssid is hidden |
| 713 | * @return : int, If equal to 0 succeeds, others fail |
| 714 | * @todo: NA |
| 715 | * @see: NA |
| 716 | * @warning: NA |
| 717 | *********************************************************************/ |
| 718 | int qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide) |
| 719 | { |
| 720 | int ret = -1; |
| 721 | ret = sc_wifi_ap_ssid_hidden_set((sc_wifi_ap_index_e)idx, (int)hide); |
| 722 | if (0 != ret) |
| 723 | { |
| 724 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 725 | return ret; |
| 726 | } |
| 727 | LYINFLOG("[%s ] idx = %d hide = %d \n", __func__, idx, hide); |
| 728 | return 0; |
| 729 | } |
| 730 | |
| 731 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 732 | * @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of 2.4G or 5G is hidden |
| 733 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 734 | * @param hide [OUT]: bool *, Get whether the ssid is hidden |
| 735 | * @return : int, If equal to 0 succeeds, others fail |
| 736 | * @todo: NA |
| 737 | * @see: NA |
| 738 | * @warning: NA |
| 739 | *********************************************************************/ |
| 740 | int qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide) |
| 741 | { |
| 742 | int ret = -1; |
| 743 | sc_wifi_ap_param_t param = {0}; |
| 744 | if (hide == NULL) |
| 745 | { |
| 746 | LYERRLOG("[%s ] Null pointer hide = 0x%p \n", __func__, hide); |
| 747 | return ret; |
| 748 | } |
| 749 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 750 | if (0 != ret) |
| 751 | { |
| 752 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 753 | return ret; |
| 754 | } |
| 755 | LYINFLOG("[%s ] idx = %d ssid_hide = %d \n", __func__, idx, param.ssid_hide); |
| 756 | *hide = (bool)param.ssid_hide; |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 761 | * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of 2.4G or 5G |
| 762 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 763 | * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode |
| 764 | * @return : int, If equal to 0 succeeds, others fail |
| 765 | * @todo: NA |
| 766 | * @see: NA |
| 767 | * @warning: NA |
| 768 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 769 | 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] | 770 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 771 | int ret = -1; |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 772 | 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] | 773 | if (0 != ret) |
| 774 | { |
| 775 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 776 | return ret; |
| 777 | } |
| 778 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, mode); |
| 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 783 | * @brief: qser_wifi_ap_mode_get, Get the working protocol mode of 2.4G or 5G |
| 784 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 785 | * @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode |
| 786 | * @return : int, If equal to 0 succeeds, others fail |
| 787 | * @todo: NA |
| 788 | * @see: NA |
| 789 | * @warning: NA |
| 790 | *********************************************************************/ |
| 791 | int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode) |
| 792 | { |
| 793 | int ret = -1; |
| 794 | sc_wifi_ap_param_t param = {0}; |
| 795 | if (mode == NULL) |
| 796 | { |
| 797 | LYERRLOG("[%s ] Null pointer mode = 0x%p \n", __func__, mode); |
| 798 | return ret; |
| 799 | } |
| 800 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 801 | if (0 != ret) |
| 802 | { |
| 803 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 804 | return ret; |
| 805 | } |
| 806 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, param.mode); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 807 | *mode = sc_to_lynq_mode(param.mode); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 808 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 812 | * @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of 2.4G or 5G |
| 813 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 814 | * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth |
| 815 | * @return : int, If equal to 0 succeeds, others fail |
| 816 | * @todo: NA |
| 817 | * @see: NA |
| 818 | * @warning: NA |
| 819 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 820 | 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] | 821 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 822 | int ret = -1; |
| 823 | ret = sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth); |
| 824 | if (0 != ret) |
| 825 | { |
| 826 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 827 | return ret; |
| 828 | } |
| 829 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, bandwidth); |
| 830 | return 0; |
| 831 | } |
| 832 | |
| 833 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 834 | * @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of 2.4G or 5G |
| 835 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 836 | * @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth |
| 837 | * @return : int, If equal to 0 succeeds, others fail |
| 838 | * @todo: NA |
| 839 | * @see: NA |
| 840 | * @warning: NA |
| 841 | *********************************************************************/ |
| 842 | int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth) |
| 843 | { |
| 844 | int ret = -1; |
| 845 | sc_wifi_ap_param_t param = {0}; |
| 846 | if (bandwidth == NULL) |
| 847 | { |
| 848 | LYERRLOG("[%s ] Null pointer bandwidth = 0x%p \n", __func__, bandwidth); |
| 849 | return ret; |
| 850 | } |
| 851 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 852 | if (0 != ret) |
| 853 | { |
| 854 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 855 | return ret; |
| 856 | } |
| 857 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, param.bandwidth); |
| 858 | *bandwidth = (lynq_wifi_bandwidth_type_e)param.bandwidth; |
| 859 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 863 | * @brief: qser_wifi_ap_channel_set, Set the channel for 2.4G or 5G |
| 864 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 865 | * @param country_code [IN]: const char *, Set country code |
| 866 | * @param channel [IN]: int, Set the channel |
| 867 | * @return : int, If equal to 0 succeeds, others fail |
| 868 | * @todo: NA |
| 869 | * @see: NA |
| 870 | * @warning: NA |
| 871 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 872 | 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] | 873 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 874 | int ret = -1; |
| 875 | if (country_code == NULL) |
| 876 | { |
| 877 | LYERRLOG("[%s ] Null pointer country_code = 0x%p \n", __func__, country_code); |
| 878 | return ret; |
| 879 | } |
| 880 | ret = sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel); |
| 881 | if (0 != ret) |
| 882 | { |
| 883 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 884 | return ret; |
| 885 | } |
| 886 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, country_code, channel); |
| 887 | return 0; |
| 888 | } |
| 889 | |
| 890 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 891 | * @brief: qser_wifi_ap_channel_get, Get the channel for 2.4G or 5G |
| 892 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 893 | * @param country_code [OUT]: char *, Get country code |
| 894 | * @param channel [OUT]: int *, Get the channel |
| 895 | * @return : int, If equal to 0 succeeds, others fail |
| 896 | * @todo: NA |
| 897 | * @see: NA |
| 898 | * @warning: NA |
| 899 | *********************************************************************/ |
| 900 | int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel) |
| 901 | { |
| 902 | int ret = -1; |
| 903 | sc_wifi_ap_param_t param = {0}; |
| 904 | if (country_code == NULL || channel == NULL) |
| 905 | { |
| 906 | LYERRLOG("[%s ] Null pointer country_code = 0x%p channel = 0x%p\n", __func__, country_code, channel); |
| 907 | return ret; |
| 908 | } |
| 909 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 910 | if (0 != ret) |
| 911 | { |
| 912 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 913 | return ret; |
| 914 | } |
| 915 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, param.countrycode, param.channel); |
| 916 | strncpy(country_code, param.countrycode, sizeof(param.countrycode) - 1); |
| 917 | *channel = param.channel; |
| 918 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 922 | * @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of 2.4G or 5G |
| 923 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 924 | * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode |
| 925 | * @param auth_passwd [IN]: const char *, Set password |
| 926 | * @return : int, If equal to 0 succeeds, others fail |
| 927 | * @todo: NA |
| 928 | * @see: NA |
| 929 | * @warning: NA |
| 930 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 931 | 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] | 932 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 933 | int ret = -1; |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 934 | if (auth_passwd == NULL) |
| 935 | { |
| 936 | LYERRLOG("[%s ] Null pointer auth_passwd = 0x%p\n", __func__, auth_passwd); |
| 937 | return ret; |
| 938 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 939 | |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 940 | sc_wifi_ap_auth_t auth; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 941 | auth.auth = lynq_to_sc_auth_mode(auth_mode); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 942 | strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 943 | ret = sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth); |
| 944 | if (0 != ret) |
| 945 | { |
| 946 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 947 | return ret; |
| 948 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 949 | 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] | 950 | return 0; |
| 951 | } |
| 952 | |
| 953 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 954 | * @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of 2.4G or 5G |
| 955 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 956 | * @param auth_mode [OUT]: lynq_wifi_auth_e *, Get the security authentication mode |
| 957 | * @param auth_passwd [OUT]: char *, Get password |
| 958 | * @return : int, If equal to 0 succeeds, others fail |
| 959 | * @todo: NA |
| 960 | * @see: NA |
| 961 | * @warning: NA |
| 962 | *********************************************************************/ |
| 963 | int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd) |
| 964 | { |
| 965 | int ret = -1; |
| 966 | sc_wifi_ap_param_t param = {0}; |
| 967 | if (auth_mode == NULL || auth_passwd == NULL) |
| 968 | { |
| 969 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p auth_passwd = 0x%p\n", __func__, auth_mode, auth_passwd); |
| 970 | return ret; |
| 971 | } |
| 972 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 973 | if (0 != ret) |
| 974 | { |
| 975 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 976 | return ret; |
| 977 | } |
| 978 | LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s \n", __func__, idx, param.auth.auth, param.auth.passwd); |
| 979 | strncpy(auth_passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 980 | |
| 981 | *auth_mode = sc_to_lynq_auth_mode(param.auth.auth); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 982 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 983 | } |
| 984 | |
| 985 | /******************************************************************** |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 986 | * @brief: qser_wifi_ap_auth_get_s, Get the security authentication mode , password group_rekey and pairwise of 2.4G or 5G |
| 987 | * @param idx [IN]: int, Set 2.4G or 5G |
| 988 | * @param auth_mode [OUT]: lynq_wifi_ap_auth_t *, Get the security authentication mode |
| 989 | * @return : int, If equal to 0 succeeds, others fail |
| 990 | * @todo: NA |
| 991 | * @see: NA |
| 992 | * @warning: NA |
| 993 | *********************************************************************/ |
| 994 | int qser_wifi_ap_auth_get_s(lynq_wifi_ap_index_e idx, lynq_wifi_ap_auth_t *auth_mode) |
| 995 | { |
| 996 | int ret = -1; |
| 997 | sc_wifi_ap_param_t param = {0}; |
| 998 | if (auth_mode == NULL) |
| 999 | { |
| 1000 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p\n", __func__, auth_mode); |
| 1001 | return ret; |
| 1002 | } |
| 1003 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1004 | if (0 != ret) |
| 1005 | { |
| 1006 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1007 | return ret; |
| 1008 | } |
| 1009 | 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); |
| 1010 | strncpy(auth_mode->passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
| 1011 | auth_mode->group_rekey = param.auth.group_rekey; |
| 1012 | auth_mode->pairwise = (lynq_wifi_auth_wpa_psk_e)param.auth.pairwise; |
| 1013 | auth_mode->auth = sc_to_lynq_auth_mode(param.auth.auth); |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
| 1017 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1018 | * @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for 2.4G or 5G |
| 1019 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1020 | * @param max_sta_num [IN]: int, Set the maximum number |
| 1021 | * @return : int, If equal to 0 succeeds, others fail |
| 1022 | * @todo: NA |
| 1023 | * @see: NA |
| 1024 | * @warning: NA |
| 1025 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1026 | 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] | 1027 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1028 | int ret = -1; |
| 1029 | ret = sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num); |
| 1030 | if (0 != ret) |
| 1031 | { |
| 1032 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1033 | return ret; |
| 1034 | } |
| 1035 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, max_sta_num); |
| 1036 | return 0; |
| 1037 | } |
| 1038 | |
| 1039 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1040 | * @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for 2.4G or 5G |
| 1041 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1042 | * @param max_sta_num [OUT]: int *, Get the maximum number |
| 1043 | * @return : int, If equal to 0 succeeds, others fail |
| 1044 | * @todo: NA |
| 1045 | * @see: NA |
| 1046 | * @warning: NA |
| 1047 | *********************************************************************/ |
| 1048 | int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num) |
| 1049 | { |
| 1050 | int ret = -1; |
| 1051 | sc_wifi_ap_param_t param = {0}; |
| 1052 | if (max_sta_num == NULL) |
| 1053 | { |
| 1054 | LYERRLOG("[%s ] Null pointer max_sta_num = 0x%p\n", __func__,max_sta_num); |
| 1055 | return ret; |
| 1056 | } |
| 1057 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 1058 | if (0 != ret) |
| 1059 | { |
| 1060 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1061 | return ret; |
| 1062 | } |
| 1063 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, param.max_sta_num); |
| 1064 | *max_sta_num = param.max_sta_num; |
| 1065 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | /******************************************************************** |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1069 | * @brief: qser_wifi_lanhost_get_list, Get sta device information received as an ap for 2.4G or 5G |
| 1070 | * @param lynq_arrays [OUT]: lynq_lanhost_ts *, Get sta device information received as an ap |
| 1071 | * @return : int, If equal to 0 succeeds, others fail |
| 1072 | * @todo: NA |
| 1073 | * @see: NA |
| 1074 | * @warning: NA |
| 1075 | *********************************************************************/ |
| 1076 | int qser_wifi_lanhost_get_list(lynq_lanhost_ts *lynq_arrays) |
| 1077 | { |
| 1078 | int ret = -1; |
| 1079 | int i = 0; |
| 1080 | sc_lanhost_t array[32] = {0}; |
| 1081 | if (lynq_arrays == NULL) |
| 1082 | { |
| 1083 | LYERRLOG("[%s ] Null pointer lynq_arrays = 0x%p\n", __func__, lynq_arrays); |
| 1084 | return ret; |
| 1085 | } |
| 1086 | lynq_arrays->array_len = 32; |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 1087 | ret = sc_wifi_lanhost_get_list(array, &lynq_arrays->array_len); |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1088 | if (0 != ret) |
| 1089 | { |
| 1090 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 1091 | return ret; |
| 1092 | } |
| 1093 | LYINFLOG("[%s]ap_lanhost len[%d]\n", __func__, lynq_arrays->array_len); |
| 1094 | for (i = 0; i < lynq_arrays->array_len; i++) |
| 1095 | { |
| 1096 | LYINFLOG("[%s]Element : [%d] ifname = %s macaddr = %s addr = %s name = %s uptime = %d\n", __func__, i, |
| 1097 | array[i].ifname, array[i].macaddr, array[i].addr, array[i].name, array[i].uptime); |
| 1098 | strncpy(lynq_arrays->array[i].ifname, array[i].ifname, sizeof(lynq_arrays->array[i].ifname) - 1); |
| 1099 | strncpy(lynq_arrays->array[i].macaddr, array[i].macaddr, sizeof(lynq_arrays->array[i].macaddr) - 1); |
| 1100 | strncpy(lynq_arrays->array[i].addr, array[i].addr, sizeof(lynq_arrays->array[i].addr) - 1); |
| 1101 | strncpy(lynq_arrays->array[i].name, array[i].name, sizeof(lynq_arrays->array[i].name) - 1); |
| 1102 | lynq_arrays->array[i].uptime = array[i].uptime; |
| 1103 | } |
| 1104 | return 0; |
| 1105 | } |
| 1106 | |
| 1107 | /******************************************************************** |
| 1108 | * @brief: qser_wifi_get_ap_pkt_stats, Obtain data packets sent and received by ap for 2.4G or 5G |
| 1109 | * @param idx [IN]: int, Set 2.4G or 5G |
| 1110 | * @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by ap |
| 1111 | * @return : int, If equal to 0 succeeds, others fail |
| 1112 | * @todo: NA |
| 1113 | * @see: NA |
| 1114 | * @warning: NA |
| 1115 | *********************************************************************/ |
| 1116 | int qser_wifi_get_ap_pkt_stats(lynq_wifi_ap_index_e idx, lynq_wifi_pkt_stats_t *pkt_stat) |
| 1117 | { |
| 1118 | int ret = -1; |
| 1119 | sc_wifi_pkt_stats_t stat = {0}; |
| 1120 | if (pkt_stat == NULL) |
| 1121 | { |
| 1122 | LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat); |
| 1123 | return ret; |
| 1124 | } |
| 1125 | idx = LYNQ_WIFI_AP_INDEX_AP0; |
| 1126 | ret = sc_wifi_get_ap_pkt_stats((sc_wifi_ap_index_e)idx, &stat); |
| 1127 | if (0 != ret) |
| 1128 | { |
| 1129 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 1130 | return ret; |
| 1131 | } |
| 1132 | LYINFLOG("[%s ]ap_pkt_get[%d] rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__, idx, |
| 1133 | stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped, |
| 1134 | stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped); |
| 1135 | pkt_stat->rx_packets = stat.rx_packets; |
| 1136 | pkt_stat->rx_bytes = stat.rx_bytes; |
| 1137 | pkt_stat->rx_errors = stat.rx_errors; |
| 1138 | pkt_stat->rx_dropped = stat.rx_dropped; |
| 1139 | pkt_stat->tx_packets = stat.tx_packets; |
| 1140 | pkt_stat->tx_bytes = stat.tx_bytes; |
| 1141 | pkt_stat->tx_errors = stat.tx_errors; |
| 1142 | pkt_stat->tx_dropped = stat.tx_dropped; |
| 1143 | return 0; |
| 1144 | } |
| 1145 | |
| 1146 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1147 | * @brief: qser_wifi_ap_start, Set the ap mode of 2.4G or 5G to enable |
| 1148 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1149 | * @return : int, If equal to 0 succeeds, others fail |
| 1150 | * @todo: NA |
| 1151 | * @see: NA |
| 1152 | * @warning: NA |
| 1153 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1154 | int qser_wifi_ap_start(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1155 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1156 | int ret = -1; |
| 1157 | ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 1158 | if (0 != ret) |
| 1159 | { |
| 1160 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1161 | return ret; |
| 1162 | } |
| 1163 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 1164 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1168 | * @brief: qser_wifi_ap_stop, Disable ap mode for 2.4G or 5G |
| 1169 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1170 | * @return : int, If equal to 0 succeeds, others fail |
| 1171 | * @todo: NA |
| 1172 | * @see: NA |
| 1173 | * @warning: NA |
| 1174 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1175 | int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1176 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1177 | int ret = -1; |
| 1178 | ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| 1179 | if (0 != ret) |
| 1180 | { |
| 1181 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 1182 | return ret; |
| 1183 | } |
| 1184 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 1185 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 1189 | * @brief: qser_wifi_ap_restart, Set the ap mode of 2.4G or 5G to restart |
| 1190 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1191 | * @return : int, If equal to 0 succeeds, others fail |
| 1192 | * @todo: NA |
| 1193 | * @see: NA |
| 1194 | * @warning: NA |
| 1195 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1196 | int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1197 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1198 | int ret = -1; |
| 1199 | ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1200 | if (0 != ret) |
| 1201 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1202 | LYERRLOG("[%s ] stop ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1203 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1204 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1205 | ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 1206 | if (0 != ret) |
| 1207 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1208 | LYERRLOG("[%s ] start ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1209 | return ret; |
| 1210 | } |
| 1211 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 1212 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1213 | } |
| 1214 | |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1215 | /******************************************************************** |
| 1216 | * @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] | 1217 | * @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] | 1218 | * @return : int, If equal to 0 succeeds, others fail |
| 1219 | * @todo: NA |
| 1220 | * @see: NA |
| 1221 | * @warning: NA |
| 1222 | *********************************************************************/ |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1223 | 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] | 1224 | { |
| 1225 | int ret = -1; |
| 1226 | sc_wifi_sta_param_t stat = {0}; |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1227 | stat.auth = lynq_to_sc_auth_mode(param_stat->auth); |
| 1228 | stat.pairwise = (sc_wifi_auth_wpa_psk_e )param_stat->pairwise; |
| 1229 | strncpy(stat.ssid, param_stat->ssid, sizeof(stat.ssid) - 1); |
| 1230 | strncpy(stat.passwd, param_stat->passwd, sizeof(stat.passwd) - 1); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1231 | ret = sc_wifi_sta_param_set(&stat); |
| 1232 | if (0 != ret) |
| 1233 | { |
| 1234 | LYERRLOG("[%s ] sta_param_set ret = %d\n", __func__,ret); |
| 1235 | return ret; |
| 1236 | } |
| 1237 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1238 | return 0; |
| 1239 | } |
| 1240 | |
| 1241 | /******************************************************************** |
| 1242 | * @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] | 1243 | * @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] | 1244 | * @return : int, If equal to 0 succeeds, others fail |
| 1245 | * @todo: NA |
| 1246 | * @see: NA |
| 1247 | * @warning: NA |
| 1248 | *********************************************************************/ |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1249 | 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] | 1250 | { |
| 1251 | int ret = -1; |
| 1252 | sc_wifi_sta_param_t stat = {0}; |
| 1253 | ret = sc_wifi_sta_param_get(&stat); |
| 1254 | if (0 != ret) |
| 1255 | { |
| 1256 | LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__,ret); |
| 1257 | return ret; |
| 1258 | } |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1259 | param_stat->auth = sc_to_lynq_auth_mode(stat.auth); |
| 1260 | param_stat->pairwise = (lynq_wifi_auth_wpa_psk_e )stat.pairwise; |
| 1261 | strncpy(param_stat->ssid, stat.ssid, sizeof(stat.ssid) - 1); |
| 1262 | strncpy(param_stat->passwd, stat.passwd, sizeof(stat.passwd) -1); |
| 1263 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1264 | return 0; |
| 1265 | } |
| 1266 | |
| 1267 | /******************************************************************** |
| 1268 | * @brief: qser_wifi_sta_get_status, Gets the status value associated with sta |
| 1269 | * @param status_stat [OUT]: lynq_wifi_sta_status_t *, Gets the status value associated with sta |
| 1270 | * @return : int, If equal to 0 succeeds, others fail |
| 1271 | * @todo: NA |
| 1272 | * @see: NA |
| 1273 | * @warning: NA |
| 1274 | *********************************************************************/ |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1275 | 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] | 1276 | { |
| 1277 | int ret = -1; |
| 1278 | sc_wifi_sta_status_t stat; |
| 1279 | ret = sc_wifi_sta_get_status(&stat); |
| 1280 | if (0 != ret) |
| 1281 | { |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1282 | LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__, ret); |
wz.wang | 5bbe6d6 | 2024-05-29 13:39:35 +0800 | [diff] [blame] | 1283 | return ret; |
| 1284 | } |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1285 | print_sta_status(&stat); |
zw.wang | 0044b01 | 2024-08-08 11:48:49 +0800 | [diff] [blame^] | 1286 | sc_to_lynq_sta_status(&stat, status_stat); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1287 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
| 1291 | /******************************************************************** |
wz.wang | 72c432c | 2024-06-18 09:16:26 +0800 | [diff] [blame] | 1292 | * @brief: qser_wifi_get_sta_pkt_stats, Obtain data packets sent and received by sta for 2.4G or 5G |
| 1293 | * @param pkt_stat [OUT]: lynq_wifi_pkt_stats_t *, Obtain data packets sent and received by sta |
| 1294 | * @return : int, If equal to 0 succeeds, others fail |
| 1295 | * @todo: NA |
| 1296 | * @see: NA |
| 1297 | * @warning: NA |
| 1298 | *********************************************************************/ |
| 1299 | int qser_wifi_get_sta_pkt_stats(lynq_wifi_pkt_stats_t *pkt_stat) |
| 1300 | { |
| 1301 | int ret = -1; |
| 1302 | sc_wifi_pkt_stats_t stat = {0}; |
| 1303 | if (pkt_stat == NULL) |
| 1304 | { |
| 1305 | LYERRLOG("[%s ] Null pointer pkt_stat = 0x%p\n", __func__, pkt_stat); |
| 1306 | return ret; |
| 1307 | } |
| 1308 | ret = sc_wifi_get_sta_pkt_stats(&stat); |
| 1309 | if (0 != ret) |
| 1310 | { |
| 1311 | LYERRLOG("[%s ] ret = %d\n", __func__, ret); |
| 1312 | return ret; |
| 1313 | } |
| 1314 | LYINFLOG("[%s ]sta_pkt_get rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu]\n", __func__, |
| 1315 | stat.rx_packets, stat.rx_bytes, stat.rx_errors, stat.rx_dropped, |
| 1316 | stat.tx_packets, stat.tx_bytes, stat.tx_errors, stat.tx_dropped); |
| 1317 | pkt_stat->rx_packets = stat.rx_packets; |
| 1318 | pkt_stat->rx_bytes = stat.rx_bytes; |
| 1319 | pkt_stat->rx_errors = stat.rx_errors; |
| 1320 | pkt_stat->rx_dropped = stat.rx_dropped; |
| 1321 | pkt_stat->tx_packets = stat.tx_packets; |
| 1322 | pkt_stat->tx_bytes = stat.tx_bytes; |
| 1323 | pkt_stat->tx_errors = stat.tx_errors; |
| 1324 | pkt_stat->tx_dropped = stat.tx_dropped; |
| 1325 | return 0; |
| 1326 | } |
| 1327 | |
| 1328 | /******************************************************************** |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 1329 | * @brief: qser_wifi_sta_start_scan, Scan for ap nodes and return them through callback |
| 1330 | * @return : int, If equal to 0 succeeds, others fail |
| 1331 | * @todo: NA |
| 1332 | * @see: NA |
| 1333 | * @warning: NA |
| 1334 | *********************************************************************/ |
| 1335 | int qser_wifi_sta_start_scan(void) |
| 1336 | { |
| 1337 | int ret = -1; |
| 1338 | ret = sc_wifi_sta_start_scan(); |
| 1339 | if (0 != ret) |
| 1340 | { |
| 1341 | LYERRLOG("[%s ] scan ret = %d\n", __func__,ret); |
| 1342 | return ret; |
| 1343 | } |
| 1344 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1345 | return 0; |
| 1346 | } |
| 1347 | |
| 1348 | /******************************************************************** |
| 1349 | * @brief: qser_wifi_sta_start, To enable sta mode, you need to enable ap mode first |
| 1350 | * @return : int, If equal to 0 succeeds, others fail |
| 1351 | * @todo: NA |
| 1352 | * @see: NA |
| 1353 | * @warning: NA |
| 1354 | *********************************************************************/ |
| 1355 | int qser_wifi_sta_start(void) |
| 1356 | { |
| 1357 | int ret = -1; |
| 1358 | ret = sc_wifi_sta_start(); |
| 1359 | if (0 != ret) |
| 1360 | { |
| 1361 | LYERRLOG("[%s ] sta_start ret = %d\n", __func__,ret); |
| 1362 | return ret; |
| 1363 | } |
| 1364 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1365 | return 0; |
| 1366 | } |
| 1367 | |
| 1368 | /******************************************************************** |
| 1369 | * @brief: qser_wifi_sta_stop, To disable sta mode. |
| 1370 | * @return : int, If equal to 0 succeeds, others fail |
| 1371 | * @todo: NA |
| 1372 | * @see: NA |
| 1373 | * @warning: NA |
| 1374 | *********************************************************************/ |
| 1375 | int qser_wifi_sta_stop(void) |
| 1376 | { |
| 1377 | int ret = -1; |
| 1378 | ret = sc_wifi_sta_stop(); |
| 1379 | if (0 != ret) |
| 1380 | { |
| 1381 | LYERRLOG("[%s ] sta_stop ret = %d\n", __func__,ret); |
| 1382 | return ret; |
| 1383 | } |
| 1384 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1385 | return 0; |
| 1386 | } |
| 1387 | |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1388 | DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1389 | |
| 1390 | #ifdef __cplusplus |
| 1391 | } |
| 1392 | #endif |