Posts: 7
Registered: ‎04-03-2017
Accepted Solution

Read using characteristic UUID



Currently I am working on BLE Master project using BLE1212LR. In this I am adding TIs keyfob slave device to my BLE Master. I achieved simple keys service. But I am not getting how to use the Battery service. In keyfob document and its BTOOL, they are showing that I should read the battery value by using "Read using characteristic UUID". Through their BTOOL software and dongle I am successfully reading the battery percentage. But I am not getting how to do "Read using characteristic UUID" through BGScript. 


Battery service UUID is 0x180F

Battery level characteristic UUID is 0x2A19 and its handler value is 0x2F.


And I want to know in which event it will be good to read the battery percentage, like connection event or procedure completed event. Right now I want read battery percentage every one second so, I will read in timer interrupt event. But I want to read it like whenever I send some command through UART. So, in which event I should read and how to read. 


By the way, I tried "attclient_read_by_handle" , but I am not getting any value from "attclient_attribute_value".


Please provide me example codes if possible. 


Thanks in advance.

Posts: 343
Registered: ‎10-07-2015

Re: Read using characteristic UUID



The BGScript function attclient_read_by_handle together with event attclient_attribute_value are correct for this purpose. Are you sure that you give the correct parameters? Could you please provide us your BGScript file?




Posts: 7
Registered: ‎04-03-2017

Re: Read using characteristic UUID

Thank you so much for the help Mr. Bartosz.


For reading the battery Percentage, I tried with ReadByType function and it is working fine now. And i want to implement accelerometer service also in this code. 


For this I need to enable accelerometer by writing 0x0001 to handler 0x0034 and to get notifications of x-axis changes, I need to write 0x0001 to handler 0x3B.


I am writing those but still I am not getting the accelerometer values from attclient_attribute_value. 


I wrote the code for accelerometer same as I wrote for simple keys which is working fine. 


Please find the attached files for code and details of the Keyfob.


One more thing I want to know is how to check the result of the function attclient_attribute_write.