Giter Club home page Giter Club logo

ota-update's Introduction

This document describes the method of ota firmware updating

More about firmware esp8266 program.

The server has two function:

  • REST API to for application versions
  • Upload new version

Firmware version

ESP host

When bootup, OTA client polls for latest informations of firmware of an application via REST calling:

GET /api/:application/versions/:image?current_version=version
HEADERS:
    api-key: "Api-key of your device or your user Api-key"

####By default:

  • image Parameter instead of image1 or image2.
  • application Parameter is application name

OTA server should return information of last version, which contain metadata of the latest, including parsed URL to get user1/user2.bin.

{
"application": "application",
"last": {
        "version": "0.0.1",
        "created": "2015-06-04T10:15:33.917Z",
        "protocol": "https:",
        "host": "ubisen.com",
        "path": "/files/user1.bin"
    }
}

Note: ESP host will refuse the response if it doesnot contain tuble {version, protocol, host, url}.

Get the raw image of an application at specific version

Connect cdn-host
GET /url HTTP/1.1

To register new version

One when create new version of an application, need to register to fota server. The registration infomation provides dirrect url for the user1.bin and user2.bin, e.g. from Dropbox or Amazon.

POST /firmware/:application
HEADERS:
    api-key: "Api-key of user"

BODY
{
    version:"0.0.1",
    firmwares: [{
        name: image1,
        url: "https://dl.dropboxusercontent.com/s/jwnjhet4tngh3nh/user1.bin?dl=0"
    },
    {
        name: image2,
        url: "https://dl.dropboxusercontent.com/s/o996zg2vmyx3396/user2.bin?dl=0"
    }]
}

Note: the url provided should be the dirrect link to download userx.bin, since esp http client is simple, cannot handle redirect HTTP links. Use curl -I url to check for return which should contain Content-Length:

HTTP/1.1 200 OK
accept-ranges: bytes
cache-control: max-age=0
Content-Length: 387808

Upload firmware

The firmware could be upload to third party storage service, or use this own server.

POST /api/firmware
HEADERS:
    api-key: "Api-key of user"
BODY: 
    data: binary file
    description:"Your file description" // optional
    tags:"tag1,tag2" // optional

Example:

curl -i -H "api-key:0f551a846d865ef167a496f8584ac75ce284d3de4562b81cfce4ccccfb3b5e66" -F name=data -F [email protected] http://ota.ubisen.com/api/firmware

return

{  
    "url":"http://ota.ubisen.com/firmwares/5572b380130d0c000040bfee/download",
    "parseUrl":{  
        "protocol":"http:",
        "host":"localhost:3000",
        "path":"/firmwares/5572b380130d0c000040bfee/download"
    },
    "created":"2015-06-06T08:46:56.755Z"
}

Then the returned url use to register new version.

Run project

Install

Rename /config/env/env.example.json to /config/env/env.json or create env.json file in /config/env/ with your oauth config.

npm install

Run

npm start

Test

npm test

ota-update's People

Contributors

nguyenthenguyen avatar nqd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.