DFU Revision Characteristic is not being used optimally.

This commit is contained in:
Michael Dietz
2016-02-16 13:08:00 +01:00
parent 908bf53902
commit 4903d0b9dd

8
dist/dfu.js vendored
View File

@@ -122,16 +122,18 @@
connect(device) connect(device)
.then(chars => { .then(chars => {
// Older DFU implementations (from older Nordic SDKs < 7.0) have no DFU Version characteristic.
if (chars.versionChar) { if (chars.versionChar) {
return chars.versionChar.readValue() return chars.versionChar.readValue()
.then(data => { .then(data => {
console.log('read versionChar');
var view = new DataView(data); var view = new DataView(data);
var major = view.getUint8(0); var major = view.getUint8(0);
var minor = view.getUint8(1); var minor = view.getUint8(1);
return transfer(chars, arrayBuffer, imageType, major, minor); return transfer(chars, arrayBuffer, imageType, major, minor);
}); });
} else { } else {
// Default to version 6.0 // Default to version 6.0 (mbed).
return transfer(chars, arrayBuffer, imageType, 6, 0); return transfer(chars, arrayBuffer, imageType, 6, 0);
} }
}) })
@@ -183,12 +185,14 @@
log("found packet characteristic"); log("found packet characteristic");
packetChar = characteristic; packetChar = characteristic;
service.getCharacteristic(versionUUID) service.getCharacteristic(versionUUID)
.then(characteristic => { .then(characteristic => { // Older DFU implementations (from older Nordic SDKs) have no DFU Version characteristic. So this may fail.
log("found version characteristic"); log("found version characteristic");
versionChar = characteristic; versionChar = characteristic;
complete(); complete();
}) })
.catch(error => { .catch(error => {
error += ' no version charactersitic found';
log(error);
complete(); complete();
}); });
}) })