First of all, my English is very poor.
I am developing an Android Application that connects to a BLE Device and reads the specific GATT Characteristics and Services that I need to check. I used the BluetoothLeGATT example from the Android Dev site as my reference. I can connect to a predefined Address without problems and read the GATT Attribute updates.
Next, I would like to design an automatic connection device and read the function of the device data.
Following:
1.Automatic scanning, the device will be stored in DeviceList;
2.Connect(mBluetoothGatt.connect()) the device to the DeviceList sequence and read the data,then disconnect(mBluetoothGatt.disconnect()),finally,close( mBluetoothGatt.close());
3.Ten minutes after the interval to repeat the second step;
Result: A few times before the connection is not any problem.
Then there will be such a problem:I only called once Connect(mBluetoothGatt.connect()),but BluetoothGattCallback.onConnectionStateChange() will be called many times.
So will appear repeatedly called connected and disconnected.
Then there will be a Device called disconnect, but did not cancel the pairing.
How can I solve?