Question

I would like to detect if a botton is pushed on my SensorTag using the gatttool, but I'm not able to do that.

In http://processors.wiki.ti.com/index.php/SensorTag_User_Guide TI reports that in order to read the pressed buttons, you should:

1) Enable test mode by writing the value 0x80 to the AA62 (CONFIGURATION) attribute.

I did that with the command:

[CON][BC:6A:29:AE:CD:E5][LE]> char-write-req 0x67 80
[CON][BC:6A:29:AE:CD:E5][LE]> Characteristic value was written successfully

Now I should be in test mode, and:

2) Enable Simple keys notification

Looking at the http://processors.wiki.ti.com/index.php/File:BLE_SensorTag_GATT_Server.pdf and at the bluepy lib it seems I've to write 0100 in 0x60 for doing that. But

 [CON][BC:6A:29:AE:CD:E5][LE]> char-write-req 0x60 0100
 [CON][BC:6A:29:AE:CD:E5][LE]> Characteristic Write Request failed: Attribute can't be written

I observed that 0x61 is writtable and accept the value 0100, but I'm still not able to detect if a key is pressed.

Any suggestion?

Was it helpful?

Solution

That PDF document may be out of date... I just tried using gatttool on my SensorTag and got button notifications with the following command: char-write-req 0x6c 0100

I'd stick with just the TI wiki for the SensorTag as it's probably more likely to be kept up-to-date. The wiki says you only need to do that "test mode" step if you want to get notifications when the side button is pressed (because normally it just activates the advertising).

Also, you probably have to figure out what handle to use on your specific device as every firmware will cause the handles to move around. What shouldn't change between firmwares is the UUID. Try the primary and characteristics commands in gatttool to get the details of the services on the device.

My primary showed this:

attr handle: 0x005e, end grp handle: 0x0068 uuid: f000aa50-0451-4000-b000-000000000000
attr handle: 0x0069, end grp handle: 0x006d uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
attr handle: 0x006e, end grp handle: 0x0074 uuid: f000aa60-0451-4000-b000-000000000000

ffe0 is the UUID of the simple key service (though the wiki says it's f000ffe0, it's not on mine). So, all the handles you want to look at are from 0x69 to 0x6d

char-read-uuid 0x2902 0x69 0x6d will show all CCC (Client Characteristic Configuration) in that range:

handle: 0x006c   value: 01 00 

Setting that handle to 0100 will turn on notifications for that service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top