通过BLE查找另一个Apple Watch的Apple Watch广告数据以计算距离

问题描述 投票:0回答:1

我想通过BLE从另一个Apple Watch捕获广告数据(例如手表名称和RSSI)。我们知道在Apple Watch上使用BLE只能做Central。它们无需连接,仅需相互捕获广告数据并基于RSSI计算距离即可。我有用于将RSSI值传输到距离的公式。

如何使Central在一个Watch上做广告(数据和RSSI),并在另一个Watch Central上发布那些在Name和RSSI上做广告的数据?

下面的代码使用peripheral。如何使用central

// CBCentralManagerDelegate - This is called with the CBPeripheral class as its main input parameter. 
// This contains most of the information there is to know about a BLE peripheral.

func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    print("Peripheral: \(peripheral.name), RSSI: \(rssi)")
}
bluetooth-lowenergy watchkit core-bluetooth watchos cbcentralmanager
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.