Thx Martin for your tip ... so now i'm trying to use "Update.write" to flash new firmware ...
So now i have an another problem, Esp reboot and bug when i want to put file object in a uint8_t buffer...
Here is my code ..
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include "FS.h"
const char *ssid = "CaptoBox";
ESP8266WebServer server(80); // create server
void setup() {
Serial.begin(115200);
Serial.println();
SPIFFS.begin();
Dir dir = SPIFFS.openDir("/");
serveur();
server.begin();
pinMode(BUILTIN_LED, OUTPUT);
digitalWrite(BUILTIN_LED, HIGH);
}
void loop() {
server.handleClient();
}
void serveur() {
server.on("/flash", HTTP_GET, []() {
digitalWrite(BUILTIN_LED, LOW);
//handleFileRead("/blinkESP.bin");
Serial.println("mise a jour");
server.send(200, "text/plain", "Update");
File file = SPIFFS.open("/blinkESP.bin", "r");
size_t len = file.size();
Serial.println(file.size());
uint8_t *buff;
file.read(buff, len) ; ////here is my problem
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
if (!Update.begin(maxSketchSpace, U_FLASH)) { //start with max available size
Update.printError(Serial);
}
// Update.write(buff,len);
file.close();
});
}