Adafruit Library
ws_uart.h
Go to the documentation of this file.
1 
16 #ifndef WS_UART_H
17 #define WS_UART_H
18 
19 #include "Wippersnapper.h"
20 #include "drivers/ws_uart_drv.h"
22 
23 /**************************************************************************/
28 /**************************************************************************/
29 class ws_uart {
30 public:
31  ws_uart(){};
32  ~ws_uart(void);
33 
34  void
35  initUARTBus(wippersnapper_uart_v1_UARTDeviceAttachRequest
36  *msgUARTRequest);
37  bool initUARTDevice(wippersnapper_uart_v1_UARTDeviceAttachRequest
38  *msgUARTRequest);
39  bool isUARTBusInitialized();
40  void detachUARTDevice(
41  wippersnapper_uart_v1_UARTDeviceDetachRequest
42  *msgUARTDetachReq);
43  void deinitUARTDevice(const char *device_id);
44  void update();
45 #ifdef USE_SW_UART
47  bool initUARTDevicePM25AQI(SoftwareSerial *swSerial, int32_t pollingInterval,
48  const char *device_id);
49 #else
50  bool initUARTDevicePM25AQI(HardwareSerial *hwSerial, int32_t pollingInterval,
51  const char *device_id);
52 #endif
53 private:
54 #ifdef USE_SW_UART
55  SoftwareSerial *_swSerial = nullptr;
56 #else
57  HardwareSerial *_hwSerial = nullptr;
58 #endif
59  bool _is_bus_initialized = false;
60  std::vector<ws_uart_drv *> uartDrivers;
61  ws_uart_drv_pm25aqi *_pm25aqi = nullptr;
62 };
63 
64 #endif // WS_UART_H
void detachUARTDevice(wippersnapper_uart_v1_UARTDeviceDetachRequest *msgUARTDetachReq)
Detaches a UART device from the UART bus.
Definition: ws_uart.cpp:222
void initUARTBus(wippersnapper_uart_v1_UARTDeviceAttachRequest *msgUARTRequest)
Initializes the UART bus, called once.
Definition: ws_uart.cpp:38
bool initUARTDevicePM25AQI(HardwareSerial *hwSerial, int32_t pollingInterval, const char *device_id)
Initializes the pms5003 device driver using HardwareSerial.
Definition: ws_uart.cpp:116
Class that provides an interface for a PM25 AQI UART sensor.
Definition: ws_uart_drv_pm25aqi.h:27
bool isUARTBusInitialized()
Returns true if the UART bus is initialized.
Definition: ws_uart.cpp:144
void update()
Polls the UART driver for new data and sends it to IO.
Definition: ws_uart.cpp:233
bool initUARTDevice(wippersnapper_uart_v1_UARTDeviceAttachRequest *msgUARTRequest)
Initializes a UART driver.
Definition: ws_uart.cpp:154
~ws_uart(void)
UART class destructor.
Definition: ws_uart.cpp:23
void deinitUARTDevice(const char *device_id)
Deinitializes a device from the UART bus and frees its memory.
Definition: ws_uart.cpp:197
Class that provides an interface between WipperSnapper&#39;s app and the device&#39;s UART bus...
Definition: ws_uart.h:29