如何检查设备发现和蓝牙Le设备的发现

时间:2014-03-26 12:47:59

标签: android bluetooth bluetooth-lowenergy

我正在使用Android应用程序列出已发现的蓝牙LE设备。

我正在使用以下代码来扫描BLE设备。

    BluetoothManager mBta = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter();
    SNFBluetoothAdapter mSNFBluetoothAdapter=new SNFBluetoothAdapter(MainActivity.this);

    mBta.startLeScan(mSNFBluetoothAdapter);

使用此方法,我可以扫描范围内的蓝牙设备。

    onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord)

但现在我的问题是, 如何检查设备是否超出蓝牙范围并更新我的设备列表? 请帮助。

对不起我的语言。

3 个答案:

答案 0 :(得分:0)

你可以使用几个开发人员sdk。查看Radius Network beacon和Estimote beacon。 Estimote descovers只是estimote beacons。信标具有接近功能作为您的要求,当您进入/退出该区域时,它们可以通知您。

答案 1 :(得分:0)

除非您停止此过程,否则方法onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord)始终会运行。

因此,如果Device Goes Out of bluetooth range,它会自动消失。

无需担心。

答案 2 :(得分:0)

最后我用Timer来刷新列表。

经过一段特定时间后重置列表数据并重新获取DeviceList,以便获取属于范围设备的新列表。

相关问题