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