Skip to content

Instantly share code, notes, and snippets.

@bitristan
Created August 27, 2015 08:16
Show Gist options
  • Save bitristan/82c22a4b4d6c047028d6 to your computer and use it in GitHub Desktop.
Save bitristan/82c22a4b4d6c047028d6 to your computer and use it in GitHub Desktop.
private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
Log.v(TAG, "Connection State Changed: " + (newState == BluetoothProfile.STATE_CONNECTED ? "Connected" : "Disconnected"));
if (newState == BluetoothProfile.STATE_CONNECTED) {
setState(State.CONNECTED);
gatt.discoverServices();
} else {
setState(State.IDLE);
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Log.v(TAG, "onServicesDiscovered: " + status);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment