ESPMegaPRO-v3-SDK/Template Project/lib/ESPMegaPRO/DigitalInputIoT.hpp

23 lines
740 B
C++
Raw Normal View History

2023-12-28 05:46:39 +00:00
#pragma once
2023-12-27 20:09:41 +00:00
2023-12-28 05:46:39 +00:00
#include <IoTComponent.hpp>
2023-12-27 20:09:41 +00:00
#include <DigitalInputCard.hpp>
2023-12-28 13:20:49 +00:00
#include <FRAM.h>
2023-12-28 05:46:39 +00:00
2023-12-28 12:11:12 +00:00
#define PUBLISH_ENABLE_TOPIC "publish_enable"
2023-12-28 05:46:39 +00:00
class DigitalInputIoT : public IoTComponent {
2023-12-27 20:09:41 +00:00
public:
2023-12-28 16:28:21 +00:00
bool begin(uint8_t card_id, ExpansionCard *card, PubSubClient *mqtt, char *base_topic);
2023-12-27 20:09:41 +00:00
void handleMqttMessage(char *topic, char *payload);
void publishDigitalInputs();
2023-12-28 12:11:12 +00:00
void publishDigitalInput(uint8_t pin);
2023-12-27 20:09:41 +00:00
void setDigitalInputsPublishEnabled(bool enabled);
void handleValueChange(uint8_t pin, uint8_t value);
2023-12-28 06:14:18 +00:00
void publishReport();
2023-12-28 13:20:49 +00:00
void subscribe();
2023-12-28 06:14:18 +00:00
uint8_t getType();
2023-12-27 20:09:41 +00:00
private:
bool digital_inputs_publish_enabled = false;
DigitalInputCard *card;
};