9 posts / 0 new
Last post
sklin
Offline
Last seen:5 years 10 months ago
Expert
Joined:2014-08-12 08:01
Add Profile Database

Hi Dialog

I have a bit confuse about Characteristic and value attributes.
I read the chapter 10.4 of UM_B_003.pdf, it told me how to add service and attribute in database.
But I don't understand the function whose name is "attmdb_add_attribute()"...

Why the demo code uses the function to add "service attribute" with the second parameter is ATT_UUID_128_LEN while
添加第二个参数是“char属性”ATT_UUID_128_LEN+3 ?

And why the third paramter is ATT_UUID_16_LEN while add a "char attribute" ?
I am confused about the structure of the profile database...

Is there any documents about the structure of the profile database?
Thanks.

MHv_Dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2013-12-06 15:10
Hi Sklin,

Hi Sklin,

A service attribute has onevaluefield, the UUID, which is either 16bit or 128bits wide. Acharacteristicattribute has a UUID (16 or 128 bits wide) and a 16bit handle to thevaluefield as well as anoptionsfield which is 8bit wide. So the total memory size of a 128bit characteristic attribute is 16bytes UUID + 2bytes handle + 1 byte options.

I hope that helps you. The GATT database is described in the BT specification and I find the book below really useful for understanding the attributes.

The book can be found on Amazon:

http://www.amazon.com/Bluetooth-Low-Energy-Developers-Handbook/dp/013288836X#

sklin
Offline
Last seen:5 years 10 months ago
Expert
Joined:2014-08-12 08:01
Hi MHv_Dialog

Hi MHv_Dialog

In the file name with "sample128_task.c" in demo code,I see it add a service with the total_size is 58.
Can I consider it as
58 =
Lenth of Service UUID(16Byte) +
Lenth of Characteristic1 Descriptor ( properties(1Byte) + Handle(2Byte) + UUID(16Byte) )+
Lenth of Characteristic1 Value (1Byte) +
Lenth of Characteristic2 Descriptor ( properties(1Byte) + Handle(2Byte) + UUID(16Byte) )+
Lenth of Characteristic2 Value(1Byte) +
Lenth of Characteristic2 Config(2Byte)

But what the use of the attr_type instruct att_char128_desc?
Thank you.

MHv_Dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2013-12-06 15:10
The att_char128_desc struct

Theatt_char128_descstruct is the placeholder for a characteristic. The first characteristic descriptor is in fact defined as:

struct att_char128_desc sample128_1_char = {ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR,
{0,0},

{0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}};

As you can see, this descriptor consists of 1byte properties + 2 byte handle {0,0} and the 16 byte UUID. The handle is filled out by the stack, so you don't have to define that.

MHv_Dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2013-12-06 15:10
Oh, and your calculation

Oh, and your calculation above is spot-on!

sklin
Offline
Last seen:5 years 10 months ago
Expert
Joined:2014-08-12 08:01
Hi MHv_Dialog

Hi MHv_Dialog
Thanks for your answer,and now I can add custem profiles and it work well...

MHv_Dialog
Offline
Last seen:2 months 1 week ago
Staff
Joined:2013-12-06 15:10
Glad to hear it.

Glad to hear it.

sunnysingh
Offline
Last seen:3 years 4 days ago
Joined:2016-10-21 15:43
How can I get the attribute

How can I get the attribute values from the database?

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi sunnysingh,

Hi sunnysingh,

If you mean how you can read the database attributes from the application itself, you can use the attmdb_att_get_value() function. Also please dont post a question on a thread with an irrelevant topic, you can always create a new thread.

Thanks MT_dialog