【问题标题】:Watch OS 2: Is it possible to get bluetooth signal strength of connectivity between paired iPhone and Apple Watch?Watch OS 2:是否可以获得配对的 iPhone 和 Apple Watch 之间连接的蓝牙信号强度?
【发布时间】:2015-10-28 15:10:58
【问题描述】:

标题是不言自明的。我已经尝试过 CoreBluetooth,但我不认为 Apple Watch 是连接的外围设备。

【问题讨论】:

  • 为什么需要信号强度?
  • @Michał Ciuba:说出来,他们之间的距离有多远
  • 我不知道它是否可以在 watchOS 上使用,或者它是否可以满足您的需求,但您可能需要查看 Multipeer Connectivity Framework

标签: swift core-bluetooth watchos-2


【解决方案1】:

这是可能的。

使用retrieveConnectedPeripherals(withServices serviceUUIDs: [CBUUID]) -> [CBPeripheral]。您需要为 serviceUUID 指定蓝牙 GATT 特性。我使用了Continuity UUID:“D0611E78-BBB4-4591-A5F8-487910AE4366”。该函数返回一个 CBPeripheral 对象,然后您可以使用connect(_ peripheral: CBPeripheral, options: [String : Any]? = nil) 连接到该对象。

在您确认您的 iOS 应用通过centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral 连接到手表后,您可以使用readRSSI() 查找 iPhone 和 Apple Watch 之间的信号强度。

【讨论】:

    【解决方案2】:

    您需要检查RSSI 信号电平。

    你可以使用:

    - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
        NSLog(@"Did discover peripheral. peripheral: %@ rssi: %@, UUID: %@ advertisementData: %@ ", peripheral, RSSI, peripheral.UUID, advertisementData);
        //Do something when a peripheral is discovered.
    
        rssiLabel.text = [RSSI stringValue];
    
        [manager retrievePeripherals:[NSArray arrayWithObject:(id)peripheral.UUID]];}
    

    【讨论】:

      猜你喜欢
      • 2015-12-22
      • 1970-01-01
      • 2014-08-12
      • 2015-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多