MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / handleWebResponse

Method handleWebResponse

lib/OpenWeatherPlugin/src/OpenWeatherPlugin.cpp:609–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609void 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;

Callers

nothing calls this directly

Calls 12

c_strMethod · 0.80
parseMethod · 0.45
getHumidityMethod · 0.45
getWeatherIconIdMethod · 0.45
getTemperatureMethod · 0.45
getUvIndexMethod · 0.45
getWindSpeedMethod · 0.45
setWeatherInfoCurrentMethod · 0.45
stopMethod · 0.45
getTemperatureMaxMethod · 0.45
getTemperatureMinMethod · 0.45

Tested by

no test coverage detected