gpt4 book ai didi

ios - 如何在 iOS 上使用 BluetoothManager.framework 私有(private) API 发送和接收数据

转载 作者:可可西里 更新时间:2023-11-01 03:32:17 26 4
gpt4 key购买 nike

这些天我正在做一个项目,我们需要将一个非 MFI 蓝牙设备连接到 iPhone,并且该设备不支持成为 BLE 外设客户端,所以我们必须在经典蓝牙上执行此操作.

我在 demo project BeeTee 的指导下使用 BluetoothManager.framework 成功地将设备配对并连接到 iPhone

但我不知道如何发送和接收数据,我在类转储 header 中找不到 API。

似乎答案就在这三个structs:BTAccessoryManagerImpl & BTSessionImpl & BTDeviceImpl 中,但我无法得到定义他们。

@class NSMutableDictionary;

struct BTSessionImpl { };
struct BTDeviceImpl { };


@interface BluetoothManager : NSObject {
struct BTAccessoryManagerImpl { } *_accessoryManager;
BOOL _audioConnected;
int _available;
NSMutableDictionary *_btAddrDict;
NSMutableDictionary *_btDeviceDict;
struct BTDiscoveryAgentImpl { } *_discoveryAgent;
struct BTLocalDeviceImpl { } *_localDevice;
struct BTPairingAgentImpl { } *_pairingAgent;
BOOL _scanningEnabled;
BOOL _scanningInProgress;
unsigned int _scanningServiceMask;
struct BTSessionImpl *_session; // struct BTSessionImpl { } *_session;

}

+ (int)lastInitError;
+ (id)sharedInstance;

- (struct BTAccessoryManagerImpl *)_accessoryManager; // - (struct BTAccessoryManagerImpl { }*)_accessoryManager;
- (void)_advertisingChanged;
- (BOOL)_attach:(id)arg1;
- (void)_cleanup:(BOOL)arg1;
- (void)_connectabilityChanged;
- (void)_connectedStatusChanged;
- (void)_discoveryStateChanged;
- (BOOL)_onlySensorsConnected;
- (void)_postNotification:(id)arg1;
- (void)_postNotificationWithArray:(id)arg1;
- (void)_powerChanged;
- (void)_removeDevice:(id)arg1;
- (void)_restartScan;
- (void)_scanForServices:(unsigned int)arg1 withMode:(int)arg2;
- (void)_setScanState:(int)arg1;
- (BOOL)_setup:(struct BTSessionImpl*)arg1;
- (void)acceptSSP:(int)arg1 forDevice:(id)arg2;
- (id)addDeviceIfNeeded:(struct BTDeviceImpl *)arg1;
- (BOOL)audioConnected;
- (BOOL)available;
- (void)cancelPairing;
- (void)connectDevice:(id)arg1 withServices:(unsigned int)arg2;
- (void)connectDevice:(id)arg1;
- (BOOL)connectable;
- (BOOL)connected;
- (id)connectedDevices;
- (id)connectingDevices;
- (void)dealloc;
- (BOOL)devicePairingEnabled;
- (BOOL)deviceScanningEnabled;
- (BOOL)deviceScanningInProgress;
- (void)enableTestMode;
- (BOOL)enabled;
- (void)endVoiceCommand:(id)arg1;
- (id)init;
- (BOOL)isAnyoneAdvertising;
- (BOOL)isAnyoneScanning;
- (BOOL)isDiscoverable;
- (BOOL)isServiceSupported:(unsigned int)arg1;
- (int)localDeviceSupportsService:(unsigned int)arg1;
- (id)pairedDevices;
- (void)postNotification:(id)arg1;
- (void)postNotificationName:(id)arg1 object:(id)arg2 error:(id)arg3;
- (void)postNotificationName:(id)arg1 object:(id)arg2;
- (int)powerState;
- (BOOL)powered;
- (void)resetDeviceScanning;
- (void)scanForConnectableDevices:(unsigned int)arg1;
- (void)scanForServices:(unsigned int)arg1;
- (void)setAudioConnected:(BOOL)arg1;
- (void)setConnectable:(BOOL)arg1;
- (void)setDevicePairingEnabled:(BOOL)arg1;
- (void)setDeviceScanningEnabled:(BOOL)arg1;
- (void)setDiscoverable:(BOOL)arg1;
- (BOOL)setEnabled:(BOOL)arg1;
- (void)setPincode:(id)arg1 forDevice:(id)arg2;
- (BOOL)setPowered:(BOOL)arg1;
- (void)showPowerPrompt;
- (void)startVoiceCommand:(id)arg1;
- (void)unpairDevice:(id)arg1;
- (BOOL)wasDeviceDiscovered:(id)arg1;

@end

最佳答案

可以通过虚拟文件 /dev/ttys* 在蓝牙连接上读取或写入数据。成功连接到正确的服务后,您需要从 MobileBluetooth.framework 调用 BTDeviceGetComPortForService,这将检索正确的文件路径。您将找到带有正确头文件的完整示例 here .

打开文件并读取或写入它。而已。要异步读取数据,您可能需要 look here在方法 openTtyreadCompletionNotification 中。

这对我在越狱的 iOS 7 iPhone 上有效。我想听听其他人是否已成功使用此解决方案。

关于ios - 如何在 iOS 上使用 BluetoothManager.framework 私有(private) API 发送和接收数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28314955/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com