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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Connects to a given BLE devicevoid
disconnect
(BleDevice device) Disconnects from a given BLE devicevoid
readCharacteristic
(BleDevice device, UUID uuidProfile, UUID uuidCharacteristic) Given a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its valuevoid
startBroadcasting
(UUID beaconUUID, int major, int minor, String identifier) Configure the current device as a Bluetooth beacon, and start advertising with a given UUIDvoid
startScanning
(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.void
Stop advertising the current iOS device as a Bluetooth beaconvoid
stopScanning, if the manager is initializedvoid
Stops scanning for BLE devicesvoid
subscribeCharacteristic
(BleDevice device, UUID uuidProfile, UUID uuidCharacteristic) Given a BleDevice, with a given BleProfile and a given BleCharacteristic, subscribes to listen to changes in its valuevoid
unsubscribeCharacteristic
(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 valuevoid
writeCharacteristic
(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:
startScanning
in interfaceBleService
- Parameters:
region
- Containing the beacon uuidcallback
- Callback added to the beacon
-
stopScanning
public void stopScanning()stopScanning, if the manager is initialized- Specified by:
stopScanning
in interfaceBleService
-
startBroadcasting
Description copied from interface:BleService
Configure the current device as a Bluetooth beacon, and start advertising with a given UUID- Specified by:
startBroadcasting
in 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:BleService
Stop advertising the current iOS device as a Bluetooth beacon- Specified by:
stopBroadcasting
in interfaceBleService
-
startScanningDevices
Description copied from interface:BleService
Start scanning for BLE Devices.- Specified by:
startScanningDevices
in interfaceBleService
- Returns:
- an observable list of
BleDevice
found
-
stopScanningDevices
public void stopScanningDevices()Description copied from interface:BleService
Stops scanning for BLE devices- Specified by:
stopScanningDevices
in interfaceBleService
-
connect
Description copied from interface:BleService
Connects to a given BLE device- Specified by:
connect
in interfaceBleService
- Parameters:
device
- The BleDevice to connect to
-
disconnect
Description copied from interface:BleService
Disconnects from a given BLE device- Specified by:
disconnect
in interfaceBleService
- Parameters:
device
- The BleDevice to disconnect from
-
readCharacteristic
Description copied from interface:BleService
Given a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its value- Specified by:
readCharacteristic
in 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:BleService
Given a BleDevice, with a given BleProfile and a given BleCharacteristic, writes its value- Specified by:
writeCharacteristic
in 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:BleService
Given a BleDevice, with a given BleProfile and a given BleCharacteristic, subscribes to listen to changes in its value- Specified by:
subscribeCharacteristic
in 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:BleService
Given a BleDevice, with a given BleProfile and a given BleCharacteristic, unsubscribes and stop listening to changes in its value- Specified by:
unsubscribeCharacteristic
in interfaceBleService
- Parameters:
device
- The connected BleDeviceuuidProfile
- The UUID that identifies the BLE ProfileuuidCharacteristic
- The UUID that identifies the BLE Characteristic
-