Pet Project - Centrally managed ESP images. - Page 1
Forum section: electronics / general

author: paulca
author_rank: Super Contributor
timestamp: May 19, 2020, 03:42:50 pm
content: So I have too many ESPs to manage using Arduino IDE. I have about 12, all running different custom code, some with fixed IPs, most with hardcoded particulars as you do in Arduino land. I mean it's great, rapid development, but at around 10 different devices when a "new feature" needs added across them all it's a right blood pain.So, what devices do I have and what are they running?And there and then I realised what step one was. ie. Be able to answer that. LOL!Here's the plan.1. Create a thin bootstrap like layer and base all my images upon it.....Have that layer launch an OTA update service so images can be pushed to it.....Also have that layer broadcast, at start up, on whatever network it finds itself on, stating it's mac address and the firmware it's running.2. A python server with a list of mac->imageFile data, watches these broadcasts. If one pops up with a firmware that doesn't match, it flashes that device with the one it should have.Each new image is based on the same base, bootstrap/bootloader setup of course.I have this working, haven't done the python yet, but it works in test with PlatformIO.After that I need to look at parameterising builds, or moving to pushing config into EEPROMs or SPIFFs. I have quite a few groups of similar devices that maybe only differ by the name of the thing they send.

author: paulca
author_rank: Super Contributor
timestamp: May 21, 2020, 07:02:26 pm
content: I got a prototype workingAs it works by broadcast, neither the server, not ESP need to know where the other is initially.ESP Side... Boots FirstBaseV6, broadcasts it's presence. Get's flashed by the server, reboots with FirstBaseV7.Code:MyESPDevice Booting as myesp with firmware FirstBaseV6ReadyIP address: 10.0.0.212{"macAddress": "60:01:94:70:3B:xx", "firmware": "FirstBaseV6", "ipAddress": "10.0.0.212"}Broadcast : 10.0.0.255Start updating sketchProgress: 100%Endets Jan 8 2013,rst cause:2, boot mode:(3,7)load 0x4010f000, len 3456, room 16tail 0chksum 0x84csum 0x84va5432625@cp:0ldMyESPDevice Booting as myesp with firmware FirstBaseV7ReadyIP address: 10.0.0.212{"macAddress": "60:01:94:70:3B:xx", "firmware": "FirstBaseV7", "ipAddress": "10.0.0.212"}Broadcast : 10.0.0.255{"macAddress": "60:01:94:70:3B:xx", "firmware": "FirstBaseV7", "ipAddress": "10.0.0.212"}Server side....The server sees the ESP with that mac's broadcast and decided it's firmware does not match required and initiates an over the air flash.The server sees the ESP when it reboots and decides it's firmware is now okay.Code:MAC: 60:01:94:70:3B:xxFW: FirstBaseV6IP: 10.0.0.212Device is knownDevice is running FirstBaseV6 and should be running FirstBaseV7Flashing...Uploading: [============================================================] 100% Done...Flashed ret code 0MAC: 60:01:94:70:3B:xxFW: FirstBaseV7IP: 10.0.0.212Device is knownDevice is running FirstBaseV7 OKThe impact on the "sketch" or main.cpp is just:In setup.Code:if(! MyESPDevice.setup("<dhcp and mdns hostname>", FIRMWARE, ssid, password ) ) {ESP.restart();}In loop.Code:MyESPDevice.handle();The config boils down to a dictionary...Code:firmwares = { "60:01:94:70:3B:xx":"FirstBaseV7", "60:01:94:xx:xx:xx":"none"}Next steps will be to add SPIFFs config support. So I can have multiple ESPs with the same firmware but different configs.