35#ifdef _USE_SYSTEM_JSONLIB
36#include <nlohmann/json.hpp>
56 virtual bool ISNewText(
const char *dev,
const char *name,
char *texts[],
char *names[],
int n)
override;
57 virtual bool ISNewNumber(
const char *dev,
const char *name,
double values[],
char *names[],
int n)
override;
62 virtual bool updateLocation(
double latitude,
double longitude,
double elevation)
override;
74 WF_CONNECTION_TIMEOUT,
79 struct WeatherFlowData
81 double air_temperature = 0.0;
82 double relative_humidity = 0.0;
83 double barometric_pressure = 0.0;
84 double wind_avg = 0.0;
85 double wind_gust = 0.0;
86 double wind_direction = 0.0;
87 double precip_accum_local_day = 0.0;
88 double precip_rate = 0.0;
89 double solar_radiation = 0.0;
91 std::chrono::system_clock::time_point timestamp;
95 bool fetchStationInfo();
96 bool fetchCurrentObservations();
97 bool parseStationResponse(
const std::string &response);
98 bool parseObservationsResponse(
const std::string &response);
99 bool makeAPIRequest(
const std::string &endpoint, std::string &response);
100 bool retryRequest(
const std::function<
bool()> &request);
103 std::string m_stationID;
104 std::string m_deviceID;
105 WeatherFlowData m_lastData;
106 std::chrono::system_clock::time_point m_lastUpdate;
107 bool m_isConnected =
false;
111 const std::string API_HOST =
"swd.weatherflow.com";
112 const std::string STATIONS_ENDPOINT =
"/swd/rest/stations";
113 const std::string OBSERVATIONS_ENDPOINT =
"/swd/rest/observations/station/";
114 const std::string DEVICE_OBSERVATIONS_ENDPOINT =
"/swd/rest/observations/";
117 const int RATE_LIMIT_REQUESTS = 1000;
118 const int RATE_LIMIT_PERIOD = 3600;
119 std::chrono::system_clock::time_point m_lastRequestTime;
120 int m_requestCount = 0;
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState updateWeather() override
updateWeather Update weather conditions from device or service. The function should not change the st...
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update weather station location.
const char * getDefaultName() override
bool Disconnect() override
Disconnect from device.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
a class to store JSON values
basic_json<> json
default specialization