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