mirror of
https://github.com/thegecko/web-bluetooth-dfu.git
synced 2025-12-13 04:28:13 +08:00
Added linting
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
42
dist/dfu.js
vendored
42
dist/dfu.js
vendored
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
29
dist/hex2bin.js
vendored
29
dist/hex2bin.js
vendored
@@ -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') {
|
||||
|
||||
10
gulpfile.js
Normal file
10
gulpfile.js
Normal file
@@ -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']);
|
||||
@@ -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 <rob@thegecko.org>",
|
||||
@@ -22,5 +22,9 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"bleat": "git://github.com/thegecko/bleat.git#web-bluetooth"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-jshint": "^1.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user