mirror of
https://github.com/thegecko/web-bluetooth-dfu.git
synced 2025-12-12 20:18:13 +08:00
Further refactor
This commit is contained in:
14
dist/dfu.js
vendored
14
dist/dfu.js
vendored
@@ -192,8 +192,13 @@
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
log("enabling notifications");
|
||||
controlChar.startNotifications()
|
||||
.then(() => {
|
||||
controlChar.addEventListener('characteristicvaluechanged', handleControl);
|
||||
log("sending imagetype: " + imageType);
|
||||
controlChar.writeValue(new Uint8Array([1, imageType]))
|
||||
return controlChar.writeValue(new Uint8Array([1, imageType]));
|
||||
})
|
||||
.then(() => {
|
||||
log("sent start");
|
||||
|
||||
@@ -212,12 +217,6 @@
|
||||
})
|
||||
.then(() => {
|
||||
log("sent buffer size: " + arrayBuffer.byteLength);
|
||||
log("enabling notifications");
|
||||
return controlChar.startNotifications()
|
||||
.then(() => {
|
||||
log("notifications started");
|
||||
controlChar.addEventListener('characteristicvaluechanged', handleControl);
|
||||
})
|
||||
})
|
||||
.catch(error => {
|
||||
error = "start error: " + error;
|
||||
@@ -226,6 +225,7 @@
|
||||
});
|
||||
|
||||
function handleControl(event) {
|
||||
log("event received");
|
||||
var data = event.target.value;
|
||||
var view = new DataView(data);
|
||||
var opCode = view.getUint8(0);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
<script src="dist/hex2bin.js"></script>
|
||||
|
||||
<script>
|
||||
var names = ["DFU_Test", "Hi_Rob", "Bye_Rob"];
|
||||
var urlMask = "//thegecko.github.io/web-bluetooth-dfu/firmware/NRF51822_{0}_Rob_OTA.hex";
|
||||
var resultsEl = document.getElementById("results");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user