Wrapped message rewrite#22
Conversation
|
|
||
| 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.
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.
| // 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? |
| 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.
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.
Let's get rid of this for now then.
| // Wrap it to wrapped message | ||
| BurtProto::encode() |
There was a problem hiding this comment.
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.
Maybe delete this so that you get the warning until you're done. Or introduce this in a separate PR
No description provided.