Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/helpers/CommonCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you dropped the else and moved the guard to here I think it would achieve the same outcome but you could drop the duplicated if (_prefs->advert_loc_policy == ADVERT_LOC_NONE) branch in the #else below?

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) {
Expand Down