Library for making BLE programming easier.
It is safe practise to call function evothings.scriptsLoaded to ensure dependent libraries are loaded before calling functions in this library.
Namespaces
Members
-
<static> printObject
-
Prints and object for debugging purposes.
Methods
-
<static> closeConnectedDevices()
-
Disconnect and close all connected BLE devices.
Example
evothings.easyble.closeConnectedDevices();
-
<static> filterDevicesByService(services)
-
Set to an Array of UUID strings to enable filtering of devices found by startScan().
Parameters:
Name Type Description services
Array of UUID strings. Set to false to disable filtering. The default is no filtering. An empty array will cause no devices to be reported. -
<static> reportDeviceOnce(reportOnce)
-
Set whether to report devices once or continuously during scan. The default is to report continously.
Parameters:
Name Type Description reportOnce
boolean Set to true to report found devices only once. Set to false to report continuously. -
<static> reset()
-
Reset the BLE hardware. Can be time consuming.
-
<static> startScan(success, fail)
-
Start scanning for devices.
Parameters:
Name Type Description success
evothings.easyble.scanCallback Success function called when a device is found. Format: success(evothings.easyble.EasyBLEDevice). fail
evothings.easyble.failCallback Error callback: fail(error). Example
evothings.easyble.startScan( function(device) { console.log('BLE Found device: ' + device.name); }, function(error) { console.log('BLE Scan error: ' + error); });
-
<static> stopScan()
-
Stop scanning for devices.
Example
evothings.easyble.stopScan();
Type Definitions
-
connectCallback(device)
-
Called when successfully connected to a device.
Parameters:
Name Type Description device
evothings.easyble.EasyBLEDevice EasyBLE devices object. -
dataCallback(data)
-
Function when data is available.
Parameters:
Name Type Description data
ArrayBuffer The data is an array buffer. Use an ArrayBufferView to access the data. -
emptyCallback()
-
This callback indicates that an operation was successful, without specifying and additional information.
-
failCallback(errorString)
-
This function is called when an operation fails.
Parameters:
Name Type Description errorString
string A human-readable string that describes the error that occurred. -
rssiCallback(rssi)
-
Called with RSSI value.
Parameters:
Name Type Description rssi
number A negative integer, the signal strength in decibels. This value may be 127 which indicates an unknown value. -
scanCallback(device)
-
Called during scanning when a BLE device is found.
Parameters:
Name Type Description device
evothings.easyble.EasyBLEDevice EasyBLE device object found during scanning. -
servicesCallback(device)
-
Called when services are successfully read.
Parameters:
Name Type Description device
evothings.easyble.EasyBLEDevice EasyBLE devices object.