Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
- ................
- }
- @Override
- public void onConnectionStateChange(final BluetoothGatt gatt, int status, int newState) {
- Log.d(TAG, String.format("BluetoothGattCallback: onConnectionStateChange: status:%d newState:%d", status, newState));
- if (newState == BluetoothProfile.STATE_DISCONNECTED) {
- Log.d(TAG, "Disconnected from GATT server. Flag = " + connectionStateFlag);
- mainThreadHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- gatt.getDevice().connectGatt(applicationContext, true, callback);
- }
- }, 2000);
- return;
- }
- if (newState == BluetoothProfile.STATE_CONNECTED) {
- Log.d(TAG, "Connected to GATT server. Flag = " + connectionStateFlag);
- Log.i(TAG, "Connected to GATT server.");
- ...
- }
- }
- @Override
- public void onDescriptorWrite(final BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
- Log.d(TAG, "onDescriptorWrite()");
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement