From 49a8e9ff1d1cc801558af3745d2485dd664fdd9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 23 Feb 2017 23:29:23 +0100 Subject: [PATCH] Issue #84. prevent using the hardware serial in the Dual for debug messages --- code/espurna/config/debug.h | 6 +++++- code/espurna/i2c.ino | 6 +++--- code/espurna/settings.ino | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/code/espurna/config/debug.h b/code/espurna/config/debug.h index 7d4a3346..e91a19bd 100644 --- a/code/espurna/config/debug.h +++ b/code/espurna/config/debug.h @@ -1,7 +1,11 @@ #ifdef DEBUG_PORT +#ifndef SONOFF_DUAL #define DEBUG_MSG(...) DEBUG_PORT.printf( __VA_ARGS__ ) #define DEBUG_MSG_P(...) { char buffer[81]; snprintf_P(buffer, 80, __VA_ARGS__ ); DEBUG_PORT.printf( buffer ); } -#else +#endif +#endif + +#ifndef DEBUG_MSG #define DEBUG_MSG(...) #define DEBUG_MSG_P(...) #endif diff --git a/code/espurna/i2c.ino b/code/espurna/i2c.ino index 9bdf60ab..221c22df 100644 --- a/code/espurna/i2c.ino +++ b/code/espurna/i2c.ino @@ -24,14 +24,14 @@ void i2cScan() { response = brzo_i2c_end_transaction(); if (response == 0) { - Serial.printf("[I2C] Device found at address 0x%02X\n", address); + DEBUG_MSG("[I2C] Device found at address 0x%02X\n", address); nDevices++; } else if (response != 32) { - //Serial.printf("[I2C] Unknown error at address 0x%02X\n", address); + //DEBUG_MSG("[I2C] Unknown error at address 0x%02X\n", address); } } - if (nDevices == 0) Serial.println("[I2C] No devices found"); + if (nDevices == 0) DEBUG_MSG("[I2C] No devices found"); } diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 8f58179e..5d99d6ab 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -93,16 +93,16 @@ void settingsSetup() { }); Embedis::command( F("STATUS"), [](Embedis* e) { - Serial.printf("Free heap: %d bytes\n", ESP.getFreeHeap()); + e->stream->printf("Free heap: %d bytes\n", ESP.getFreeHeap()); e->response(Embedis::OK); }); Embedis::command( F("EEPROM.DUMP"), [](Embedis* e) { for (unsigned int i = 0; i < SPI_FLASH_SEC_SIZE; i++) { - if (i % 16 == 0) Serial.printf("\n[%04X] ", i); - Serial.printf("%02X ", EEPROM.read(i)); + if (i % 16 == 0) e->stream->printf("\n[%04X] ", i); + e->stream->printf("%02X ", EEPROM.read(i)); } - Serial.printf("\n"); + e->stream->printf("\n"); e->response(Embedis::OK); });