Browse Source

Added support for progmem debug messages

fastled
Xose Pérez 7 years ago
parent
commit
6f793ff376
2 changed files with 31 additions and 29 deletions
  1. +2
    -0
      code/espurna/config/debug.h
  2. +29
    -29
      code/espurna/wifi.ino

+ 2
- 0
code/espurna/config/debug.h View File

@ -1,5 +1,7 @@
#ifdef DEBUG_PORT
#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
#define DEBUG_MSG(...)
#define DEBUG_MSG_P(...)
#endif

+ 29
- 29
code/espurna/wifi.ino View File

@ -87,34 +87,34 @@ void wifiConfigure() {
void wifiStatus() {
if (WiFi.getMode() == WIFI_AP_STA) {
DEBUG_MSG("[WIFI] MODE AP + STA --------------------------------\n");
DEBUG_MSG_P(PSTR("[WIFI] MODE AP + STA --------------------------------\n"));
} else if (WiFi.getMode() == WIFI_AP) {
DEBUG_MSG("[WIFI] MODE AP --------------------------------------\n");
DEBUG_MSG_P(PSTR("[WIFI] MODE AP --------------------------------------\n"));
} else if (WiFi.getMode() == WIFI_STA) {
DEBUG_MSG("[WIFI] MODE STA -------------------------------------\n");
DEBUG_MSG_P(PSTR("[WIFI] MODE STA -------------------------------------\n"));
} else {
DEBUG_MSG("[WIFI] MODE OFF -------------------------------------\n");
DEBUG_MSG("[WIFI] No connection\n");
DEBUG_MSG_P(PSTR("[WIFI] MODE OFF -------------------------------------\n"));
DEBUG_MSG_P(PSTR("[WIFI] No connection\n"));
}
if ((WiFi.getMode() & WIFI_AP) == WIFI_AP) {
DEBUG_MSG("[WIFI] SSID %s\n", jw.getAPSSID().c_str());
DEBUG_MSG("[WIFI] PASS %s\n", getSetting("adminPass", ADMIN_PASS).c_str());
DEBUG_MSG("[WIFI] IP %s\n", WiFi.softAPIP().toString().c_str());
DEBUG_MSG("[WIFI] MAC %s\n", WiFi.softAPmacAddress().c_str());
DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), jw.getAPSSID().c_str());
DEBUG_MSG_P(PSTR("[WIFI] PASS %s\n"), getSetting("adminPass", ADMIN_PASS).c_str());
DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.softAPIP().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.softAPmacAddress().c_str());
}
if ((WiFi.getMode() & WIFI_STA) == WIFI_STA) {
DEBUG_MSG("[WIFI] SSID %s\n", WiFi.SSID().c_str());
DEBUG_MSG("[WIFI] IP %s\n", WiFi.localIP().toString().c_str());
DEBUG_MSG("[WIFI] MAC %s\n", WiFi.macAddress().c_str());
DEBUG_MSG("[WIFI] GW %s\n", WiFi.gatewayIP().toString().c_str());
DEBUG_MSG("[WIFI] MASK %s\n", WiFi.subnetMask().toString().c_str());
DEBUG_MSG("[WIFI] DNS %s\n", WiFi.dnsIP().toString().c_str());
DEBUG_MSG("[WIFI] HOST %s\n", WiFi.hostname().c_str());
DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), WiFi.SSID().c_str());
DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.localIP().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.macAddress().c_str());
DEBUG_MSG_P(PSTR("[WIFI] GW %s\n"), WiFi.gatewayIP().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str());
DEBUG_MSG_P(PSTR("[WIFI] HOST %s\n"), WiFi.hostname().c_str());
}
DEBUG_MSG("[WIFI] ----------------------------------------------\n");
DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n"));
}
@ -128,27 +128,27 @@ void wifiSetup() {
#ifdef DEBUG_PORT
if (code == MESSAGE_SCANNING) {
DEBUG_MSG("[WIFI] Scanning\n");
DEBUG_MSG_P(PSTR("[WIFI] Scanning\n"));
}
if (code == MESSAGE_SCAN_FAILED) {
DEBUG_MSG("[WIFI] Scan failed\n");
DEBUG_MSG_P(PSTR("[WIFI] Scan failed\n"));
}
if (code == MESSAGE_NO_NETWORKS) {
DEBUG_MSG("[WIFI] No networks found\n");
DEBUG_MSG_P(PSTR("[WIFI] No networks found\n"));
}
if (code == MESSAGE_NO_KNOWN_NETWORKS) {
DEBUG_MSG("[WIFI] No known networks found\n");
DEBUG_MSG_P(PSTR("[WIFI] No known networks found\n"));
}
if (code == MESSAGE_FOUND_NETWORK) {
DEBUG_MSG("[WIFI] %s\n", parameter);
DEBUG_MSG_P(PSTR("[WIFI] %s\n"), parameter);
}
if (code == MESSAGE_CONNECTING) {
DEBUG_MSG("[WIFI] Connecting to %s\n", parameter);
DEBUG_MSG_P(PSTR("[WIFI] Connecting to %s\n"), parameter);
}
if (code == MESSAGE_CONNECT_WAITING) {
@ -156,7 +156,7 @@ void wifiSetup() {
}
if (code == MESSAGE_CONNECT_FAILED) {
DEBUG_MSG("[WIFI] Could not connect to %s\n", parameter);
DEBUG_MSG_P(PSTR("[WIFI] Could not connect to %s\n"), parameter);
}
if (code == MESSAGE_CONNECTED) {
@ -168,15 +168,15 @@ void wifiSetup() {
}
if (code == MESSAGE_DISCONNECTED) {
DEBUG_MSG("[WIFI] Disconnected\n");
DEBUG_MSG_P(PSTR("[WIFI] Disconnected\n"));
}
if (code == MESSAGE_ACCESSPOINT_CREATING) {
DEBUG_MSG("[WIFI] Creating access point\n");
DEBUG_MSG_P(PSTR("[WIFI] Creating access point\n"));
}
if (code == MESSAGE_ACCESSPOINT_FAILED) {
DEBUG_MSG("[WIFI] Could not create access point\n");
DEBUG_MSG_P(PSTR("[WIFI] Could not create access point\n"));
}
#endif
@ -185,9 +185,9 @@ void wifiSetup() {
if (code == MESSAGE_CONNECTED) {
if (MDNS.begin((char *) WiFi.hostname().c_str())) {
MDNS.addService("http", "tcp", 80);
DEBUG_MSG("[MDNS] OK\n");
DEBUG_MSG_P(PSTR("[MDNS] OK\n"));
} else {
DEBUG_MSG("[MDNS] FAIL\n");
DEBUG_MSG_P(PSTR("[MDNS] FAIL\n"));
}
}


Loading…
Cancel
Save