Re: Bluetooth Switched On - Notification/Callback
Re: Bluetooth Switched On - Notification/Callback
- Subject: Re: Bluetooth Switched On - Notification/Callback
- From: Alexander Traud <email@hidden>
- Date: Wed, 12 Apr 2006 01:19:00 +0200
> is there a ... callback ... that tells me that bluetooth is switch on/off
Short answer:
IOServiceAddInterestNotification of IOKitLib
service = instance of IOBluetoothHCIController
type = kIOGeneralInterest
In your callback filter for messages of type kIOMessageDeviceWillPowerOff
for On > Off and kIOMessageDeviceHasPoweredOn for Off > On.
Long answer:
Have you received an answer on this? I noticed that this question was not
answered on the mailing list previously:
Sorry for making it so short, however, I am not doing any C here so my code
would not make sense to you. The above works for me in Mac OS X v10.2.8 and
v10.3.9. Nevertheless, this seems to be broken in v10.4.6. There you will
get kIOMessageDeviceWillPowerOff and kIOMessageDeviceHasPoweredOn togeher
always - at least I get that for my D-Link DBT-120 with updated firmware.
Perhaps the driver fails somewhere. In Mac OS X v10.4 you should query the
normal IOBluetooth API for the actual status when you receive one of the
above message types. Still much, much better than polling, isn't it?
How do you use IOServiceAddInterestNotification?
I recommend to have a look at the "Accessing Hardware From Applications"
document from Apple. It covers in detail IOServiceAddMatchingNotification of
IOKitLib which is quite similar to IOServiceAddInterestNotification. You can
(and should because of v10.4) use IOServiceAddMatchingNotification anyway to
get all IOBluetoothHCIController instances. For each found
IOBluetoothHCIController you request an IOServiceAddInterestNotification
because in Mac OS X v10.4 it is possible to have several
IOBluetoothHCIControllers. Although only one is active a time, the user is
able to change the selected one by inserting a new one or using the Apple
Developer Tool "Bluetooth Explorer".
This way you even get notifications, when a user adds or removes the
Bluetooth (PC Card or USB) adapter.
Any comments? Works here for me.
@ Apple Bluetooth engineers:
- Why is this so wired in Mac OS X v10.4 - at least in v10.4.6?
- Why does not work kIOAppPowerStateInterest or
kIOPriorityPowerStateInterest as requested message types? The latter does
not fire at Off > On and the first confuses the Bluetooth menu state with
the On > Off transition. I do not understand this.
- What about a macro function for this within the IOBluetooth headers...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden