Re: Bluetooth Switched On - Notification/Callback
site_archiver@lists.apple.com Delivered-To: bluetooth-dev@lists.apple.com Hi Alexander, Thanks for your solution, but that's a bit oversized for me. Ruotger P.S. the code (I poll timerAction every second): Am 12.04.2006 um 01:19 schrieb Alexander Traud: Short answer: Long answer: 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: --- "Less code is better code" - Wil Shipley Ruotger Skupin, Mac OS X Software Engineering ilink Kommunikationssysteme GmbH Münzstr. 13; 10178 Berlin - Germany _______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bluetooth-dev/site_archiver%40lists.a... no, I didn't get an answer, so I opted for polling. This is Ok in my case, because all I do is show the user if bluetooth is switched off. I then tell him/her to switch it on. - (void) timerAction:(id)sender { BluetoothDeviceAddress localBTAddress; if (IOBluetoothLocalDeviceReadAddress (&localBTAddress, NULL, NULL, NULL) == 0) [_phoneDiagnosisData setIsBluetoothOff:NO]; else [_phoneDiagnosisData setIsBluetoothOff:YES]; } is there a ... callback ... that tells me that bluetooth is switch on/off 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. 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". - 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 (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bluetooth-dev/ruotger.skupin% 40ilink.de This email sent to ruotger.skupin@ilink.de This email sent to site_archiver@lists.apple.com
participants (1)
-
Ruotger Skupin