1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

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.
This commit is contained in:
Dirk Mueller 2019-10-04 04:17:36 +02:00 committed by Develo
parent fb2cbe36a1
commit 3890e1af1e
4 changed files with 19 additions and 27 deletions

View File

@ -113,8 +113,8 @@ protected:
* constructor * constructor
*/ */
HTTPClient::HTTPClient() HTTPClient::HTTPClient()
: _client(nullptr), _userAgent(F("ESP8266HTTPClient"))
{ {
_client = nullptr;
#if HTTPCLIENT_1_1_COMPATIBLE #if HTTPCLIENT_1_1_COMPATIBLE
_tcpDeprecated.reset(nullptr); _tcpDeprecated.reset(nullptr);
#endif #endif
@ -1294,21 +1294,21 @@ int HTTPClient::handleHeaderResponse()
String headerValue = headerLine.substring(headerLine.indexOf(':') + 1); String headerValue = headerLine.substring(headerLine.indexOf(':') + 1);
headerValue.trim(); headerValue.trim();
if(headerName.equalsIgnoreCase("Content-Length")) { if(headerName.equalsIgnoreCase(F("Content-Length"))) {
_size = headerValue.toInt(); _size = headerValue.toInt();
} }
if(_canReuse && headerName.equalsIgnoreCase("Connection")) { if(_canReuse && headerName.equalsIgnoreCase(F("Connection"))) {
if(headerValue.indexOf("close") >= 0 && headerValue.indexOf("keep-alive") < 0) { if(headerValue.indexOf("close") >= 0 && headerValue.indexOf("keep-alive") < 0) {
_canReuse = false; _canReuse = false;
} }
} }
if(headerName.equalsIgnoreCase("Transfer-Encoding")) { if(headerName.equalsIgnoreCase(F("Transfer-Encoding"))) {
transferEncoding = headerValue; transferEncoding = headerValue;
} }
if(headerName.equalsIgnoreCase("Location")) { if(headerName.equalsIgnoreCase(F("Location"))) {
_location = headerValue; _location = headerValue;
} }
@ -1334,7 +1334,7 @@ int HTTPClient::handleHeaderResponse()
if(transferEncoding.length() > 0) { if(transferEncoding.length() > 0) {
DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Transfer-Encoding: %s\n", transferEncoding.c_str()); DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Transfer-Encoding: %s\n", transferEncoding.c_str());
if(transferEncoding.equalsIgnoreCase("chunked")) { if(transferEncoding.equalsIgnoreCase(F("chunked"))) {
_transferEncoding = HTTPC_TE_CHUNKED; _transferEncoding = HTTPC_TE_CHUNKED;
} else { } else {
return HTTPC_ERROR_ENCODING; return HTTPC_ERROR_ENCODING;

View File

@ -242,7 +242,7 @@ protected:
String _uri; String _uri;
String _protocol; String _protocol;
String _headers; String _headers;
String _userAgent = "ESP8266HTTPClient"; String _userAgent;
String _base64Authorization; String _base64Authorization;
/// Response handling /// Response handling

View File

@ -238,7 +238,7 @@ bool ESP8266WebServerTemplate<ServerType>::_parseRequest(ClientType& client) {
DEBUG_OUTPUT.println(headerValue); DEBUG_OUTPUT.println(headerValue);
#endif #endif
if (headerName.equalsIgnoreCase("Host")){ if (headerName.equalsIgnoreCase(F("Host"))){
_hostHeader = headerValue; _hostHeader = headerValue;
} }
} }

View File

@ -49,24 +49,24 @@ extern "C" {
* @param p Print interface * @param p Print interface
*/ */
void ESP8266WiFiClass::printDiag(Print& p) { void ESP8266WiFiClass::printDiag(Print& p) {
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" }; const char* const modes[] = { "NULL", "STA", "AP", "STA+AP" };
p.print("Mode: "); p.print(F("Mode: "));
p.println(modes[wifi_get_opmode()]); p.println(modes[wifi_get_opmode()]);
const char* phymodes[] = { "", "B", "G", "N" }; const char* const phymodes[] = { "", "B", "G", "N" };
p.print("PHY mode: "); p.print(F("PHY mode: "));
p.println(phymodes[(int) wifi_get_phy_mode()]); p.println(phymodes[(int) wifi_get_phy_mode()]);
p.print("Channel: "); p.print(F("Channel: "));
p.println(wifi_get_channel()); p.println(wifi_get_channel());
p.print("AP id: "); p.print(F("AP id: "));
p.println(wifi_station_get_current_ap_id()); p.println(wifi_station_get_current_ap_id());
p.print("Status: "); p.print(F("Status: "));
p.println(wifi_station_get_connect_status()); p.println(wifi_station_get_connect_status());
p.print("Auto connect: "); p.print(F("Auto connect: "));
p.println(wifi_station_get_auto_connect()); p.println(wifi_station_get_auto_connect());
struct station_config conf; struct station_config conf;
@ -75,22 +75,14 @@ void ESP8266WiFiClass::printDiag(Print& p) {
char ssid[33]; //ssid can be up to 32chars, => plus null term char ssid[33]; //ssid can be up to 32chars, => plus null term
memcpy(ssid, conf.ssid, sizeof(conf.ssid)); memcpy(ssid, conf.ssid, sizeof(conf.ssid));
ssid[32] = 0; //nullterm in case of 32 char ssid ssid[32] = 0; //nullterm in case of 32 char ssid
p.printf_P(PSTR("SSID (%d): %s\n"), strlen(ssid), ssid);
p.print("SSID (");
p.print(strlen(ssid));
p.print("): ");
p.println(ssid);
char passphrase[65]; char passphrase[65];
memcpy(passphrase, conf.password, sizeof(conf.password)); memcpy(passphrase, conf.password, sizeof(conf.password));
passphrase[64] = 0; passphrase[64] = 0;
p.printf_P(PSTR("Passphrase (%d): %s\n"), strlen(passphrase), passphrase);
p.print("Passphrase ("); p.print(F("BSSID set: "));
p.print(strlen(passphrase));
p.print("): ");
p.println(passphrase);
p.print("BSSID set: ");
p.println(conf.bssid_set); p.println(conf.bssid_set);
} }