Reading Bluetooth RSSI for BLE proximity profile in Android

半世苍凉 提交于 2019-12-21 18:29:55

问题


I am currently developing Bluetooth Low Energy proximity profile for Android and I have stumbled upon an issue regarding RSSI.

In order to make proximity profile work I have to receive RSSI data with already connected device every short period.

As I did some research I understand it is possible to get Bluetooth RSSI during device discovery. That doesn't work for me as the slave device doesn't advertise after connection.

The other way round is digging down to HCI level and using BlueZ. It seems to be pretty low level. Has anyone had any experience with that?

Has anyone seen a proximity profile developed on Android?


回答1:


you can use readRemoteRssi () method repeatedly after some time after connection. but it will not work well.because of pending flag error. another approch is you can start and stop blescan and get rssi value of scan device it will be better approach because in nexus 7 2013 device and some Samsung devices are not filter ble device and it will return ble device ones .




回答2:


You can get the data & RSSI in device scan call back. Refer to the BluetoothLeGatt sample.




回答3:


final Runnable runnable = new Runnable() {  
    @Override
    public void run() {
        // TODO Auto-generated method stub
        mBluetoothLeService.readRemoteRssi();
        mHandler.postDelayed(this, 1000);
    }
};

and add mHandler.postDelayed(runnable, 1000); Should work.


来源:https://stackoverflow.com/questions/11774510/reading-bluetooth-rssi-for-ble-proximity-profile-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!