Created
June 8, 2015 15:09
-
-
Save aantunovic/d4e8c3eb2dbacf861ea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If a given GATT characteristic is selected, check for supported features. This sample | |
// demonstrates 'Read' and 'Notify' features. See | |
// http://d.android.com/reference/android/bluetooth/BluetoothGatt.html for the complete | |
// list of supported characteristic features. | |
private final ExpandableListView.OnChildClickListener servicesListClickListner = | |
new ExpandableListView.OnChildClickListener() { | |
@Override | |
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, | |
int childPosition, long id) { | |
if (mGattCharacteristics != null) { | |
final BluetoothGattCharacteristic characteristic = | |
mGattCharacteristics.get(groupPosition).get(childPosition); | |
final int charaProp = characteristic.getProperties(); | |
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { | |
// If there is an active notification on a characteristic, clear | |
// it first so it doesn't update the data field on the user interface. | |
if (mNotifyCharacteristic != null) { | |
mBluetoothLeService.setCharacteristicNotification( | |
mNotifyCharacteristic, false); | |
mNotifyCharacteristic = null; | |
} | |
mBluetoothLeService.readCharacteristic(characteristic); | |
} | |
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { | |
mNotifyCharacteristic = characteristic; | |
mBluetoothLeService.setCharacteristicNotification( | |
characteristic, true); | |
} | |
return true; | |
} | |
return false; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment