Adafruit Library
Public Member Functions | Public Attributes | List of all members
ws_uart_drv Class Reference

Base class for UART Device Drivers. More...

#include <ws_uart_drv.h>

Inheritance diagram for ws_uart_drv:
ws_uart_drv_pm25aqi

Public Member Functions

 ws_uart_drv (HardwareSerial *hwSerial, int32_t interval)
 Initializes a UART device driver. More...
 
bool isReady ()
 Checks if the UART device is ready to be polled at its time interval. More...
 
void setPrvPollTime (unsigned long curTime)
 Sets the last time a UART device driver was polled. More...
 
const char * getDriverID ()
 Gets the UART device's unique identifier. More...
 
void setDriverID (const char *id)
 Sets the UART driver's identifer. More...
 
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. More...
 
virtual bool begin ()
 Initializes the UART device driver. More...
 
virtual bool read_data ()
 Checks if the UART device's data is ready. More...
 
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. More...
 
virtual void send_data ()
 Reads the UART device's data then packs and sends it to IO.
 

Public Attributes

const char * uartTopic = nullptr
 UART device's MQTT topic.
 
Adafruit_MQTT * mqttClient = nullptr
 Pointer to MQTT client object.
 
unsigned long pollingInterval
 UART device's polling interval, in milliseconds.
 

Detailed Description

Base class for UART Device Drivers.

Constructor & Destructor Documentation

◆ ws_uart_drv()

ws_uart_drv::ws_uart_drv ( HardwareSerial *  hwSerial,
int32_t  interval 
)
inline

Initializes a UART device driver.

Parameters
hwSerialPointer to an instance of a HardwareSerial object.
intervalHow often the UART device will be polled, in milliseconds.

Member Function Documentation

◆ isReady()

bool ws_uart_drv::isReady ( )
inline

Checks if the UART device is ready to be polled at its time interval.

Returns
True if the UART device is ready to be polled, False otherwise.

◆ setPrvPollTime()

void ws_uart_drv::setPrvPollTime ( unsigned long  curTime)
inline

Sets the last time a UART device driver was polled.

Parameters
curTimeThe current time, in milliseconds.

◆ getDriverID()

const char* ws_uart_drv::getDriverID ( )
inline

Gets the UART device's unique identifier.

Returns
The UART device's unique identifier.

◆ setDriverID()

void ws_uart_drv::setDriverID ( const char *  id)
inline

Sets the UART driver's identifer.

Parameters
idThe UART device's unique identifier.

◆ set_mqtt_client()

virtual void ws_uart_drv::set_mqtt_client ( Adafruit_MQTT *  AMQTT,
const char *  mqtt_topic 
)
inlinevirtual

Provides the UART device driver with an instance of the application's MQTT configuration.

Parameters
AMQTTPointer to an Adafruit_MQTT object.
mqtt_topicUART topic string, generated by adafruit MQTT

◆ begin()

virtual bool ws_uart_drv::begin ( )
inlinevirtual

Initializes the UART device driver.

Returns
True if UART device driver initialized successfully, False otherwise.

Reimplemented in ws_uart_drv_pm25aqi.

◆ read_data()

virtual bool ws_uart_drv::read_data ( )
inlinevirtual

Checks if the UART device's data is ready.

Returns
True if data is available, False otherwise.

Reimplemented in ws_uart_drv_pm25aqi.

◆ packUARTResponse()

void ws_uart_drv::packUARTResponse ( wippersnapper_signal_v1_UARTResponse *  msgUARTResponse,
int  event_index,
wippersnapper_i2c_v1_SensorType  sensor_type,
float  sensor_value 
)
inline

Packs the UART device's data into a UARTResponse message.

Parameters
msgUARTResponsePointer to a UARTResponse message.
event_indexIndex of the UART device's event.
sensor_typeType of sensor data.
sensor_valueSensor data value.

The documentation for this class was generated from the following file: