-
Notifications
You must be signed in to change notification settings - Fork 85
Low Energy Bluetooth Service
Daniel Hindi edited this page Feb 8, 2017
·
4 revisions
This is a service that allows your widget to link to the devices bluetooth signal and paired devices. This is very useful when developing for IoT (Internet of Things)
Note: this will not work on the control side of your plugin
Used on the Widget side communicate with paired bluetooth devices
- From the Widget
<script src="../../../scripts/buildfire/services/bluetooth/ble.js"></script>
- in
plugin.json
addbluetooth
in yourfeature
array"features" : ["bluetooth"]
https://github.com/BuildFire/bluetoothExamplePlugin
none. ble
is a singleton
-
connect (deviceId,callback)
: use this method to connect to the device-
deviceId
: the device Id you received from the paired device list -
callback (err,data)
: callback function called when connected or failed to connect.
-
-
disconnect function (callback)
: used to disconnect from the previously connected device-
callback (err,data)
: callback function called when the disconnect occurs or fails.
-
-
listPairedDevices function(callback)
: Get a list of paired bluetooth devices-
callback(err,devices)
: a callback function the is called anarray
of devices.-
devices
: anarray
of devices with two properties-
deviceId
:string
-
name
:string
-
-
-
-
write function (data, callback)
: Used to sendstring
data to the device -
available function (callback)
: check if device is available -
read function (callback)
:reads the buffer from the bluetooth -
readUntil function (terminator,callback)
: reads from the buffer until theterminator
is found. for example if theterminator
equals,
it will continue to read until it finds the next comma -
subscribe function (delimiter,callback)
: will automatically send you the buffer when theterminator
if found -
unsubscribe function (callback)
: stop subscribing -
clear function (callback)
clears the buffer -
isConnected function (callback)
: checks to see if the connection is still alive -
isEnabled function (callback)
:checks if bluetooth is enabled
-
onConnect function()
: gets called when connection is established -
onDisconnect function()
: get called when the connection is severed