ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerIoT.hpp

27 lines
886 B
C++
Raw Normal View History

2024-02-12 09:15:31 +00:00
#include <CurrentTransformerCard.hpp>
#include <IoTComponent.hpp>
#include <ExpansionCard.hpp>
#define CT_REQUESTSTATE_TOPIC "requeststate"
#define CT_SET_ENERGY_TOPIC "energy/set"
#define CT_RESET_ENERGY_TOPIC "energy/reset"
#define CT_ENERGY_TOPIC "energy"
#define CT_POWER_TOPIC "power"
#define CT_CURRENT_TOPIC "current"
class CurrentTransformerIoT : public IoTComponent
{
public:
CurrentTransformerIoT();
~CurrentTransformerIoT();
bool begin(uint8_t card_id, ExpansionCard *card, PubSubClient *mqtt, char *base_topic);
void handleMqttMessage(char *topic, char *payload);
void subscribe();
void loop();
void publishReport();
uint8_t getType();
private:
CurrentTransformerCard *currentTransformerCard;
bool processSetEnergyMessage(char* topic, char* payload, uint8_t topic_length);
void handleCTCallback(float current, double energy);
};