Closed
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: [ESP8266]
- Core Version: [Update EEPROM.cpp #6599]
- Development Env: [Arduino IDE]
- Operating System: [Windows]
Settings in IDE
- Module: [Generic ESP8266 Module]
- Flash Mode: [dio]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [115200]
Problem Description
The EEPROM::put() method's param doesn't support the type of String or a pointer. The put() method used sizeof(T)
, But the sizeof(String)
's output is a const value of 12. So, when the String's length bigger than 12, it failed.
MCVE Sketch
#include <Arduino.h>
#include <EEPROM.h>
String apikey("el2bmjdq45ttqqfrxsy15fx3wyr313t8");
String read__byte_array(unsigned short addr, unsigned short length)
{
char temp[length];
for (int i = 0; i < length; i++)
{
temp[i] = EEPROM.read(addr + i); //读取数据
}
return temp;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.printf("apikey: %d\n", sizeof(apikey));
EEPROM.begin(64);
EEPROM.put(0, apikey);
EEPROM.end();
Serial.println("network configruation successfuly saved in EEPROM");
EEPROM.begin(64);
String apikey_r = read__byte_array(0, 64);
Serial.println("=====");
Serial.println(apikey_r);
}
void loop() {
// put your main code here, to run repeatedly:
}
Debug Messages
apikey: 12
network configruation successfuly saved in EEPROM
=====
ゑ?/
Metadata
Metadata
Assignees
Labels
No labels