本文介绍了的iOS 5.1切换蓝牙通过BluetoothManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试一下BluetoothManager。但我读,在这里测试的所有条目后,真的很困惑。

首先,我在

发现<$p$p><$c$c>X$c$c/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework

所需的框架。但是,仅仅是binarie文件存在。所以我添加了一个头文件夹,把的在它的文件。

在我的项目,我想补充这个框架,但找不到任何BluetoothManager.h文件,所以我得到一个错误,如果我用

 #进口BluetoothManager.h

 #进口&LT; BluetoothManager / BluetoothManager.h&GT;

我想用下面的code启动BT:

   - (BOOL)应用:(*的UIApplication)的应用didFinishLaunchingWithOptions:(NSDictionary的*)launchOptions
{
    //覆盖点后,应用程序启动定制。
#如果TARGET_IPHONE_SIMULATOR
    出口(EXIT_SUCCESS);
#其他
    / *这个作品中的iOS 4.2.3 * /
    类BluetoothManager = objc_getClass(BluetoothManager);
    ID btCont = [BluetoothManager sharedInstance];
    [btCont setPowered:YES];
#万一
    返回YES;
}

我在这里也试过所有的想法:

here
要么
here
要么
here

有没有人真的一个好主意,一个教程或使用(PrivateFramework /)BluetoothManager切换蓝牙在iPhone上运行的真正例如,SKD 5.1?

非常感谢你。

isicom


解决方案

您可以使用类转储工具从GitHub生成的头文件

或者复制/粘贴下面的内容(我的IOS 5.1生成)为BluetoothManager.h并添加文件在您的项目。那么你不应该看到错误。


  @class的NSMutableDictionary;@interface BluetoothManager:NSObject的
{
    结构BTLocalDeviceImpl * _localDevice;
    结构BTSessionImpl * _session;
    INT _available;
    BOOL _audioConnected;
    BOOL _scanningEnabled;
    BOOL _scanningInProgress;
    无符号整型_scanningServiceMask;
    结构BTDiscoveryAgentImpl * _discoveryAgent;
    结构BTPairingAgentImpl * _pairingAgent;
    结构BTAccessoryManagerImpl * _accessoryManager;
    *的NSMutableDictionary _btAddrDict;
    *的NSMutableDictionary _btDeviceDict;
}+(ID)sharedInstance;
+(INT)lastInitError;
- (BOOL)可用;
- (id)的初始化;
- (BOOL)_attach:(ID)ARG1;
- (BOOL)_setup:(结构BTSessionImpl *)ARG1;
- (无效)_cleanup:(BOOL)ARG1;
- (空)dealloc的;
- (无效)_postNotificationWithArray:(ID)ARG1;
- (无效)_postNotification:(ID)ARG1;
- (无效)postNotification:(ID)ARG1;
- (无效)postNotificationName:(ID)ARG1对象:(ID)ARG2;
- (无效)postNotificationName:(ID)ARG1对象:(ID)ARG2错误:(ID)ARG3;
- (INT)将PowerState;
- (BOOL)供电;
- (BOOL)启用;
- (BOOL)setPowered:(BOOL)ARG1;
- (BOOL)的setEnabled:(BOOL)ARG1;
- (无效)_powerChanged;
- (BOOL)isAnyoneScanning;
- (ID)addDeviceIfNeeded:(结构BTDeviceImpl *)ARG1;
- (无效)_removeDevice:(ID)ARG1;
- (BOOL)wasDeviceDiscovered:(ID)ARG1;
- (BOOL)deviceScanningEnabled;
- (BOOL)deviceScanningInProgress;
- (无效)resetDeviceScanning;
- (无效)_scanForServices:(unsigned int类型)ARG1 withMode:(INT)ARG2;
- (无效)scanForServices:(unsigned int类型)ARG1;
- (无效)scanForConnectableDevices:(unsigned int类型)ARG1;
- (无效)setDeviceScanningEnabled:(BOOL)ARG1;
- (无效)_restartScan;
- (无效)_setScanState:(INT)ARG1;
- (无效)_discoveryStateChanged;
- (BOOL)isDiscoverable;
- (无效)setDiscoverable:(BOOL)ARG1;
- (BOOL)devicePairingEnabled;
- (无效)setDevicePairingEnabled:(BOOL)ARG1;
- (无效)cancelPairing;
- (无效)unpairDevice:(ID)ARG1;
- (ID)pairedDevices:(BOOL)ARG1;
- (ID)pairedDevices;
- (ID)pairedLEDevices;
- (无效)setPin code:(ID)ARG1 forDevice:(ID)ARG2;
- (无效)acceptSSP:(INT)ARG1 forDevice:(ID)ARG2;
- (无效)connectDevice:(ID)ARG1 withServices:(unsigned int类型)ARG2;
- (无效)connectDevice:(ID)ARG1;
- (BOOL)连接;
- (无效)setConnectable:(BOOL)ARG1;
- (ID)connectingDevices;
- (ID)connectedDevices;
- (BOOL)_onlySensorsConnected;
- (BOOL)连接;
- (无效)_connectedStatusChanged;
- (无效)_connectabilityChanged;
- (BOOL)audioConnected;
- (无效)setAudioConnected:(BOOL)ARG1;
- (无效)startVoiceCommand:(ID)ARG1;
- (无效)endVoiceCommand:(ID)ARG1;
- (BOOL)isServiceSupported:(unsigned int类型)ARG1;
- (无效)enableTestMode;@结束


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

First, I found in

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

the needed Framework. But there was only the binarie file there. So I add a "Headers" folder and put the BluetoothManager.h file in it.

In my project, I add this framework, but it couldn't find any BluetoothManager.h file, so I get an error, if I use

#import "BluetoothManager.h"

or

#import <BluetoothManager/BluetoothManager.h>

I want to use the following code to start 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 had tried also all the ideas here:

hereorhereorhere

Has any one a realy good idea, a tutorial or a really running example for using (PrivateFramework/)BluetoothManager to toggle Bluetooth on iPhone, SKD 5.1?

Thank you very much.

isicom

解决方案

You can generate the header files using class-dump tools from github

Or copy/paste the below content(I generated for IOS 5.1) into BluetoothManager.h and add that file in your project. Then you should not see the error.


@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


这篇关于的iOS 5.1切换蓝牙通过BluetoothManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 12:45