Skip to content
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

Provide public REST API for uploading a new firmware #745

Closed
FlorianSW opened this issue Apr 2, 2018 · 3 comments
Closed

Provide public REST API for uploading a new firmware #745

FlorianSW opened this issue Apr 2, 2018 · 3 comments
Milestone

Comments

@FlorianSW
Copy link

There're currently some ways to upload an OTA firmware to a board where espurna is already flahed:

  • Manually uploading it via the web UI
  • using platformio upload task
  • using telnet, by providing the URL to the firmware binary

However, all of these are not easily to use while running in an CI/CD toolchain:

  • The manual upload via the web UI can be scripted easily with curl based on a request sniff from Chrome brwoser, e.g., however, the upgrade endpoint used for this is not documented and not public api, which means, it can change at any time, which may makes this solution a bit unstable.
  • Using platformio requires the espurna board to have access to a specific port on the host computer. This is not always possible, let it be because of a firewall blocking all incoming requests or a containerized setup, where only outgoing requests are mapped through NAT to the container, but not incoming traffic (the board would not be able to request the firmarwa from the platformio opened port). Requiring the user to open the firewall or whatever blocks the access for this port, which is used more or less rarely and is otherwise open, doesn't sound like a good solution, either.
  • Using telnet requires the user to setup an http server somewhere just to serve the firmware binary, which is a huge overhead.

This issue requests a rather simple, client-driven, approach for uploading the firmware. It's more or less based on the first way to upload the firmware to the board via the web UI. There's already a REST API, which allows to set different values. It would be nice to have an upgrade endpoint there, too, which takes the firmware.bin as the payload and updates the board accordingly.

The easiest solution here would be, to make the /upgrade endpoint public API and document it so, however, I'm not sure, if this is the best way of doing it. But maybe it's behavior can be taken as an example, as it's working pretty well currently with the following cURL command:

curl -XPOST --digest -uadmin:fibonacci -H "Content-Type: multipart/form-data" \
  -F "filename=@build/firmware.bin" -F "name=\"upgrade\"" http://192.168.4.1/upgrade
@xoseperez
Copy link
Owner

Good tip. Current API implementation is too focused on sending and receiving simple values and it would require a complete rewrite to support blobs... I'm not doing this atm because I think your approach is good enough.

I have added this info to the wiki OTA page.

Thank you!!

@shaguarger
Copy link

Thanks for all your work xoseperez! If you are interested in using this for automatic deployments check out https://github.com/shaguarger/espurna-pipeline for more informations...

@xoseperez
Copy link
Owner

Amazing!! Thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants