Skip to content

Commit

Permalink
Refine code
Browse files Browse the repository at this point in the history
1. Change the time unit to minutes.
2. Web Setting display tips.
3. Determine whether the setting numbers are compliant.
4. Fix possible memory leak.
5. Change config file name.
6. Fix the end of snprintf string may not be '\0'.
7. Fix Web Setting crash.
  • Loading branch information
chase535 committed Jul 11, 2024
1 parent e66ddc4 commit cef56bf
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 92 deletions.
11 changes: 8 additions & 3 deletions AIO_Firmware_PIO/src/app/server/web_setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ String file_size(int bytes)

#define WEATHER_SETTING "<form method=\"GET\" action=\"saveWeatherConf\">" \
"<label class=\"input\"><span>和风天气KEY</span><input type=\"text\"name=\"key\"value=\"%s\"></label>" \
"<label class=\"input\"><span>天气更新周期(毫秒)</span><input type=\"text\"name=\"weatherUpdataInterval\"value=\"%s\"></label>" \
"<label class=\"input\"><span>日期更新周期(毫秒)</span><input type=\"text\"name=\"timeUpdataInterval\"value=\"%s\"></label>" \
"<label class=\"input\"><span>天气更新周期(分钟)</span><input type=\"text\"name=\"weatherUpdataInterval\"value=\"%s\"></label>" \
"<label class=\"input\"><span>日期更新周期(分钟)</span><input type=\"text\"name=\"timeUpdataInterval\"value=\"%s\"></label>" \
"<label class=\"input\"><span>自动获取位置信息</span><input class=\"radio\" type=\"radio\" value=\"1\" name=\"auto_get_location\" %s>开启(以下设置无效)<input class=\"radio\" type=\"radio\" value=\"0\" name=\"auto_get_location\" %s>关闭</label>" \
"<label class=\"input\"><span>国家(缩写)</span><input type=\"text\"name=\"country\"value=\"%s\"></label>" \
"<label class=\"input\"><span>省、直辖市</span><input type=\"text\"name=\"province\"value=\"%s\"></label>" \
"<label class=\"input\"><span>地级市</span><input type=\"text\"name=\"city\"value=\"%s\"></label>" \
"<label class=\"input\"><span>区、县、县级市</span><input type=\"text\"name=\"area\"value=\"%s\"></label>" \
"<br>" \
"<h3>和风天气免费订阅的KEY每日最多可请求1000次,而程序每次更新天气时需要请求5次</h3>" \
"<h3>请在设置更新周期前提前计算理论的每日最少请数,否则当请求超过1000次后将会请求失败</h3>" \
"<h3>以默认每10分钟更新一次为例,每日最少请求数=24×60÷10×5=720次</h3>" \
"<br>" \
"</label><input class=\"btn\" type=\"submit\" name=\"submit\" value=\"保存\"></form>"

#define WEATHER_OLD_SETTING "<form method=\"GET\" action=\"saveWeatherOldConf\">" \
Expand Down Expand Up @@ -310,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
Loading

0 comments on commit cef56bf

Please sign in to comment.