- java.lang.Object
-
- com.gluonhq.attach.ble.impl.AndroidBleService
-
- All Implemented Interfaces:
BleService
public class AndroidBleService extends java.lang.Object implements BleService
Android implementation of BleService
-
-
Constructor Summary
Constructors Constructor Description AndroidBleService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect(BleDevice device)Connects to a given BLE devicevoiddisconnect(BleDevice device)Disconnects from a given BLE devicevoidreadCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)Given a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its valuevoidstartBroadcasting(java.util.UUID beaconUUID, int major, int minor, java.lang.String identifier)Configure the current device as a Bluetooth beacon, and start advertising with a given UUIDvoidstartScanning(Configuration region, java.util.function.Consumer<ScanDetection> callback)Start scanning for BLE beacons.javafx.collections.ObservableList<BleDevice>startScanningDevices()Start scanning for BLE Devices.voidstopBroadcasting()Stop advertising the current iOS device as a Bluetooth beaconvoidstopScanning()Stops the last called startScanning operation.voidstopScanningDevices()Stops scanning for BLE devicesvoidsubscribeCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)Given a BleDevice, with a given BleProfile and a given BleCharacteristic, subscribes to listen to changes in its valuevoidunsubscribeCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)Given a BleDevice, with a given BleProfile and a given BleCharacteristic, unsubscribes and stop listening to changes in its valuevoidwriteCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic, byte[] value)Given a BleDevice, with a given BleProfile and a given BleCharacteristic, writes its value
-
-
-
Method Detail
-
startScanning
public void startScanning(Configuration region, java.util.function.Consumer<ScanDetection> callback)
Description copied from interface:BleServiceStart scanning for BLE beacons. When such a device is discovered, the callback will be called with the detailed information on the detected beacon. Note that this method can be called multiple times. In order to stop receiving notifications, the stopScanning method should be used.- Specified by:
startScanningin interfaceBleService- Parameters:
region- provide setting options to filter the beacons to be scannedcallback- provided function that will be called once a beacon is detected
-
stopScanning
public void stopScanning()
Description copied from interface:BleServiceStops the last called startScanning operation.- Specified by:
stopScanningin interfaceBleService
-
startBroadcasting
public void startBroadcasting(java.util.UUID beaconUUID, int major, int minor, java.lang.String identifier)Description copied from interface:BleServiceConfigure the current device as a Bluetooth beacon, and start advertising with a given UUID- Specified by:
startBroadcastingin interfaceBleService- Parameters:
beaconUUID- the UUID of the beacon that will be advertisedmajor- the most significant valueminor- the least significant valueidentifier- a string to identify the beacon
-
stopBroadcasting
public void stopBroadcasting()
Description copied from interface:BleServiceStop advertising the current iOS device as a Bluetooth beacon- Specified by:
stopBroadcastingin interfaceBleService
-
startScanningDevices
public javafx.collections.ObservableList<BleDevice> startScanningDevices()
Description copied from interface:BleServiceStart scanning for BLE Devices.- Specified by:
startScanningDevicesin interfaceBleService- Returns:
- an observable list of
BleDevicefound
-
stopScanningDevices
public void stopScanningDevices()
Description copied from interface:BleServiceStops scanning for BLE devices- Specified by:
stopScanningDevicesin interfaceBleService
-
connect
public void connect(BleDevice device)
Description copied from interface:BleServiceConnects to a given BLE device- Specified by:
connectin interfaceBleService- Parameters:
device- The BleDevice to connect to
-
disconnect
public void disconnect(BleDevice device)
Description copied from interface:BleServiceDisconnects from a given BLE device- Specified by:
disconnectin interfaceBleService- Parameters:
device- The BleDevice to disconnect from
-
readCharacteristic
public void readCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)
Description copied from interface:BleServiceGiven a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its value- Specified by:
readCharacteristicin interfaceBleService- Parameters:
device- The connected BleDeviceuuidProfile- The UUID that identifies the BLE ProfileuuidCharacteristic- The UUID that identifies the BLE Characteristic
-
writeCharacteristic
public void writeCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic, byte[] value)
Description copied from interface:BleServiceGiven a BleDevice, with a given BleProfile and a given BleCharacteristic, writes its value- Specified by:
writeCharacteristicin interfaceBleService- Parameters:
device- The connected BleDeviceuuidProfile- The UUID that identifies the BLE ProfileuuidCharacteristic- The UUID that identifies the BLE Characteristicvalue- a new value for the Ble Characteristic
-
subscribeCharacteristic
public void subscribeCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)
Description copied from interface:BleServiceGiven a BleDevice, with a given BleProfile and a given BleCharacteristic, subscribes to listen to changes in its value- Specified by:
subscribeCharacteristicin interfaceBleService- Parameters:
device- The connected BleDeviceuuidProfile- The UUID that identifies the BLE ProfileuuidCharacteristic- The UUID that identifies the BLE Characteristic
-
unsubscribeCharacteristic
public void unsubscribeCharacteristic(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)
Description copied from interface:BleServiceGiven a BleDevice, with a given BleProfile and a given BleCharacteristic, unsubscribes and stop listening to changes in its value- Specified by:
unsubscribeCharacteristicin interfaceBleService- Parameters:
device- The connected BleDeviceuuidProfile- The UUID that identifies the BLE ProfileuuidCharacteristic- The UUID that identifies the BLE Characteristic
-
-