-
-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement firmware update functionality #153
Conversation
miio/vacuum_cli.py
Outdated
click.echo("Using %s (md5: %s)" % (file, md5)) | ||
else: | ||
pass | ||
#Updater() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
block comment should start with '# '
miio/updater.py
Outdated
|
||
if __name__ == "__main__": | ||
import netifaces | ||
ifaces_without_lo = [x for x in netifaces.interfaces() if not x.startswith("lo")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (85 > 79 characters)
miio/updater.py
Outdated
self.server.timeout = 10 | ||
|
||
with open(file, 'rb') as f: | ||
self.payload = f.read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be memory inefficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't matter here, as the file needs to be read at some point for sending it to the client. The code is however incomplete, there is currently no way to tell interface/IP to use for the url (e.g. when one has multiple network interfaces as I do). I will have to look more into it in a week when I'll be able to test it on the device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point i mean is you should read file by chunks and feed data to hash, reading hundreds megabytes to memory at once is a bad idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand what you mean, but at some the file has to be read (again) for sending over the wire to the device. I'll look into that though, thanks :-)
btw, why own server? why handle_request so bad? |
@CODeRUS I wanted to have it so that one can simply point it to any file (and not to expose the contents over HTTP), although I think changing to the source directory and launching the server there would be fine too. |
Thanks for exploring the device in-depth goes to the dustcloud project, which also describes how to build own, custom firmwares.
26fb61f
to
b268cd3
Compare
miio/updater.py
Outdated
ifaces_without_lo = [x for x in netifaces.interfaces() if not x.startswith("lo")] | ||
# print(ifaces_without_lo) | ||
logging.basicConfig(level=logging.DEBUG) | ||
upd = Updater("/tmp/test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'Updater'
… to fix the progress reporting
miio/vacuumcontainers.py
Outdated
@@ -522,7 +522,13 @@ def error(self) -> int: | |||
@property | |||
def is_installing(self) -> bool: | |||
"""True if install is in progress.""" | |||
return self.sid != 0 and self.progress < 100 and self.error == 0 | |||
return self.state == SoundInstallState.Downloading or \ | |||
self.state == SoundInstallState.Installing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line over-indented for visual indent
miio/vacuum_cli.py
Outdated
try: | ||
state = vac.update_state() | ||
progress = vac.update_progress() | ||
except: # we may not get our messages through during upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least two spaces before inline comment
miio/vacuum_cli.py
Outdated
if update_state == UpdateState.Downloading: | ||
click.echo("Update progress: %s" % vac.update_progress()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
miio/vacuum_cli.py
Outdated
@@ -480,6 +504,67 @@ def configure_wifi(vac: miio.Vacuum, ssid: str, password: str, | |||
click.echo("Configuring wifi to SSID: %s" % ssid) | |||
click.echo(vac.configure_wifi(ssid, password, uid, timezone)) | |||
|
|||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
miio/vacuumcontainers.py
Outdated
@@ -522,7 +522,13 @@ def error(self) -> int: | |||
@property | |||
def is_installing(self) -> bool: | |||
"""True if install is in progress.""" | |||
return self.sid != 0 and self.progress < 100 and self.error == 0 | |||
return self.state == SoundInstallState.Downloading or \ | |||
self.state == SoundInstallState.Installing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line over-indented for visual indent
miio/vacuum_cli.py
Outdated
try: | ||
state = vac.update_state() | ||
progress = vac.update_progress() | ||
except: # we may not get our messages through during upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least two spaces before inline comment
miio/vacuum_cli.py
Outdated
if update_state == UpdateState.Downloading: | ||
click.echo("Update progress: %s" % vac.update_progress()) | ||
|
||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
miio/vacuum_cli.py
Outdated
@@ -480,6 +504,67 @@ def configure_wifi(vac: miio.Vacuum, ssid: str, password: str, | |||
click.echo("Configuring wifi to SSID: %s" % ssid) | |||
click.echo(vac.configure_wifi(ssid, password, uid, timezone)) | |||
|
|||
@cli.command() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected 2 blank lines, found 1
I think this is pretty much done and ready to be tested now. The code could be made cleaner, but that can be done later. |
Add ability to perform firmware updates on the device.
Works either by passing an URL with md5sum for the firmware image,
or alternatively by passing a local filename.
In case of the input is a local filename, its md5sum will be calculated automatically,
and the update will be delivered by the built-in web server.
or
The
install_sound
functionality is also extended to use the builtin web-server class, so installing sound packages is as simple as callingmirobo install_sound <soundfile.pkg>
.For more details & archive of firmware updates see https://github.com/dgiese/dustcloud .
Thanks for exploring the device in-depth goes to the dustcloud project,
which also describes how to build own, custom firmwares.