【问题标题】:How to connect two iPhone using corebluetooth?如何使用corebluetooth连接两部iPhone?
【发布时间】:2012-08-22 17:52:58
【问题描述】:

我可以使用核心蓝牙框架连接两个idevice吗?我正在使用以下代码sn-p:

cBCM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

[cBCM scanForPeripheralsWithServices:nil options:nil];


- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {

}

但代表们根本没有开火。有什么解决办法吗?

【问题讨论】:

    标签: iphone ios5 ios6 core-bluetooth


    【解决方案1】:

    与其尝试触发didDiscoverCharacteristicsForService,不如尝试didDiscoverPeripheral,它将在所有外围设备上触发。 didDiscoverChar... 只会在您在外围设备属性中找到特定特征时触发。

    didDiscover... 触发时,您可以尝试打印其名称

    // Discovered peripheral
    - (void) centralManager:(CBCentralManager *)central 
    didDiscoverPeripheral:(CBPeripheral *)peripheral 
      advertisementData:(NSDictionary *)advertisementData 
                   RSSI:(NSNumber *)RSSI 
    {
        // Print out the name parameter of the discovered peripheral
        @NSSlog ("Discovered peripheral: %@", [peripheral name];
    }
    

    【讨论】:

      猜你喜欢
      • 2018-09-29
      • 1970-01-01
      • 2013-07-21
      • 2014-05-19
      • 2021-07-29
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 1970-01-01
      相关资源
      最近更新 更多