-
Notifications
You must be signed in to change notification settings - Fork 83
Low Energy Bluetooth Service
o5faruk edited this page May 2, 2021
·
4 revisions
This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/low-energy-bluetooth/
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.jsonaddbluetoothin yourfeaturearray"features" : [{"name" : "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 anarrayof devices.-
devices: anarrayof devices with two properties-
deviceId:string -
name:string
-
-
-
-
write function (data, callback): Used to sendstringdata 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 theterminatoris found. for example if theterminatorequals,it will continue to read until it finds the next comma -
subscribe function (delimiter,callback): will automatically send you the buffer when theterminatorif 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