Merge pull request #15 from mjdietzx/add_timeouts

Add timeouts so entire DFU process works
This commit is contained in:
Rob Moran
2016-03-10 21:07:00 +00:00
2 changed files with 10 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ $ node example_node <device-type>
Where ```<device-type>``` is one of ```nrf51``` or ```nrf52```.
## Updating the SoftDevice or Bootloader (nRF52 only)
## Updating the SoftDevice or Bootloader
The ```.hex``` files below can be transferred via DFU to test SoftDevice and Bootloader updates respectivley:

10
dist/dfu.js vendored
View File

@@ -134,6 +134,9 @@
})
.then(function() {
log("modeData written");
setTimeout(function() { // TODO: Remove this when gattserverdisconnected event is implemented and possibly put a timeout in that event handler before resolving.
resolve(device);
}, 2000);
})
.catch(function(error) {
error = "writeMode error: " + error;
@@ -215,7 +218,12 @@
device.gatt.connect()
.then(function(gattServer) {
log("connected to device");
server = gattServer;
return new Promise(function(resolve) {
server = gattServer;
setTimeout(resolve, 2000); // This delay is needed because BlueZ needs time to update it's cache.
});
})
.then(function() {
return server.getPrimaryService(serviceUUID);
})
.then(function(primaryService) {