mirror of
https://github.com/thegecko/web-bluetooth-dfu.git
synced 2025-12-12 20:18:13 +08:00
Change order of parameters of provision().
This commit is contained in:
4
dist/dfu.js
vendored
4
dist/dfu.js
vendored
@@ -162,11 +162,11 @@
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
function provision(device, arrayBuffer, imageType, crc) {
|
function provision(device, arrayBuffer, crc, imageType) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var versionChar = null;
|
var versionChar = null;
|
||||||
imageType = imageType || ImageType.Application;
|
|
||||||
initPacket.crc = crc || 0xFFFF; // Not used in mbed/ older bootloader revisions.
|
initPacket.crc = crc || 0xFFFF; // Not used in mbed/ older bootloader revisions.
|
||||||
|
imageType = imageType || ImageType.Application;
|
||||||
|
|
||||||
connect(device)
|
connect(device)
|
||||||
.then(function(chars) {
|
.then(function(chars) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ dfu.findDevice({ services: [0x180D] })
|
|||||||
log("file length: " + buffer.byteLength);
|
log("file length: " + buffer.byteLength);
|
||||||
var crc = crc16(buffer);
|
var crc = crc16(buffer);
|
||||||
|
|
||||||
return dfu.provision(device, buffer, 4, crc);
|
return dfu.provision(device, buffer, crc);
|
||||||
})
|
})
|
||||||
.then(() => process.exit())
|
.then(() => process.exit())
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
log("downloaded length: " + buffer.byteLength);
|
log("downloaded length: " + buffer.byteLength);
|
||||||
var crc = crc16(buffer);
|
var crc = crc16(buffer);
|
||||||
|
|
||||||
return dfu.provision(device, buffer, 4, crc);
|
return dfu.provision(device, buffer, crc); // dfu.ImageType.Application is the default value for the fourth parameter. Specify this if you want to upload a softdevice/bootloader.
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
log('dfu complete');
|
log('dfu complete');
|
||||||
|
|||||||
Reference in New Issue
Block a user