From 2b7dc88601e75536a9d131c84caac7ce010a484f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Br=C3=A1zio?= Date: Fri, 4 Sep 2026 21:04:20 +0100 Subject: [PATCH] Honour advert location policy in builds without GPS buildAdvertData() read the sensed coordinates unconditionally, so in builds with ENV_INCLUDE_GPS disabled ADVERT_LOC_SHARE advertised 0.0000/0.0000 (sensed coordinates are generally unavailable there, and the CLI cannot select ADVERT_LOC_SHARE without GPS support). Gate the sensor branch on the macro, keep honouring ADVERT_LOC_NONE, and fall back to the configured position otherwise. --- src/helpers/CommonCLI.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 4930e81e9a..373f403762 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -168,6 +168,7 @@ void CommonCLI::savePrefs() { } uint8_t CommonCLI::buildAdvertData(uint8_t node_type, uint8_t* app_data) { +#if ENV_INCLUDE_GPS == 1 if (_prefs->advert_loc_policy == ADVERT_LOC_NONE) { AdvertDataBuilder builder(node_type, _prefs->node_name); return builder.encodeTo(app_data); @@ -178,6 +179,16 @@ uint8_t CommonCLI::buildAdvertData(uint8_t node_type, uint8_t* app_data) { AdvertDataBuilder builder(node_type, _prefs->node_name, _prefs->node_lat, _prefs->node_lon); return builder.encodeTo(app_data); } +#else + // No GPS support: sensed coordinates are never populated, so honour + // ADVERT_LOC_NONE and otherwise fall back to the configured position. + if (_prefs->advert_loc_policy == ADVERT_LOC_NONE) { + AdvertDataBuilder builder(node_type, _prefs->node_name); + return builder.encodeTo(app_data); + } + AdvertDataBuilder builder(node_type, _prefs->node_name, _prefs->node_lat, _prefs->node_lon); + return builder.encodeTo(app_data); +#endif } void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* reply) {