-
Notifications
You must be signed in to change notification settings - Fork 614
Description
Hi everyone,
I've been playing with this plugin for a few days, trying to have a cordova app and a BLE device talk to each other. The device is a so called "itag", a keyring bought on ebay, purpose of which is ~= "don't loose your keys".
What I could do:
-connect to the device and get some of its characteristics
-read the state of the button and also the battery level using ble.read(..)
-make the device ring using ble.writeWithoutResponse(..)
What I could not do (and this is the reason for this post):
-be notified when the device button is pressed.
ble.startNotification(device.id, "ffe0", "ffe1", success, fail) result is fail function answering:
"set notification failed for 0000ffe1-0000-1000-8000-00805f9b34fb"
Here are the device characteristics published when connected:
{"name":"MLE-15","id":"FF:FF:F0:00:7D:A2","advertising":{},"rssi":-56,
"services":["1800","180f","1802","ffe0"],
"characteristics":[
{"service":"1800","characteristic":"2a00","properties":["Read","Notify"]},
{"service":"1800","characteristic":"2a01","properties":["Read"]},
{"service":"180f","characteristic":"2a19","properties":["Read","Notify"]},
{"service":"1802","characteristic":"2a06","properties":["WriteWithoutResponse","Write","Notify"]},
{"service":"ffe0","characteristic":"ffe1","properties":["Read","Notify"]}]}
Here is the code:
`ble.scan([], 5, scan_success, scan_fail);
function scan_success(device) {
ble.connect(device.id, connect_success, connect_fail);
}
function scan_fail() {
alert('error during scan');
}
function connect_success(device) {
console.log(JSON.stringify(device));
ble.startNotification(device.id, "ffe0", "ffe1", success, fail);
}
function connect_fail(device) {
alert('error during connect');
}
var success = function(buffer) {
// Decode the ArrayBuffer into a typed Array based on the data you expect
var data = new Uint8Array(buffer);
alert("device answers: " + data[0]);
}
var fail = function(buffer) {
alert(buffer);
} `
Any help appreciated!