Multi-image OTA support on small flash devices

master
informatic 2017-09-29 21:00:56 +02:00
parent 904253dca4
commit 3abe49fb0e
2 changed files with 7 additions and 4 deletions

View File

@ -129,6 +129,7 @@ void SpejsNode::onConnected() {
notify("$mac", WifiStation.getMAC());
notify("$fw/name", "spejsiot");
notify("$fw/version", BUILD_ID);
notify("$fw/slot", String(currentSlot));
// HTTP initialization
http.listen(80);

View File

@ -11,7 +11,12 @@ EndpointResult ImplementationEndpoint::onValue(String property, String value) {
void ImplementationEndpoint::startOTA() {
uint8_t slot;
rboot_config bootconf;
#ifdef RBOOT_TWO_ROMS
String romURL = OTA_URL + parent->deviceID + (parent->currentSlot ? "/rom1.bin" : "/rom0.bin");
#else
String romURL = OTA_URL + parent->deviceID + "/rom0.bin";
#endif
String spiffsURL = OTA_URL + parent->deviceID + "/spiff_rom.bin";
Serial.println("Updating...");
@ -22,10 +27,7 @@ void ImplementationEndpoint::startOTA() {
bootconf = rboot_get_config();
if (parent->currentSlot == 0)
slot = 1;
else
slot = 0;
slot = !parent->currentSlot;
Serial.printf("Updating to rom %d.\r\n", slot);