-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #584 from adafruit/pb-error-msgs
Pb error msgs
- Loading branch information
Showing
17 changed files
with
570 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*! | ||
* @file ws_pb_helpers.cpp | ||
* | ||
* Protobuf encode/decode helpers with error logging for Wippersnapper. | ||
* | ||
* Adafruit invests time and resources providing this open source code, | ||
* please support Adafruit and open-source hardware by purchasing | ||
* products from Adafruit! | ||
* | ||
* Copyright (c) Tyeth Gundry 2024 for Adafruit Industries. | ||
* | ||
* BSD license, all text here must be included in any redistribution. | ||
* | ||
*/ | ||
|
||
#include "ws_pb_helpers.h" | ||
#include "../Wippersnapper.h" | ||
|
||
// ***************************************************************************** | ||
/*! | ||
@brief Decodes a protobuf message from a stream and prints any error. | ||
@param stream | ||
The stream to decode from. | ||
@param fields | ||
The protobuf message fields. | ||
@param dest_struct | ||
The destination struct to decode into. | ||
@return True if decode was successful, false otherwise. | ||
!*/ | ||
// ***************************************************************************** | ||
bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, | ||
void *dest_struct) { | ||
bool status = pb_decode(stream, fields, dest_struct); | ||
if (!status) { | ||
WS_DEBUG_PRINT("Protobuf decode error: "); | ||
WS_DEBUG_PRINTLN(PB_GET_ERROR(stream)); | ||
} | ||
return status; | ||
} | ||
|
||
// ***************************************************************************** | ||
/*! | ||
@brief Encodes a protobuf message to a stream and prints any error. | ||
@param stream | ||
The stream to encode to. | ||
@param fields | ||
The protobuf message fields. | ||
@param src_struct | ||
The source struct to encode from. | ||
@return True if encode was successful, false otherwise. | ||
!*/ | ||
// ***************************************************************************** | ||
bool ws_pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, | ||
const void *src_struct) { | ||
bool status = pb_encode(stream, fields, src_struct); | ||
if (!status) { | ||
WS_DEBUG_PRINT("Protobuf encode error: "); | ||
WS_DEBUG_PRINTLN(PB_GET_ERROR(stream)); | ||
} | ||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*! | ||
* @file ws_pb_helpers.h | ||
* | ||
* Protobuf encode/decode helpers with error logging for Wippersnapper. | ||
* | ||
* Adafruit invests time and resources providing this open source code, | ||
* please support Adafruit and open-source hardware by purchasing | ||
* products from Adafruit! | ||
* | ||
* Copyright (c) Tyeth Gundry 2024 for Adafruit Industries. | ||
* | ||
* BSD license, all text here must be included in any redistribution. | ||
* | ||
*/ | ||
#ifndef WS_PB_ENCODE_H | ||
#define WS_PB_ENCODE_H | ||
|
||
#include "pb.h" | ||
#include "pb_decode.h" | ||
#include "pb_encode.h" | ||
|
||
bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, | ||
void *dest_struct); | ||
|
||
bool ws_pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, | ||
const void *src_struct); | ||
|
||
#endif // WS_PB_ENCODE_H |
Oops, something went wrong.