java.lang.Object
com.gluonhq.attach.ble.impl.IOSBleService
- All Implemented Interfaces:
BleService
iOS implementation of BleService
Important note:
To scan Beacons, it requires adding to the info.plist file:
<key>NSLocationUsageDescription</key>
<string>Reason to use Location Service (iOS 6+)</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Reason to use Location Service (iOS 8+)</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Reason to use Bluetooth interface (iOS 13+)</string>
To scan Devices, it requires adding to the info.plist file:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Reason to use Bluetooth interface (iOS 13+)</string>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConnects to a given BLE devicevoiddisconnect(BleDevice device) Disconnects from a given BLE devicevoidreadCharacteristic(BleDevice device, UUID uuidProfile, UUID uuidCharacteristic) Given a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its valuevoidstartBroadcasting(UUID beaconUUID, int major, int minor, String identifier) Configure the current device as a Bluetooth beacon, and start advertising with a given UUIDvoidstartScanning(Configuration region, Consumer<ScanDetection> callback) startScanning is called with a given uuid and a callback for the beacon found.javafx.collections.ObservableList<BleDevice>Start scanning for BLE Devices.voidStop advertising the current iOS device as a Bluetooth beaconvoidstopScanning, if the manager is initializedvoidStops scanning for BLE devicesvoidsubscribeCharacteristic(BleDevice device, UUID uuidProfile, UUID uuidCharacteristic) Given a BleDevice, with a given BleProfile and a given BleCharacteristic, subscribes to listen to changes in its valuevoidunsubscribeCharacteristic(BleDevice device, UUID uuidProfile, UUID uuidCharacteristic) Given a BleDevice, with a given BleProfile and a given BleCharacteristic, unsubscribes and stop listening to changes in its valuevoidwriteCharacteristic(BleDevice device, UUID uuidProfile, UUID uuidCharacteristic, byte[] value) Given a BleDevice, with a given BleProfile and a given BleCharacteristic, writes its value
-
Constructor Details
-
IOSBleService
public IOSBleService()
-
-
Method Details
-
startScanning
startScanning is called with a given uuid and a callback for the beacon found. iOS iBeacon only scans for given uuid's iOS apps using BleService require the use of the key NSLocationAlwaysDescription in the plist file so the user is asked about allowing location services- Specified by:
startScanningin interfaceBleService- Parameters:
region- Containing the beacon uuidcallback- Callback added to the beacon
-
stopScanning
public void stopScanning()stopScanning, if the manager is initialized- Specified by:
stopScanningin interfaceBleService
-
startBroadcasting
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
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
Description copied from interface:BleServiceConnects to a given BLE device- Specified by:
connectin interfaceBleService- Parameters:
device- The BleDevice to connect to
-
disconnect
Description copied from interface:BleServiceDisconnects from a given BLE device- Specified by:
disconnectin interfaceBleService- Parameters:
device- The BleDevice to disconnect from
-
readCharacteristic
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, UUID uuidProfile, 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
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
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
-