Android 上连续的蓝牙低功耗信号强度

3
3个回答


1
if(newState == BluetoothProfile.STATE_CONNECTED) 
{
   TimerTask task = new TimerTask()
   {
      @Override
      public void run()
      {
         mBluetoothGatt.readRemoteRssi();
      }
   };
   Timer rssiTimer = new Timer();
   rssiTimer.schedule(task, 1000, 1000);
}

0

在调用readRemoteRssi()函数读取信号强度之前,需要先进行连接。 代码示例:

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status,
        int newState) {
    // TODO Auto-generated method stub
    String intentAction;
    if(newState == BluetoothProfile.STATE_CONNECTED) {
        intentAction = ACTION_GATT_CONNECTED;
        mConnectionState = STATE_CONNECTED;
        mBluetoothGatt.readRemoteRssi();

      


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接