IOS 5.1 switches Bluetooth via BluetoothManager

I want to try BluetoothManager. But I'm really confused after reading and testing all the entries here.

I first found in

Xcode/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework 

necessary structure. But there was only a binari file. So I add the Headers folder and put BluetoothManager.h in it.

In my project, I add this framework, but it cannot find the BluetoothManager.h file, so I get an error message if I use

 #import "BluetoothManager.h" 

or

 #import <BluetoothManager/BluetoothManager.h> 

I want to use the following code to run BT:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. #if TARGET_IPHONE_SIMULATOR exit( EXIT_SUCCESS ) ; #else /* this works in iOS 4.2.3 */ Class BluetoothManager = objc_getClass( "BluetoothManager" ) ; id btCont = [BluetoothManager sharedInstance] ; [btCont setPowered:YES] ; #endif return YES ; } 

I also tried all the ideas here:

here or here or here

Does anyone have a really good idea, tutorial, or a really running example of using (PrivateFramework /) BluetoothManager to switch Bluetooth to iPhone, SKD 5.1?

Thank you very much.

isicom

+1
source share
2 answers

You can generate header files using class dump tools from github

Or copy / paste the content below (I generated for iOS 5.1) into BluetoothManager.h and add this file to your project. Then you should not see a mistake.


 @class NSMutableDictionary; @interface BluetoothManager : NSObject { struct BTLocalDeviceImpl *_localDevice; struct BTSessionImpl *_session; int _available; BOOL _audioConnected; BOOL _scanningEnabled; BOOL _scanningInProgress; unsigned int _scanningServiceMask; struct BTDiscoveryAgentImpl *_discoveryAgent; struct BTPairingAgentImpl *_pairingAgent; struct BTAccessoryManagerImpl *_accessoryManager; NSMutableDictionary *_btAddrDict; NSMutableDictionary *_btDeviceDict; } + (id)sharedInstance; + (int)lastInitError; - (BOOL)available; - (id)init; - (BOOL)_attach:(id)arg1; - (BOOL)_setup:(struct BTSessionImpl *)arg1; - (void)_cleanup:(BOOL)arg1; - (void)dealloc; - (void)_postNotificationWithArray:(id)arg1; - (void)_postNotification:(id)arg1; - (void)postNotification:(id)arg1; - (void)postNotificationName:(id)arg1 object:(id)arg2; - (void)postNotificationName:(id)arg1 object:(id)arg2 error:(id)arg3; - (int)powerState; - (BOOL)powered; - (BOOL)enabled; - (BOOL)setPowered:(BOOL)arg1; - (BOOL)setEnabled:(BOOL)arg1; - (void)_powerChanged; - (BOOL)isAnyoneScanning; - (id)addDeviceIfNeeded:(struct BTDeviceImpl *)arg1; - (void)_removeDevice:(id)arg1; - (BOOL)wasDeviceDiscovered:(id)arg1; - (BOOL)deviceScanningEnabled; - (BOOL)deviceScanningInProgress; - (void)resetDeviceScanning; - (void)_scanForServices:(unsigned int)arg1 withMode:(int)arg2; - (void)scanForServices:(unsigned int)arg1; - (void)scanForConnectableDevices:(unsigned int)arg1; - (void)setDeviceScanningEnabled:(BOOL)arg1; - (void)_restartScan; - (void)_setScanState:(int)arg1; - (void)_discoveryStateChanged; - (BOOL)isDiscoverable; - (void)setDiscoverable:(BOOL)arg1; - (BOOL)devicePairingEnabled; - (void)setDevicePairingEnabled:(BOOL)arg1; - (void)cancelPairing; - (void)unpairDevice:(id)arg1; - (id)pairedDevices:(BOOL)arg1; - (id)pairedDevices; - (id)pairedLEDevices; - (void)setPincode:(id)arg1 forDevice:(id)arg2; - (void)acceptSSP:(int)arg1 forDevice:(id)arg2; - (void)connectDevice:(id)arg1 withServices:(unsigned int)arg2; - (void)connectDevice:(id)arg1; - (BOOL)connectable; - (void)setConnectable:(BOOL)arg1; - (id)connectingDevices; - (id)connectedDevices; - (BOOL)_onlySensorsConnected; - (BOOL)connected; - (void)_connectedStatusChanged; - (void)_connectabilityChanged; - (BOOL)audioConnected; - (void)setAudioConnected:(BOOL)arg1; - (void)startVoiceCommand:(id)arg1; - (void)endVoiceCommand:(id)arg1; - (BOOL)isServiceSupported:(unsigned int)arg1; - (void)enableTestMode; @end 

+3
source

Here is the tutorial that I wrote: http://www.pocketmagic.net/?p=2827 .

It shows how to set up Xcode using the BluetoothManager framework, and then use these private apis to turn on / off bluetooth, discover nearby devices or connect to a remote bluetooth device. Tested with iOS 5.1

Let me know if there is anything else I can help you.

+1
source

All Articles