Skip to content

Commit d7562bc

Browse files
committed
Cleanup of logs and remove unnecessary delays
1 parent 76af1d7 commit d7562bc

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

src/modules/Telemetry/AirQualityTelemetry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ int32_t AirQualityTelemetryModule::runOnce()
107107
// Check if sen5x is ready to return data, or if it needs more time because of the low concentration threshold
108108
if (sen5xSensor.hasSensor() && sen5xSensor.isActive()) {
109109
sen5xPendingForReady = sen5xSensor.pendingForReady();
110+
LOG_DEBUG("SEN5X: Pending for ready %ums", sen5xPendingForReady);
110111
if (sen5xPendingForReady) {
111112
return sen5xPendingForReady;
112113
}

src/modules/Telemetry/Sensor/SEN5XSensor.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SEN5XSensor::SEN5XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SEN5
1313
bool SEN5XSensor::restoreClock(uint32_t currentClock){
1414
#ifdef SEN5X_I2C_CLOCK_SPEED
1515
if (currentClock != SEN5X_I2C_CLOCK_SPEED){
16-
LOG_DEBUG("Restoring I2C clock to %uHz", currentClock);
16+
// LOG_DEBUG("Restoring I2C clock to %uHz", currentClock);
1717
return bus->setClock(currentClock);
1818
}
1919
return true;
@@ -116,7 +116,7 @@ bool SEN5XSensor::sendCommand(uint16_t command, uint8_t* buffer, uint8_t byteNum
116116
uint32_t currentClock;
117117
currentClock = bus->getClock();
118118
if (currentClock != SEN5X_I2C_CLOCK_SPEED){
119-
LOG_DEBUG("Changing I2C clock to %u", SEN5X_I2C_CLOCK_SPEED);
119+
// LOG_DEBUG("Changing I2C clock to %u", SEN5X_I2C_CLOCK_SPEED);
120120
bus->setClock(SEN5X_I2C_CLOCK_SPEED);
121121
}
122122
#endif
@@ -135,7 +135,7 @@ bool SEN5XSensor::sendCommand(uint16_t command, uint8_t* buffer, uint8_t byteNum
135135
}
136136

137137
if (i2c_error != 0) {
138-
LOG_ERROR("SEN5X: Error on I2c communication: %x", i2c_error);
138+
LOG_ERROR("SEN5X: Error on I2C communication: %x", i2c_error);
139139
return false;
140140
}
141141
return true;
@@ -147,7 +147,7 @@ uint8_t SEN5XSensor::readBuffer(uint8_t* buffer, uint8_t byteNumber)
147147
uint32_t currentClock;
148148
currentClock = bus->getClock();
149149
if (currentClock != SEN5X_I2C_CLOCK_SPEED){
150-
LOG_DEBUG("Changing I2C clock to %u", SEN5X_I2C_CLOCK_SPEED);
150+
// LOG_DEBUG("Changing I2C clock to %u", SEN5X_I2C_CLOCK_SPEED);
151151
bus->setClock(SEN5X_I2C_CLOCK_SPEED);
152152
}
153153
#endif
@@ -219,7 +219,7 @@ bool SEN5XSensor::idle()
219219
LOG_ERROR("SEN5X: Error stoping measurement");
220220
return false;
221221
}
222-
delay(200); // From Sensirion Arduino library
222+
// delay(200); // From Sensirion Arduino library
223223

224224
LOG_INFO("SEN5X: Stop measurement mode");
225225

@@ -237,13 +237,13 @@ void SEN5XSensor::loadCleaningState()
237237
if (file) {
238238
file.read();
239239
file.close();
240-
LOG_INFO("Cleaning state %u read for %s read from %s", lastCleaning, sensorName, sen5XCleaningFileName);
240+
LOG_INFO("SEN5X: Cleaning state %u read for %s read from %s", lastCleaning, sensorName, sen5XCleaningFileName);
241241
} else {
242-
LOG_INFO("No %s state found (File: %s)", sensorName, sen5XCleaningFileName);
242+
LOG_INFO("SEN5X: No %s state found (File: %s)", sensorName, sen5XCleaningFileName);
243243
}
244244
spiLock->unlock();
245245
#else
246-
LOG_ERROR("ERROR: Filesystem not implemented");
246+
LOG_ERROR("SEN5X: ERROR - Filesystem not implemented");
247247
#endif
248248
}
249249

@@ -253,21 +253,21 @@ void SEN5XSensor::updateCleaningState()
253253
spiLock->lock();
254254

255255
if (FSCom.exists(sen5XCleaningFileName) && !FSCom.remove(sen5XCleaningFileName)) {
256-
LOG_WARN("Can't remove old state file");
256+
LOG_WARN("SEN5X: Can't remove old state file");
257257
}
258258
auto file = FSCom.open(sen5XCleaningFileName, FILE_O_WRITE);
259259
if (file) {
260-
LOG_INFO("Save cleaning state %u for %s to %s", lastCleaning, sensorName, sen5XCleaningFileName);
260+
LOG_INFO("SEN5X: Save cleaning state %u for %s to %s", lastCleaning, sensorName, sen5XCleaningFileName);
261261
file.write(lastCleaning);
262262
file.flush();
263263
file.close();
264264
} else {
265-
LOG_INFO("Can't write %s state (File: %s)", sensorName, sen5XCleaningFileName);
265+
LOG_INFO("SEN5X: Can't write %s state (File: %s)", sensorName, sen5XCleaningFileName);
266266
}
267267

268268
spiLock->unlock();
269269
#else
270-
LOG_ERROR("ERROR: Filesystem not implemented");
270+
LOG_ERROR("SEN5X: ERROR: Filesystem not implemented");
271271
#endif
272272
}
273273

