Skip to content
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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Wrapped message rewrite #22

wants to merge 8 commits into from

Conversation

warfarm
Copy link

@warfarm warfarm commented Nov 12, 2024

No description provided.

Copy link
Member

@Levi-Lesches Levi-Lesches left a 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!

BURT_proto.h Outdated Show resolved Hide resolved
@@ -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) {
Copy link
Member

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.

Comment on lines +11 to +17
// bool isResetCode(uint8_t* buffer, int length) {
// return length >= 4
// && buffer[0] == 0
// && buffer[1] == 0
// && buffer[2] == 0
// && buffer[3] == 0;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// bool isResetCode(uint8_t* buffer, int length) {
// return length >= 4
// && buffer[0] == 0
// && buffer[1] == 0
// && buffer[2] == 0
// && buffer[3] == 0;
// }

BURT_serial.cpp Outdated Show resolved Hide resolved
switch(msg.type)
{
case MessageType::HEARTBEAT:
// check sender validity?
Copy link
Member

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!

BURT_serial.cpp Outdated Show resolved Hide resolved
isConnected = false;
break;
case MessageType::COMMAND:
// what special thing we do here other than onMessage(input,length) lil bro
Copy link
Member

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.

Comment on lines +44 to +45
default:
onMessage(input, length);
Copy link
Member

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.

Comment on lines +90 to +91
// Wrap it to wrapped message
BurtProto::encode()
Copy link
Member

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.

Comment on lines +105 to +106

return true;
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants