2015-02-04 13 views
5

In questi giorni sto lavorando a un progetto in cui è necessario connettere un dispositivo Bluetooth non MFI a iPhone e tale dispositivo non supporta un client periferico BLE, quindi dobbiamo farlo sul classico bluetooth.Come inviare e ricevere dati utilizzando l'API privata BluetoothManager.framework su iOS

sono riuscito a accoppiato e collegato il dispositivo per iPhone utilizzando BluetoothManager.framework con la guida del demo project BeeTee

Ma non sa come inviare i dati e RECV, non riesco a trovare l'API nella classe- buttare le intestazioni.

sembra che la risposta sta in questa tre structs:BTAccessoryManagerImpl & BTSessionImpl & BTDeviceImpl, ma non riesco a ottenere la definizione di loro.

@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 
+0

Come ti sei connesso al bluetooth usando il Tee Bee Bluetooth Framework –

risposta

2

La lettura o la scrittura di dati su una connessione bluetooth può essere eseguita su un file virtuale /dev/ttys*. Dopo aver effettuato correttamente la connessione al servizio corretto, è necessario chiamare BTDeviceGetComPortForService da MobileBluetooth.framework, per recuperare il percorso file corretto. Un esempio completo con il file di intestazione corretto si trova here.

Aprire il file e leggere o scrivere su di esso. Questo è tutto. Per leggere i dati in modo asincrono si potrebbe avere look here con i metodi openTty e readCompletionNotification.

Questo ha funzionato per me su un iPhone iOS7 jailbroken. Mi piacerebbe sapere se qualcun altro ha successo con questa soluzione.

+0

Grazie mille! alu. – Nick

+0

Ciao! Sto cercando di connettermi a un dispositivo bluetooth tramite iOS 10.0, lo realizzo tramite Bluetooth Manager ma devo inviare/ricevere dati e non so come usare MobileBluetooth.framework. Sai come posso recuperare i dati dal dispositivo? Grazie ;) – llKoull

Problemi correlati