Skip to content

Commit 71cb68d

Browse files
committed
Add deserializer hooks
1 parent 209abea commit 71cb68d

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/Wippersnapper.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,21 @@ void cbSignalUARTReq(char *data, uint16_t len) {
16551655
WS_DEBUG_PRINTLN("ERROR: Unable to decode UART Signal message");
16561656
}
16571657

1658+
/*!
1659+
@brief Deserializes a DisplayRequest message and sends it to the display component.
1660+
@param stream
1661+
Incoming data stream from buffer.
1662+
@param field
1663+
Protobuf message's tag type.
1664+
@param arg
1665+
Optional arguments from decoder calling function.
1666+
@returns True if decoded successfully, False otherwise.
1667+
*/
1668+
bool cbDecodeDisplayMsg(pb_istream_t *stream, const pb_field_t *field, void **arg) {
1669+
// TODO: Need to write deserializer logic here
1670+
return true;
1671+
}
1672+
16581673
/*!
16591674
@brief Called when the device receives a new message from the
16601675
/display/ topic.
@@ -1675,14 +1690,12 @@ void cbDisplayMessage(char *data, uint16_t len) {
16751690

16761691
// Set up the payload callback, which will set up the callbacks for
16771692
// each oneof payload field once the field tag is known
1678-
// TODO:
1679-
// WS.msgPixels.cb_payload.funcs.decode = cbDecodePixelsMsg;
1693+
WS.msgSignalDisplay.cb_payload.funcs.decode = cbDecodeDisplayMsg;
16801694

16811695
// Decode pixel message from buffer
16821696
pb_istream_t istream = pb_istream_from_buffer(WS._buffer, WS.bufSize);
1683-
// TODO: Change fields and message type here
1684-
if (!ws_pb_decode(&istream, wippersnapper_signal_v1_PixelsRequest_fields,
1685-
&WS.msgPixels))
1697+
if (!ws_pb_decode(&istream, wippersnapper_signal_v1_DisplayRequest_fields,
1698+
&WS.msgSignalDisplay))
16861699
WS_DEBUG_PRINTLN("ERROR: Unable to decode display message");
16871700
}
16881701

src/Wippersnapper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ class Wippersnapper {
433433
wippersnapper_signal_v1_UARTRequest
434434
msgSignalUART; ///< UARTReq wrapper message
435435

436+
wippersnapper_signal_v1_DisplayRequest msgSignalDisplay;
437+
436438
char *throttleMessage; /*!< Pointer to throttle message data. */
437439
int throttleTime; /*!< Total amount of time to throttle the device, in
438440
milliseconds. */

0 commit comments

Comments
 (0)