Skip to content

Conversation

@liamcottle
Copy link
Member

This PR implements frame header parsing for the TCP/WiFI interface used in the companion firmware.

Currently, it's possible for the WiFi firmware to crash if you send TCP packets faster than the firmware can process them.
This happens due to client.available() having more bytes available than the MAX_FRAME_SIZE allows for.
The current implementation tries to copy all of the available bytes into the buffer, resulting in overflow/stack smashing.

I've added parsing of the protocol provided frame header, which tells us how many bytes we should expect to follow.
If we haven't received enough bytes yet, which could happen on slow links, it will wait for the next loop and check again.

I've been working on fast channel syncing in the mobile app, which works on BLE connections, however noticed the WiFi firmware would crash due to the large amount of bytes available.

In addition to this, I've also added new checks to ensure frames that are of unexpected type, or are larger than the MAX_FRAME_SIZE are skipped.

Requesting review from @fdlamotte as you were the original author ;)

Screenshot 2026-01-03 at 1 12 27 AM

Copy link
Collaborator

@fdlamotte fdlamotte left a comment

Choose a reason for hiding this comment

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

Hi,
Good for me, hopefully it'll solve some issues @awolden had in meshcore_py with persistent connexions ;)

@ripplebiz ripplebiz merged commit 09005fa into meshcore-dev:dev Jan 4, 2026
@liamcottle liamcottle deleted the fix/wifi-interface-frames branch January 4, 2026 06:34
@DH1994 DH1994 mentioned this pull request Jan 24, 2026
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.

3 participants