Skip to content

Commit 8c3268f

Browse files
committed
Use Flash Strings for Debug output
This is hopefully very infrequently used, so it shouldn't be in main memory.
1 parent dcdc62a commit 8c3268f

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ extern "C" {
4949
* @param p Print interface
5050
*/
5151
void ESP8266WiFiClass::printDiag(Print& p) {
52-
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };
53-
p.print("Mode: ");
52+
const char* const modes[] = { "NULL", "STA", "AP", "STA+AP" };
53+
p.print(F("Mode: "));
5454
p.println(modes[wifi_get_opmode()]);
5555

56-
const char* phymodes[] = { "", "B", "G", "N" };
57-
p.print("PHY mode: ");
56+
const char* const phymodes[] = { "", "B", "G", "N" };
57+
p.print(F("PHY mode: "));
5858
p.println(phymodes[(int) wifi_get_phy_mode()]);
5959

60-
p.print("Channel: ");
60+
p.print(F("Channel: "));
6161
p.println(wifi_get_channel());
6262

63-
p.print("AP id: ");
63+
p.print(F("AP id: "));
6464
p.println(wifi_station_get_current_ap_id());
6565

66-
p.print("Status: ");
66+
p.print(F("Status: "));
6767
p.println(wifi_station_get_connect_status());
6868

69-
p.print("Auto connect: ");
69+
p.print(F("Auto connect: "));
7070
p.println(wifi_station_get_auto_connect());
7171

7272
struct station_config conf;
@@ -75,22 +75,14 @@ void ESP8266WiFiClass::printDiag(Print& p) {
7575
char ssid[33]; //ssid can be up to 32chars, => plus null term
7676
memcpy(ssid, conf.ssid, sizeof(conf.ssid));
7777
ssid[32] = 0; //nullterm in case of 32 char ssid
78-
79-
p.print("SSID (");
80-
p.print(strlen(ssid));
81-
p.print("): ");
82-
p.println(ssid);
78+
p.printf_P(PSTR("SSID (%d): %s\n"), strlen(ssid), ssid);
8379

8480
char passphrase[65];
8581
memcpy(passphrase, conf.password, sizeof(conf.password));
8682
passphrase[64] = 0;
83+
p.printf_P(PSTR("Passphrase (%d): %s\n"), strlen(passphrase), passphrase);
8784

88-
p.print("Passphrase (");
89-
p.print(strlen(passphrase));
90-
p.print("): ");
91-
p.println(passphrase);
92-
93-
p.print("BSSID set: ");
85+
p.print(F("BSSID set: "));
9486
p.println(conf.bssid_set);
9587

9688
}

0 commit comments

Comments
 (0)