Repository navigation
feat(companion): full capture of dropped frames for observer apps - #29
Merged
Merged
Conversation
Opt-in command 0xE0 makes the companion also push (0xC0) what it drops today: valid frames of 174-255 bytes that do not fit the 0x88 RX log push, frames received with a CRC or header error (now kept by the RadioLib wrapper in two slots instead of discarded), and on ESP32 a count of frames lost to a full receive queue. A frame that does not fit one 176-byte push is split in two. The setting is RAM only and cleared when no app is connected, so an observer such as RTFM-EV sends it on every connect. A valid frame of up to 173 bytes still goes out as 0x88 only. Nothing extra is transmitted on RF. The encoder is pure and has native tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
This adds Full capture: an opt-in way for an observer app to also get the frames the companion drops today.
0xE0 [flags]. The flags are 0x01 for over-long frames, 0x02 for damaged frames and 0x04 for drop notices. The reply is[0x00][supported flags], and unknown bits getERR_CODE_ILLEGAL_ARG. Stock firmware answers0xE0with an error, so an app can tell whether the feature is there.0xC0. The layout is[tag][index<<4|count][status][snr_x4][rssi][total_len][chunk]. A frame that does not fit one 176-byte push is split in two, so it works over BLE too. Statuses:0x88RX log push, which is limited to 173 bytes of raw data. A frame of up to 173 bytes still goes out as0x88only.tryParsePacket().Why
RTFM-EV wants to act as a complete observer, for other firmwares' traffic and for link debugging. Its receiver side is Elektr0Vodka/RTFM-EV#366 and uses exactly this wire format.
How
examples/companion_radio/FullCapture.{h,cpp}is a pure encoder, built intonativewith tests intest/test_full_capture.FullCaptureHook.cppholds the MyMesh side: the command, the long push fromlogRxRaw, the damaged push from a newlogRxBad, and the reset and drop notices inloop(). It follows theCompanionFilterHook.cpppattern.mesh::Radio::recvBad()andgetRxQueueDrops();Dispatcher::logRxBad(), called only whenrecvRaw()returned nothing and a damaged frame is waiting;RadioLibWrapperkeeps the damaged frames under the existing radio mutex. This costs about 530 bytes of RAM.docs/companion_protocol.md(section 10);changelog_ev.mdhas an entry.Tested
pio test -e native: 102 test cases passed, including the 8 newtest_full_capturecases.pio run -e Heltec_v3_companion_radio_usb_tcp: success (RAM 33.9%, flash 48.8%).pio run -e RAK_4631_companion_radio_usb: success (RAM 26.9%, flash 68.1%). This checks the polled path without the drain task.native_kiss_modemerrors on this Windows machine (0xC0000139, a DLL entry point). The same happens on cleanorigin/main, and this change does not touch it.Not tested