This commit is contained in:
Siwat Sirichai 2024-02-12 16:15:31 +07:00
parent 8378338ed8
commit 000c06809c
5 changed files with 116 additions and 24 deletions

View file

@ -0,0 +1,27 @@
#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);
};