【问题标题】:How to get the address of BLE device which I am reading for RSSI?如何获取我正在为 RSSI 读取的 BLE 设备的地址?
【发布时间】:2014-11-07 09:16:57
【问题描述】:

我已经实现了通过在 Android 中使用多个 BluetoothGatt parameter 来连接到多个 BLE device

我使用 mBluetoothGatt.readRemoteRssi(); 读取 RSSI ,并通过 BroadcastReceiver 接收 RSSI 值,如下代码:

private final BroadcastReceiver mGattreceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                final String action = intent.getAction();
                if(BluetoothLeService.EXTRA_RSSI.equalsIgnoreCase(action)){
                    int rssi = intent.getIntExtra(BluetoothLeService.EXTRA_RSSI, 0);
                    Log.i(TAG, "mGattreceiver   BroadcastReceiver---rssi = " + rssi);
                }
            }
        };

我可以通过上面的代码得到RSSI,我也看到了类似下面的日志

11-07 17:09:29.595: D/BluetoothGatt(16612): onReadRemoteRssi() - Device=20:73:20:00:6C:C5 rssi=-56 status=0

但是如果有多个 BLE device ,我会得到多个 RSSI 值但没有 BLE address BroadcastReceiver

如何获取我正在为 RSSI 阅读的 address of BLE device

我可以在 BroadcastReceiver 中获取 address 吗?

提前致谢。

【问题讨论】:

标签: android bluetooth-lowenergy rssi


【解决方案1】:

BluetoothDevice 有一个名为 getAddress() 的方法,它返回设备的 MAC 地址。

如果手头不方便,可以使用BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 获取BluetoothDevice 的实例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-14
    • 2013-12-02
    • 1970-01-01
    • 2013-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多