Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
slav-at-attachix committed May 26, 2021
1 parent c9323e1 commit 3f62fef
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ For more examples take a look at the [HttpClient](samples/HttpClient/app/applica
### OTA Application Update
```c++
void OtaUpdate()
void doUpgrade()
{
// need a clean object, otherwise if run before and failed will not run again
if(otaUpdater) {
Expand All @@ -253,7 +253,7 @@ void OtaUpdate()
  otaUpdater->addItem(ROM_0_URL, part);
  // and/or set a callback (called on failure or success without switching requested)
  otaUpdater->setCallback(OtaUpdate_CallBack);
  otaUpdater->setCallback(upgradeCallback);
  // start update
  otaUpdater->start();
Expand Down
2 changes: 1 addition & 1 deletion Sming/Components/Ota/src/Arch/Esp32/IdfUpgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool IdfUpgrader::begin(Partition partition, size_t size)
writtenSoFar = 0;
maxSize = size ?: partition.size();

esp_err_t result = esp_ota_begin(convertToIdfPartition(partition), size ?: partition.size(), &handle);
esp_err_t result = esp_ota_begin(convertToIdfPartition(partition), maxSize, &handle);

return result == ESP_OK;
}
Expand Down
3 changes: 1 addition & 2 deletions Sming/Components/Ota/src/Arch/Esp8266/RbootUpgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ Partition RbootUpgrader::getRunningPartition()
uint8_t slot = rboot_get_current_rom();
#ifdef RBOOT_ENABLE_RTC
rboot_rtc_data rtc;
rboot_get_rtc_data(&rtc);
if(rtc.last_mode == MODE_TEMP_ROM) {
if(rboot_get_rtc_data(&rtc) && rtc.last_mode == MODE_TEMP_ROM) {
slot = rtc.last_rom;
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class RbootUpgrader : public UpgraderBase
Partition getNextBootPartition(Partition startFrom = {}) override
{
uint8_t currentSlot = rboot_get_current_rom();
if(startFrom) {
currentSlot = getSlotForPartition(startFrom);
}
return getPartitionForSlot(currentSlot ? 0 : 1);
}

Expand Down
7 changes: 1 addition & 6 deletions Sming/Components/OtaNetwork/src/HttpUpgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
* http://github.com/SmingHub/Sming
* All files of the Sming Core are provided under the LGPL v3 license.
*
* RbootHttpUpdater.cpp
*
* Created on: 2015/09/03.
* Author: Richard A Burton & Anakod
*
* Modified: 2017 - Slavey Karadzhov <[email protected]>
* HttpUpdater.cpp
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Created on: 2015/09/03.
* Author: Richard A Burton & Anakod
*
* Modified: 2017 - Slavey Karadzhov <[email protected]>
* Modified: 2017, 2021 - Slavey Karadzhov <[email protected]>
*
****/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ COMPONENT_DEPENDS := OtaUpgradeMqtt
RBOOT_ENABLED := 1

## Use standard hardware config with two ROM slots and two SPIFFS partitions
HWCONFIG := ota
HWCONFIG := ota

APP_CFLAGS = -DMQTT_URL="\"$(MQTT_URL)"\" \
-DMQTT_FINGERPRINT_SHA1=$(MQTT_FINGERPRINT_SHA1) \
Expand Down
18 changes: 9 additions & 9 deletions Sming/Libraries/OtaUpgradeMqtt/samples/Upgrade/ota.hw
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"base_config": "spiffs-two-roms",
"partitions": {
"rom0": {
"subtype": "ota_0"
},
"rom1": {
"subtype": "ota_1"
}
}
"base_config": "spiffs-two-roms",
"partitions": {
"rom0": {
"subtype": "ota_0"
},
"rom1": {
"subtype": "ota_1"
}
}
}
18 changes: 9 additions & 9 deletions samples/Basic_Ota/ota.hw
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"base_config": "spiffs-two-roms",
"partitions": {
"rom0": {
"subtype": "ota_0"
},
"rom1": {
"subtype": "ota_1"
}
}
"base_config": "spiffs-two-roms",
"partitions": {
"rom0": {
"subtype": "ota_0"
},
"rom1": {
"subtype": "ota_1"
}
}
}

0 comments on commit 3f62fef

Please sign in to comment.