dfu-js
v0.2.1
Published
a web bluetooth library for performing DFU of Nordic Semiconductor SOCs. Includes Vue.js Mixin for simplifed use.
Downloads
15
Maintainers
Readme
dfu-js
This JS library was build against Nordic Semiconductors nRF SDK 12.3 using the secure bootloader. The library requires Chrome 56 on Linux and Mac and Chrome 70 on Windows 10 which is partial support for Web Bluetooth was introduced. Other browswers have not fully or partially implemented Web Bluetooth.
The package also includes a Vue.js Mixin that sets up few useful computed properties. See this gist of a vue component.
A demo web applicatiion using this library and web-bluetooth-vuex is available here, Chrome only.
Installation
$ yarn add dfu-js
# OR
$ npm install dfu-js
Usage
an semi pseduo code example on how to use the library straight.
import {StateMachine, StateMachineStates, Firmware, DFUServiceUUID, DFUCharacteristicUUID} from 'dfu-js'
import JSZip from 'jszip'
/**
... Assume you discovered a ble device and aquired the service and
characteristic needed. Servie uuid DFUServiceUUID.DFU and characteristics
DFUCharacteristicUUID.PacketPoint, DFUCharacteristicUUID.ControlPoint
**/
//Create a dfu object with the characteristics
const dfu = StateMachine(deviceControlPoint, devicePacketPoint)
/**
load fileContentStream from a url or a local file
**/
const zip = new JSZip()
await zip.loadAsync(fileContentStream)
const dfuFirmware = new Firmware(zip)
await dfuFirmware.parseManifest()
/**
Register for events fired by the dfu
**/
dfu.on('progressChanged', (payload) => console.log(payload))
dfu.on('stateChanged', (payload) => console.log(payload) )
/**
Finally send the firmware update and await the callbacks to indicate
sucess or failure. Besides the callvack the current state is expressed in
dfu.state and dfu.progress
**/
dfu.sendFirmware(dfuFirmware)