This commit is contained in:
Jerry
2025-04-06 16:53:09 +08:00
parent 8eab03f808
commit 25101e659a
3 changed files with 8 additions and 4 deletions

View File

@@ -110,6 +110,9 @@ A: 1. 换根质量较好的或短一些的USB线或换个USB口插入。 <br>
A: 仅刷新app固件后配置是保留的所以无需重新配置。如果刷新了分区表partition.bin会将esp的nvs区刷新这时候需要重新配置。
## Releases
### 1.0.23
* Refine: 修改和风天气请求url。
* Fix: bug(获取holiday返回码)。
### 1.0.22
* 项目开源此项目使用GNU General Public License v3.0许可证授权。详情请参阅LICENSE文件。
* Refine农历计算功能移出。农历功能作为独立库以MIT协议开源

View File

@@ -166,7 +166,7 @@ public:
bool getWeatherNow(Weather& result, const char* key, const char* locid) {
// return getRestfulAPI("https://www.baidu.com", [&result](JsonDocument& json) {
return getRestfulAPI(
"https://devapi.qweather.com/v7/weather/now?key=" + String(key) + "&location=" + String(locid), [&result](JsonDocument& json) {
"https://api.qweather.com/v7/weather/now?key=" + String(key) + "&location=" + String(locid), [&result](JsonDocument& json) {
if (strcmp(json["code"], "200") != 0) {
Serial.print(F("Get weather failed, error: "));
Serial.println(json["code"].as<const char*>());
@@ -189,7 +189,7 @@ public:
// 和风天气 - 逐小时天气预报: https://dev.qweather.com/docs/api/weather/weather-hourly-forecast/
bool getForecastHourly(HourlyForecast& result, const char* key, const char* locid) {
return getRestfulAPI("https://devapi.qweather.com/v7/weather/24h?key=" + String(key) + "&location=" + String(locid), [&result](JsonDocument& json) {
return getRestfulAPI("https://api.qweather.com/v7/weather/24h?key=" + String(key) + "&location=" + String(locid), [&result](JsonDocument& json) {
if (strcmp(json["code"], "200") != 0) {
Serial.print(F("Get hourly forecast failed, error: "));
Serial.println(json["code"].as<const char*>());
@@ -217,7 +217,7 @@ public:
// 和风天气 - 逐天天气预报: https://dev.qweather.com/docs/api/weather/weather-daily-forecast/
bool getForecastDaily(DailyForecast& result, const char* key, const char* locid) {
return getRestfulAPI("https://devapi.qweather.com/v7/weather/3d?key=" + String(key) + "&location=" + String(locid), [&result](JsonDocument& json) {
return getRestfulAPI("https://api.qweather.com/v7/weather/3d?key=" + String(key) + "&location=" + String(locid), [&result](JsonDocument& json) {
if (strcmp(json["code"], "200") != 0) {
Serial.print(F("Get daily forecast failed, error: "));
Serial.println(json["code"].as<const char*>());

View File

@@ -35,7 +35,8 @@ bool getHolidays(Holiday& result, int year, int month) {
}
http.end();
if (int status = doc["code"]) {
int status = doc["code"].as<int>();
if (status != 0) {
Serial.println("Get holidays error.");
return false;
}