1

我想试试蓝牙管理器。但是在阅读和测试了这里的所有条目后,我真的很困惑。

首先,我在

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

所需的框架。但那里只有二进制文件。所以我添加了一个“Headers”文件夹并将BluetoothManager.h文件放入其中。

在我的项目中,我添加了这个框架,但它找不到任何 BluetoothManager.h 文件,所以如果我使用会出现错误

#import "BluetoothManager.h"

或者

#import <BluetoothManager/BluetoothManager.h>

我想用下面的代码来启动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 ;
}

我也尝试了这里的所有想法:

这里这里这里

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

非常感谢。

伊西康

4

1 回答 1

3

您可以使用来自 github 的类转储工具生成头文件

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


@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

于 2012-05-16T14:03:31.683 回答