onServicesDiscovered never called while connecting to GATT Server

前端 未结 5 356
闹比i
闹比i 2020-12-17 20:04

I have a bluetooth headset which is paired with my Nexus 5X (running Android 7.1) and I would like to connect to a GATT Server of the headset. I tried it with the following

5条回答
  •  伪装坚强ぢ
    2020-12-17 20:31

    In fact,I solve this problem by Execution the method mBluetoothGatt.discoverServices() several times(10 or more),

        int i = 10;
        while (i > 0)
        {
            if (!mIsBLE_Finded)  //如果服务发现失败,继续执行discoverServices方法
            {
                i--;
                mBluetoothGatt.discoverServices();
                System.out.println("BLEService-->" + "尝试次数:" + i);
            }
            else //在10次的尝试中,存在某次服务发现成功了
            {
                i = -1;
            }
        }
    

提交回复
热议问题