-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapped message rewrite #22
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far!
@@ -15,9 +15,10 @@ class BurtProto { | |||
static bool decodeRaw(const uint8_t* buffer, int length, const pb_msgdesc_t* fields, void* message); | |||
|
|||
template<typename T> | |||
static T decode(const uint8_t* buffer, int length, const pb_msgdesc_t* fields) { | |||
static std::optional<T> decode(const uint8_t* buffer, int length, const pb_msgdesc_t* fields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support this and the move to safety in general, but let's be sure to follow up on all the firmware that we did actually check these values.
// bool isResetCode(uint8_t* buffer, int length) { | ||
// return length >= 4 | ||
// && buffer[0] == 0 | ||
// && buffer[1] == 0 | ||
// && buffer[2] == 0 | ||
// && buffer[3] == 0; | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// bool isResetCode(uint8_t* buffer, int length) { | |
// return length >= 4 | |
// && buffer[0] == 0 | |
// && buffer[1] == 0 | |
// && buffer[2] == 0 | |
// && buffer[3] == 0; | |
// } |
switch(msg.type) | ||
{ | ||
case MessageType::HEARTBEAT: | ||
// check sender validity? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary, but we should respond back!
isConnected = false; | ||
break; | ||
case MessageType::COMMAND: | ||
// what special thing we do here other than onMessage(input,length) lil bro |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do a version check first. If the major versions are the same, call onMessage
.
default: | ||
onMessage(input, length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get rid of this for now then.
// Wrap it to wrapped message | ||
BurtProto::encode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you don't actually use encode()
here, but rather first encode the message, then put it as the bytes of the wrapper, then encode the wrapper and send that.
...and it's now that I'm realizing this will cause you some trouble. Read this section of the docs for more background.
|
||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe delete this so that you get the warning until you're done. Or introduce this in a separate PR
No description provided.