提交 eb1035a1 编写于 作者: CharlesGuo11's avatar CharlesGuo11

解决了看门狗报错问题,点击reset wii即可重新连接

上级 d1e933f6
......@@ -12,6 +12,8 @@
#include "app_rmaker.h"
#include "ui_main.h"
#include "ui_net_config.h"
#include "nvs_flash.h"
#include "nvs.h"
static const char *TAG = "ui_net_config";
......@@ -21,9 +23,16 @@ static lv_obj_t *g_qr = NULL;
static lv_obj_t *g_img = NULL;
static lv_obj_t *g_page = NULL;
static ui_net_state_t g_net_state = UI_NET_EVT_LOARDING;
static void nvs_erase(void);
static void (*g_net_config_end_cb)(void) = NULL;
static void nvs_erase(void){
nvs_flash_erase();
// ESP_LOGI("Wifi is reset, please scan the QR to reconnect the wifi again");
printf("Wifi is reset, please scan the QR to reconnect the wifi again\n");
}
static void ui_app_page_return_click_cb(lv_event_t *e)
{
lv_obj_t *obj = lv_event_get_user_data(e);
......@@ -183,9 +192,25 @@ void ui_net_config_update_cb(ui_net_state_t state, void *args)
lv_img_set_src(g_img, &icon_rmaker);
lv_obj_align(g_img, LV_ALIGN_CENTER, 0, -10);
lv_obj_clear_flag(g_hint_lab, LV_OBJ_FLAG_HIDDEN);
lv_label_set_text_fmt(g_hint_lab, "Device already connected to cloud\n"
"Wi-Fi is connected to #000000 %s#", ssid);
lv_obj_align_to(g_hint_lab, g_img, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
// lv_label_set_text_fmt(g_hint_lab, "Device already connected to cloud\n"
// "Wi-Fi is connected to #000000 %s#", ssid);
// lv_obj_align_to(g_hint_lab, g_img, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
//Create a button to erase the nvs space where the wifi ssid and its password are located
lv_obj_t *wifi_reset=lv_btn_create(g_page);
lv_obj_set_size(wifi_reset, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_add_style(wifi_reset, &ui_button_styles()->style, 0);
lv_obj_add_style(wifi_reset, &ui_button_styles()->style_pr, LV_STATE_PRESSED);
lv_obj_add_style(wifi_reset, &ui_button_styles()->style_focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(wifi_reset, &ui_button_styles()->style_focus, LV_STATE_FOCUSED);
lv_obj_align_to(wifi_reset, g_img,LV_ALIGN_OUT_BOTTOM_MID, -30, 10);
lv_obj_t *reset_label=lv_label_create(wifi_reset);
lv_label_set_text_static(reset_label,"Reset WiFi");
lv_obj_set_style_text_color(reset_label, lv_color_make(18, 18, 18), LV_STATE_DEFAULT);
lv_obj_align(reset_label, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(wifi_reset, nvs_erase, LV_EVENT_CLICKED, NULL);
}
break;
default:
......@@ -232,6 +257,8 @@ void ui_net_config_start(void (*fn)(void))
lv_indev_set_button_points(ui_get_button_indev(), points_array);
}
/* **************** APP NOT INSTALLED **************** */
g_btn_app_hint = lv_btn_create(ui_main_get_status_bar());
lv_obj_set_size(g_btn_app_hint, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
......@@ -240,6 +267,7 @@ void ui_net_config_start(void (*fn)(void))
lv_obj_add_style(g_btn_app_hint, &ui_button_styles()->style_focus, LV_STATE_FOCUS_KEY);
lv_obj_add_style(g_btn_app_hint, &ui_button_styles()->style_focus, LV_STATE_FOCUSED);
lv_obj_align(g_btn_app_hint, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_t *lab_app_inst = lv_label_create(g_btn_app_hint);
lv_label_set_text_static(lab_app_inst, "To install APP");
lv_obj_set_style_text_color(lab_app_inst, lv_color_make(18, 18, 18), LV_STATE_DEFAULT);
......
......@@ -43,6 +43,7 @@
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include"app_wifi.h"
extern bool s_connected;
void * play_sound(const char *path);
......@@ -62,7 +63,6 @@ bool recv_warning_flag=0;
//AED socket
void * aedSocketMonitorFunc(void* args){
while(!s_connected)sleep(60);
while(1){
int emergencyReponseSocket=socket(AF_INET,SOCK_STREAM,0);/*建立socket*/
if(emergencyReponseSocket==-1){
......@@ -367,8 +367,8 @@ void app_main(void)
app_sr_start(false);
app_rmaker_start();
while(!s_connected){sleep(5);};
pthread_t aedMontorThread;
pthread_create(&aedMontorThread,NULL,aedSocketMonitorFunc,NULL);
pthread_join(aedMontorThread,NULL);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册