获得连续的RSSI值BLE

时间:2017-05-17 14:04:06

标签: android bluetooth-lowenergy

我想在Android中进行BLE扫描,这是我的代码 -

try {
        if (Build.VERSION.SDK_INT < 21) {
            Log.d(TAG, "Starting BLE scan (SDK < 21)");
            bluetoothAdapter.startLeScan(this);
        }
        else {
            try {
                Log.d(TAG, "Starting BLE scan (SDK >= 21)");
                androidBleScanner.startScan(filters, settings, androidScannerCallback);
            } catch (NullPointerException e) {
                Log.w(TAG, "BLE scan for SDK >= 21 failed, using fallback to SDK < 21!");
                e.printStackTrace();
                bluetoothAdapter.startLeScan(this);
            }
        }

    } catch (NullPointerException e) {
        Log.e(TAG, "Fatal error trying to start BLE scanner!");
    }

问题是它只扫描一次并且在我收到它时给出了RSSI值 -

 @Override
    public void onLeScan(BluetoothDevice bluetoothDevice, int rssi, byte[] bytes) {
        //RSSI got only once
    }

如何扫描30秒并持续获得连续的RSSI值?

0 个答案:

没有答案