@@ -281,7 +281,7 @@ uint32_t SEN5XSensor::wakeUp(){
281281
LOG_INFO("SEN5X: Error starting measurement");
282282
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
283283
}
284-
delay(50); // From Sensirion Arduino library
284+
// delay(50); // From Sensirion Arduino library
285285

286286
// LOG_INFO("SEN5X: Setting measurement mode");
287287
uint32_t now;
@@ -308,7 +308,7 @@ bool SEN5XSensor::startCleaning()
308308
LOG_ERROR("SEN5X: Error starting fan cleaning");
309309
return false;
310310
}
311-
delay(20); // From Sensirion Arduino library
311+
// delay(20); // From Sensirion Arduino library
312312

313313
// This message will be always printed so the user knows the device it's not hung
314314
LOG_INFO("SEN5X: Started fan cleaning it will take 10 seconds...");
@@ -318,7 +318,7 @@ bool SEN5XSensor::startCleaning()
318318
// Serial.print(".");
319319
delay(500);
320320
}
321-
LOG_INFO(" Cleaning done!!");
321+
LOG_INFO("SEN5X: Cleaning done!!");
322322

323323
// Save timestamp in flash so we know when a week has passed
324324
uint32_t now;
@@ -370,24 +370,24 @@ int32_t SEN5XSensor::runOnce()
370370
// Check if it is time to do a cleaning
371371
// TODO - this is not currently working as intended - always reading 0 from the file. We should probably make a unified approach for both the cleaning and the VOCstate
372372
loadCleaningState();
373-
LOG_INFO("Last cleaning time: %u", lastCleaning);
373+
LOG_INFO("SEN5X: Last cleaning time: %u", lastCleaning);
374374
if (lastCleaning) {
375-
LOG_INFO("Last cleaning is valid");
375+
LOG_INFO("SEN5X: Last cleaning is valid");
376376

377377
uint32_t now;
378378
now = getTime();
379-
LOG_INFO("Current time %us", now);
379+
LOG_INFO("SEN5X: Current time %us", now);
380380
uint32_t passed = now - lastCleaning;
381-
LOG_INFO("Elapsed time since last cleaning: %us", passed);
381+
LOG_INFO("SEN5X: Elapsed time since last cleaning: %us", passed);
382382

383383
if (passed > ONE_WEEK_IN_SECONDS && (now > 1514764800)) { // If current date greater than 01/01/2018 (validity check)
384384
LOG_INFO("SEN5X: More than a week since las cleaning, cleaning...");
385385
startCleaning();
386386
} else {
387-
LOG_INFO("Last cleaning date (in epoch): %u", lastCleaning);
387+
LOG_INFO("SEN5X: Last cleaning date (in epoch): %u", lastCleaning);
388388
}
389389
} else {
390-
LOG_INFO("Last cleaning is not valid");
390+
LOG_INFO("SEN5X: Last cleaning is not valid");
391391
// We asume the device has just been updated or it is new, so no need to trigger a cleaning.
392392
// Just save the timestamp to do a cleaning one week from now.
393393
lastCleaning = getTime();
@@ -574,7 +574,7 @@ int32_t SEN5XSensor::pendingForReady(){
574574
uint32_t now;
575575
now = getTime();
576576
uint32_t sinceMeasureStarted = (now - measureStarted)*1000;
577-
LOG_INFO("Since measure started: %u", sinceMeasureStarted);
577+
LOG_DEBUG("SEN5X: Since measure started: %ums", sinceMeasureStarted);
578578
switch (state) {
579579
case SEN5X_MEASUREMENT: {
580580

0 commit comments

Comments
 (0)