diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index 36b009ff2..59ce043bc 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -28,6 +28,7 @@ #define DEBUG_PORT (*console) // Serial debug port #ifdef USE_SEGGER +#define DEBUG_PORT #define LOG_DEBUG(...) SEGGER_RTT_printf(0, __VA_ARGS__) #define LOG_INFO(...) SEGGER_RTT_printf(0, __VA_ARGS__) #define LOG_WARN(...) SEGGER_RTT_printf(0, __VA_ARGS__) diff --git a/src/GPSStatus.h b/src/GPSStatus.h index bdfce36ff..6b760385f 100644 --- a/src/GPSStatus.h +++ b/src/GPSStatus.h @@ -138,8 +138,9 @@ class GPSStatus : public Status LOG_DEBUG("New GPS pos@%x:3 lat=%f, lon=%f, alt=%d, pdop=%.2f, track=%.2f, speed=%.2f, sats=%d\n", p.timestamp, p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5, p.ground_speed * 1e-2, p.sats_in_view); - } else + } else { LOG_DEBUG("No GPS lock\n"); + } onNewStatus.notifyObservers(this); } return 0; diff --git a/src/concurrency/NotifiedWorkerThread.cpp b/src/concurrency/NotifiedWorkerThread.cpp index 39a594c5a..271e3e60d 100644 --- a/src/concurrency/NotifiedWorkerThread.cpp +++ b/src/concurrency/NotifiedWorkerThread.cpp @@ -31,12 +31,14 @@ IRAM_ATTR bool NotifiedWorkerThread::notifyCommon(uint32_t v, bool overwrite) runASAP = true; notification = v; - if (debugNotification) + if (debugNotification) { LOG_DEBUG("setting notification %d\n", v); + } return true; } else { - if (debugNotification) + if (debugNotification) { LOG_DEBUG("dropping notification %d\n", v); + } return false; } } @@ -64,8 +66,9 @@ bool NotifiedWorkerThread::notifyLater(uint32_t delay, uint32_t v, bool overwrit if (didIt) { // If we didn't already have something queued, override the delay to be larger setIntervalFromNow(delay); // a new version of setInterval relative to the current time - if (debugNotification) + if (debugNotification) { LOG_DEBUG("delaying notification %u\n", delay); + } } return didIt; diff --git a/src/concurrency/OSThread.cpp b/src/concurrency/OSThread.cpp index c71d3510e..f23cbe1dc 100644 --- a/src/concurrency/OSThread.cpp +++ b/src/concurrency/OSThread.cpp @@ -61,14 +61,17 @@ bool OSThread::shouldRun(unsigned long time) { bool r = Thread::shouldRun(time); - if (showRun && r) + if (showRun && r) { LOG_DEBUG("Thread %s: run\n", ThreadName.c_str()); + } - if (showWaiting && enabled && !r) + if (showWaiting && enabled && !r) { LOG_DEBUG("Thread %s: wait %lu\n", ThreadName.c_str(), interval); + } - if (showDisabled && !enabled) + if (showDisabled && !enabled) { LOG_DEBUG("Thread %s: disabled\n", ThreadName.c_str()); + } return r; } diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 219214091..072a9d14d 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1239,8 +1239,10 @@ void Screen::setFrames() moduleFrames = MeshModule::GetMeshModulesWithUIFrames(); LOG_DEBUG("Showing %d module frames\n", moduleFrames.size()); +#ifdef DEBUG_PORT int totalFrameCount = MAX_NUM_NODES + NUM_EXTRA_FRAMES + moduleFrames.size(); LOG_DEBUG("Total frame count: %d\n", totalFrameCount); +#endif // We don't show the node info our our node (if we have it yet - we should) size_t numnodes = nodeDB.getNumNodes(); diff --git a/src/main.cpp b/src/main.cpp index 324422a69..202dce549 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -462,10 +462,11 @@ void setup() gps = createGps(); - if (gps) + if (gps) { gpsStatus->observe(&gps->newStatus); - else + } else { LOG_WARN("No GPS found - running without GPS\n"); + } nodeStatus->observe(&nodeDB.newStatus); diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 5e2cb41ba..2a0b5ee39 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -108,8 +108,9 @@ CryptoKey Channels::getKey(ChannelIndex chIndex) if (ch.role == meshtastic_Channel_Role_SECONDARY) { LOG_DEBUG("Unset PSK for secondary channel %s. using primary key\n", ch.settings.name); k = getKey(primaryIndex); - } else + } else { LOG_WARN("User disabled encryption\n"); + } } else if (k.length == 1) { // Convert the short single byte variants of psk into variant that can be used more generally diff --git a/src/mesh/MeshModule.cpp b/src/mesh/MeshModule.cpp index d8dbf8a3a..55948b33f 100644 --- a/src/mesh/MeshModule.cpp +++ b/src/mesh/MeshModule.cpp @@ -179,9 +179,10 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src) } } - if (!moduleFound) + if (!moduleFound) { LOG_DEBUG("No modules interested in portnum=%d, src=%s\n", mp.decoded.portnum, (src == RX_SRC_LOCAL) ? "LOCAL" : "REMOTE"); + } } meshtastic_MeshPacket *MeshModule::allocReply() diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5ee839b80..c64468d05 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -468,8 +468,9 @@ void NodeDB::loadFromDisk() } } - if (loadProto(oemConfigFile, meshtastic_OEMStore_size, sizeof(meshtastic_OEMStore), &meshtastic_OEMStore_msg, &oemStore)) + if (loadProto(oemConfigFile, meshtastic_OEMStore_size, sizeof(meshtastic_OEMStore), &meshtastic_OEMStore_msg, &oemStore)) { LOG_INFO("Loaded OEMStore\n"); + } } /** Save a protobuf from a file, return true for success */ @@ -494,10 +495,12 @@ bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_ f.close(); // brief window of risk here ;-) - if (FSCom.exists(filename) && !FSCom.remove(filename)) + if (FSCom.exists(filename) && !FSCom.remove(filename)) { LOG_WARN("Can't remove old pref file\n"); - if (!renameFile(filenameTmp.c_str(), filename)) + } + if (!renameFile(filenameTmp.c_str(), filename)) { LOG_ERROR("Error: can't rename new pref file\n"); + } } else { LOG_ERROR("Can't write prefs\n"); #ifdef ARCH_NRF52 @@ -802,10 +805,11 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co // Print error to screen and serial port String lcd = String("Critical error ") + code + "!\n"; screen->print(lcd.c_str()); - if (filename) + if (filename) { LOG_ERROR("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address); - else + } else { LOG_ERROR("NOTE! Recording critical error %d, address=0x%lx\n", code, address); + } // Record error to DB myNodeInfo.error_code = code; diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index cdda05913..559f7ed31 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -423,8 +423,9 @@ int PhoneAPI::onNotify(uint32_t newValue) if (state == STATE_SEND_PACKETS) { LOG_INFO("Telling client we have new packets %u\n", newValue); onNowHasData(newValue); - } else + } else { LOG_DEBUG("(Client not yet interested in packets)\n"); + } return 0; } diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 0d53dc887..1eee86c8e 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -241,6 +241,7 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr) void printPacket(const char *prefix, const meshtastic_MeshPacket *p) { +#ifdef DEBUG_PORT std::string out = DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%02x to=0x%02x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff, p->want_ack, p->hop_limit, p->channel); if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { @@ -283,6 +284,7 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p) out += ")"; LOG_DEBUG("%s\n", out.c_str()); +#endif } RadioInterface::RadioInterface() diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 8fd715718..bce6b8a97 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -78,8 +78,9 @@ bool RadioLibInterface::canSendImmediately() bool busyRx = isReceiving && isActivelyReceiving(); if (busyTx || busyRx) { - if (busyTx) + if (busyTx) { LOG_WARN("Can not send yet, busyTx\n"); + } // If we've been trying to send the same packet more than one minute and we haven't gotten a // TX IRQ from the radio, the radio is probably broken. if (busyTx && (millis() - lastTxStart > 60000)) { @@ -88,8 +89,9 @@ bool RadioLibInterface::canSendImmediately() // reboot in 5 seconds when this condition occurs. rebootAtMsec = lastTxStart + 65000; } - if (busyRx) + if (busyRx) { LOG_WARN("Can not send yet, busyRx\n"); + } return false; } else return true; @@ -164,9 +166,9 @@ meshtastic_QueueStatus RadioLibInterface::getQueueStatus() bool RadioLibInterface::canSleep() { bool res = txQueue.empty(); - if (!res) // only print debug messages if we are vetoing sleep + if (!res) { // only print debug messages if we are vetoing sleep LOG_DEBUG("radio wait to sleep, txEmpty=%d\n", res); - + } return res; } diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index 7f5c9b7fc..946a669cc 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -104,13 +104,14 @@ void ReliableRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas if (p->to == ourNode) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability) if (p->want_ack) { - if (MeshModule::currentReply) + if (MeshModule::currentReply) { LOG_DEBUG("Some other module has replied to this message, no need for a 2nd ack\n"); - else if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) + } else if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel); - else + } else { // Send a 'NO_CHANNEL' error on the primary channel if want_ack packet destined for us cannot be decoded sendAckNak(meshtastic_Routing_Error_NO_CHANNEL, getFrom(p), p->id, channels.getPrimaryIndex()); + } } // We consider an ack to be either a !routing packet with a request ID or a routing packet with !error diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index e85d85450..156b48209 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -211,8 +211,10 @@ ErrorCode Router::send(meshtastic_MeshPacket *p) if (!config.lora.override_duty_cycle && myRegion->dutyCycle < 100) { float hourlyTxPercent = airTime->utilizationTXPercent(); if (hourlyTxPercent > myRegion->dutyCycle) { +#ifdef DEBUG_PORT uint8_t silentMinutes = airTime->getSilentMinutes(hourlyTxPercent, myRegion->dutyCycle); LOG_WARN("Duty cycle limit exceeded. Aborting send for now, you can send again in %d minutes.\n", silentMinutes); +#endif meshtastic_Routing_Error err = meshtastic_Routing_Error_DUTY_CYCLE_LIMIT; if (getFrom(p) == nodeDB.getNodeNum()) { // only send NAK to API, not to the mesh abortSendAndNak(err, p); @@ -479,9 +481,9 @@ void Router::perhapsHandleReceived(meshtastic_MeshPacket *p) // assert(radioConfig.has_preferences); bool ignore = is_in_repeated(config.lora.ignore_incoming, p->from); - if (ignore) + if (ignore) { LOG_DEBUG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from); - else if (ignore |= shouldFilterReceived(p)) { + } else if (ignore |= shouldFilterReceived(p)) { LOG_DEBUG("Incoming message was filtered 0x%x\n", p->from); } diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 5305adfe8..495840d50 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -179,8 +179,9 @@ template void SX126xInterface::setStandby() int err = lora.standby(); - if (err != RADIOLIB_ERR_NONE) + if (err != RADIOLIB_ERR_NONE) { LOG_DEBUG("SX126x standby failed with error %d\n", err); + } assert(err == RADIOLIB_ERR_NONE); diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp index 691d5dff0..9c3ec3e91 100644 --- a/src/mesh/SX128xInterface.cpp +++ b/src/mesh/SX128xInterface.cpp @@ -151,8 +151,9 @@ template void SX128xInterface::setStandby() int err = lora.standby(); - if (err != RADIOLIB_ERR_NONE) + if (err != RADIOLIB_ERR_NONE) { LOG_ERROR("SX128x standby failed with error %d\n", err); + } assert(err == RADIOLIB_ERR_NONE); diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index ade96fb8a..89503d2b9 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -112,8 +112,9 @@ meshtastic_MeshPacket *PositionModule::allocReply() if (getRTCQuality() < RTCQualityDevice) { LOG_INFO("Stripping time %u from position send\n", p.time); p.time = 0; - } else + } else { LOG_INFO("Providing time to mesh %u\n", p.time); + } LOG_INFO("Position reply: time=%i, latI=%i, lonI=-%i\n", p.time, p.latitude_i, p.longitude_i); diff --git a/src/modules/ReplyModule.cpp b/src/modules/ReplyModule.cpp index 3bfad28ad..439f6b7f7 100644 --- a/src/modules/ReplyModule.cpp +++ b/src/modules/ReplyModule.cpp @@ -8,10 +8,12 @@ meshtastic_MeshPacket *ReplyModule::allocReply() { assert(currentRequest); // should always be !NULL +#ifdef DEBUG_PORT auto req = *currentRequest; auto &p = req.decoded; // The incoming message is in p.payload LOG_INFO("Received message from=0x%0x, id=%d, msg=%.*s\n", req.from, req.id, p.payload.size, p.payload.bytes); +#endif screen->print("Sending reply\n"); diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index de74c0bf9..f87ea504b 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -59,6 +59,7 @@ int32_t AirQualityTelemetryModule::runOnce() bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) { if (t->which_variant == meshtastic_Telemetry_air_quality_metrics_tag) { +#ifdef DEBUG_PORT const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): pm10_standard=%i, pm25_standard=%i, pm100_standard=%i\n", sender, @@ -68,7 +69,7 @@ bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPack LOG_INFO(" | PM1.0(Environmental)=%i, PM2.5(Environmental)=%i, PM10.0(Environmental)=%i\n", t->variant.air_quality_metrics.pm10_environmental, t->variant.air_quality_metrics.pm25_environmental, t->variant.air_quality_metrics.pm100_environmental); - +#endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) packetPool.release(lastMeasurementPacket); diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 199a90209..696429aeb 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -31,12 +31,13 @@ int32_t DeviceTelemetryModule::runOnce() bool DeviceTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) { if (t->which_variant == meshtastic_Telemetry_device_metrics_tag) { +#ifdef DEBUG_PORT const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", sender, t->variant.device_metrics.air_util_tx, t->variant.device_metrics.channel_utilization, t->variant.device_metrics.battery_level, t->variant.device_metrics.voltage); - +#endif nodeDB.updateTelemetry(getFrom(&mp), *t, RX_SRC_RADIO); } return false; // Let others look at this message also if they want diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 3b8a7dda1..bf0ca6182 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -183,6 +183,7 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) { if (t->which_variant == meshtastic_Telemetry_environment_metrics_tag) { +#ifdef DEBUG_PORT const char *sender = getSenderShortName(mp); LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, " @@ -190,7 +191,7 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage); - +#endif // release previous packet before occupying a new spot if (lastMeasurementPacket != nullptr) packetPool.release(lastMeasurementPacket); diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 43e4c0386..6e28aac06 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -92,10 +92,12 @@ void BME680Sensor::updateState() file.flush(); file.close(); // brief window of risk here ;-) - if (FSCom.exists(bsecConfigFileName) && !FSCom.remove(bsecConfigFileName)) + if (FSCom.exists(bsecConfigFileName) && !FSCom.remove(bsecConfigFileName)) { LOG_WARN("Can't remove old state file\n"); - if (!renameFile(filenameTmp.c_str(), bsecConfigFileName)) + } + if (!renameFile(filenameTmp.c_str(), bsecConfigFileName)) { LOG_ERROR("Error: can't rename new state file\n"); + } } else { LOG_INFO("Can't write %s state (File: %s).\n", sensorName, bsecConfigFileName); diff --git a/src/modules/TextMessageModule.cpp b/src/modules/TextMessageModule.cpp index 0fa175a14..8ff034fa9 100644 --- a/src/modules/TextMessageModule.cpp +++ b/src/modules/TextMessageModule.cpp @@ -7,8 +7,10 @@ TextMessageModule *textMessageModule; ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp) { +#ifdef DEBUG_PORT auto &p = mp.decoded; LOG_INFO("Received text msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes); +#endif // We only store/display messages destined for us. // Keep a copy of the most recent text message. diff --git a/src/modules/TraceRouteModule.cpp b/src/modules/TraceRouteModule.cpp index 14396266d..f26c40d2f 100644 --- a/src/modules/TraceRouteModule.cpp +++ b/src/modules/TraceRouteModule.cpp @@ -47,6 +47,7 @@ void TraceRouteModule::appendMyID(meshtastic_RouteDiscovery *updated) void TraceRouteModule::printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, uint32_t dest) { +#ifdef DEBUG_PORT LOG_INFO("Route traced:\n"); LOG_INFO("0x%x --> ", origin); for (uint8_t i = 0; i < r->route_count; i++) { @@ -56,6 +57,7 @@ void TraceRouteModule::printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, LOG_INFO("0x%x\n", dest); else LOG_INFO("...\n"); +#endif } meshtastic_MeshPacket *TraceRouteModule::allocReply() diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp index f95bdec34..83485c8ee 100644 --- a/src/modules/WaypointModule.cpp +++ b/src/modules/WaypointModule.cpp @@ -7,8 +7,10 @@ WaypointModule *waypointModule; ProcessMessage WaypointModule::handleReceived(const meshtastic_MeshPacket &mp) { +#ifdef DEBUG_PORT auto &p = mp.decoded; LOG_INFO("Received waypoint msg from=0x%0x, id=0x%x, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes); +#endif // We only store/display messages destined for us. // Keep a copy of the most recent text message. diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp index e6a975119..4a154878d 100644 --- a/src/modules/esp32/AudioModule.cpp +++ b/src/modules/esp32/AudioModule.cpp @@ -195,8 +195,9 @@ int32_t AudioModule::runOnce() .tx_desc_auto_clear = true, .fixed_mclk = 0}; res = i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL); - if (res != ESP_OK) + if (res != ESP_OK) { LOG_ERROR("Failed to install I2S driver: %d\n", res); + } const i2s_pin_config_t pin_config = { .bck_io_num = moduleConfig.audio.i2s_sck, @@ -204,12 +205,14 @@ int32_t AudioModule::runOnce() .data_out_num = moduleConfig.audio.i2s_din ? moduleConfig.audio.i2s_din : I2S_PIN_NO_CHANGE, .data_in_num = moduleConfig.audio.i2s_sd ? moduleConfig.audio.i2s_sd : I2S_PIN_NO_CHANGE}; res = i2s_set_pin(I2S_PORT, &pin_config); - if (res != ESP_OK) + if (res != ESP_OK) { LOG_ERROR("Failed to set I2S pin config: %d\n", res); + } res = i2s_start(I2S_PORT); - if (res != ESP_OK) + if (res != ESP_OK) { LOG_ERROR("Failed to start I2S: %d\n", res); + } radio_state = RadioState::rx; diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index bd1a85641..490543bf6 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -461,8 +461,9 @@ std::string MQTT::downstreamPacketToJson(meshtastic_MeshPacket *mp) msgPayload["current"] = new JSONValue(decoded->variant.environment_metrics.current); } jsonObj["payload"] = new JSONValue(msgPayload); - } else + } else { LOG_ERROR("Error decoding protobuf for telemetry message!\n"); + } }; break; } @@ -479,8 +480,9 @@ std::string MQTT::downstreamPacketToJson(meshtastic_MeshPacket *mp) msgPayload["shortname"] = new JSONValue(decoded->short_name); msgPayload["hardware"] = new JSONValue(decoded->hw_model); jsonObj["payload"] = new JSONValue(msgPayload); - } else + } else { LOG_ERROR("Error decoding protobuf for nodeinfo message!\n"); + } }; break; } diff --git a/src/sleep.cpp b/src/sleep.cpp index e612b0032..6dcf385b7 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -132,6 +132,7 @@ void initDeepSleep() support busted boards, assume button one was pressed wakeButtons = ((uint64_t)1) << buttons.gpios[0]; */ +#ifdef DEBUG_PORT // If we booted because our timer ran out or the user pressed reset, send those as fake events const char *reason = "reset"; // our best guess RESET_REASON hwReason = rtc_get_reset_reason(0); @@ -150,6 +151,7 @@ void initDeepSleep() LOG_INFO("Booted, wake cause %d (boot count %d), reset_reason=%s\n", wakeCause, bootCount, reason); #endif +#endif } bool doPreflightSleep() @@ -329,23 +331,27 @@ esp_sleep_wakeup_cause_t doLightSleep(uint64_t sleepMsec) // FIXME, use a more r gpio_wakeup_enable((gpio_num_t)PMU_IRQ, GPIO_INTR_LOW_LEVEL); // pmu irq #endif auto res = esp_sleep_enable_gpio_wakeup(); - if (res != ESP_OK) + if (res != ESP_OK) { LOG_DEBUG("esp_sleep_enable_gpio_wakeup result %d\n", res); + } assert(res == ESP_OK); res = esp_sleep_enable_timer_wakeup(sleepUsec); - if (res != ESP_OK) + if (res != ESP_OK) { LOG_DEBUG("esp_sleep_enable_timer_wakeup result %d\n", res); + } assert(res == ESP_OK); res = esp_light_sleep_start(); - if (res != ESP_OK) + if (res != ESP_OK) { LOG_DEBUG("esp_light_sleep_start result %d\n", res); + } assert(res == ESP_OK); esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause(); #ifdef BUTTON_PIN - if (cause == ESP_SLEEP_WAKEUP_GPIO) + if (cause == ESP_SLEEP_WAKEUP_GPIO) { LOG_INFO("Exit light sleep gpio: btn=%d\n", !digitalRead(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN)); + } #endif return cause;