diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..8ab3485 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,3 @@ +{ + "esversion": 6 +} \ No newline at end of file diff --git a/README.md b/README.md index 875f6d1..d8ef20e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Web Bluetooth DFU Device firmware update with Web Bluetooth +Update device firmware via [Web Bluetooth](https://webbluetoothcg.github.io/web-bluetooth/) using the protocol here: + +[http://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s110/html/a00103.html](http://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s110/html/a00103.html) + ## Device Configuration Put this firmware onto an [nrf51822](https://www.nordicsemi.com/eng/Products/nRF51-DK): @@ -11,7 +15,7 @@ Then reset the device. ## Web Example -Open this site in a [web-bluetooth](https://webbluetoothcg.github.io/web-bluetooth/) enabled browser: +Open this site in a Web Bluetooth enabled browser: [https://thegecko.github.io/web-bluetooth-dfu](https://thegecko.github.io/web-bluetooth-dfu) diff --git a/dist/dfu.js b/dist/dfu.js index 6957881..312c2dd 100644 --- a/dist/dfu.js +++ b/dist/dfu.js @@ -1,6 +1,32 @@ -/* +/* @license + * + * Device firmware update with Web Bluetooth + * Version: 0.0.1 + * * Protocol from: * http://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s110/html/a00103.html + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Rob Moran + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ // https://github.com/umdjs/umd @@ -172,7 +198,7 @@ reject(error); }); }); - }; + } var interval; var offset; @@ -213,7 +239,7 @@ view.setUint32(8, appLength, littleEndian); // Set firmware length - return packetChar.writeValue(view) + return packetChar.writeValue(view); }) .then(() => { log("sent buffer size: " + arrayBuffer.byteLength); @@ -258,7 +284,7 @@ log('complete, send packet count'); var buffer = new ArrayBuffer(3); - var view = new DataView(buffer); + view = new DataView(buffer); view.setUint8(0, 8); view.setUint16(1, interval, littleEndian); @@ -288,8 +314,8 @@ }); } else if (req_opcode === 7) { - var bytecount = view.getUint32(3, littleEndian); - log('length: ' + bytecount); + var byteCount = view.getUint32(3, littleEndian); + log('length: ' + byteCount); log('complete, validate...'); controlChar.writeValue(new Uint8Array([4])) @@ -323,8 +349,8 @@ } } else if (opCode === 17) { - var bytecount = view.getUint32(1, littleEndian); - log('transferred: ' + bytecount); + var bytes = view.getUint32(1, littleEndian); + log('transferred: ' + bytes); writePacket(packetChar, arrayBuffer, 0); } } diff --git a/dist/hex2bin.js b/dist/hex2bin.js index 1b868ff..d17728b 100644 --- a/dist/hex2bin.js +++ b/dist/hex2bin.js @@ -1,4 +1,31 @@ -// https://github.com/umdjs/umd +/* @license + * + * Hex to Bin library + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Rob Moran + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + + // https://github.com/umdjs/umd (function(global, factory) { if (typeof exports === 'object') { diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..c640a4e --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var jshint = require('gulp-jshint'); + +gulp.task('lint', function() { + return gulp.src(['dist/*.js', '!dist/web-bluetooth*.js']) + .pipe(jshint()) + .pipe(jshint.reporter('default')); +}); + +gulp.task('default', ['lint']); \ No newline at end of file diff --git a/package.json b/package.json index 1c1d894..737f5f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "web-bluetooth-dfu", - "version": "1.0.0", + "version": "0.0.1", "description": "Device firmware update with Web Bluetooth", "homepage": "https://github.com/thegecko/web-bluetooth-dfu", "author": "Rob Moran ", @@ -22,5 +22,9 @@ ], "dependencies": { "bleat": "git://github.com/thegecko/bleat.git#web-bluetooth" + }, + "devDependencies": { + "gulp": "^3.9.1", + "gulp-jshint": "^1.9.0" } }