Finding distance from RSSI value of Bluetooth Low Energy enabled device

后端 未结 4 1128
Happy的楠姐
Happy的楠姐 2020-11-28 02:26

I am working on Bluetooth low energy concept project. I am getting the RSSI value between 1 and 100. As I move the tag the RSSI value increase as the peripheral moves away

4条回答
  •  抹茶落季
    2020-11-28 02:54

    In swift 4.2

    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    if let power = advertisementData[CBAdvertisementDataTxPowerLevelKey] as? Double{
       print("Distance is ", pow(10, ((power - Double(truncating: RSSI))/20)))
       }
    }
    

    More detailed answer Here

提交回复
热议问题