working end to end transmit, receive and code example using companion mode

This commit is contained in:
Scott Penrose
2026-06-08 15:27:37 +10:00
parent c12d0ac70a
commit 1c3d7b094d
3 changed files with 45 additions and 18 deletions
+10 -7
View File
@@ -254,15 +254,18 @@ radio comes up configured with no manual steps:
```sh ```sh
cd examples/AutoProvision cd examples/AutoProvision
pio run -t upload && pio device monitor pio run -e esp32-s3-devkitc-1 -t upload # or: -e xiao-esp32s3 for a XIAO host
pio device monitor
``` ```
It's a self-contained PlatformIO project (`platformio.ini` + `src/main.cpp`). The It's a self-contained PlatformIO project (`platformio.ini` + `src/main.cpp`) with
region is set the same way you'd compile MeshCore firmware — `LORA_FREQ` / an env per host board — a generic ESP32-S3 dev board and a Seeed **XIAO
`LORA_BW` / `LORA_SF` / `LORA_CR` / `LORA_TX_POWER` in `platformio.ini`'s ESP32-S3** (their host UART pins differ, since the XIAO doesn't break out
`build_flags` (916.575 MHz / 62.5 kHz / SF7 / CR4/8 / 20 dBm). The code is plain GPIO17/18). The region is set the same way you'd compile MeshCore firmware —
Arduino C++, so you can rename `src/main.cpp` to `AutoProvision.ino` for the `LORA_FREQ` / `LORA_BW` / `LORA_SF` / `LORA_CR` / `LORA_TX_POWER` in
Arduino IDE instead. `platformio.ini`'s `build_flags` (916.575 MHz / 62.5 kHz / SF7 / CR4/8 / 20 dBm).
The code is plain Arduino C++, so you can rename `src/main.cpp` to
`AutoProvision.ino` for the Arduino IDE instead.
## Notes ## Notes
+33 -11
View File
@@ -1,26 +1,26 @@
; Self-contained PlatformIO project for the AutoProvision example. ; Self-contained PlatformIO project for the AutoProvision example.
; ;
; The radio region is set via build flags — the same LORA_* defines you'd use ; Two host boards are provided — pick one with -e:
; when compiling MeshCore firmware. Override them here for your region. ; pio run -e esp32-s3-devkitc-1 -t upload # generic ESP32-S3 dev board
; ; pio run -e xiao-esp32s3 -t upload # Seeed XIAO ESP32-S3
; cd examples/AutoProvision
; pio run -t upload
; pio device monitor ; pio device monitor
; ;
; The radio region is set via build flags — the same LORA_* defines you'd use
; when compiling MeshCore firmware. The host UART pins differ per board because
; the XIAO does not break out GPIO17/18.
;
; The library is pulled from the repo root (two levels up) via a relative ; The library is pulled from the repo root (two levels up) via a relative
; symlink dependency, so there's no copy of the source. ; symlink dependency, so there's no copy of the source.
[env:esp32-s3] [platformio]
default_envs = esp32-s3-devkitc-1
[common]
platform = espressif32 platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200
lib_deps = symlink://../.. lib_deps = symlink://../..
build_flags = build_flags =
; host UART pins to the companion
-D UART_RX_PIN=17
-D UART_TX_PIN=18
-D UART_BAUD=115200 -D UART_BAUD=115200
; AU narrow band radio region ; AU narrow band radio region
-D LORA_FREQ=916.575 -D LORA_FREQ=916.575
@@ -28,3 +28,25 @@ build_flags =
-D LORA_SF=7 -D LORA_SF=7
-D LORA_CR=8 -D LORA_CR=8
-D LORA_TX_POWER=20 -D LORA_TX_POWER=20
[env:esp32-s3-devkitc-1]
extends = common
board = esp32-s3-devkitc-1
build_flags =
${common.build_flags}
; host UART pins to the companion
-D UART_RX_PIN=17
-D UART_TX_PIN=18
[env:xiao-esp32s3]
extends = common
board = seeed_xiao_esp32s3
build_flags =
${common.build_flags}
; host UART pins to the companion (XIAO pads D7=GPIO44 RX, D6=GPIO43 TX)
-D UART_RX_PIN=44
-D UART_TX_PIN=43
; the XIAO has only native USB (no UART bridge) — route Serial to USB-CDC so
; the monitor sees output. (The devkit doesn't need this; it has a CP2102.)
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
+2
View File
@@ -75,6 +75,8 @@ static void provision() {
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
delay(1000);
Serial.printf("[boot] test auto provision started\n");
Serial1.begin(UART_BAUD, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN); Serial1.begin(UART_BAUD, SERIAL_8N1, UART_RX_PIN, UART_TX_PIN);
mc.onDeviceInfo([](const mc_device_info_t& d) { mc.onDeviceInfo([](const mc_device_info_t& d) {