Skip to content

Commit 3890e1a

Browse files
dirkmuellerdevyte
authored andcommitted
Put longer string literals into PROGMEM (#6588)
* Put longer string literals into PROGMEM * Use Flash Strings for Debug output This is hopefully very infrequently used, so it shouldn't be in main memory.
1 parent fb2cbe3 commit 3890e1a

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class BearSSLTraits : public TransportTraits
113113
* constructor
114114
*/
115115
HTTPClient::HTTPClient()
116+
: _client(nullptr), _userAgent(F("ESP8266HTTPClient"))
116117
{
117-
_client = nullptr;
118118
#if HTTPCLIENT_1_1_COMPATIBLE
119119
_tcpDeprecated.reset(nullptr);
120120
#endif
@@ -1294,21 +1294,21 @@ int HTTPClient::handleHeaderResponse()
12941294
String headerValue = headerLine.substring(headerLine.indexOf(':') + 1);
12951295
headerValue.trim();
12961296

1297-
if(headerName.equalsIgnoreCase("Content-Length")) {
1297+
if(headerName.equalsIgnoreCase(F("Content-Length"))) {
12981298
_size = headerValue.toInt();
12991299
}
13001300

1301-
if(_canReuse && headerName.equalsIgnoreCase("Connection")) {
1301+
if(_canReuse && headerName.equalsIgnoreCase(F("Connection"))) {
13021302
if(headerValue.indexOf("close") >= 0 && headerValue.indexOf("keep-alive") < 0) {
13031303
_canReuse = false;
13041304
}
13051305
}
13061306

1307-
if(headerName.equalsIgnoreCase("Transfer-Encoding")) {
1307+
if(headerName.equalsIgnoreCase(F("Transfer-Encoding"))) {
13081308
transferEncoding = headerValue;
13091309
}
13101310

1311-
if(headerName.equalsIgnoreCase("Location")) {
1311+
if(headerName.equalsIgnoreCase(F("Location"))) {
13121312
_location = headerValue;
13131313
}
13141314

@@ -1334,7 +1334,7 @@ int HTTPClient::handleHeaderResponse()
13341334

13351335
if(transferEncoding.length() > 0) {
13361336
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Transfer-Encoding: %s\n", transferEncoding.c_str());
1337-
if(transferEncoding.equalsIgnoreCase("chunked")) {
1337+
if(transferEncoding.equalsIgnoreCase(F("chunked"))) {
13381338
_transferEncoding = HTTPC_TE_CHUNKED;
13391339
} else {
13401340
return HTTPC_ERROR_ENCODING;

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class HTTPClient
242242
String _uri;
243243
String _protocol;
244244
String _headers;
245-
String _userAgent = "ESP8266HTTPClient";
245+
String _userAgent;
246246
String _base64Authorization;
247247

248248
/// Response handling

libraries/ESP8266WebServer/src/Parsing-impl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ bool ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
238238
DEBUG_OUTPUT.println(headerValue);
239239
#endif
240240

241-
if (headerName.equalsIgnoreCase("Host")){
241+
if (headerName.equalsIgnoreCase(F("Host"))){
242242
_hostHeader = headerValue;
243243
}
244244
}

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

+11-19
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)