UARTPerif class
#include <main/perif/UARTPerif.hpp>
Contents
A peripheral that operates over serial UART. ESP32 has 3 UART bus's, one being the serial used for logging. Most devices using UART on the ESP32 will probably use UART2.
Base classes
- class Perif
Derived classes
- class GPS
Constructors, destructors, conversion operators
-
UARTPerif(const char* name,
uint8_t uart_num,
uint8_t txPin,
uint8_t rxPin,
int baud = DEFAULT_
BAUD) explicit -
UARTPerif(const char* name,
int baud = DEFAULT_
BAUD) explicit
Public functions
- auto begin() -> bool override
- auto isConnected() -> bool override
- void update()
- void registerHook(function<void(DevMap&)>&& hook)
Public variables
Protected functions
- void updateData() pure virtual
- void representData() pure virtual
- auto getTimer() -> Timer&
Protected variables
Function documentation
perif:: UARTPerif:: UARTPerif(const char* name,
uint8_t uart_num,
uint8_t txPin,
uint8_t rxPin,
int baud = DEFAULT_ BAUD) explicit
| Parameters | |
|---|---|
| name | the name of the peripheral |
| uart_num | the UART bus number |
| txPin | the GPIO transmit pin |
| rxPin | the GPIO receive pin |
| baud | the baud rate |
Explicit value constructor for UART devices.
perif:: UARTPerif:: UARTPerif(const char* name,
int baud = DEFAULT_ BAUD) explicit
| Parameters | |
|---|---|
| name | the name of the peripheral |
| baud | the baud rate |
Explicit value constructor for a preconfigured HardwareSerial instance.
bool perif:: UARTPerif:: begin() override
| Returns | whether the peripheral initialization succeeded |
|---|
Performs initialization of a peripheral. Necessary to avoid initialization in the constructor which causes many side effects.
bool perif:: UARTPerif:: isConnected() override
| Returns | if the sensor is connected |
|---|
Returns whether the sensor is connected or not.
void perif:: UARTPerif:: update()
#include <main/perif/Perif.hpp>
Performs a manual update of peripheral data and notifies observers.
void perif:: UARTPerif:: registerHook(function<void(DevMap&)>&& hook)
#include <main/perif/Perif.hpp>
| Parameters | |
|---|---|
| hook | the observer function |
Registers a hook for obtaining sensor data on update in Json format.
void perif:: UARTPerif:: updateData() pure virtual protected
#include <main/perif/Perif.hpp>
Updates sensor data. Subclasses should maintain a reference to the data obtained from this function so it can be provided to observers.
void perif:: UARTPerif:: representData() pure virtual protected
#include <main/perif/Perif.hpp>
The representation of this peripheral's data in a meaningful way for debugging, caching, and database operations.
Timer& perif:: UARTPerif:: getTimer() protected
#include <main/perif/Perif.hpp>
| Returns | a timer reference |
|---|
Obtains a reference to this peripheral's timer.
Variable documentation
DevMap perif:: UARTPerif:: data
#include <main/perif/Perif.hpp>
The key-value mapping of peripheral data.
list<function<void(DevMap&)>> perif:: UARTPerif:: hooks
#include <main/perif/Perif.hpp>
Hooks registered to this peripheral so observers can be notified of any necessary changes.
int perif:: UARTPerif:: baud protected
The baud rate.
uint8_t perif:: UARTPerif:: txPin protected
The transmit GPIO pins.
uint8_t perif:: UARTPerif:: rxPin protected
The receive GPIO pins.
Timer perif:: UARTPerif:: timer protected
#include <main/perif/Perif.hpp>
A timer for managing peripheral updates.