Skip to content

Commit b5a8e8f

Browse files
DEBUG_MUTE correctness (meshtastic#7492)
* treewide: make 'ifdef DEBUG_PORT' guards also take into account DEBUG_MUTE * stm32wl: Add a guard against having debug prints turned on without PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF defined --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
1 parent cc5d00e commit b5a8e8f

13 files changed

Lines changed: 19 additions & 13 deletions

src/mesh/Router.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,18 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
224224
if (!config.lora.override_duty_cycle && myRegion->dutyCycle < 100) {
225225
float hourlyTxPercent = airTime->utilizationTXPercent();
226226
if (hourlyTxPercent > myRegion->dutyCycle) {
227-
#ifdef DEBUG_PORT
228227
uint8_t silentMinutes = airTime->getSilentMinutes(hourlyTxPercent, myRegion->dutyCycle);
228+
229229
LOG_WARN("Duty cycle limit exceeded. Aborting send for now, you can send again in %d mins", silentMinutes);
230+
230231
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
231232
cn->has_reply_id = true;
232233
cn->reply_id = p->id;
233234
cn->level = meshtastic_LogRecord_Level_WARNING;
234235
cn->time = getValidTime(RTCQualityFromNet);
235236
sprintf(cn->message, "Duty cycle limit exceeded. You can send again in %d mins", silentMinutes);
236237
service->sendClientNotification(cn);
237-
#endif
238+
238239
meshtastic_Routing_Error err = meshtastic_Routing_Error_DUTY_CYCLE_LIMIT;
239240
if (isFromUs(p)) { // only send NAK to API, not to the mesh
240241
abortSendAndNak(err, p);

src/modules/ReplyModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
meshtastic_MeshPacket *ReplyModule::allocReply()
99
{
1010
assert(currentRequest); // should always be !NULL
11-
#ifdef DEBUG_PORT
11+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
1212
auto req = *currentRequest;
1313
auto &p = req.decoded;
1414
// The incoming message is in p.payload

src/modules/Telemetry/AirQualityTelemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int32_t AirQualityTelemetryModule::runOnce()
121121
bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
122122
{
123123
if (t->which_variant == meshtastic_Telemetry_air_quality_metrics_tag) {
124-
#ifdef DEBUG_PORT
124+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
125125
const char *sender = getSenderShortName(mp);
126126

127127
LOG_INFO("(Received from %s): pm10_standard=%i, pm25_standard=%i, pm100_standard=%i", sender,

src/modules/Telemetry/DeviceTelemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool DeviceTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &
4949
return false;
5050

5151
if (t->which_variant == meshtastic_Telemetry_device_metrics_tag) {
52-
#ifdef DEBUG_PORT
52+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
5353
const char *sender = getSenderShortName(mp);
5454

5555
LOG_INFO("(Received from %s): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f", sender,

src/modules/Telemetry/EnvironmentTelemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
502502
bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
503503
{
504504
if (t->which_variant == meshtastic_Telemetry_environment_metrics_tag) {
505-
#ifdef DEBUG_PORT
505+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
506506
const char *sender = getSenderShortName(mp);
507507

508508
LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, "

src/modules/Telemetry/HealthTelemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void HealthTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *
149149
bool HealthTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
150150
{
151151
if (t->which_variant == meshtastic_Telemetry_health_metrics_tag) {
152-
#ifdef DEBUG_PORT
152+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
153153
const char *sender = getSenderShortName(mp);
154154

155155
LOG_INFO("(Received from %s): temperature=%f, heart_bpm=%d, spO2=%d,", sender, t->variant.health_metrics.temperature,

src/modules/Telemetry/HostMetrics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool HostMetricsModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
2727
return false;
2828

2929
if (t->which_variant == meshtastic_Telemetry_host_metrics_tag) {
30-
#ifdef DEBUG_PORT
30+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
3131
const char *sender = getSenderShortName(mp);
3232
if (t->variant.host_metrics.has_user_string)
3333
t->variant.host_metrics.user_string[sizeof(t->variant.host_metrics.user_string) - 1] = '\0';

src/modules/Telemetry/PowerTelemetry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *s
168168
bool PowerTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t)
169169
{
170170
if (t->which_variant == meshtastic_Telemetry_power_metrics_tag) {
171-
#ifdef DEBUG_PORT
171+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
172172
const char *sender = getSenderShortName(mp);
173173

174174
LOG_INFO("(Received from %s): ch1_voltage=%.1f, ch1_current=%.1f, ch2_voltage=%.1f, ch2_current=%.1f, "

src/modules/TextMessageModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TextMessageModule *textMessageModule;
99

1010
ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp)
1111
{
12-
#ifdef DEBUG_PORT
12+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
1313
auto &p = mp.decoded;
1414
LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s", mp.from, mp.id, p.payload.size, p.payload.bytes);
1515
#endif

src/modules/TraceRouteModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void TraceRouteModule::appendMyIDandSNR(meshtastic_RouteDiscovery *updated, floa
232232

233233
void TraceRouteModule::printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, uint32_t dest, bool isTowardsDestination)
234234
{
235-
#ifdef DEBUG_PORT
235+
#if defined(DEBUG_PORT) && !defined(DEBUG_MUTE)
236236
std::string route = "Route traced:\n";
237237
route += vformat("0x%x --> ", origin);
238238
for (uint8_t i = 0; i < r->route_count; i++) {

0 commit comments

Comments
 (0)