Conversation
The bridge implementations take NodePrefs*, so they can only be built into the examples that use the CLI NodePrefs class. The companion has its own, unrelated NodePrefs, so including a bridge from a companion fails outright: src/helpers/CommonCLI.h:25:7: error: redefinition of 'class NodePrefs' That is why ESP-NOW exists as a mesh radio and as a repeater bridge, but never as a companion: a host-connected node could not be the cheap end of a 2.4 GHz link. Extract the six bridge settings into BridgePrefs and have both NodePrefs classes inherit it. Every existing _prefs.bridge_* call site keeps working unchanged, and a bridge no longer has to know which prefs class it was handed. Then wire the bridge into the companion the way the repeater does it: logRx and logTx are already virtual on Dispatcher, and the companion simply never overrode them. Adds a heltec_v4 companion environment with the ESP-NOW bridge enabled.
…ke the other bridge The bridge code had no CI coverage at all: no environment in pr-build-check.yml compiles src/helpers/bridges, so a change to a bridge - or to the prefs both NodePrefs classes now share - would not be built by the gate. Also rename the new environment to heltec_v4_companion_radio_usb_bridge_espnow so it reads like the existing heltec_v4_repeater_bridge_espnow. Note that neither ends with _companion_radio_usb or _repeater, so build.sh's get-*-firmwares-to-build does not pick either up for releases; that is existing behaviour for bridge variants, not something this change alters.
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.
The problem
A companion radio cannot use a bridge, and it is not an oversight in the companion - it is a type conflict:
The bridges take
NodePrefs*(BridgeBase.h), and theNodePrefsthey mean is the CLI one inhelpers/CommonCLI.h. The companion has its own, unrelatedNodePrefsinexamples/companion_radio/NodePrefs.h. Both areclass NodePrefs : public ConfigSerializer, so any translation unit that includes a bridge and the companion's prefs defines the class twice. That is why ESP-NOW today exists as a mesh radio (variants/generic_espnow) and as a repeater bridge (heltec_v4_repeater_bridge_espnow), but never as a companion: a host-connected node cannot be the cheap end of a 2.4 GHz link, even though it is exactly the node with a host behind it to use the bandwidth.The fix, in two parts
1. Give the bridges their own settings type.
BridgePrefsholds the six fields the bridges and their examples use. BothNodePrefsclasses inherit it, so every existing_prefs.bridge_enabled,_prefs.bridge_secret, ... call site keeps working with no edit, andBridgeBaseno longer includesCommonCLI.hat all. Only the constructor parameter types change.2. Wire the bridge into the companion the way the repeater does it:
logRxandlogTxare already virtual onDispatcherand the companion simply never overrode them. The companion gains a bridge member, those two hooks,bridge.loop()andbridge.isRunning()inhasPendingWork()- the same shape asexamples/simple_repeater.examples/companion_radio/NodePrefs.hpersists the bridge settings under new keys, so an existing config file is unaffected; anything unset keeps theBridgePrefsdefaults.Outcome
A companion node keeps LoRa as its long-range transport and mirrors mesh packets onto ESP-NOW for nearby nodes - a fast local lane rather than a replacement radio. New environment:
Regression checks
heltec_v4_companion_radio_usb(no bridge)RAK_4631_companion_radio_ble(nRF52, no bridge)RAK_4631_repeater(uses the CLI NodePrefs)heltec_v4_companion_radio_usb_bridge_espnow(new)I could not build
heltec_v4_repeater_bridge_espnowhere: fetchingESP32Async/ESPAsyncWebServerfor that environment failed repeatedly on this machine ("RPC failed; curl 18 Transferred a partial file"). That is a download failure, not a compile one, but I want it stated rather than implied - the existing ESP-NOW bridge repeater is the one configuration I have not compiled. It should be checked in CI.Not done
No hardware validation - I have no ESP32 boards reachable while writing this. It is compile-verified only. The bridge itself is unchanged apart from its prefs type, and the ESP-NOW bridge's shared-secret XOR is left exactly as it is (it is documented upstream as network isolation, not security; that is a separate conversation).
CI
pr-build-check.ymlhad no environment that compilessrc/helpers/bridgesat all, so nothing in that gate would have caught a mistake in this PR - or would catch one later in a bridge or in the shared prefs. The matrix now includesheltec_v4_companion_radio_usb_bridge_espnowfor that reason.The environment name follows the existing
heltec_v4_repeater_bridge_espnow. Note that, like that one, it does not end in_companion_radio_usb, sobuild.sh get-companion-firmwares-to-buildwill not pick it up for releases. That is existing behaviour for bridge variants and this change does not alter it - raising it here in case releasing a bridge build is wanted.