Which characteristic are you trying to read from? Battery level?
I think what you need is startNotifications - there's a bit of code in the reference: http://www.espruino.com/Reference#l_BluetoothRemoteGATTCharacteristic_startNotifications
startNotifications
It looks like there might be a UART characteristic there, and to use that the code above can be used pretty much as-is.
But for battery I think something like this might do it:
var gatt; NRF.connect("pu:ck:js:ad:dr:es random").then(function(g) { gatt = g; return gatt.getPrimaryService(0x180F); }).then(function(service) { return service.getCharacteristic(0x2A19); }).then(function(characteristic) { characteristic.on('characteristicvaluechanged', function(event) { console.log("battery: "+JSON.stringify(event.target.value.buffer)); }); return characteristic.startNotifications(); }).then(function() { console.log("Done!"); });
@Gordon started
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.
Which characteristic are you trying to read from? Battery level?
I think what you need is
startNotifications
- there's a bit of code in the reference: http://www.espruino.com/Reference#l_BluetoothRemoteGATTCharacteristic_startNotificationsIt looks like there might be a UART characteristic there, and to use that the code above can be used pretty much as-is.
But for battery I think something like this might do it: