instead of reading the main config's powermeter struct(s), the individual power meters now are instanciated using a copy of their respective config. this allows to instanciate different power meters with different configs. as a first step, this simplifies instanciating power meters for test purposes.
30 lines
628 B
C++
30 lines
628 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <stdint.h>
|
|
#include <Arduino.h>
|
|
#include "HttpGetter.h"
|
|
#include "Configuration.h"
|
|
#include "PowerMeterSml.h"
|
|
|
|
class PowerMeterHttpSml : public PowerMeterSml {
|
|
public:
|
|
explicit PowerMeterHttpSml(PowerMeterHttpSmlConfig const& cfg)
|
|
: _cfg(cfg) { }
|
|
|
|
bool init() final;
|
|
void loop() final;
|
|
|
|
// returns an empty string on success,
|
|
// returns an error message otherwise.
|
|
String poll();
|
|
|
|
private:
|
|
PowerMeterHttpSmlConfig const _cfg;
|
|
|
|
uint32_t _lastPoll = 0;
|
|
|
|
std::unique_ptr<HttpGetter> _upHttpGetter;
|
|
};
|