2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file ui_event_wifi.c
|
|
|
|
|
|
* @brief 此文件中专门实现WIFI事件的处理
|
|
|
|
|
|
*
|
|
|
|
|
|
* 仅仅Debug模式下运行
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author wang xiang en
|
|
|
|
|
|
* @date 2025-04-19
|
|
|
|
|
|
* @version 版本号
|
|
|
|
|
|
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd)
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
#include "ui.h"
|
|
|
|
|
|
#include "esp_err.h"
|
|
|
|
|
|
#include "esp_log.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "FluxWifi.h"
|
|
|
|
|
|
#include "FluxUart.h"
|
|
|
|
|
|
#include "FluxSD.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************ WIFI调节函数 ******************************************* */
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 点击Wifi搜索事件
|
|
|
|
|
|
*
|
|
|
|
|
|
* wifi搜索回调函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
void on_buttonSearchWifi_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
2025-04-19 09:30:40 +08:00
|
|
|
|
/*部分电路板不具有WIFI连接功能*/
|
|
|
|
|
|
#if CONFIG_WIFI_SCAN_ENABLE
|
2025-03-25 11:15:34 +08:00
|
|
|
|
wifi_scan();
|
2025-04-19 09:30:40 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2025-03-25 11:15:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 修改WIFI选定事件
|
|
|
|
|
|
*
|
|
|
|
|
|
* WiFi连接选项修改回调函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
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");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief Wifi连接按键按下回调函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* WIFI连接按键按下回调函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
void on_buttonConnectWifi_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
2025-04-19 09:30:40 +08:00
|
|
|
|
/*部分电路板不具有WIFI连接功能*/
|
|
|
|
|
|
#if CONFIG_WIFI_SCAN_ENABLE
|
2025-03-25 11:15:34 +08:00
|
|
|
|
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();
|
2025-04-19 09:30:40 +08:00
|
|
|
|
#endif
|
2025-03-25 11:15:34 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 清空WIFI密码
|
|
|
|
|
|
*
|
|
|
|
|
|
* WIFI密码清空按键按下回调函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
void on_buttonClearPassword_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Your code here
|
|
|
|
|
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "");
|
|
|
|
|
|
}
|