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.

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#
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.
Theatt_char128_descstruct is the placeholder for a characteristic. The first characteristic descriptor is in fact defined as:
{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.
Oh, and your calculation above is spot-on!
Hi MHv_Dialog
Thanks for your answer,and now I can add custem profiles and it work well...
Glad to hear it.
How can I get the attribute values from the database?
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