Refactor Companion Interfaces + Add ThinkNode M7 Ethernet Support - #3049
Merged
Conversation
hermes-gadget
added a commit
to gadgethd/MeshCore-MQTT
that referenced
this pull request
Jul 30, 2026
Upstream dev: 449f0b5..db23280 (22 commits) - PR meshcore-dev#2688: room_server system posts (3a9f19c, 5a04e06, db23280) - PR meshcore-dev#3004: preserve UTF-8 advert names (79dc1de, 57ddada) - PR meshcore-dev#3060: fix mesh-debug-active (d7f378b, b797ca1) - PR meshcore-dev#3063: unify IRQ timeout (a5c323c, a3732e1, 79eb7f5, a7426de, 6e39cff) - PR meshcore-dev#3062: fix IRQ clear (20f55a4, 9f73fbf) - PR meshcore-dev#3049: ethernet refactor (5de857f, b4143a4, e672679, 203fd4e, 834ad72, 279ac78) - USB companion flag requirement (e7f2c71) - Bluetooth toggle on UI tiny (dd778e2) Conflicts resolved: - variants/mesh_pocket/platformio.ini: USB companion AUTO_OFF_MILLIS + ENABLE_USB_INTERFACE Clean auto-merge (no conflicts) in all MQTT files — guard pattern held. MQTT additions preserved.
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.
This PR adds support for a companion ethernet interface on the ThinkNode M7.
At the same time, it refactors our companion interface management code to allow for multiple interfaces to be active at the same time.
Currently, we are building 3 variations of our companion firmware:
companion_radio_ble,companion_radio_usbandcompanion_radio_wifi.With the addition of
companion_radio_ethernet, this isn't really a scalable approach, and users have already made note that it's annoying to have to re-flash between BLE, USB and WiFi firmware variants when they want to change how they connect to their companion nodes.So, this PR will allow us to soon move to building a new firmware variant:
companion_radio, which will be able to bake in BLE, USB, WiFi and Ethernet interfaces all into one. This would mean users will no longer need to re-flash between firmwares if they want to connect via a different connection method.For now, we will continue to build the individual firmware variants, especially because some boards will not have enough RAM to allow for WiFi and BLE to run at the same time. For newer boards with more resources, the larger firmware will be okay. However we will still retain the ability to compile firmwares with specific interfaces only.
This PR does not implement the new
companion_radiofirmware type, it just refactors the build flags and code structure to allow for multiple interfaces to be registered at the same time.A new
MultiSerialInterfacehas been added, which reads/writes to all otherBaseSerialInterface(s) that have been registered with it. I've tested this on various ESP32 and nRF52 boards, with a combination of different connection methods baked in.Users building custom firmware will be able to create their own subclass of BaseSerialInterface and register it with the new
MultiSerialInterfacemanager.This refactor makes it possible to connect to the same companion node via multiple interfaces at the same time. Currently, we aren't looking to prohibit this, however there may be some unexpected side effects if multiple clients are connected at the same time. Note that we still only allow 1 connection to an interface at one time, for example, 1x BLE and 1x Ethernet. But you could connect to both of those at the same time from different apps.
A future refactor to the WiFi and Ethernet interfaces could potentially allow for multiple clients connecting at the same time to the same interface, but this is not planned right now.
Main Changes:
-D ENABLE_USB_INTERFACEbuild flag to all existingcompanion_radio_usbvariants.It is planned in a further PR to add preferences/cli commands to configure WiFi SSID/Password via the apps. Along with a new toggle to configure how the USB interface behaves. We will need to select between companion protocol mode, or serial logging mode, as these can't both be active at the same time.
All companion firmwares are successfully building with these changes:
The PR touches a fair few files, but the majority of those are just adding the build flag to all USB companion variants.