Skip to content

Adding code to make wifi work better on companions#1888

Open
NickDunklee wants to merge 4 commits into
meshcore-dev:devfrom
NickDunklee:wifi-improvement-v2
Open

Adding code to make wifi work better on companions#1888
NickDunklee wants to merge 4 commits into
meshcore-dev:devfrom
NickDunklee:wifi-improvement-v2

Conversation

@NickDunklee
Copy link
Copy Markdown

@NickDunklee NickDunklee commented Mar 1, 2026

Adding code to improve wifi behavior on companions:

  * Retry handling if disconnected
  * Properly uses WIFI_STA
  * Adding first pass CLI commands for provisioning
  * Gated only for ESP32
  * Tested on Heltec v3

      * Retry handling if disconnected
      * Properly uses WIFI_STA
      * Adding first pass CLI commands for provisioning
      * Gated only for ESP32
@beala
Copy link
Copy Markdown

beala commented Mar 19, 2026

Tried to build but got the following error. This is with the latest version of dev merged in.

(penv) alex@dev ~/w/MeshCore (wifi-improvement-v2)> FIRMWARE_VERSION=1.14.0-dev-heltecv3-companion-wifi ./build.sh build-firmware Heltec_v3_companion_radio_wifi
Processing Heltec_v3_companion_radio_wifi (board: esp32-s3-devkitc-1; platform: platformio/espressif32@6.11.0; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1.html
PLATFORM: Espressif 32 (6.11.0) > Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 64 compatible libraries
Scanning dependencies...
Dependency Graph
|-- SPI @ 2.0.0
|-- Wire @ 2.0.0
|-- RadioLib @ 7.6.0
|-- Crypto @ 0.4.0
|-- RTClib @ 2.1.4
|-- Melopero RV3028 @ 1.2.0
|-- CayenneLPP @ 1.6.1
|-- Adafruit INA3221 Library @ 1.0.1
|-- Adafruit INA219 @ 1.2.3
|-- INA226 @ 0.6.6
|-- Adafruit INA260 Library @ 1.5.3
|-- Adafruit AHTX0 @ 2.0.6
|-- Adafruit BME280 Library @ 2.3.0
|-- Adafruit BMP280 Library @ 2.6.8
|-- Adafruit SHTC3 Library @ 1.0.2
|-- Sensirion I2C SHT4x @ 1.1.2
|-- Arduino_LPS22HB @ 1.0.2
|-- Adafruit MLX90614 Library @ 2.1.6
|-- Adafruit_VL53L0X @ 1.2.5
|-- MicroNMEA @ 2.0.6
|-- Adafruit BME680 Library @ 2.0.6
|-- Adafruit BMP085 Library @ 1.2.4
|-- base64 @ 1.4.0
|-- LittleFS @ 2.0.0
|-- SPIFFS @ 2.0.0
|-- WiFi @ 2.0.0
|-- ed25519
|-- nrf52
|-- ESP32 BLE Arduino @ 2.0.0
|-- FS @ 2.0.0
|-- Adafruit GFX Library @ 1.12.5
|-- Adafruit SSD1306 @ 2.5.16
Building in release mode
Compiling .pio/build/Heltec_v3_companion_radio_wifi/examples/companion_radio/main.cpp.o
examples/companion_radio/main.cpp: In function 'void loop()':
examples/companion_radio/main.cpp:292:3: error: 'wifi_reconnect_check' was not declared in this scope
   wifi_reconnect_check();
   ^~~~~~~~~~~~~~~~~~~~
examples/companion_radio/main.cpp:292:3: note: suggested alternative: 'wifi_second_chan_t'
   wifi_reconnect_check();
   ^~~~~~~~~~~~~~~~~~~~
   wifi_second_chan_t
Compiling .pio/build/Heltec_v3_companion_radio_wifi/lib22c/RadioLib/modules/SX127x/SX127x.cpp.o
Compiling .pio/build/Heltec_v3_companion_radio_wifi/lib22c/RadioLib/modules/SX128x/SX1280.cpp.o
Compiling .pio/build/Heltec_v3_companion_radio_wifi/lib22c/RadioLib/modules/SX128x/SX1281.cpp.o
Compiling .pio/build/Heltec_v3_companion_radio_wifi/lib22c/RadioLib/modules/SX128x/SX1282.cpp.o
*** [.pio/build/Heltec_v3_companion_radio_wifi/examples/companion_radio/main.cpp.o] Error 1
================================================================================ [FAILED] Took 2.42 seconds ================================================================================

Environment                     Status    Duration
------------------------------  --------  ------------
Heltec_v3_companion_radio_wifi  FAILED    00:00:02.424
=========================================================================== 1 failed, 0 succeeded in 00:00:02.424 ===========================================================================
Processing Heltec_v3_companion_radio_wifi (board: esp32-s3-devkitc-1; platform: platformio/espressif32@6.11.0; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1.html
PLATFORM: Espressif 32 (6.11.0) > Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 64 compatible libraries
Scanning dependencies...
Dependency Graph
|-- SPI @ 2.0.0
|-- Wire @ 2.0.0
|-- RadioLib @ 7.6.0
|-- Crypto @ 0.4.0
|-- RTClib @ 2.1.4
|-- Melopero RV3028 @ 1.2.0
|-- CayenneLPP @ 1.6.1
|-- Adafruit INA3221 Library @ 1.0.1
|-- Adafruit INA219 @ 1.2.3
|-- INA226 @ 0.6.6
|-- Adafruit INA260 Library @ 1.5.3
|-- Adafruit AHTX0 @ 2.0.6
|-- Adafruit BME280 Library @ 2.3.0
|-- Adafruit BMP280 Library @ 2.6.8
|-- Adafruit SHTC3 Library @ 1.0.2
|-- Sensirion I2C SHT4x @ 1.1.2
|-- Arduino_LPS22HB @ 1.0.2
|-- Adafruit MLX90614 Library @ 2.1.6
|-- Adafruit_VL53L0X @ 1.2.5
|-- MicroNMEA @ 2.0.6
|-- Adafruit BME680 Library @ 2.0.6
|-- Adafruit BMP085 Library @ 1.2.4
|-- base64 @ 1.4.0
|-- LittleFS @ 2.0.0
|-- SPIFFS @ 2.0.0
|-- WiFi @ 2.0.0
|-- ed25519
|-- nrf52
|-- ESP32 BLE Arduino @ 2.0.0
|-- FS @ 2.0.0
|-- Adafruit GFX Library @ 1.12.5
|-- Adafruit SSD1306 @ 2.5.16
Building in release mode
Compiling .pio/build/Heltec_v3_companion_radio_wifi/examples/companion_radio/main.cpp.o
examples/companion_radio/main.cpp: In function 'void loop()':
examples/companion_radio/main.cpp:292:3: error: 'wifi_reconnect_check' was not declared in this scope
   wifi_reconnect_check();
   ^~~~~~~~~~~~~~~~~~~~
examples/companion_radio/main.cpp:292:3: note: suggested alternative: 'wifi_second_chan_t'
   wifi_reconnect_check();
   ^~~~~~~~~~~~~~~~~~~~
   wifi_second_chan_t
Compiling .pio/build/Heltec_v3_companion_radio_wifi/lib22c/RadioLib/modules/SX128x/SX128x.cpp.o
*** [.pio/build/Heltec_v3_companion_radio_wifi/examples/companion_radio/main.cpp.o] Error 1
================================================================================ [FAILED] Took 2.21 seconds ================================================================================

Environment                     Status    Duration
------------------------------  --------  ------------
Heltec_v3_companion_radio_wifi  FAILED    00:00:02.205
=========================================================================== 1 failed, 0 succeeded in 00:00:02.205 ===========================================================================

Comment thread examples/companion_radio/main.cpp Outdated
@beala
Copy link
Copy Markdown

beala commented Mar 19, 2026

I erased flash and uploaded the firmware.bin that the build produced, and now I'm just getting this in the serial console.

image

beala fix suggestion to repair malformed ifdef

Co-authored-by: Alex Beal <alex@alb.computer>
@NickDunklee
Copy link
Copy Markdown
Author

I erased flash and uploaded the firmware.bin that the build produced, and now I'm just getting this in the serial console.
image

For this one, did you use pio to flash the firmware directly, or merge the binary before flashing on the web flasher?

The former would look something like:

pio run -e Heltec_v3_companion_radio_wifi -t clean && pio run -e Heltec_v3_companion_radio_wifi -t upload --upload-port /dev/cu.usbserial-0001

For the latter you should be able to run pio run -e Heltec_v3_companion_radio_wifi -t mergebin and that will combine the bootloader+partition table+app binary.

Which would output .pio/build/Heltec_v3_companion_radio_wifi/firmware-merged.bin which should then work on the web flasher.

@NickDunklee
Copy link
Copy Markdown
Author

@beala did the flashing tips get you up and running?

@beala
Copy link
Copy Markdown

beala commented Mar 24, 2026

@beala did the flashing tips get you up and running?

Looks good on my end! Thanks for setting this up!

@NickDunklee
Copy link
Copy Markdown
Author

NickDunklee commented Apr 3, 2026

So this is more of a first step, I wanted to nose in a solution gently to avoid people having to compile the platform locally and accidentally submitting their private WiFi networks to GitHub due the hard-coded nature of the current implementation. I didn't, but ask me how I almost had that risk-assessment happen. Plus, this lets people just download the image from the flasher site, hold a button down on their mesh radio, and type some things and get it online.

It has been working pretty good here for a month without issue, even with rebasing to newer firmware releases.

@NickDunklee
Copy link
Copy Markdown
Author

Just figured out yesterday, my concerns about console output were due to my using screen - switched to CoolTerm and no display issues while provisioning. Still chugging as well on 1.15.0 (local rebase.)

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