Claire/include/backend_communication.hpp
admar 7094d20eca Several improvements:
* Fix color mapping of precipitation
* Fix bug in calculation of max value of pollen / AQI
* Added update() method to backend which will only update after interval period has passed
2024-09-07 00:03:53 +02:00

53 lines
No EOL
1 KiB
C++

#ifndef __BACKEND_COMMUNICATION_HPP__
#define __BACKEND_COMMUNICATION_HPP__
#include <Arduino.h>
#include <ArduinoJson.h>
#include "../include/root_ca.hpp"
#include "../include/wifi_handler.hpp"
class BackendCommunication {
public:
// Public enums
enum State { ERROR, STILL_VALID, UPDATED };
public:
// Constructor
BackendCommunication(WifiHandler& p_wifi_handler);
public:
// Public methods
bool getConfig();
bool getWeatherData();
State update();
private:
// Private methods
bool parseConfig(String& p_payload);
bool parseWeatherData(String& p_payload);
String urlencode(String str);
public:
// Public member objects
JsonDocument m_config;
bool m_is_config_valid;
String m_config_timestamp;
JsonDocument m_weather_data;
int32_t m_next_call;
private:
// Private static members
constexpr static uint32_t INTERVAL_MS = 60U * 1000U;
private:
// Private member objects
WifiHandler& m_wifi_handler;
};
#endif // __BACKEND_COMMUNICATION_HPP__