Skip to content

Commit

Permalink
Fix Web Setting crash
Browse files Browse the repository at this point in the history
  • Loading branch information
chase535 committed Jul 10, 2024
1 parent b3b16fe commit 21c75e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion AIO_Firmware_PIO/src/app/server/web_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void rgb_setting()

void weather_setting()
{
char buf[2048];
char buf[4096];
char key[64];
char timeUpdataInterval[32];
char weatherUpdataInterval[32];
Expand Down
15 changes: 4 additions & 11 deletions AIO_Firmware_PIO/src/app/weather/weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,13 @@ static uint8_t *json_buffer = NULL;

static void write_config(WT_Config *cfg)
{
char tmp[16] = {0};
// 将配置数据保存在文件中(持久化)
String w_data;
cfg->location_info.country.toLowerCase();
w_data = w_data + cfg->key + "\n";
snprintf(tmp, 15, "%lu\n", cfg->weatherUpdataInterval);
w_data += tmp;
snprintf(tmp, 15, "%lu\n", cfg->timeUpdataInterval);
w_data += tmp;
snprintf(tmp, 15, "%u\n", cfg->auto_get_location);
w_data += tmp;
w_data = w_data + String(cfg->weatherUpdataInterval) + "\n";
w_data = w_data + String(cfg->timeUpdataInterval) + "\n";
w_data = w_data + String(cfg->auto_get_location) + "\n";
w_data = w_data + cfg->location_info.country + "\n";
w_data = w_data + cfg->location_info.province + "\n";
w_data = w_data + cfg->location_info.city + "\n";
Expand All @@ -110,7 +106,7 @@ static void read_config(WT_Config *cfg)
{
// 如果有需要持久化配置文件 可以调用此函数将数据存在flash中
// 配置文件名最好以APP名为开头 以".cfg"结尾,以免多个APP读取混乱
char info[128] = {0};
char info[512] = {0};
uint16_t size = g_flashCfg.readFile(WEATHER_CONFIG_PATH, (uint8_t *)info);
info[size] = 0;
if (size == 0)
Expand Down Expand Up @@ -628,9 +624,6 @@ static int weather_exit_callback(void *param)
}

// 释放运行数据
delete cfg_data;
delete run_data;
delete task_param_data;
if (get_response != NULL)
{
free(get_response);
Expand Down

0 comments on commit 21c75e6

Please sign in to comment.