| 607 | } |
| 608 | |
| 609 | void OpenWeatherPlugin::handleWebResponse(const DynamicJsonDocument& jsonDoc) |
| 610 | { |
| 611 | IOpenWeatherGeneric* source = getWeatherSourceByStatus(); |
| 612 | |
| 613 | if (nullptr != source) |
| 614 | { |
| 615 | /* Any error? */ |
| 616 | if (true == jsonDoc.isNull()) |
| 617 | { |
| 618 | /* Reset weather request status to avoid to stuck. */ |
| 619 | m_weatherReqStatus = WEATHER_REQUEST_STATUS_IDLE; |
| 620 | } |
| 621 | /* Response received */ |
| 622 | else |
| 623 | { |
| 624 | source->parse(jsonDoc); |
| 625 | |
| 626 | if (WEATHER_REQUEST_STATUS_CURRENT_PENDING == m_weatherReqStatus) |
| 627 | { |
| 628 | /* Handle current weather information. */ |
| 629 | if (nullptr != m_sourceCurrent) |
| 630 | { |
| 631 | _OpenWeatherPlugin::View::WeatherInfoCurrent weatherInfo; |
| 632 | |
| 633 | weatherInfo.humidity = m_sourceCurrent->getHumidity(); |
| 634 | weatherInfo.iconId = m_sourceCurrent->getWeatherIconId(); |
| 635 | weatherInfo.temperature = m_sourceCurrent->getTemperature(); |
| 636 | weatherInfo.uvIndex = m_sourceCurrent->getUvIndex(); |
| 637 | weatherInfo.windSpeed = m_sourceCurrent->getWindSpeed(); |
| 638 | |
| 639 | m_view.setWeatherInfoCurrent(weatherInfo); |
| 640 | |
| 641 | LOG_INFO("Icon id: %s", weatherInfo.iconId.c_str()); |
| 642 | LOG_INFO("Temperature: %0.2f", weatherInfo.temperature); |
| 643 | LOG_INFO("Humidity: %u", weatherInfo.humidity); |
| 644 | LOG_INFO("UV-Index: %0.2f", weatherInfo.uvIndex); |
| 645 | LOG_INFO("Wind speed: %0.2f", weatherInfo.windSpeed); |
| 646 | } |
| 647 | |
| 648 | if (true == _OpenWeatherPlugin::View::isWeatherForecastSupported()) |
| 649 | { |
| 650 | m_weatherReqStatus = WEATHER_REQUEST_STATUS_FORECAST_REQ; |
| 651 | m_requestTimer.stop(); /* Force immediate request in process(). */ |
| 652 | } |
| 653 | else |
| 654 | { |
| 655 | m_weatherReqStatus = WEATHER_REQUEST_STATUS_IDLE; |
| 656 | } |
| 657 | } |
| 658 | else if (true == _OpenWeatherPlugin::View::isWeatherForecastSupported()) |
| 659 | { |
| 660 | if (WEATHER_REQUEST_STATUS_FORECAST_PENDING == m_weatherReqStatus) |
| 661 | { |
| 662 | /* Handle forecast weather information. */ |
| 663 | if (nullptr != m_sourceForecast) |
| 664 | { |
| 665 | uint8_t day; |
| 666 | _OpenWeatherPlugin::View::WeatherInfoForecast weatherInfo; |
nothing calls this directly
no test coverage detected