diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 9ef6bcc2..e55f0016 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -48,6 +48,22 @@ static bool g_sim_ready = false; extern "C" EMSCRIPTEN_KEEPALIVE int sim_is_ready() { return g_sim_ready ? 1 : 0; } + +// Same idea as companion_radio's sim_test_advert_flood() -- MyMesh's own +// updateAdvertTimer() (called once from begin()) doesn't fire the repeater's +// first self-advert for a full 2 minutes (advert_interval defaults to 1, +// scaled *2*60*1000ms -- see MyMesh::updateAdvertTimer()/begin() in this +// same MyMesh.cpp), so a host page that wants hero/B to discover the +// repeater as a contact immediately on boot (rather than waiting out that +// timer) needs some way to trigger it early. sendSelfAdvertisement(0, true) +// is the exact same call updateAdvertTimer()'s scheduled path eventually +// makes, just invoked now instead of on a timer -- real crypto, real +// packet, nothing faked. +extern "C" EMSCRIPTEN_KEEPALIVE int sim_test_advert_flood() { + if (!g_sim_ready) return 0; + the_mesh.sendSelfAdvertisement(0, true); + return 1; +} #endif static char command[160]; diff --git a/variants/sim/build_wasm.sh b/variants/sim/build_wasm.sh index 8662b5ad..d5651158 100755 --- a/variants/sim/build_wasm.sh +++ b/variants/sim/build_wasm.sh @@ -136,6 +136,17 @@ DEFINES=( -DFIRMWARE_SOLO_BUILD=1 -DMAX_CONTACTS=100 -DMAX_GROUP_CHANNELS=8 + # Both off by default on every real board variant except the GPS/sensor- + # carrying ones (see variants/wio-tracker-l1/platformio.ini, + # variants/heltec_t114/platformio.ini etc.) -- without ENV_INCLUDE_GPS, + # HomeScreen's GPS enum entry (ui-new/UITask.cpp) doesn't even exist in + # the build, so the "GPS" home page from sim_test_show_all_home_pages' + # mask=0 has nothing to map to. The demo site wants both on: SimSensorManager + # already feeds a real (JS-settable) GPS fix and one temperature/battery + # channel (see SimSensorManager.h) -- these two flags are what actually + # surface them as on-device pages. + -DENV_INCLUDE_GPS=1 + -DUI_SENSORS_PAGE=1 ) # -funsigned-char: carried over from Phase 1 verbatim -- real ARM cores diff --git a/variants/sim/platformio.ini b/variants/sim/platformio.ini index 58b1f2fe..b8861d02 100644 --- a/variants/sim/platformio.ini +++ b/variants/sim/platformio.ini @@ -41,6 +41,12 @@ build_flags = -D FIRMWARE_SOLO_BUILD=1 -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=8 + ; Mirrors build_wasm.sh's DEFINES (see that script's own comment) -- both + ; off by default on every real board except the sensor-carrying ones; the + ; sim always has a (fake) GPS + one JS-settable env channel behind them + ; (SimSensorManager.h), so both are worth showing here. + -D ENV_INCLUDE_GPS=1 + -D UI_SENSORS_PAGE=1 -I variants/sim/arduino -I variants/sim -I variants/sim/thirdparty/crypto