Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libraries/Common/board/ports/filesystem/mnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ static void _fal_mount(void)
{
LOG_I("Block device created for filesystem");

rt_thread_mdelay(200);

/* Try to mount filesystem */
if (dfs_mount("filesystem", "/flash", "lfs", 0, 0) != 0)
{
LOG_W("Mount filesystem failed, try to mkfs");
LOG_E("Mount filesystem failed, try to mkfs");

/* Format filesystem */
rt_thread_mdelay(200);

if (dfs_mkfs("lfs", "filesystem") != 0)
{
LOG_E("mkfs failed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>

#define AP_INFO_DEFAULT_TEXT "SSID: RT-Thread-AP 密码: 123456789 IP:192.168.169.1"

#define EMOJI_NUM 18
#define UI_MSG_DATA_SIZE 128
#define UI_MSG_POOL_SIZE 10
Expand Down Expand Up @@ -449,7 +451,7 @@ static void ui_process_message(const ui_msg_t *msg)
case UI_CMD_SHOW_AP_INFO:
if (s_label_status) lv_label_set_text(s_label_status, "连接中...");
if (s_label_info) lv_label_set_text(s_label_info, "使用手机或电脑连接热点");
if (s_label_output) lv_label_set_text(s_label_output, "SSID: RT-Thread-AP 密码: 123456789 IP:192.168.169.1");
if (s_label_output) lv_label_set_text(s_label_output, msg->data[0] ? msg->data : AP_INFO_DEFAULT_TEXT);
break;

case UI_CMD_SHOW_CONNECTING:
Expand Down Expand Up @@ -654,9 +656,9 @@ void xiaozhi_ui_clear_info(void)
ui_send_message(UI_CMD_CLEAR_INFO, RT_NULL, RT_NULL);
}

void xiaozhi_ui_show_ap_config(void)
void xiaozhi_ui_show_ap_config(const char *ap_info)
{
ui_send_message(UI_CMD_SHOW_AP_INFO, RT_NULL, RT_NULL);
ui_send_message(UI_CMD_SHOW_AP_INFO, ap_info, AP_INFO_DEFAULT_TEXT);
}

void xiaozhi_ui_show_connecting(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ void xiaozhi_ui_clear_info(void);

/**
* @brief Show AP config mode info on screen
* @param ap_info AP info text, e.g. "SSID: xxx 密码: xxx IP:192.168.169.1"
*/
void xiaozhi_ui_show_ap_config(void);
void xiaozhi_ui_show_ap_config(const char *ap_info);

/**
* @brief Show connecting status (for auto-connect from saved config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <cJSON.h>
#include <cy_syslib.h>
#include "wifi_manager.h"
#include "xiaozhi_ui.h"

Expand All @@ -42,6 +43,10 @@ extern int ws_xiaozhi_init(void);
static char s_result_buffer[RESULT_BUF_SIZE];
static rt_bool_t s_sta_connected = RT_FALSE;

/* AP display and runtime config */
static char s_ap_ssid[33] = WIFI_AP_SSID;
static char s_ap_info_text[128] = "SSID: " WIFI_AP_SSID " 密码: " WIFI_AP_PASSWORD " IP:192.168.169.1";

/* Temporary storage for current WiFi credentials */
static char s_saved_ssid[64] = {0};
static char s_saved_password[64] = {0};
Expand All @@ -51,6 +56,17 @@ static struct rt_wlan_info s_scan_result[MAX_SCAN_RESULTS];
static int s_scan_cnt = 0;
static struct rt_wlan_info *s_scan_filter = RT_NULL;

static void wifi_ap_build_runtime_config(void)
{
uint64_t uid = Cy_SysLib_GetUniqueId();
rt_snprintf(s_ap_ssid, sizeof(s_ap_ssid), "%s-%06X", WIFI_AP_SSID, (rt_uint32_t)(uid & 0xFFFFFFU));
rt_snprintf(s_ap_info_text,
sizeof(s_ap_info_text),
"SSID: %s 密码: %s IP:192.168.169.1",
s_ap_ssid,
WIFI_AP_PASSWORD);
}

/*****************************************************************************
* Private Functions - Configuration
*****************************************************************************/
Expand Down Expand Up @@ -377,6 +393,8 @@ static void start_ap_config_mode(void)
{
rt_err_t ret;

wifi_ap_build_runtime_config();

/* Wait for WLAN device ready */
LOG_I("Waiting for WLAN device ready...");
for (int i = 0; i < 20; i++) /* Wait up to 10 seconds */
Expand All @@ -396,13 +414,13 @@ static void start_ap_config_mode(void)
}

/* Start AP */
ret = rt_wlan_start_ap("RT-Thread-AP", "123456789");
ret = rt_wlan_start_ap(s_ap_ssid, WIFI_AP_PASSWORD);
if (ret != RT_EOK)
{
LOG_E("Start AP failed: %d", ret);
return;
}
LOG_I("AP Started -> SSID: RT-Thread-AP Password: 123456789");
LOG_I("AP Started -> SSID: %s Password: %s", s_ap_ssid, WIFI_AP_PASSWORD);

/* Wait for AP network interface ready */
rt_thread_mdelay(1000);
Expand All @@ -414,6 +432,8 @@ static void start_ap_config_mode(void)
webnet_cgi_register("wifi_connect", cgi_wifi_connect);
webnet_cgi_register("wifi_scan", cgi_wifi_scan);

xiaozhi_ui_show_ap_config(s_ap_info_text);

LOG_I("=== WiFi Config Portal Ready ===");
LOG_I("Open browser -> http://192.168.169.1");
}
Expand Down Expand Up @@ -557,9 +577,6 @@ void wifi_manager_init(void)
/* Connection failed or no config, start AP config mode */
LOG_I("Starting AP config mode...");

/* Show AP config info on UI */
xiaozhi_ui_show_ap_config();

start_ap_config_mode();
}

Expand Down
2 changes: 1 addition & 1 deletion projects/Edgi_Talk_M55_XiaoZhi/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/* RT-Thread Kernel */

#define RT_NAME_MAX 8
#define RT_NAME_MAX 20
#define RT_ALIGN_SIZE 8
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
Expand Down
Loading