Allow subscribing to Bluetooth state changes
I think it would be good to have a way to listen to changes in the bluetooth adapter state (Power on/off, Authorized, etc.). Since there is already a delegate for centralManagerDidUpdateState, adding the callback is quite simple.
I'm not sure whether Windows or Linux provide a similar functionality, but this PR should contain the necessary changes for MacOS.
Hey @naali! Thanks a lot for your contribution!
One important thing to highlight is that a key design principle for SimpleBLE is to offer a consistent API across all operating systems. In order to add these new features as part of the stable API, we also need to have the Windows and Linux implementations available.
If you can help by doing some research on how this is done in Windows (I have more experience with Linux BLE, so I think that one should be quicker for me to implement) I would really appreciate it and it would also help the speed at which we can roll the feature out for all users.
Excellent!
I’ll take a look at Windows next week.
Hey @naali, how's it going?
Despite not being able to get exactly this feature in (there are some limitations on how these aspects are updated on Windows), I just landed on main a way in which you can manually poll the OS to check the status of Bluetooth: https://github.com/OpenBluetoothToolbox/SimpleBLE/blob/60d9388707aeaff107454d013a93616b5aecd513/simpleble/include/simpleble/Adapter.h#L42
This is the closest we can get for now, but I think it should do the trick.