Conversation
miio/vacuum_cli.py
Outdated
| click.echo("Using %s (md5: %s)" % (file, md5)) | ||
| else: | ||
| pass | ||
| #Updater() |
There was a problem hiding this comment.
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")] |
| self.server.timeout = 10 | ||
|
|
||
| with open(file, 'rb') as f: | ||
| self.payload = f.read() |
There was a problem hiding this comment.
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.
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.
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") |
… to fix the progress reporting
miio/vacuumcontainers.py
Outdated
| """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.
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.
at least two spaces before inline comment
| if update_state == UpdateState.Downloading: | ||
| click.echo("Update progress: %s" % vac.update_progress()) | ||
|
|
||
| @cli.command() |
| click.echo("Configuring wifi to SSID: %s" % ssid) | ||
| click.echo(vac.configure_wifi(ssid, password, uid, timezone)) | ||
|
|
||
| @cli.command() |
miio/vacuumcontainers.py
Outdated
| """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.
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.
at least two spaces before inline comment
| if update_state == UpdateState.Downloading: | ||
| click.echo("Update progress: %s" % vac.update_progress()) | ||
|
|
||
| @cli.command() |
| click.echo("Configuring wifi to SSID: %s" % ssid) | ||
| click.echo(vac.configure_wifi(ssid, password, uid, timezone)) | ||
|
|
||
| @cli.command() |
|
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_soundfunctionality 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.