Class IOSBleService

  • All Implemented Interfaces:
    BleService

    public class IOSBleService
    extends java.lang.Object
    implements 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 
      Constructor Description
      IOSBleService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void connect​(BleDevice device)
      Connects to a given BLE device
      void disconnect​(BleDevice device)
      Disconnects from a given BLE device
      void readCharacteristic​(BleDevice device, java.util.UUID uuidProfile, java.util.UUID uuidCharacteristic)
      Given a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its value
      void startBroadcasting​(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 UUID
      void startScanning​(Configuration region, java.util.function.Consumer<ScanDetection> callback)
      startScanning is called with a given uuid and a callback for the beacon found.
      javafx.collections.ObservableList<BleDevice> startScanningDevices()
      Start scanning for BLE Devices.
      void stopBroadcasting()
      Stop advertising the current iOS device as a Bluetooth beacon
      void stopScanning()
      stopScanning, if the manager is initialized
      void stopScanningDevices()
      Stops scanning for BLE devices
      void subscribeCharacteristic​(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 value
      void unsubscribeCharacteristic​(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 value
      void writeCharacteristic​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IOSBleService

        public IOSBleService()
    • Method Detail

      • startScanning

        public void startScanning​(Configuration region,
                                  java.util.function.Consumer<ScanDetection> callback)
        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 interface BleService
        Parameters:
        region - Containing the beacon uuid
        callback - Callback added to the beacon
      • stopScanning

        public void stopScanning()
        stopScanning, if the manager is initialized
        Specified by:
        stopScanning in interface BleService
      • startBroadcasting

        public void startBroadcasting​(java.util.UUID beaconUUID,
                                      int major,
                                      int minor,
                                      java.lang.String identifier)
        Description copied from interface: BleService
        Configure the current device as a Bluetooth beacon, and start advertising with a given UUID
        Specified by:
        startBroadcasting in interface BleService
        Parameters:
        beaconUUID - the UUID of the beacon that will be advertised
        major - the most significant value
        minor - the least significant value
        identifier - 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 interface BleService
      • stopScanningDevices

        public void stopScanningDevices()
        Description copied from interface: BleService
        Stops scanning for BLE devices
        Specified by:
        stopScanningDevices in interface BleService
      • connect

        public void connect​(BleDevice device)
        Description copied from interface: BleService
        Connects to a given BLE device
        Specified by:
        connect in interface BleService
        Parameters:
        device - The BleDevice to connect to
      • disconnect

        public void disconnect​(BleDevice device)
        Description copied from interface: BleService
        Disconnects from a given BLE device
        Specified by:
        disconnect in interface BleService
        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: BleService
        Given a BleDevice, with a given BleProfile and a given BleCharacteristic, reads its value
        Specified by:
        readCharacteristic in interface BleService
        Parameters:
        device - The connected BleDevice
        uuidProfile - The UUID that identifies the BLE Profile
        uuidCharacteristic - 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: BleService
        Given a BleDevice, with a given BleProfile and a given BleCharacteristic, writes its value
        Specified by:
        writeCharacteristic in interface BleService
        Parameters:
        device - The connected BleDevice
        uuidProfile - The UUID that identifies the BLE Profile
        uuidCharacteristic - The UUID that identifies the BLE Characteristic
        value - 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: BleService
        Given a BleDevice, with a given BleProfile and a given BleCharacteristic, subscribes to listen to changes in its value
        Specified by:
        subscribeCharacteristic in interface BleService
        Parameters:
        device - The connected BleDevice
        uuidProfile - The UUID that identifies the BLE Profile
        uuidCharacteristic - 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: 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 interface BleService
        Parameters:
        device - The connected BleDevice
        uuidProfile - The UUID that identifies the BLE Profile
        uuidCharacteristic - The UUID that identifies the BLE Characteristic