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 | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 17 | static lynq_wifi_event_s global_event; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 18 | |
| 19 | /******************************************************************** |
| 20 | * @brief: lynq_to_sc_auth_mode, The encryption mode of wifi is changed from api to platform |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 21 | * @return :sc_wifi_auth_e, all |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 22 | * @todo: NA |
| 23 | * @see: NA |
| 24 | * @warning: NA |
| 25 | *********************************************************************/ |
| 26 | static sc_wifi_auth_e lynq_to_sc_auth_mode(lynq_wifi_auth_e auth_mode) |
| 27 | { |
| 28 | sc_wifi_auth_e type; |
| 29 | switch (auth_mode) |
| 30 | { |
| 31 | case LYNQ_WIFI_AUTH_OPEN: |
| 32 | type = SC_WIFI_AUTH_OPEN; |
| 33 | break; |
| 34 | case LYNQ_WIFI_AUTH_WPA2_PSK: |
| 35 | type = SC_WIFI_AUTH_WPA2_PSK; |
| 36 | break; |
| 37 | case LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 38 | type = SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 39 | break; |
| 40 | case LYNQ_WIFI_AUTH_WPA3_PSK: |
| 41 | type = SC_WIFI_AUTH_WPA3_PSK; |
| 42 | break; |
| 43 | case LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 44 | type = SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 45 | break; |
| 46 | default: |
| 47 | type = SC_WIFI_AUTH_MIN; |
| 48 | break; |
| 49 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 50 | return type; |
| 51 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 52 | |
| 53 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 54 | * @brief: sc_to_lynq_auth_mode, The wifi protocol moves from platform to api |
| 55 | * @return :lynq_wifi_auth_e, all |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 56 | * @todo: NA |
| 57 | * @see: NA |
| 58 | * @warning: NA |
| 59 | *********************************************************************/ |
| 60 | static lynq_wifi_auth_e sc_to_lynq_auth_mode(sc_wifi_auth_e auth_mode) |
| 61 | { |
| 62 | lynq_wifi_auth_e type; |
| 63 | switch (auth_mode) |
| 64 | { |
| 65 | case SC_WIFI_AUTH_OPEN: |
| 66 | type = LYNQ_WIFI_AUTH_OPEN; |
| 67 | break; |
| 68 | case SC_WIFI_AUTH_WPA2_PSK: |
| 69 | type = LYNQ_WIFI_AUTH_WPA2_PSK; |
| 70 | break; |
| 71 | case SC_WIFI_AUTH_WPA_WPA2_PSK_BOTH: |
| 72 | type = LYNQ_WIFI_AUTH_WPA_WPA2_PSK_BOTH; |
| 73 | break; |
| 74 | case SC_WIFI_AUTH_WPA3_PSK: |
| 75 | type = LYNQ_WIFI_AUTH_WPA3_PSK; |
| 76 | break; |
| 77 | case SC_WIFI_AUTH_WPA2_WPA3_PSK_BOTH: |
| 78 | type = LYNQ_WIFI_AUTH_WPA2_WPA3_PSK_BOTH; |
| 79 | break; |
| 80 | default: |
| 81 | type = LYNQ_WIFI_AUTH_MIN; |
| 82 | break; |
| 83 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 84 | return type; |
| 85 | } |
| 86 | |
| 87 | /******************************************************************** |
| 88 | * @brief: lynq_to_sc_mode, The wifi protocol is transferred from api to platform |
| 89 | * @return :sc_wifi_ap_mode_type_e, all |
| 90 | * @todo: NA |
| 91 | * @see: NA |
| 92 | * @warning: NA |
| 93 | *********************************************************************/ |
| 94 | static sc_wifi_ap_mode_type_e lynq_to_sc_mode(lynq_wifi_mode_type_e mode) |
| 95 | { |
| 96 | sc_wifi_ap_mode_type_e type; |
| 97 | switch (mode) |
| 98 | { |
| 99 | case LYNQ_WIFI_MODE_80211BGN: |
| 100 | type = SC_WIFI_AP_MODE_80211BGN; |
| 101 | break; |
| 102 | case LYNQ_WIFI_MODE_80211BGNAX_2G: |
| 103 | type = SC_WIFI_AP_MODE_80211BGNAX_2G; |
| 104 | break; |
| 105 | case LYNQ_WIFI_MODE_80211AN: |
| 106 | type = SC_WIFI_AP_MODE_80211AN; |
| 107 | break; |
| 108 | case LYNQ_WIFI_MODE_80211ANAC: |
| 109 | type = SC_WIFI_AP_MODE_80211ANAC; |
| 110 | break; |
| 111 | case LYNQ_WIFI_MODE_80211ANACAX_5G: |
| 112 | type = SC_WIFI_AP_MODE_80211ANACAX_5G; |
| 113 | break; |
| 114 | default: |
| 115 | type = SC_WIFI_AP_MODE_MIN; |
| 116 | break; |
| 117 | } |
| 118 | return type; |
| 119 | } |
| 120 | |
| 121 | /******************************************************************** |
| 122 | * @brief: sc_to_lynq_mode, The encryption mode of wifi is changed from platform to api |
| 123 | * @return :lynq_wifi_mode_type_e, all |
| 124 | * @todo: NA |
| 125 | * @see: NA |
| 126 | * @warning: NA |
| 127 | *********************************************************************/ |
| 128 | static lynq_wifi_mode_type_e sc_to_lynq_mode(sc_wifi_ap_mode_type_e mode) |
| 129 | { |
| 130 | lynq_wifi_mode_type_e type; |
| 131 | switch (mode) |
| 132 | { |
| 133 | case SC_WIFI_AP_MODE_80211BGN: |
| 134 | type = LYNQ_WIFI_MODE_80211BGN; |
| 135 | break; |
| 136 | case SC_WIFI_AP_MODE_80211BGNAX_2G: |
| 137 | type = LYNQ_WIFI_MODE_80211BGNAX_2G; |
| 138 | break; |
| 139 | case SC_WIFI_AP_MODE_80211AN: |
| 140 | type = LYNQ_WIFI_MODE_80211AN; |
| 141 | break; |
| 142 | case SC_WIFI_AP_MODE_80211ANAC: |
| 143 | type = LYNQ_WIFI_MODE_80211ANAC; |
| 144 | break; |
| 145 | case SC_WIFI_AP_MODE_80211ANACAX_5G: |
| 146 | type = LYNQ_WIFI_MODE_80211ANACAX_5G; |
| 147 | break; |
| 148 | default: |
| 149 | type = LYNQ_WIFI_MODE_MIN; |
| 150 | break; |
| 151 | } |
| 152 | return type; |
| 153 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 154 | |
| 155 | /******************************************************************** |
| 156 | * @brief: lynq_user_status, wifi startup callback |
| 157 | * @return : NA |
| 158 | * @todo: NA |
| 159 | * @see: NA |
| 160 | * @warning: NA |
| 161 | *********************************************************************/ |
| 162 | static void lynq_user_status(sc_wifi_enable_status_e pre_status, sc_wifi_enable_status_e status) |
| 163 | { |
| 164 | LYINFLOG("%s:%d,%d\n", __func__, pre_status, status); |
| 165 | } |
| 166 | |
| 167 | /******************************************************************** |
| 168 | * @brief: lynq_user_wifi_service_error, wifi service status callback |
| 169 | * @return : NA |
| 170 | * @todo: NA |
| 171 | * @see: NA |
| 172 | * @warning: NA |
| 173 | *********************************************************************/ |
| 174 | static void lynq_user_wifi_service_error(int error) |
| 175 | { |
| 176 | LYINFLOG("%s: %d\n", __func__, error); |
| 177 | } |
| 178 | |
| 179 | /******************************************************************** |
| 180 | * @brief: lynq_user_ap_status, wifi Obtains the ap status callback |
| 181 | * @return : NA |
| 182 | * @todo: NA |
| 183 | * @see: NA |
| 184 | * @warning: NA |
| 185 | *********************************************************************/ |
| 186 | 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) |
| 187 | { |
| 188 | if(wifi_event_handle != NULL && global_arg != NULL) |
| 189 | { |
| 190 | global_event.idx = (lynq_wifi_ap_index_e)index; |
| 191 | global_event.status = (lynq_wifi_status_e)pre_status; |
| 192 | wifi_event_handle(&global_event, global_arg); |
| 193 | } |
| 194 | else{ |
| 195 | LYINFLOG("%s:%d,%d,%s,%d\n", __func__, index, pre_status, p_msg->ifname, p_msg->status); |
| 196 | } |
| 197 | |
| 198 | } |
| 199 | |
| 200 | /******************************************************************** |
| 201 | * @brief: lynq_user_ap_sta_conn_status, wifi as ap is sta information callback |
| 202 | * @return : NA |
| 203 | * @todo: NA |
| 204 | * @see: NA |
| 205 | * @warning: NA |
| 206 | *********************************************************************/ |
| 207 | static void lynq_user_ap_sta_conn_status(sc_wifi_ap_index_e index, sc_wifi_sta_connect_status_t *p_msg) |
| 208 | { |
| 209 | if(wifi_event_handle != NULL && global_arg != NULL) |
| 210 | { |
| 211 | global_event.idx = (lynq_wifi_ap_index_e)index; |
| 212 | global_event.ap_sta_info.connected = p_msg->is_connected; |
| 213 | strncpy(global_event.ap_sta_info.mac, p_msg->macaddr, |
| 214 | sizeof(global_event.ap_sta_info.mac) <= sizeof(p_msg->macaddr) ? sizeof(global_event.ap_sta_info.mac):sizeof(p_msg->macaddr)); |
| 215 | wifi_event_handle(&global_event, global_arg); |
| 216 | } |
| 217 | else{ |
| 218 | LYINFLOG("%s:%d,%d,%s\n", __func__, index, p_msg->is_connected, p_msg->macaddr); |
| 219 | } |
| 220 | |
| 221 | } |
| 222 | |
| 223 | /******************************************************************** |
| 224 | * @brief: print_sta_status, wifi gets the status callback in sta mode |
| 225 | * @return : NA |
| 226 | * @todo: NA |
| 227 | * @see: NA |
| 228 | * @warning: NA |
| 229 | *********************************************************************/ |
| 230 | static void print_sta_status(sc_wifi_sta_status_t *p_msg) |
| 231 | { |
| 232 | LYINFLOG("%s: %d, %s, %s, %d, %d\n", __func__, p_msg->status, p_msg->ifname, p_msg->ap_bssid, |
| 233 | p_msg->signal_level, p_msg->reason_code); |
| 234 | |
| 235 | if (p_msg->has_addr == 1) { |
| 236 | char addrtxt[48] = {0}; |
| 237 | inet_ntop(AF_INET, &p_msg->addr, addrtxt, sizeof(addrtxt)); |
| 238 | LYINFLOG("%s : addr inet_ntop: %s\n", __func__, addrtxt); |
| 239 | |
| 240 | LYINFLOG("%s : addr: %08X\n", __func__, p_msg->addr.s_addr); |
| 241 | } |
| 242 | |
| 243 | if (p_msg->has_addr6 == 1) { |
| 244 | char addrtxt[48] = {0}; |
| 245 | inet_ntop(AF_INET6, &p_msg->addr6, addrtxt, sizeof(addrtxt)); |
| 246 | LYINFLOG("%s : addr6 inet_ntop: %s\n", __func__, addrtxt); |
| 247 | |
| 248 | LYINFLOG("%s : addr6: %02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X\n",__func__, |
| 249 | p_msg->addr6.s6_addr[0], p_msg->addr6.s6_addr[1], p_msg->addr6.s6_addr[2], p_msg->addr6.s6_addr[3], |
| 250 | p_msg->addr6.s6_addr[4], p_msg->addr6.s6_addr[5], p_msg->addr6.s6_addr[6], p_msg->addr6.s6_addr[7], |
| 251 | p_msg->addr6.s6_addr[8], p_msg->addr6.s6_addr[9], p_msg->addr6.s6_addr[10], p_msg->addr6.s6_addr[11], |
| 252 | p_msg->addr6.s6_addr[12], p_msg->addr6.s6_addr[13], p_msg->addr6.s6_addr[14], p_msg->addr6.s6_addr[15]); |
| 253 | } |
| 254 | LYINFLOG("%s : sta_status end\n",__func__); |
| 255 | } |
| 256 | |
| 257 | /******************************************************************** |
| 258 | * @brief: lynq_user_sta_status_ind, wifi gets the status callback in sta mode |
| 259 | * @return : NA |
| 260 | * @todo: NA |
| 261 | * @see: NA |
| 262 | * @warning: NA |
| 263 | *********************************************************************/ |
| 264 | static void lynq_user_sta_status_ind(sc_wifi_sta_status_e pre_status, |
| 265 | sc_wifi_sta_status_t *p_msg) |
| 266 | { |
| 267 | LYINFLOG("%s : user_sta_status_ind_cb pre:%d, cur:%d\n", __func__, pre_status, p_msg->status); |
| 268 | print_sta_status(p_msg); |
| 269 | } |
| 270 | |
| 271 | /******************************************************************** |
| 272 | * @brief: lynq_user_sta_scan_result_ind, wifi gets the callback of sta mode traversing the hotspot |
| 273 | * @return : NA |
| 274 | * @todo: NA |
| 275 | * @see: NA |
| 276 | * @warning: NA |
| 277 | *********************************************************************/ |
| 278 | static void lynq_user_sta_scan_result_ind(sc_wifi_sta_scan_list_t *p_msg) |
| 279 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 280 | int i = 0; |
| 281 | LYINFLOG("%s : user_sta_scan_result_ind_cb:%d\n", __func__, p_msg->cnt); |
| 282 | if (p_msg->cnt <= 0) |
| 283 | { |
| 284 | return; |
| 285 | } |
| 286 | if (wifi_event_handle_sta != NULL) |
| 287 | { |
| 288 | lynq_wifi_sta_scan_list_t event; |
| 289 | event.cnt = p_msg->cnt; |
| 290 | for (i = 0; i < event.cnt; i++) |
| 291 | { |
| 292 | strncpy(event.info[i].essid, p_msg->info[i].essid, sizeof(p_msg->info[i].essid)); |
| 293 | strncpy(event.info[i].bssid, p_msg->info[i].bssid, sizeof(p_msg->info[i].bssid)); |
| 294 | event.info[i].auth = sc_to_lynq_auth_mode(p_msg->info[i].auth); |
| 295 | event.info[i].cipher = (lynq_wifi_auth_wpa_psk_e)p_msg->info[i].cipher; |
| 296 | event.info[i].channel = p_msg->info[i].channel; |
| 297 | event.info[i].signal_level = p_msg->info[i].signal_level; |
| 298 | } |
| 299 | wifi_event_handle_sta(&event); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | for (i = 0; i < p_msg->cnt; i++) |
| 304 | { |
| 305 | LYINFLOG("%s : ap[%d]:%s,%d,%d,%d,%s,%d\n", __func__, i, p_msg->info[i].essid, sc_to_lynq_auth_mode(p_msg->info[i].auth), |
| 306 | p_msg->info[i].cipher, p_msg->info[i].channel, p_msg->info[i].bssid, p_msg->info[i].signal_level); |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | /******************************************************************** |
| 312 | * @brief: qser_wifi_work_mode_set, 2.4g or 5g working mode Settings |
| 313 | * @param type [IN]: lynq_wifi_work_mode_e, 2.4G or 5G working mode Settings |
| 314 | * @return : int, If equal to 0 succeeds, others fail |
| 315 | * @todo: NA |
| 316 | * @see: NA |
| 317 | * @warning: NA |
| 318 | *********************************************************************/ |
| 319 | int qser_wifi_work_mode_set(lynq_wifi_work_mode_e type) |
| 320 | { |
| 321 | int ret = -1; |
| 322 | ret = sc_wifi_work_mode_set((sc_wifi_work_mode_e)type); |
| 323 | if (0 != ret) |
| 324 | { |
| 325 | LYERRLOG("[%s ] work_mode ret = %d\n", __func__,ret); |
| 326 | return ret; |
| 327 | } |
| 328 | LYINFLOG("[%s ]\n", __func__); |
| 329 | return 0; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /******************************************************************** |
| 333 | * @brief: qser_wifi_register_handle, Register callback functions |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 334 | * @param event_handle [IN]: lynq_wifi_event_handle, Register the ap event callback function |
| 335 | * @param event_handle_sta [IN]: Register sta's event callback function |
| 336 | * @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] | 337 | * @return :int, If equal to 0 succeeds, others fail |
| 338 | * @todo: NA |
| 339 | * @see: NA |
| 340 | * @warning: NA |
| 341 | *********************************************************************/ |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 342 | 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] | 343 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 344 | if((event_handle == NULL && event_handle_sta == NULL) || arg == NULL) |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 345 | { |
| 346 | LYERRLOG("[%s ] NUll pointer event_handle = 0x%p arg = 0x%p\n", __func__, event_handle, arg); |
| 347 | return -1; |
| 348 | } |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 349 | wifi_event_handle_sta = event_handle_sta; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 350 | wifi_event_handle = event_handle; |
| 351 | global_arg = arg; |
| 352 | return 0; |
| 353 | } |
| 354 | |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 355 | /******************************************************************** |
| 356 | * @brief: qser_wifi_enable, Enable WiFi function |
| 357 | * @return : int, If equal to 0 succeeds, others fail |
| 358 | * @todo: NA |
| 359 | * @see: NA |
| 360 | * @warning: NA |
| 361 | *********************************************************************/ |
| 362 | int qser_wifi_enable(void) |
| 363 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 364 | int ret = -1; |
| 365 | ret = sc_wifi_init(); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 366 | if (0 != ret) |
| 367 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 368 | LYERRLOG("[%s ] init wifi ret = %d fail\n", __func__,ret); |
| 369 | return ret; |
| 370 | } |
| 371 | |
| 372 | //wifi |
| 373 | ret = sc_wifi_set_enable_status_ind_cb(lynq_user_status); |
| 374 | if (0 != ret) |
| 375 | { |
| 376 | LYERRLOG("[%s ] Request lynq_user_status ret = %d fail\n", __func__,ret); |
| 377 | return ret; |
| 378 | } |
| 379 | |
| 380 | //ap |
| 381 | ret = sc_wifi_ap_set_status_ind_cb(lynq_user_ap_status); |
| 382 | if (0 != ret) |
| 383 | { |
| 384 | LYERRLOG("[%s ] Request lynq_user_ap_status ret = %d fail\n", __func__,ret); |
| 385 | return ret; |
| 386 | } |
| 387 | ret = sc_wifi_set_ap_sta_connect_ind_cb(lynq_user_ap_sta_conn_status); |
| 388 | if (0 != ret) |
| 389 | { |
| 390 | LYERRLOG("[%s ] Request lynq_user_ap_sta_conn_status ret = %d fail\n", __func__,ret); |
| 391 | return ret; |
| 392 | } |
| 393 | |
| 394 | //sta |
| 395 | ret = sc_wifi_sta_set_status_ind_cb(lynq_user_sta_status_ind); |
| 396 | if (0 != ret) |
| 397 | { |
| 398 | LYERRLOG("[%s ] Request lynq_user_sta_status_ind ret = %d fail\n", __func__,ret); |
| 399 | return ret; |
| 400 | } |
| 401 | ret = sc_wifi_sta_set_scan_result_ind_cb(lynq_user_sta_scan_result_ind); |
| 402 | if (0 != ret) |
| 403 | { |
| 404 | LYERRLOG("[%s ] Request lynq_user_sta_scan_result_ind ret = %d fail\n", __func__,ret); |
| 405 | return ret; |
| 406 | } |
| 407 | //proxy |
| 408 | ret = sc_wifi_set_service_error_cb(lynq_user_wifi_service_error); |
| 409 | if (0 != ret) |
| 410 | { |
| 411 | 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] | 412 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 413 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 414 | |
| 415 | ret = sc_wifi_enable(); |
| 416 | if (0 != ret) |
| 417 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 418 | LYERRLOG("[%s ] enable wifi ret = %d fail\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 419 | return ret; |
| 420 | } |
| 421 | LYINFLOG("[%s ]\n", __func__); |
| 422 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | /******************************************************************** |
| 426 | * @brief: qser_wifi_disable, Turn off WiFi |
| 427 | * @return : int, If equal to 0 succeeds, others fail |
| 428 | * @todo: NA |
| 429 | * @see: NA |
| 430 | * @warning: NA |
| 431 | *********************************************************************/ |
| 432 | int qser_wifi_disable(void) |
| 433 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 434 | int ret = -1; |
| 435 | ret = sc_wifi_disable(); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 436 | if (0 != ret) |
| 437 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 438 | LYERRLOG("[%s ] disable ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 439 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 440 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 441 | |
| 442 | ret = sc_wifi_uninit(); |
| 443 | if (0 != ret) |
| 444 | { |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 445 | LYERRLOG("[%s ] uninit ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 446 | return ret; |
| 447 | } |
| 448 | LYINFLOG("[%s ]\n", __func__); |
| 449 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 453 | * @brief: qser_wifi_ap_ssid_set, Set the name of the ssid of 2.4G or 5G |
| 454 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 455 | * @param ssid [IN]: const char *, Set the ssid name |
| 456 | * @return : int, If equal to 0 succeeds, others fail |
| 457 | * @todo: NA |
| 458 | * @see: NA |
| 459 | * @warning: NA |
| 460 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 461 | 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] | 462 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 463 | int ret = -1; |
| 464 | if (ssid == NULL) |
| 465 | { |
| 466 | LYERRLOG("[%s ] Null pointer ssid = 0x%p \n", __func__, ssid); |
| 467 | return ret; |
| 468 | } |
| 469 | ret = sc_wifi_ap_ssid_set((sc_wifi_ap_index_e)idx, ssid); |
| 470 | if (0 != ret) |
| 471 | { |
| 472 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 473 | return ret; |
| 474 | } |
| 475 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, ssid); |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 480 | * @brief: qser_wifi_ap_ssid_get, Get the name of the ssid of 2.4G or 5G |
| 481 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 482 | * @param ssid [OUT]: char *, Get the ssid name |
| 483 | * @return : int, If equal to 0 succeeds, others fail |
| 484 | * @todo: NA |
| 485 | * @see: NA |
| 486 | * @warning: NA |
| 487 | *********************************************************************/ |
| 488 | int qser_wifi_ap_ssid_get(lynq_wifi_ap_index_e idx, char *ssid) |
| 489 | { |
| 490 | int ret = -1; |
| 491 | sc_wifi_ap_param_t param = {0}; |
| 492 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 493 | if (0 != ret) |
| 494 | { |
| 495 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 496 | return ret; |
| 497 | } |
| 498 | LYINFLOG("[%s ] idx = %d ssid = %s \n", __func__, idx, param.ssid); |
| 499 | strncpy(ssid, param.ssid, sizeof(param.ssid) - 1); |
| 500 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 504 | * @brief: qser_wifi_ap_ssid_hide_set, Set whether the ssid of 2.4G or 5G is hidden |
| 505 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 506 | * @param hide [IN]: bool, Set whether the ssid is hidden |
| 507 | * @return : int, If equal to 0 succeeds, others fail |
| 508 | * @todo: NA |
| 509 | * @see: NA |
| 510 | * @warning: NA |
| 511 | *********************************************************************/ |
| 512 | int qser_wifi_ap_ssid_hide_set(lynq_wifi_ap_index_e idx, bool hide) |
| 513 | { |
| 514 | int ret = -1; |
| 515 | ret = sc_wifi_ap_ssid_hidden_set((sc_wifi_ap_index_e)idx, (int)hide); |
| 516 | if (0 != ret) |
| 517 | { |
| 518 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 519 | return ret; |
| 520 | } |
| 521 | LYINFLOG("[%s ] idx = %d hide = %d \n", __func__, idx, hide); |
| 522 | return 0; |
| 523 | } |
| 524 | |
| 525 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 526 | * @brief: qser_wifi_ap_ssid_hide_get, Get whether the ssid of 2.4G or 5G is hidden |
| 527 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 528 | * @param hide [OUT]: bool *, Get whether the ssid is hidden |
| 529 | * @return : int, If equal to 0 succeeds, others fail |
| 530 | * @todo: NA |
| 531 | * @see: NA |
| 532 | * @warning: NA |
| 533 | *********************************************************************/ |
| 534 | int qser_wifi_ap_ssid_hide_get(lynq_wifi_ap_index_e idx, bool *hide) |
| 535 | { |
| 536 | int ret = -1; |
| 537 | sc_wifi_ap_param_t param = {0}; |
| 538 | if (hide == NULL) |
| 539 | { |
| 540 | LYERRLOG("[%s ] Null pointer hide = 0x%p \n", __func__, hide); |
| 541 | return ret; |
| 542 | } |
| 543 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 544 | if (0 != ret) |
| 545 | { |
| 546 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 547 | return ret; |
| 548 | } |
| 549 | LYINFLOG("[%s ] idx = %d ssid_hide = %d \n", __func__, idx, param.ssid_hide); |
| 550 | *hide = (bool)param.ssid_hide; |
| 551 | return 0; |
| 552 | } |
| 553 | |
| 554 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 555 | * @brief: qser_wifi_ap_mode_set, Set the working protocol mode of 2.4G or 5G |
| 556 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 557 | * @param mode [IN]: lynq_wifi_mode_type_e, Set the working protocol mode |
| 558 | * @return : int, If equal to 0 succeeds, others fail |
| 559 | * @todo: NA |
| 560 | * @see: NA |
| 561 | * @warning: NA |
| 562 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 563 | 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] | 564 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 565 | int ret = -1; |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 566 | 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] | 567 | if (0 != ret) |
| 568 | { |
| 569 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 570 | return ret; |
| 571 | } |
| 572 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, mode); |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 577 | * @brief: qser_wifi_ap_mode_get, Get the working protocol mode of 2.4G or 5G |
| 578 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 579 | * @param mode [OUT]: lynq_wifi_mode_type_e *, Get the working protocol mode |
| 580 | * @return : int, If equal to 0 succeeds, others fail |
| 581 | * @todo: NA |
| 582 | * @see: NA |
| 583 | * @warning: NA |
| 584 | *********************************************************************/ |
| 585 | int qser_wifi_ap_mode_get(lynq_wifi_ap_index_e idx, lynq_wifi_mode_type_e *mode) |
| 586 | { |
| 587 | int ret = -1; |
| 588 | sc_wifi_ap_param_t param = {0}; |
| 589 | if (mode == NULL) |
| 590 | { |
| 591 | LYERRLOG("[%s ] Null pointer mode = 0x%p \n", __func__, mode); |
| 592 | return ret; |
| 593 | } |
| 594 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 595 | if (0 != ret) |
| 596 | { |
| 597 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 598 | return ret; |
| 599 | } |
| 600 | LYINFLOG("[%s ] idx = %d mode = %d \n", __func__, idx, param.mode); |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 601 | *mode = sc_to_lynq_mode(param.mode); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 602 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 606 | * @brief: qser_wifi_ap_bandwidth_set, Set the bandwidth of 2.4G or 5G |
| 607 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 608 | * @param bandwidth [IN]: lynq_wifi_bandwidth_type_e, Set the bandwidth |
| 609 | * @return : int, If equal to 0 succeeds, others fail |
| 610 | * @todo: NA |
| 611 | * @see: NA |
| 612 | * @warning: NA |
| 613 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 614 | 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] | 615 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 616 | int ret = -1; |
| 617 | ret = sc_wifi_ap_bandwidth_set((sc_wifi_ap_index_e)idx, (sc_wifi_bandwidth_e)bandwidth); |
| 618 | if (0 != ret) |
| 619 | { |
| 620 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 621 | return ret; |
| 622 | } |
| 623 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, bandwidth); |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 628 | * @brief: qser_wifi_ap_bandwidth_get, Get the bandwidth of 2.4G or 5G |
| 629 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 630 | * @param bandwidth [OUT]: lynq_wifi_bandwidth_type_e *, Get the bandwidth |
| 631 | * @return : int, If equal to 0 succeeds, others fail |
| 632 | * @todo: NA |
| 633 | * @see: NA |
| 634 | * @warning: NA |
| 635 | *********************************************************************/ |
| 636 | int qser_wifi_ap_bandwidth_get(lynq_wifi_ap_index_e idx, lynq_wifi_bandwidth_type_e *bandwidth) |
| 637 | { |
| 638 | int ret = -1; |
| 639 | sc_wifi_ap_param_t param = {0}; |
| 640 | if (bandwidth == NULL) |
| 641 | { |
| 642 | LYERRLOG("[%s ] Null pointer bandwidth = 0x%p \n", __func__, bandwidth); |
| 643 | return ret; |
| 644 | } |
| 645 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 646 | if (0 != ret) |
| 647 | { |
| 648 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 649 | return ret; |
| 650 | } |
| 651 | LYINFLOG("[%s ] idx = %d bandwidth = %d \n", __func__, idx, param.bandwidth); |
| 652 | *bandwidth = (lynq_wifi_bandwidth_type_e)param.bandwidth; |
| 653 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 657 | * @brief: qser_wifi_ap_channel_set, Set the channel for 2.4G or 5G |
| 658 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 659 | * @param country_code [IN]: const char *, Set country code |
| 660 | * @param channel [IN]: int, Set the channel |
| 661 | * @return : int, If equal to 0 succeeds, others fail |
| 662 | * @todo: NA |
| 663 | * @see: NA |
| 664 | * @warning: NA |
| 665 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 666 | 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] | 667 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 668 | int ret = -1; |
| 669 | if (country_code == NULL) |
| 670 | { |
| 671 | LYERRLOG("[%s ] Null pointer country_code = 0x%p \n", __func__, country_code); |
| 672 | return ret; |
| 673 | } |
| 674 | ret = sc_wifi_ap_cc_ch_set((sc_wifi_ap_index_e)idx, country_code, channel); |
| 675 | if (0 != ret) |
| 676 | { |
| 677 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 678 | return ret; |
| 679 | } |
| 680 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, country_code, channel); |
| 681 | return 0; |
| 682 | } |
| 683 | |
| 684 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 685 | * @brief: qser_wifi_ap_channel_get, Get the channel for 2.4G or 5G |
| 686 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 687 | * @param country_code [OUT]: char *, Get country code |
| 688 | * @param channel [OUT]: int *, Get the channel |
| 689 | * @return : int, If equal to 0 succeeds, others fail |
| 690 | * @todo: NA |
| 691 | * @see: NA |
| 692 | * @warning: NA |
| 693 | *********************************************************************/ |
| 694 | int qser_wifi_ap_channel_get(lynq_wifi_ap_index_e idx, char *country_code, int *channel) |
| 695 | { |
| 696 | int ret = -1; |
| 697 | sc_wifi_ap_param_t param = {0}; |
| 698 | if (country_code == NULL || channel == NULL) |
| 699 | { |
| 700 | LYERRLOG("[%s ] Null pointer country_code = 0x%p channel = 0x%p\n", __func__, country_code, channel); |
| 701 | return ret; |
| 702 | } |
| 703 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 704 | if (0 != ret) |
| 705 | { |
| 706 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 707 | return ret; |
| 708 | } |
| 709 | LYINFLOG("[%s ] idx = %d country_code = %s channel = %d\n", __func__, idx, param.countrycode, param.channel); |
| 710 | strncpy(country_code, param.countrycode, sizeof(param.countrycode) - 1); |
| 711 | *channel = param.channel; |
| 712 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 716 | * @brief: qser_wifi_ap_auth_set, Set the security authentication mode and password of 2.4G or 5G |
| 717 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 718 | * @param auth_mode [IN]: lynq_wifi_auth_e, Set the security authentication mode |
| 719 | * @param auth_passwd [IN]: const char *, Set password |
| 720 | * @return : int, If equal to 0 succeeds, others fail |
| 721 | * @todo: NA |
| 722 | * @see: NA |
| 723 | * @warning: NA |
| 724 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 725 | 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] | 726 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 727 | int ret = -1; |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 728 | if (auth_passwd == NULL) |
| 729 | { |
| 730 | LYERRLOG("[%s ] Null pointer auth_passwd = 0x%p\n", __func__, auth_passwd); |
| 731 | return ret; |
| 732 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 733 | |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 734 | sc_wifi_ap_auth_t auth; |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 735 | auth.auth = lynq_to_sc_auth_mode(auth_mode); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 736 | strncpy(auth.passwd, auth_passwd, sizeof(auth.passwd) - 1); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 737 | ret = sc_wifi_ap_auth_set((sc_wifi_ap_index_e)idx, &auth); |
| 738 | if (0 != ret) |
| 739 | { |
| 740 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 741 | return ret; |
| 742 | } |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 743 | 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] | 744 | return 0; |
| 745 | } |
| 746 | |
| 747 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 748 | * @brief: qser_wifi_ap_auth_get, Get the security authentication mode and password of 2.4G or 5G |
| 749 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 750 | * @param auth_mode [OUT]: lynq_wifi_auth_e *, Get the security authentication mode |
| 751 | * @param auth_passwd [OUT]: char *, Get password |
| 752 | * @return : int, If equal to 0 succeeds, others fail |
| 753 | * @todo: NA |
| 754 | * @see: NA |
| 755 | * @warning: NA |
| 756 | *********************************************************************/ |
| 757 | int qser_wifi_ap_auth_get(lynq_wifi_ap_index_e idx, lynq_wifi_auth_e *auth_mode, char *auth_passwd) |
| 758 | { |
| 759 | int ret = -1; |
| 760 | sc_wifi_ap_param_t param = {0}; |
| 761 | if (auth_mode == NULL || auth_passwd == NULL) |
| 762 | { |
| 763 | LYERRLOG("[%s ] Null pointer auth_mode = 0x%p auth_passwd = 0x%p\n", __func__, auth_mode, auth_passwd); |
| 764 | return ret; |
| 765 | } |
| 766 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 767 | if (0 != ret) |
| 768 | { |
| 769 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 770 | return ret; |
| 771 | } |
| 772 | LYINFLOG("[%s ] idx = %d auth_mode = %d auth_passwd = %s \n", __func__, idx, param.auth.auth, param.auth.passwd); |
| 773 | strncpy(auth_passwd, param.auth.passwd, sizeof(param.auth.passwd) - 1); |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 774 | |
| 775 | *auth_mode = sc_to_lynq_auth_mode(param.auth.auth); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 776 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 780 | * @brief: qser_wifi_ap_max_sta_set, Set the maximum number of STAs for 2.4G or 5G |
| 781 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 782 | * @param max_sta_num [IN]: int, Set the maximum number |
| 783 | * @return : int, If equal to 0 succeeds, others fail |
| 784 | * @todo: NA |
| 785 | * @see: NA |
| 786 | * @warning: NA |
| 787 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 788 | 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] | 789 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 790 | int ret = -1; |
| 791 | ret = sc_wifi_ap_max_sta_num_set((sc_wifi_ap_index_e)idx, max_sta_num); |
| 792 | if (0 != ret) |
| 793 | { |
| 794 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 795 | return ret; |
| 796 | } |
| 797 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, max_sta_num); |
| 798 | return 0; |
| 799 | } |
| 800 | |
| 801 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 802 | * @brief: qser_wifi_ap_max_sta_get, Get the maximum number of STAs for 2.4G or 5G |
| 803 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 804 | * @param max_sta_num [OUT]: int *, Get the maximum number |
| 805 | * @return : int, If equal to 0 succeeds, others fail |
| 806 | * @todo: NA |
| 807 | * @see: NA |
| 808 | * @warning: NA |
| 809 | *********************************************************************/ |
| 810 | int qser_wifi_ap_max_sta_get(lynq_wifi_ap_index_e idx, int *max_sta_num) |
| 811 | { |
| 812 | int ret = -1; |
| 813 | sc_wifi_ap_param_t param = {0}; |
| 814 | if (max_sta_num == NULL) |
| 815 | { |
| 816 | LYERRLOG("[%s ] Null pointer max_sta_num = 0x%p\n", __func__,max_sta_num); |
| 817 | return ret; |
| 818 | } |
| 819 | ret = sc_wifi_ap_param_get((sc_wifi_ap_index_e)idx, ¶m); |
| 820 | if (0 != ret) |
| 821 | { |
| 822 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 823 | return ret; |
| 824 | } |
| 825 | LYINFLOG("[%s ] idx = %d max_sta_num = %d \n", __func__, idx, param.max_sta_num); |
| 826 | *max_sta_num = param.max_sta_num; |
| 827 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 831 | * @brief: qser_wifi_ap_start, Set the ap mode of 2.4G or 5G to enable |
| 832 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 833 | * @return : int, If equal to 0 succeeds, others fail |
| 834 | * @todo: NA |
| 835 | * @see: NA |
| 836 | * @warning: NA |
| 837 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 838 | int qser_wifi_ap_start(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 839 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 840 | int ret = -1; |
| 841 | ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 842 | if (0 != ret) |
| 843 | { |
| 844 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 845 | return ret; |
| 846 | } |
| 847 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 848 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 852 | * @brief: qser_wifi_ap_stop, Disable ap mode for 2.4G or 5G |
| 853 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 854 | * @return : int, If equal to 0 succeeds, others fail |
| 855 | * @todo: NA |
| 856 | * @see: NA |
| 857 | * @warning: NA |
| 858 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 859 | int qser_wifi_ap_stop(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 860 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 861 | int ret = -1; |
| 862 | ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
| 863 | if (0 != ret) |
| 864 | { |
| 865 | LYERRLOG("[%s ] ret = %d\n", __func__,ret); |
| 866 | return ret; |
| 867 | } |
| 868 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 869 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | /******************************************************************** |
wz.wang | 0feef14 | 2024-04-23 18:08:39 +0800 | [diff] [blame] | 873 | * @brief: qser_wifi_ap_restart, Set the ap mode of 2.4G or 5G to restart |
| 874 | * @param idx [IN]: int, Set 2.4G or 5G |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 875 | * @return : int, If equal to 0 succeeds, others fail |
| 876 | * @todo: NA |
| 877 | * @see: NA |
| 878 | * @warning: NA |
| 879 | *********************************************************************/ |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 880 | int qser_wifi_ap_restart(lynq_wifi_ap_index_e idx) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 881 | { |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 882 | int ret = -1; |
| 883 | ret = sc_wifi_ap_stop((sc_wifi_ap_index_e)idx); |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 884 | if (0 != ret) |
| 885 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 886 | LYERRLOG("[%s ] stop ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 887 | return ret; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 888 | } |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 889 | ret = sc_wifi_ap_start((sc_wifi_ap_index_e)idx); |
| 890 | if (0 != ret) |
| 891 | { |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 892 | LYERRLOG("[%s ] start ret = %d\n", __func__,ret); |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 893 | return ret; |
| 894 | } |
| 895 | LYINFLOG("[%s ] idx = %d \n", __func__, idx); |
| 896 | return 0; |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 897 | } |
| 898 | |
wz.wang | 9f65867 | 2024-04-15 14:23:58 +0800 | [diff] [blame] | 899 | /******************************************************************** |
| 900 | * @brief: qser_wifi_sta_param_set, Set the ssid and password that you need to connect to the access point |
| 901 | * @param lynq_stat [IN]: sc_wifi_sta_param_t *, Set parameters such as ssid and password that you want to connect to the access point |
| 902 | * @return : int, If equal to 0 succeeds, others fail |
| 903 | * @todo: NA |
| 904 | * @see: NA |
| 905 | * @warning: NA |
| 906 | *********************************************************************/ |
| 907 | int qser_wifi_sta_param_set(lynq_wifi_sta_param_t *lynq_stat) |
| 908 | { |
| 909 | int ret = -1; |
| 910 | sc_wifi_sta_param_t stat = {0}; |
| 911 | stat.auth = lynq_to_sc_auth_mode(lynq_stat->auth); |
| 912 | stat.pairwise = (sc_wifi_auth_wpa_psk_e )lynq_stat->pairwise; |
| 913 | strncpy(stat.ssid, lynq_stat->ssid, sizeof(stat.ssid)); |
| 914 | strncpy(stat.passwd, lynq_stat->passwd, sizeof(stat.passwd)); |
| 915 | ret = sc_wifi_sta_param_set(&stat); |
| 916 | if (0 != ret) |
| 917 | { |
| 918 | LYERRLOG("[%s ] sta_param_set ret = %d\n", __func__,ret); |
| 919 | return ret; |
| 920 | } |
| 921 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 922 | return 0; |
| 923 | } |
| 924 | |
| 925 | /******************************************************************** |
| 926 | * @brief: qser_wifi_sta_param_get, Get the ssid and password that you need to connect to the access point |
| 927 | * @param lynq_stat [OUT]: sc_wifi_sta_param_t *, Get parameters such as ssid and password that you want to connect to the access point |
| 928 | * @return : int, If equal to 0 succeeds, others fail |
| 929 | * @todo: NA |
| 930 | * @see: NA |
| 931 | * @warning: NA |
| 932 | *********************************************************************/ |
| 933 | int qser_wifi_sta_param_get(lynq_wifi_sta_param_t *lynq_stat) |
| 934 | { |
| 935 | int ret = -1; |
| 936 | sc_wifi_sta_param_t stat = {0}; |
| 937 | ret = sc_wifi_sta_param_get(&stat); |
| 938 | if (0 != ret) |
| 939 | { |
| 940 | LYERRLOG("[%s ] sta_param_get ret = %d\n", __func__,ret); |
| 941 | return ret; |
| 942 | } |
| 943 | lynq_stat->auth = sc_to_lynq_auth_mode(stat.auth); |
| 944 | lynq_stat->pairwise = (lynq_wifi_auth_wpa_psk_e )stat.pairwise; |
| 945 | strncpy(lynq_stat->ssid, stat.ssid, sizeof(stat.ssid)); |
| 946 | strncpy(lynq_stat->passwd, stat.passwd, sizeof(stat.passwd)); |
| 947 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 948 | return 0; |
| 949 | } |
| 950 | |
| 951 | /******************************************************************** |
| 952 | * @brief: qser_wifi_sta_start_scan, Scan for ap nodes and return them through callback |
| 953 | * @return : int, If equal to 0 succeeds, others fail |
| 954 | * @todo: NA |
| 955 | * @see: NA |
| 956 | * @warning: NA |
| 957 | *********************************************************************/ |
| 958 | int qser_wifi_sta_start_scan(void) |
| 959 | { |
| 960 | int ret = -1; |
| 961 | ret = sc_wifi_sta_start_scan(); |
| 962 | if (0 != ret) |
| 963 | { |
| 964 | LYERRLOG("[%s ] scan ret = %d\n", __func__,ret); |
| 965 | return ret; |
| 966 | } |
| 967 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | /******************************************************************** |
| 972 | * @brief: qser_wifi_sta_start, To enable sta mode, you need to enable ap mode first |
| 973 | * @return : int, If equal to 0 succeeds, others fail |
| 974 | * @todo: NA |
| 975 | * @see: NA |
| 976 | * @warning: NA |
| 977 | *********************************************************************/ |
| 978 | int qser_wifi_sta_start(void) |
| 979 | { |
| 980 | int ret = -1; |
| 981 | ret = sc_wifi_sta_start(); |
| 982 | if (0 != ret) |
| 983 | { |
| 984 | LYERRLOG("[%s ] sta_start ret = %d\n", __func__,ret); |
| 985 | return ret; |
| 986 | } |
| 987 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | /******************************************************************** |
| 992 | * @brief: qser_wifi_sta_stop, To disable sta mode. |
| 993 | * @return : int, If equal to 0 succeeds, others fail |
| 994 | * @todo: NA |
| 995 | * @see: NA |
| 996 | * @warning: NA |
| 997 | *********************************************************************/ |
| 998 | int qser_wifi_sta_stop(void) |
| 999 | { |
| 1000 | int ret = -1; |
| 1001 | ret = sc_wifi_sta_stop(); |
| 1002 | if (0 != ret) |
| 1003 | { |
| 1004 | LYERRLOG("[%s ] sta_stop ret = %d\n", __func__,ret); |
| 1005 | return ret; |
| 1006 | } |
| 1007 | LYINFLOG("[%s ] ret = %d \n", __func__, ret); |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
wz.wang | e5a0b91 | 2024-03-22 19:11:59 +0800 | [diff] [blame] | 1011 | DEFINE_LYNQ_LIB_LOG(LYNQ_WIFI) |
wz.wang | 7350413 | 2024-03-19 16:38:37 +0800 | [diff] [blame] | 1012 | |
| 1013 | #ifdef __cplusplus |
| 1014 | } |
| 1015 | #endif |