19 #include <Adafruit_Sensor.h> 24 #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_RP2040) 26 #include <SoftwareSerial.h> 28 #include <HardwareSerial.h> 48 ws_uart_drv(SoftwareSerial *swSerial, int32_t interval){};
125 virtual bool begin() {
return false; }
150 wippersnapper_i2c_v1_SensorType sensor_type,
151 float sensor_value) {
152 msgUARTResponse->payload.resp_uart_device_event.sensor_event[event_index]
154 msgUARTResponse->payload.resp_uart_device_event.sensor_event[event_index]
155 .value = sensor_value;
170 long _prvPoll = millis() - (24 * 60 * 60 * 1000);
172 const char *_driverID =
nullptr;
175 #endif // WS_UART_DRV_H const char * getDriverID()
Gets the UART device's unique identifier.
Definition: ws_uart_drv.h:92
virtual bool read_data()
Checks if the UART device's data is ready.
Definition: ws_uart_drv.h:133
virtual void send_data()
Reads the UART device's data then packs and sends it to IO.
Definition: ws_uart_drv.h:163
virtual void set_mqtt_client(Adafruit_MQTT *AMQTT, const char *mqtt_topic)
Provides the UART device driver with an instance of the application's MQTT configuration.
Definition: ws_uart_drv.h:113
unsigned long pollingInterval
UART device's polling interval, in milliseconds.
Definition: ws_uart_drv.h:168
const char * uartTopic
UART device's MQTT topic.
Definition: ws_uart_drv.h:165
ws_uart_drv(HardwareSerial *hwSerial, int32_t interval)
Initializes a UART device driver.
Definition: ws_uart_drv.h:59
virtual bool begin()
Initializes the UART device driver.
Definition: ws_uart_drv.h:125
Adafruit_MQTT * mqttClient
Pointer to MQTT client object.
Definition: ws_uart_drv.h:166
void setPrvPollTime(unsigned long curTime)
Sets the last time a UART device driver was polled.
Definition: ws_uart_drv.h:84
void packUARTResponse(wippersnapper_signal_v1_UARTResponse *msgUARTResponse, int event_index, wippersnapper_i2c_v1_SensorType sensor_type, float sensor_value)
Packs the UART device's data into a UARTResponse message.
Definition: ws_uart_drv.h:148
bool isReady()
Checks if the UART device is ready to be polled at its time interval.
Definition: ws_uart_drv.h:70
Base class for UART Device Drivers.
Definition: ws_uart_drv.h:36
void setDriverID(const char *id)
Sets the UART driver's identifer.
Definition: ws_uart_drv.h:101