That all looks fine... I just tried it between two Pucks using their UUIDs:
var DevName="Puck.js b0ca";
var serviceUUID="6e400001-b5a3-f393-e0a9-e50e24dcca9e";
var characteristicUUID="6e400002-b5a3-f393-e0a9-e50e24dcca9e";
var MessageToSend="LED1.set()\n";
function SendCommandToActuator() {
NRF.requestDevice({ filters: [{ name: DevName }] }).then(function(device) {
return device.gatt.connect();
}).then(function(g) {
gatt = g;
console.log(gatt);
return gatt.getPrimaryService(serviceUUID);
}).then(function(service) {
return service.getCharacteristic(characteristicUUID);
}).then(function(characteristic) {
return characteristic.writeValue(MessageToSend);
}).then(function() {
gatt.disconnect();
console.log("Done!");
});
}
... and it works fine, even with the Bonding.
Do you know where the error occurs? At getPrimaryService? I guess you could try delaying the call to getPrimaryService and seeing if that helps?
Also perhaps you could try NRF.on('disconnect', function(reason) { print("Disconnected",reason) });
It might help to understand why the connection broke down.
Otherwise I'm not sure what to suggest - if somehow I can get one of the magic devices here then I might be able to figure out why it's not working.
Otherwise if you have an nRF51DK then you can use Nordic's tools to sniff all the BLE packets - which might help to figure out why things aren't working.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
That all looks fine... I just tried it between two Pucks using their UUIDs:
... and it works fine, even with the Bonding.
Do you know where the error occurs? At
getPrimaryService
? I guess you could try delaying the call to getPrimaryService and seeing if that helps?Also perhaps you could try
NRF.on('disconnect', function(reason) { print("Disconnected",reason) });
It might help to understand why the connection broke down.
Otherwise I'm not sure what to suggest - if somehow I can get one of the magic devices here then I might be able to figure out why it's not working.
Otherwise if you have an nRF51DK then you can use Nordic's tools to sniff all the BLE packets - which might help to figure out why things aren't working.