Mac: Automatically connect to IOBluetoothDevice

I choose IOBluetoothDevice with IOBluetoothDeviceSelector. After that I do something with the device; irrelevant.

Can I save IOBluetoothDevice and connect automatically when the device is close enough? (after restarting the application too)

Thanks!

+6
source share
1 answer

IOBluetoothDevice has the following methods that will be useful to you:

- [IOBluetoothDevice addressString] , which will give you the device address as a string, which you can easily save in your default settings.

+ [IOBluetoothDevice deviceWithAddressString:(NSString*) address] will allow you to create IOBluetoothDevice* with this address bar after restarting the application.

- [IOBluetoothDevice openConnection] or - [IOBluetoothDevice openConnection:(id)delegate] , which allows you to open the connection to the device you created synchronously or asynchronously.

0
source

Source: https://habr.com/ru/post/909640/


All Articles