feat(docs): add local testing instructions for MQTT functionality
Include detailed instructions for local testing of observer and WiFi functionality without hardware. Document the use of a mock backend and Wokwi ESP32-S3 simulation for easier development and testing. Enhance the MQTT implementation documentation to improve developer experience and facilitate testing workflows.
This commit is contained in:
1 parent
b7795720b2
commit
cbbd01b620
23 files changed
+1403
-131
No files matched your search
@@ -159,6 +159,16 @@ lib_deps =
|
||||
0neblock/SNMP_Agent
|
||||
paulstoffregen/Time@1.6.1
|
||||
|
||||
; Emulator build (Wokwi): identical to the observer above but with the LoRa radio
|
||||
; stubbed (SIM_BUILD -> SimRadio) and WiFi pre-seeded to the Wokwi network so it
|
||||
; boots straight into WiFi/MQTT/CLI without hardware or flashing. See wokwi/.
|
||||
[env:Heltec_v3_repeater_observer_mqtt_sim]
|
||||
extends = env:Heltec_v3_repeater_observer_mqtt
|
||||
build_flags =
|
||||
${env:Heltec_v3_repeater_observer_mqtt.build_flags}
|
||||
-D SIM_BUILD=1
|
||||
-D SIM_WIFI_SSID='"Wokwi-GUEST"'
|
||||
|
||||
[env:Heltec_v3_room_server]
|
||||
extends = Heltec_lora32_v3
|
||||
build_flags =
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
HeltecV3Board board;
|
||||
|
||||
#ifdef SIM_BUILD
|
||||
SimRadio radio_driver(board); // no-op radio for emulator builds
|
||||
#else
|
||||
#if defined(P_LORA_SCLK)
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
@@ -11,6 +14,7 @@ HeltecV3Board board;
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
#endif
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
@@ -31,8 +35,10 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
|
||||
#ifdef SIM_BUILD
|
||||
return true; // no SPI radio to bring up
|
||||
#elif defined(P_LORA_SCLK)
|
||||
return radio.std_init(&spi);
|
||||
#else
|
||||
return radio.std_init();
|
||||
@@ -40,7 +46,12 @@ bool radio_init() {
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
#ifdef SIM_BUILD
|
||||
SimRNG rng;
|
||||
return mesh::LocalIdentity(&rng);
|
||||
#else
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <HeltecV3Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#ifdef SIM_BUILD
|
||||
// Emulator build (e.g. Wokwi): no SX1262 hardware — use the no-op SimRadio so
|
||||
// the firmware boots and runs WiFi/MQTT/CLI/display. See src/helpers/sim/.
|
||||
#include <helpers/sim/SimRadio.h>
|
||||
#include <HeltecV3Board.h>
|
||||
#else
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <HeltecV3Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#endif
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
@@ -14,7 +21,11 @@
|
||||
#endif
|
||||
|
||||
extern HeltecV3Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
#ifdef SIM_BUILD
|
||||
extern SimRadio radio_driver;
|
||||
#else
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
#endif
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
|
||||
Reference in new issue
Block a user