-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration files for Shelly_Plus1Mini
- Loading branch information
1 parent
d327c04
commit fbba7c3
Showing
6 changed files
with
768 additions
and
45 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Br load("Shelly_Plus1Mini.autoconf#cp_bootloader.be") load("Shelly_Plus1Mini.autoconf#bootloader.be") global.bootloader().flash() | ||
Br load("Shelly_Plus1Mini.autoconf#migrate_shelly.be") | ||
Template {"NAME":"Shelly Plus1Mini","GPIO":[320,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1,"CMND":"AdcParam1 2,5600,4700,3350"} | ||
Module 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# migration script for Shelly | ||
|
||
# simple function to copy from autoconfig archive to filesystem | ||
# return true if ok | ||
def cp(from, to) | ||
import path | ||
if to == nil to = from end # to is optional | ||
if !path.exists(to) | ||
try | ||
# tasmota.log("f_in="+tasmota.wd + from) | ||
var f_in = open(tasmota.wd + from) | ||
var f_content = f_in.readbytes() | ||
f_in.close() | ||
var f_out = open(to, "w") | ||
f_out.write(f_content) | ||
f_out.close() | ||
except .. as e,m | ||
tasmota.log("OTA: Couldn't copy "+to+" "+e+" "+m,2) | ||
return false | ||
end | ||
return true | ||
end | ||
return true | ||
end | ||
|
||
# make some room if there are some leftovers from shelly | ||
import path | ||
path.remove("index.html.gz") | ||
|
||
# copy some files from autoconf to filesystem | ||
var ok | ||
ok = cp("bootloader-tasmota-c3.bin") | ||
ok = cp("Partition_Wizard.tapp") | ||
|
||
# use an alternative to partition_core that can read Shelly's otadata | ||
tasmota.log("OTA: loading "+tasmota.wd + "partition_core_shelly.be", 2) | ||
load(tasmota.wd + "partition_core_shelly.be") | ||
|
||
# load bootloader flasher | ||
tasmota.log("OTA: loading "+tasmota.wd + "bootloader.be", 2) | ||
load(tasmota.wd + "bootloader.be") | ||
|
||
|
||
# all good | ||
if ok | ||
# do some basic check that the bootloader is not already in place | ||
import flash | ||
if flash.read(0x1000, 4) == bytes('CD3F6395') | ||
tasmota.log("OTA: bootloader already in place, not flashing it") | ||
else | ||
ok = global.bootloader().flash("bootloader-tasmota-c3.bin") | ||
end | ||
if ok | ||
var p = global.partition_core_shelly.Partition() | ||
p.save() # save with otadata compatible with new bootloader | ||
tasmota.log("OTA: Shelly migration successful", 2) | ||
end | ||
end | ||
|
||
# dump logs to file | ||
var lr = tasmota_log_reader() | ||
var f_logs = open("migration_logs.txt", "w") | ||
var logs = lr.get_log(2) | ||
while logs != nil | ||
f_logs.write(logs) | ||
logs = lr.get_log(2) | ||
end | ||
f_logs.close() | ||
|
||
# Done |
Oops, something went wrong.