2017-02-10 62 views
-1

我试图在显示扫描设备的列表上显示chainging rssi。如何在android BLE中表达chainging BLE rssi?

[在这里输入的形象描述] [1]

我想表达的RSSI chainging RSSI值:_____从图片。 我能够获得日志上的rssi值,如图片。

[请输入图片说明] [2]

请帮帮我。

+1

欢迎来到StackOverflow。请花点时间访问[帮助中心](http://stackoverflow.com/help)并阅读[如何提问](http://stackoverflow.com/help/how-to-ask),这样你可以了解这里接受哪些类型的问题,如何撰写问题以及如何有效地使用本网站 –

+1

此外,您的图片缺失 – lokusking

回答

0

您将需要扫描intervall,通过重新扫描设备“刷新”RSSI。 STH。像这样:

public void scanLeDevice(final boolean enable) 
{ 
    final static int SCAN_PERIOD = 2000; //2s 
    final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 
    final BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter(); 

    //to start or stop scanning (true/false) 
    if (enable) 
    { 
     // Stops scanning after a pre-defined scan period 
     mHandler.postDelayed(new Runnable() 
     { 
      @Override 
      public void run() 
      { 
       mBluetoothAdapter.stopLeScan(mLeScanCallback); 
       if (mGatt == null) 
        offScan(); 
      } 
     }, SCAN_PERIOD); 

     mBluetoothAdapter.startLeScan(mLeScanCallback); 

    } 
    else 
    { 
     mBluetoothAdapter.stopLeScan(mLeScanCallback); 
    } 
}