Adafruit Library
Functions | Variables
Wippersnapper.cpp File Reference
#include "Wippersnapper.h"

Functions

bool cbDecodePinConfigMsg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a repeated ConfigurePinRequests messages. More...
 
bool cbDecodeDigitalPinWriteMsg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes repeated PinEvents (digital pin write) messages. More...
 
bool cbSignalMsg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Sets payload callbacks inside the signal message's submessage. More...
 
void cbSignalTopic (char *data, uint16_t len)
 Called when signal topic receives a new message. Fills shared buffer with data from payload. More...
 
void publishI2CResponse (wippersnapper_signal_v1_I2CResponse *msgi2cResponse)
 Publishes an I2C response signal message to the broker. More...
 
bool encodeI2CResponse (wippersnapper_signal_v1_I2CResponse *msgi2cResponse)
 Encodes an wippersnapper_signal_v1_I2CResponse message. More...
 
bool initializeI2CBus (wippersnapper_i2c_v1_I2CBusInitRequest msgInitRequest)
 Initializes an I2C bus component. More...
 
bool cbDecodeI2CDeviceInitRequestList (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a list of I2C Device Initialization messages. More...
 
bool cbDecodeSignalRequestI2C (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes an I2C signal request message and executes the callback based on the message's tag. If successful, publishes an I2C signal response back to the broker. More...
 
void cbSignalI2CReq (char *data, uint16_t len)
 Called when i2c signal sub-topic receives a new message and attempts to decode a signal request message. More...
 
bool cbDecodeServoMsg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a servo message and dispatches to the servo component. More...
 
void cbServoMsg (char *data, uint16_t len)
 Called when the device recieves a new message from the /servo/ topic. More...
 
bool cbPWMDecodeMsg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a servo message and dispatches to the servo component. More...
 
void cbPWMMsg (char *data, uint16_t len)
 Called when the device recieves a new message from the /pwm/ topic. More...
 
bool cbDecodeDs18x20Msg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a Dallas Sensor (ds18x20) signal request message and executes the callback based on the message's tag. More...
 
void cbSignalDSReq (char *data, uint16_t len)
 Called when DallasSensor (DS) signal sub-topic receives a new message and attempts to decode the message. More...
 
bool cbDecodePixelsMsg (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a pixel strand request message and executes the callback based on the message's tag. More...
 
void cbPixelsMsg (char *data, uint16_t len)
 Called when the device recieves a new message from the /pixels/ topic. More...
 
bool cbDecodeUARTMessage (pb_istream_t *stream, const pb_field_t *field, void **arg)
 Decodes a UART message and executes the callback based on the message's tag. More...
 
void cbSignalUARTReq (char *data, uint16_t len)
 Called when the signal UART sub-topic receives a new message. Performs decoding. More...
 
void cbRegistrationStatus (char *data, uint16_t len)
 Called when broker responds to a device's publish across the registration topic. More...
 
void cbErrorTopic (char *errorData, uint16_t len)
 Called when client receives a message published across the Adafruit IO MQTT /error special topic. More...
 
void cbThrottleTopic (char *throttleData, uint16_t len)
 Called when client receives a message published across the Adafruit IO MQTT /throttle special topic. Delays until throttle is released. More...
 
void print_reset_reason (int reason)
 Prints last reset reason of ESP32. More...
 
void printDeviceInfo ()
 Prints information about the WS device to the serial monitor.
 

Variables

Wippersnapper WS
 Global member variable for callbacks. More...
 

Function Documentation

◆ cbDecodePinConfigMsg()

bool cbDecodePinConfigMsg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a repeated ConfigurePinRequests messages.

Parameters
streamInput stream to read from.
fieldMessage descriptor, usually autogenerated.
argStores any information the decoding callback may need.
Returns
True if pin configuration decoded successfully, False otherwise.

◆ cbDecodeDigitalPinWriteMsg()

bool cbDecodeDigitalPinWriteMsg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes repeated PinEvents (digital pin write) messages.

Parameters
streamInput stream to read from.
fieldMessage descriptor, usually autogenerated.
argStores any information the decoding callback may need.
Returns
True if successfully decoded, False otherwise.

◆ cbSignalMsg()

bool cbSignalMsg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Sets payload callbacks inside the signal message's submessage.

Parameters
streamInput stream to read from.
fieldMessage descriptor, usually autogenerated.
argStores any information the decoding callback may need.
Returns
True if successfully decoded, false otherwise.

◆ cbSignalTopic()

void cbSignalTopic ( char *  data,
uint16_t  len 
)

Called when signal topic receives a new message. Fills shared buffer with data from payload.

Parameters
dataData from MQTT broker.
lenLength of data received from MQTT broker.

◆ publishI2CResponse()

void publishI2CResponse ( wippersnapper_signal_v1_I2CResponse *  msgi2cResponse)

Publishes an I2C response signal message to the broker.

Parameters
msgi2cResponseA pointer to an I2C response message typedef.

◆ encodeI2CResponse()

bool encodeI2CResponse ( wippersnapper_signal_v1_I2CResponse *  msgi2cResponse)

Encodes an wippersnapper_signal_v1_I2CResponse message.

Parameters
msgi2cResponseA pointer to an wippersnapper_signal_v1_I2CResponse.
Returns
True if encoded successfully, False otherwise.

◆ initializeI2CBus()

bool initializeI2CBus ( wippersnapper_i2c_v1_I2CBusInitRequest  msgInitRequest)

Initializes an I2C bus component.

Parameters
msgInitRequestA pointer to an i2c bus initialization message.
Returns
True if initialized successfully, False otherwise.

◆ cbDecodeI2CDeviceInitRequestList()

bool cbDecodeI2CDeviceInitRequestList ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a list of I2C Device Initialization messages.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from pb_decode calling function.
Returns
True if decoded successfully, False otherwise.

◆ cbDecodeSignalRequestI2C()

bool cbDecodeSignalRequestI2C ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes an I2C signal request message and executes the callback based on the message's tag. If successful, publishes an I2C signal response back to the broker.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from decoder calling function.
Returns
True if decoded successfully, False otherwise.

◆ cbSignalI2CReq()

void cbSignalI2CReq ( char *  data,
uint16_t  len 
)

Called when i2c signal sub-topic receives a new message and attempts to decode a signal request message.

Parameters
dataIncoming data from MQTT broker.
lenLength of incoming data.

◆ cbDecodeServoMsg()

bool cbDecodeServoMsg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a servo message and dispatches to the servo component.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from decoder calling function.
Returns
True if decoded and executed successfully, False otherwise.

◆ cbServoMsg()

void cbServoMsg ( char *  data,
uint16_t  len 
)

Called when the device recieves a new message from the /servo/ topic.

Parameters
dataIncoming data from MQTT broker.
lenLength of incoming data.

◆ cbPWMDecodeMsg()

bool cbPWMDecodeMsg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a servo message and dispatches to the servo component.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from decoder calling function.
Returns
True if decoded and executed successfully, False otherwise.

◆ cbPWMMsg()

void cbPWMMsg ( char *  data,
uint16_t  len 
)

Called when the device recieves a new message from the /pwm/ topic.

Parameters
dataIncoming data from MQTT broker.
lenLength of incoming data.

◆ cbDecodeDs18x20Msg()

bool cbDecodeDs18x20Msg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a Dallas Sensor (ds18x20) signal request message and executes the callback based on the message's tag.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from decoder calling function.
Returns
True if decoded successfully, False otherwise.

◆ cbSignalDSReq()

void cbSignalDSReq ( char *  data,
uint16_t  len 
)

Called when DallasSensor (DS) signal sub-topic receives a new message and attempts to decode the message.

Parameters
dataIncoming data from MQTT broker.
lenLength of incoming data.

◆ cbDecodePixelsMsg()

bool cbDecodePixelsMsg ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a pixel strand request message and executes the callback based on the message's tag.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from decoder calling function.
Returns
True if decoded successfully, False otherwise.

◆ cbPixelsMsg()

void cbPixelsMsg ( char *  data,
uint16_t  len 
)

Called when the device recieves a new message from the /pixels/ topic.

Parameters
dataIncoming data from MQTT broker.
lenLength of incoming data.

◆ cbDecodeUARTMessage()

bool cbDecodeUARTMessage ( pb_istream_t *  stream,
const pb_field_t *  field,
void **  arg 
)

Decodes a UART message and executes the callback based on the message's tag.

Parameters
streamIncoming data stream from buffer.
fieldProtobuf message's tag type.
argOptional arguments from decoder calling function.
Returns
True if decoded successfully, False otherwise.

◆ cbSignalUARTReq()

void cbSignalUARTReq ( char *  data,
uint16_t  len 
)

Called when the signal UART sub-topic receives a new message. Performs decoding.

Parameters
dataIncoming data from MQTT broker.
lenLength of incoming data.

◆ cbRegistrationStatus()

void cbRegistrationStatus ( char *  data,
uint16_t  len 
)

Called when broker responds to a device's publish across the registration topic.

Parameters
dataData from MQTT broker.
lenLength of data received from MQTT broker.

◆ cbErrorTopic()

void cbErrorTopic ( char *  errorData,
uint16_t  len 
)

Called when client receives a message published across the Adafruit IO MQTT /error special topic.

Parameters
errorDataData from MQTT broker.
lenLength of data received from MQTT broker.

◆ cbThrottleTopic()

void cbThrottleTopic ( char *  throttleData,
uint16_t  len 
)

Called when client receives a message published across the Adafruit IO MQTT /throttle special topic. Delays until throttle is released.

Parameters
throttleDataThrottle message from Adafruit IO.
lenLength of data received from MQTT broker.

◆ print_reset_reason()

void print_reset_reason ( int  reason)

Prints last reset reason of ESP32.

Parameters
reasonThe return code of rtc_get_reset_reason(coreNum)

<1, Vbat power on reset

<3, Software reset digital core

<4, Legacy watch dog reset digital core

<5, Deep Sleep reset digital core

<6, Reset by SLC module, reset digital core

<7, Timer Group0 Watch dog reset digital core

<8, Timer Group1 Watch dog reset digital core

<9, RTC Watch dog Reset digital core

<10, Instrusion tested to reset CPU

<11, Time Group reset CPU

<12, Software reset CPU

<13, RTC Watch dog Reset CPU

<14, for APP CPU, reseted by PRO CPU

<15, Reset when the vdd voltage is not stable

<16, RTC Watch dog reset digital core and rtc module

Variable Documentation

◆ WS

Global member variable for callbacks.

Wippersnapper variable.