[英]Is it possible to connect iPhone4S to MBA via CoreBluetooth?
我正在嘗試通過藍牙在iOS和OSX之間發送/接收數據。
由於GameKit不支持OSX,因此我需要使用其他選項。 iPhone4S和最新的Mac Book Air支持藍牙4.0,因此我認為可以在這些設備之間建立連接。
但是我下面的示例代碼不起作用,需要您的幫助。 盡管我只是創建CBCentralManager並開始掃描設備(手邊有兩個iPhone4S和MBA),但是–從未調用centralManager:didDiscoverPeripheral:advertisementData:RSSI:...
- (void)start {
self.mgr = [[[CBCentralManager alloc] initWithDelegate:self queue:nil] autorelease];
NSDictionary * opts = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[self.mgr scanForPeripheralsWithServices:nil options:opts];
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
// not called this delegate method...
}
我的代碼有什么問題? 我想念什么嗎?
對於iOS 5.x,您不能。 但是隨着CoreBluetooth框架在iOS 6.x(尤其是CBPeripheralManager)中得到了增強,使得在兩個BLE設備之間傳輸數據成為可能。
蘋果公司剛剛發布了最新的示例代碼 。
不,恐怕CoreBluetooth僅適用於低能耗設備(手表,健康監視器等)。無法使用此藍牙配置文件將兩個低能耗“主機”設備連接在一起。
我認為Dermot沒有給我們正確的完整答案。
您應該查看此Apple技術說明 ,它清楚地說明您可以通過MBP使用Bluetooth LE aka CoreBluetooth API ,但必須插入Bluetooth LE USB適配器
從iOS 7.0和OS X Mavericks開始,我相信這是可能的。 查看兩個操作系統的最新CoreBluetooth文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.