From 1c3d7b094ddd0dc3b54a63beb7d4ce984cc84d87 Mon Sep 17 00:00:00 2001 From: Scott Penrose Date: Mon, 8 Jun 2026 15:27:37 +1000 Subject: [PATCH] working end to end transmit, receive and code example using companion mode --- README.md | 17 ++++++----- examples/AutoProvision/platformio.ini | 44 ++++++++++++++++++++------- examples/AutoProvision/src/main.cpp | 2 ++ 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index ce97c4a..c41c7f7 100644 --- a/README.md +++ b/README.md @@ -254,15 +254,18 @@ radio comes up configured with no manual steps: ```sh 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 -region is set the same way you'd compile MeshCore firmware — `LORA_FREQ` / -`LORA_BW` / `LORA_SF` / `LORA_CR` / `LORA_TX_POWER` in `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. +It's a self-contained PlatformIO project (`platformio.ini` + `src/main.cpp`) with +an env per host board — a generic ESP32-S3 dev board and a Seeed **XIAO +ESP32-S3** (their host UART pins differ, since the XIAO doesn't break out +GPIO17/18). The region is set the same way you'd compile MeshCore firmware — +`LORA_FREQ` / `LORA_BW` / `LORA_SF` / `LORA_CR` / `LORA_TX_POWER` in +`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 diff --git a/examples/AutoProvision/platformio.ini b/examples/AutoProvision/platformio.ini index beb87db..b52511f 100644 --- a/examples/AutoProvision/platformio.ini +++ b/examples/AutoProvision/platformio.ini @@ -1,26 +1,26 @@ ; Self-contained PlatformIO project for the AutoProvision example. ; -; The radio region is set via build flags — the same LORA_* defines you'd use -; when compiling MeshCore firmware. Override them here for your region. -; -; cd examples/AutoProvision -; pio run -t upload +; Two host boards are provided — pick one with -e: +; 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 ; 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 ; symlink dependency, so there's no copy of the source. -[env:esp32-s3] +[platformio] +default_envs = esp32-s3-devkitc-1 + +[common] platform = espressif32 -board = esp32-s3-devkitc-1 framework = arduino monitor_speed = 115200 lib_deps = symlink://../.. - build_flags = - ; host UART pins to the companion - -D UART_RX_PIN=17 - -D UART_TX_PIN=18 -D UART_BAUD=115200 ; AU narrow band radio region -D LORA_FREQ=916.575 @@ -28,3 +28,25 @@ build_flags = -D LORA_SF=7 -D LORA_CR=8 -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 diff --git a/examples/AutoProvision/src/main.cpp b/examples/AutoProvision/src/main.cpp index 4e0890e..5d960e6 100644 --- a/examples/AutoProvision/src/main.cpp +++ b/examples/AutoProvision/src/main.cpp @@ -75,6 +75,8 @@ static void provision() { void setup() { 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); mc.onDeviceInfo([](const mc_device_info_t& d) {