Skip to content

Refactor Companion Interfaces + Add ThinkNode M7 Ethernet Support - #3049

Merged
ripplebiz merged 7 commits into
meshcore-dev:devfrom
liamcottle:feature/ethernet
Jul 29, 2026
Merged

Refactor Companion Interfaces + Add ThinkNode M7 Ethernet Support#3049
ripplebiz merged 7 commits into
meshcore-dev:devfrom
liamcottle:feature/ethernet

Conversation

@liamcottle

Copy link
Copy Markdown
Member

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_usb and companion_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_radio firmware type, it just refactors the build flags and code structure to allow for multiple interfaces to be registered at the same time.

A new MultiSerialInterface has been added, which reads/writes to all other BaseSerialInterface(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 MultiSerialInterface manager.

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:

  • Adds support for Ethernet interface on ThinkNode M7 companion firmware.
  • Adds new -D ENABLE_USB_INTERFACE build flag to all existing companion_radio_usb variants.
  • Refactors the existing RAK13800 ethernet module to use the new base class, to avoid duping serial framing logic.
  • Removes old RAK13800 ethernet interface.

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.

@ripplebiz
ripplebiz merged commit 279ac78 into meshcore-dev:dev Jul 29, 2026
15 checks passed
@liamcottle
liamcottle deleted the feature/ethernet branch July 29, 2026 13:50
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.
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