Use a struct packet instead of an array #14
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are flaws in the library's handling of packet transmission and reception that result in buffer overflows and memory corruption. I'm fairly certain these are specifically due to the use of short uint8_t arrays to send and receive packets; where the arrays are based on the sent packet payload without regard to the length of the respond payload. There are even compiler warnings about this.
My fix is to utilize a single struct that encompasses all the fields of the packet, and names them. I'm currently using a fixed body of 64 bytes, which may be excessive; but I don't know the protocol well enough to know what the largest actual packet size would be.
This works for my use case, seems reliable, and does not exhibit the system-breaking behavior of the existing library's overflows.