【问题标题】:How to get changing RSSI of BLE in Android如何在 Android 中更改 BLE 的 RSSI
【发布时间】:2014-08-21 13:54:09
【问题描述】:

我在 nexus 5 上使用 Kontakt 信标设备和测试 ble。当我将 iPad 作为信标设备进行测试时,我能够借助 android 开发人员网站上提供的代码找出服务和特性。但现在我想根据手机与信标设备的距离做一些动作。因此,我尝试检测移动设备与 iOS CLBeacon.Proximity(CLProximityFar、CLProximityNear、CLProximityImmideate 和 CLProximityUnknown)等信标设备的距离。我搜索但无法在android中找到这样的结果。所以决定根据rssi做一些动作。但问题是无论我第一次得到什么 rssi,即在移动检测信标设备时,即使我靠近信标设备或远离它,信标设备也不会改变。

如果有人知道如何在 android 中获取不断变化的 rssi,请分享。 谢谢。

【问题讨论】:

    标签: android bluetooth-lowenergy proximity rssi


    【解决方案1】:

    我不知道您是如何通过现有的 APP 或自己编写代码来检查您所描述的从未更改的 rssi 的?

    但是从代码来看,还是挺直截了当的,我在Android 5.0放了一个核心代码,

    //get your device's BT adapter
    mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
    mLescanner = mBluetoothAdapter.getBluetoothLeScanner();
    settings = new ScanSettings.Builder().setScanMode(scanSettings.SCAN_MODE_LOW_LATENCY).build();
    mLescanner.startScan(this.mLeScanCallback);
    

    而回调是这样的,可以在函数中获取实时的rssi:

    this.mLeScanCallback = new ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {
            int realTimeRssiYouWant = result.getRssi(); 
        }
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-31
      • 2021-11-21
      • 1970-01-01
      • 2020-05-07
      • 1970-01-01
      相关资源
      最近更新 更多