Self Updating Mechanism

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Diaonic
Posts: 1
Joined: Tue Jun 19, 2018 7:27 pm

Self Updating Mechanism

Post by Diaonic » Tue Jun 19, 2018 7:30 pm

I really don't want to reinvent the wheel if I don't have to. Whats the best way to implement some type of software versioning / updating routine. There will be many ESP8266 in the field and I need them to periodically check for a new version of my .py files and update accordingly.

I've seen references to upip, is that the best way?

Thanks in advance.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Self Updating Mechanism

Post by pythoncoder » Thu Jun 21, 2018 8:14 am

If your application is sufficiently small not to need frozen bytecode then I'd consider using upip. I don't know if anyone has run it programmatically but there's no obvious reason why you shouldn't. It lacks an update mechanism (it only has install) but I'm sure you could invent a way of checking for a new version on PyPi.
Peter Hinch
Index to my micropython libraries.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Self Updating Mechanism

Post by devnull » Thu Jun 21, 2018 12:18 pm

Hi;

I have done this using a nodejs webserver to host the update files, using express server-side it is pretty trivial:

Code: Select all

var express = require('express');
var app = express();
var home = '/nfs/qnap/data/uPython/updates';

app.get('/*', function (req, res) {
  if((/robots|sitemap|favicon/).test(req.url)) return res.end();
  var path = home+req.url;
  console.log('path:',path);
  try {
    
    res.download(path);
  } catch(e){
    res.end()  
  }

});

app.listen(process.env.PORT, function () {
  console.log('Listening on port: '+process.env.PORT);
});
Client side I wrote a wget() function to download required files.

Post Reply