观看操作系统2:配对的iPhone和Apple Watch之间是否可以获得蓝牙信号连接强度?

时间:2015-10-28 15:10:58

标签: swift core-bluetooth watch-os-2

标题不言自明。我尝试过使用CoreBluetooth,但我没有将Apple Watch视为连接外设。

2 个答案:

答案 0 :(得分:0)

您需要检查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]];}

enter image description here

答案 1 :(得分:0)

有可能。

使用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之间的信号强度。