deleted deleted • almost 12 years ago
Button press notifications - identifying the type?
I am just about done with my V.BTTN interface work. The last piece consists of these two questions:
First, I see in the docs that there 4 types of notifications reported
00 - Button release detected
01 - Button press detected
03 - Button press-release between 2-10 seconds
04 - Fall event detected
When I get a notification after pressing a button, short or long, I get a notification with the UUID for the notification characteristic (fffffff4-00f7-4000-b000-000000000000), a handle with the value or 84, and a descriptor with the single letter "D". Not much else. I get that same data when I press down, lift up, and whether or not I do a short or a long button press.
Do I need to make an additional call to read the information to get the values listed above that identify the notification type? If so, what service and characteristic do I need to read, or what descriptor? A little pseudo-code would help.
Comments are closed.

8 comments
haon Manager • almost 12 years ago
Once you've successfully configured V.BTTN for desired detection, then you'll can enable notification by writing 0x01 0x00 to client characteristic configuration (gatt descriptor 00002902-0000-1000-8000-00805f9b34fb) of characteristic FFF4....
You will then get notification thru FFF4 whenever any of the events (ie. button press, fall detection,etc) is detected.
Note: enable and getting notification is similar to how you're getting notification for accelerometer. Difference is that in this case you're using characteristic FFF4
haon Manager • almost 12 years ago
for example: Instead of getting Z-axis data from FFA5, you'll get 01 from FFF4 when you press the button and then 00 when you release it, and 04 when drop the device.
haon Manager • almost 12 years ago
Just curious how does this compares to info you get when you get accelerometer.
haon Manager • almost 12 years ago
Sorry but I'm not familiar with Windows development... but here's how it's done on Android....
public static final UUID CHAR_KEY_PRESS = UUID.fromString("fffffff4-00f7-4000-b000-000000000000");// 0xFFF4
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
{
....
if (GattConstant.CHAR_KEY_PRESS.equals(characteristic.getUuid()))
{
final String keyValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0).toString();
.....
}
}
haon Manager • almost 12 years ago
I just did a quick google search. Is the info in this link useful?
http://msdn.microsoft.com/en-US/library/windows/apps/windows.devices.bluetooth.genericattributeprofile.gattvaluechangedeventargs.characteristicvalue.aspx?cs-save-lang=1&cs-lang=javascript#code-snippet-1
Seems like it would be the CharacteristicValue property of the GattValueChangedEventArgs class
haon Manager • almost 12 years ago
Excellent. Glad I can help!
haon Manager • almost 12 years ago
Perfect use case!
joelyves • over 11 years ago
hi. my issue is similar but i still need some help. may be you can tell me what's wrong in my code:
this is what i use for enabling notification
private void setNotifyNextSensor(BluetoothGatt gatt) {
BluetoothGattCharacteristic characteristic;
switch (mState) {
case 0:
Log.d(TAG, "Set notify pressure cal");
characteristic = gatt.getService(PRESSURE_SERVICE)
.getCharacteristic(PRESSURE_NOT_CHARCTER4);
break;
// case 1:
// Log.d(TAG, "Set notify pressure");
// characteristic = gatt.getService(PRESSURE_SERVICE)
// .getCharacteristic(PRESSURE_DATA_CHAR);
// break;
// case 2:
// Log.d(TAG, "Set notify humidity");
// characteristic = gatt.getService(HUMIDITY_SERVICE)
// .getCharacteristic(HUMIDITY_DATA_CHAR);
// break;
default:
mHandler.sendEmptyMessage(MSG_DISMISS);
Log.i(TAG, "All Sensors Enabled");
return;
}
//Enable local notifications
gatt.setCharacteristicNotification(characteristic, true);
//Enabled remote notifications
BluetoothGattDescriptor desc = characteristic.getDescriptor(GATT_CLIENT_CHAR_CFG_UUID);
desc.setValue( new byte [] { 0x01} );
gatt.writeDescriptor(desc);
}
and this is what i use for writing command values in my bluetooth le device
private void enableNextSensor(BluetoothGatt gatt) {
BluetoothGattCharacteristic characteristic = null;
switch (mState) {
case 0:
if (mio=="" ) {
characteristic = gatt.getService(PRESSURE_SERVICE).getCharacteristic(PRESSURE_NOT_CHARCTER4);//.getDescriptor(GATT_CLIENT_CHAR_CFG_UUID);
//.getCharacteristic(PRESSURE_DATA_CHAR_CHARCTER1);
String n="01:00";
characteristic.setValue( mio.getBytes());//n.getBytes());
gatt.writeCharacteristic(characteristic);
}
// characteristic = gatt.getService(PRESSURE_SERVICE)
// .getCharacteristic(PRESSURE_DATA_CHAR_CHARCTER3);
//ici mettre valeur de input dans mia
// characteristic.setValue( mio.getBytes());
break;
case 1:
break;
default:
mHandler.sendEmptyMessage(MSG_DISMISS);
Log.i(TAG, "All Sensors Enabled");
return;
}
i didn't get any information regarding the UUIDS from the hardware developpers, i just guess i'm using the 0xFFF0 service.
the issue is i'm not able to enable the sensor cc2541 , and if i do , i don't know where to read the data.
private static final UUID PRESSURE_SERVICE = UUID.fromString("0000fff0-0000-1000-8000-00805f9b34fb");//service used by everyone , just that the frofile change
/*characteristics*/
private static final UUID PRESSURE_DATA_CHAR_CHARCTER3 = UUID.fromString("0000fff3-0000-1000-8000-00805f9b34fb");//we write value here
private static final UUID PRESSURE_DATA_CHAR_CHARCTER1 = UUID.fromString("0000fff1-0000-1000-8000-00805f9b34fb");//here we can write first charac
private static final UUID PRESSURE_DATA_CHAR_CHARCTER2 = UUID.fromString("0000fff2-0000-1000-8000-00805f9b34fb");//here read charac
private static final UUID PRESSURE_NOT_CHARCTER4= UUID.fromString("0000fff4-0000-1000-8000-00805f9b34fb");//notification obtain after action
private static final UUID PRESSURE_DATA_CHAR_CHARCTER5= UUID.fromString("0000fff5-0000-1000-8000-00805f9b34fb");//read charac 5
//temp
// private static final UUID PRESSURE_CAL_CHAR = UUID.fromString("0000002a-0000-1000-8000-00805f9b34fb");
/* Client Configuration Descriptor */
private static final UUID GATT_CLIENT_CHAR_CFG_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
private static final UUID CONFIG_DESCRIPTOR1 = UUID.fromString("00002901-0000-1000-8000-00805f9b34fb");