Skip to content

feat(companion): move chip features behind MainBoard - #28

Merged
Elektr0Vodka merged 1 commit into
mainfrom
Feat/mainboard-capabilities
Oct 19, 2026
Merged

Elektr0Vodka merged 1 commit into
mainfrom
Feat/mainboard-capabilities

Conversation

@Elektr0Vodka

Copy link
Copy Markdown
Owner

What changed

Four new mesh::MainBoard virtuals. Each default reports "not available":

Method Default ESP32Board NRF52Board
getDeviceMac(kind, mac[6]) false esp_read_mac (Wi-Fi STA, BT) BLE static address from FICR
canRebootToBootloader() / rebootToBootloader() false / no-op S2, S3, C3: RTC force-download bit + backlight off + reboot; classic and C6: false default
getMemStats(MemStats&) false, zeroed ESP.* + heap_caps_* default
getHttpOtaProgress(pct, line) false reads the HTTP OTA display globals default

The callers change to match:

  • MyMesh.cpp: mac, get mac/wifi.mac/ble.mac, bootloader/dfu and ota status call the board. The ESP32 include block, MESHCOMOD_HAS_FORCE_DOWNLOAD and four chip #if blocks are gone.
  • CompanionSNMP.cpp: the .4.x memory OIDs read board.getMemStats(), and the file no longer includes esp_heap_caps.h. Its Wi-Fi calls stay, because the agent is Wi-Fi-only by design.
  • README mac row and changelog entry.

Why

Candidate 5 of the architecture review. Companion features called the chip directly, so every new chip family hit a guard someone had missed:

The fork had already put checkManifestOta on MainBoard. This uses the same seam for the rest. The chip-specific guards now live in one file per platform, and app code gets a working default on any new board.

How it was tested

DISABLE_DEBUG=1 build.sh build-firmware, all of which build with no new warnings in the touched files:

  • heltec_v4_companion_radio_usb_tcp (S3, SNMP, manifest OTA)
  • Heltec_T190_companion_radio_usb_tcp (S3 with PIN_TFT_LEDA_CTL)
  • Heltec_v2_companion_radio_ble (classic ESP32)
  • M5Stack_Unit_C6L_companion_radio_ble (C6)
  • WioTrackerL1_companion_radio_ble (nRF52)

Other checks:

  • On the S3 object, ESP32Board::rebootToBootloader() is 0x36 bytes and canRebootToBootloader() returns true. So the force-download path still compiles where it did before, not the "unsupported" stub.
  • pio test -e native: 94 of 94 pass.
  • Not tested on hardware. Worth checking on a V4 or V3: mac, bootloader (should enter download mode and darken the screen as before), ota status, and an SNMP walk of .4. On an nRF52 board, check that mac matches the address the phone sees.

Firmware or build impact

  • Behaviour is the same on ESP32.
  • bootloader on non-ESP32 boards now replies not supported on this chip (was ESP32-only).
  • mac on nRF52 now shows the BLE address instead of n/a.
  • MainBoard is a MeshCore header. The new methods have default bodies, so other boards and upstream code are unaffected.

Left as is: the PSRAM allocator in the backup import (#if defined(ESP32) around heap_caps_malloc), and the Wi-Fi and multi-transport guards in MyMesh. Those are about which transports exist, not about the chip.

The device MAC, the bootloader reboot into download mode, the SNMP memory
figures and the ota status progress called ESP32 APIs straight from
MyMesh.cpp and CompanionSNMP.cpp, each behind its own chip #if. Every new
chip family found a guard someone missed: #14 (nRF52), #17 (classic
ESP32) and #22 (C6) each fixed a build broken that way.

MainBoard gains getDeviceMac, canRebootToBootloader/rebootToBootloader,
getMemStats and getHttpOtaProgress, with defaults that report "not
available". ESP32Board implements them, and the S2/S3/C3-only
force-download register write now lives there. NRF52Board reports the
BLE address from FICR. The companion code just asks the board.

Replies are unchanged except: bootloader on non-ESP32 boards says "not
supported on this chip" (was "ESP32-only"), and mac on nRF52 shows the
BLE address instead of n/a.
@Elektr0Vodka
Elektr0Vodka merged commit 2bb91cb into main Oct 19, 2026
8 checks passed
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.

1 participant