100 lines
2.6 KiB
C
100 lines
2.6 KiB
C
|
|
/*此文件中专门实现WIFI事件的处理*/
|
|
|
|
// This file was generated by SquareLine Studio
|
|
// SquareLine Studio version: SquareLine Studio 1.5.1
|
|
// LVGL version: 8.3.6
|
|
// Project name: ESP32S3_UI
|
|
|
|
#include "ui.h"
|
|
#include "esp_err.h"
|
|
#include "esp_log.h"
|
|
|
|
#include "FluxWifi.h"
|
|
#include "FluxUart.h"
|
|
#include "FluxSD.h"
|
|
|
|
|
|
/************************************ WIFI调节函数 ******************************************* */
|
|
|
|
/*wifi搜索回调函数*/
|
|
void on_buttonSearchWifi_clicked(lv_event_t * e)
|
|
{
|
|
wifi_scan();
|
|
}
|
|
|
|
|
|
|
|
/*WiFi连接选项修改回调函数*/
|
|
void on_dropDownWifiName_valueChanged(lv_event_t * e)
|
|
{
|
|
// Your code here
|
|
int currentIndex=0;
|
|
|
|
currentIndex = lv_dropdown_get_selected(e->target);
|
|
|
|
lv_label_set_text_fmt(ui_pageWifiConnect_labelRssi, "RSSI:%d dBm ", ap_info[currentIndex].rssi);
|
|
lv_label_set_text_fmt(ui_pageWifiConnect_labelConnectWifi,"connect to %s",ap_info[currentIndex].ssid);
|
|
|
|
if (strcmp((char*)ap_info[currentIndex].ssid,"yuwell")==0)
|
|
{
|
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "yuwell123456");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*WIFI连接按键按下回调函数*/
|
|
void on_buttonConnectWifi_clicked(lv_event_t * e)
|
|
{
|
|
if(strcmp(lv_label_get_text(ui_pageWifiConnect_labelConnectWifi),"disconnect") == 0 )
|
|
{
|
|
esp_wifi_disconnect();
|
|
ESP_ERROR_CHECK(esp_wifi_stop());
|
|
return;
|
|
}
|
|
|
|
int currentIndex=0;
|
|
ESP_ERROR_CHECK(esp_wifi_stop());
|
|
currentIndex = lv_dropdown_get_selected(ui_pageWifiConnect_dropdownWifiName);
|
|
|
|
|
|
// Your code here
|
|
wifi_config_t wifi_config = {
|
|
.sta = {
|
|
.ssid = "yuwell",
|
|
.password = "yuwell123456",
|
|
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8).
|
|
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
|
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
|
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
|
*/
|
|
.threshold = {
|
|
.authmode = ap_info[currentIndex].authmode,
|
|
},
|
|
.sae_pwe_h2e = WPA3_SAE_PWE_BOTH,
|
|
.sae_h2e_identifier = "",
|
|
},
|
|
};
|
|
|
|
lv_dropdown_get_selected_str(ui_pageWifiConnect_dropdownWifiName,(char*)wifi_config.sta.ssid,32);
|
|
|
|
strncpy((char*)wifi_config.sta.password,lv_textarea_get_text(ui_pageWifiConnect_textAreaWifiPassword),64);
|
|
|
|
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
|
|
|
ESP_ERROR_CHECK(esp_wifi_start() );
|
|
ESP_LOGI("TAG", "wifi_init_sta finished.");
|
|
|
|
esp_wifi_connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*WIFI密码清空按键按下回调函数*/
|
|
void on_buttonClearPassword_clicked(lv_event_t * e)
|
|
{
|
|
// Your code here
|
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "");
|
|
} |