Philadelphia ETE - April 7, 2015
Don Coleman - Chariot Solutions
0000FF10-0000-1000-8000-00805F9B34FB
0000FF11-0000-1000-8000-00805F9B34FB
0000FF12-0000-1000-8000-00805F9B34FB
0000FF16-0000-1000-8000-00805F9B34FB
Provides services
cordova plugin add com.megster.cordova.ble
ble.scan(services,
seconds,
success,
failure);
ble.scan(["FF10"],
5,
app.onDeviceDiscovered,
failure);
{
"name": "Robosmart",
"id": "78:C5:E5:9A:15:AA",
"advertising": {},
"rssi": -65
}
ble.connect(device_id,
connectSuccess,
connectFailure);
ble.connect("78:C5:E5:9A:15:AA",
onConnect,
onDisconnect);
var onConnect = function(peripheral) {
console.log(peripheral);
// read current state of light
// update UI
};
ble.read(device_id,
service_uuid,
characteristic_uuid,
success,
failure);
ble.read("78:C5:E5:9A:15:AA",
"FF10",
"FF11",
success,
failure);
var success = function(buffer) {
var data = new Uint8Array(buffer);
if (data[0] === 1) {
onButton.className = 'selected';
} else {
offButton.className = 'selected';
}
};
ble.write(device_id,
service_uuid,
characteristic_uuid,
value,
success,
failure);
var data = new Uint8Array(1);
data[0] = 1;
ble.write("78:C5:E5:9A:15:AA",
"FF10",
"FF11",
data.buffer,
success);
ble.writeWithoutResponse("78:C5:E5:9A:15:AA",
"FF10",
"FF11",
data.buffer,
success,
failure);
ble.startNotification(device_id,
service_uuid,
characteristic_uuid,
success,
failure);
ble.startNotification(deviceId,
"180d",
"2a37",
onData,
failure);
onData = function(buffer) {
var data = new Unit8Array(buffer);
var flags = data[0];
// read flags, etc
var rate = data[1];
console.log("Heart Rate is " + rate);
}
ble.notify(deviceId,
"FFE0",
"FFE1",
app.onButtonData,
app.onError);
(not Core Bluetooth)
Don Coleman
Bluetooth Low Energy by Don Coleman
is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at https://github.com/don/.../2015-04-07-phillyete-bluetooth.