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
*/
HTTPClient::HTTPClient()
: _client(nullptr), _userAgent(F("ESP8266HTTPClient"))
{
_client = nullptr;
#if HTTPCLIENT_1_1_COMPATIBLE
_tcpDeprecated.reset(nullptr);
#endif
@ -1294,21 +1294,21 @@ int HTTPClient::handleHeaderResponse()
String headerValue = headerLine.substring(headerLine.indexOf(':') + 1);
headerValue.trim();
if(headerName.equalsIgnoreCase("Content-Length")) {
if(headerName.equalsIgnoreCase(F("Content-Length"))) {
_size = headerValue.toInt();
}
if(_canReuse && headerName.equalsIgnoreCase("Connection")) {
if(_canReuse && headerName.equalsIgnoreCase(F("Connection"))) {
if(headerValue.indexOf("close") >= 0 && headerValue.indexOf("keep-alive") < 0) {
_canReuse = false;
}
}
if(headerName.equalsIgnoreCase("Transfer-Encoding")) {
if(headerName.equalsIgnoreCase(F("Transfer-Encoding"))) {
transferEncoding = headerValue;
}
if(headerName.equalsIgnoreCase("Location")) {
if(headerName.equalsIgnoreCase(F("Location"))) {
_location = headerValue;
}
@ -1334,7 +1334,7 @@ int HTTPClient::handleHeaderResponse()
if(transferEncoding.length() > 0) {
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;
} else {
return HTTPC_ERROR_ENCODING;

View File

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

View File

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

View File

@ -49,24 +49,24 @@ extern "C" {
* @param p Print interface
*/
void ESP8266WiFiClass::printDiag(Print& p) {
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };
p.print("Mode: ");
const char* const modes[] = { "NULL", "STA", "AP", "STA+AP" };
p.print(F("Mode: "));
p.println(modes[wifi_get_opmode()]);
const char* phymodes[] = { "", "B", "G", "N" };
p.print("PHY mode: ");
const char* const phymodes[] = { "", "B", "G", "N" };
p.print(F("PHY mode: "));
p.println(phymodes[(int) wifi_get_phy_mode()]);
p.print("Channel: ");
p.print(F("Channel: "));
p.println(wifi_get_channel());
p.print("AP id: ");
p.print(F("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.print("Auto connect: ");
p.print(F("Auto connect: "));
p.println(wifi_station_get_auto_connect());
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
memcpy(ssid, conf.ssid, sizeof(conf.ssid));
ssid[32] = 0; //nullterm in case of 32 char ssid
p.print("SSID (");
p.print(strlen(ssid));
p.print("): ");
p.println(ssid);
p.printf_P(PSTR("SSID (%d): %s\n"), strlen(ssid), ssid);
char passphrase[65];
memcpy(passphrase, conf.password, sizeof(conf.password));
passphrase[64] = 0;
p.printf_P(PSTR("Passphrase (%d): %s\n"), strlen(passphrase), passphrase);
p.print("Passphrase (");
p.print(strlen(passphrase));
p.print("): ");
p.println(passphrase);
p.print("BSSID set: ");
p.print(F("BSSID set: "));
p.println(conf.bssid_set);
}