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