daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Oct 21st, 2018 71 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. if let bluetoothDevice = IOBluetoothDevice(addressString: "Bluetooth Device ID")
  2. {
  3.     if !bluetoothDevice.isPaired() || !bluetoothDevice.isConnected() { continue }                    
  4.     // Device is connected and paired, everything works fine until here.
  5.     if bluetoothDevice.isHandsFreeDevice
  6.     {
  7.        // This line will also be executed, so the device supports the HFP.
  8.        let handsFree = IOBluetoothHandsFree(device: bluetoothDevice, delegate: self)
  9.        // handsFree?.connect()
  10.        // Swift.print(handsFree?.isConnected) // returns false.
  11.        let batteryValue = handsFree?.indicator(IOBluetoothHandsFreeIndicatorBattChg)
  12.        Swift.print(batteryValue) // Always returns zero, can't be true.
  13.        Swift.print(handsFree?.outputVolume) // Always returns 0.5.
  14.     }
  15. }
  16.  
  17. extension Controller : IOBluetoothHandsFreeDelegate
  18. {
  19.     func handsFree(_ device: IOBluetoothHandsFree!, disconnected status: NSNumber!)
  20.     {
  21.         Swift.print("disconnected")
  22.     }
  23.    
  24.     func handsFree(_ device: IOBluetoothHandsFree!, scoConnectionClosed status: NSNumber!)
  25.     {
  26.         Swift.print("scoConnectionClosed")
  27.     }
  28.    
  29.     func handsFree(_ device: IOBluetoothHandsFree!, scoConnectionOpened status: NSNumber!)
  30.     {
  31.         Swift.print("scoConnectionOpened")
  32.     }
  33.    
  34.     func handsFree(_ device: IOBluetoothHandsFree!, connected status: NSNumber!)
  35.     {
  36.         Swift.print("connected status: " + status.description)
  37.     }
  38.    
  39.     func handsFree(_ device: IOBluetoothHandsFreeDevice!, batteryCharge: NSNumber!)
  40.     {
  41.         Swift.print("batteryCharge: " + batteryCharge.description)
  42.     }
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top