Hello,
I cannot figure how I can use 128bit UUIDs, when I specify the database description for attribute manager, which I later pass to function attm_svc_create_db().
For example, the acceleration profile is like this:
static const struct attm_desc accel_att_db[ACCEL_IDX_NB] =
{
[ACCEL_IDX_PRIM_SVC] = F /* Accelerometer service */
{ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE),
sizeof(accel_svc), sizeof(accel_svc),
(uint8_t*) &accel_svc},
[ACCEL_IDX_ENABLE_CHAR] = /* Accelerometer enable characteristic */
{ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE),
sizeof(accel_enable_char), sizeof(accel_enable_char),
(uint8_t*) &accel_enable_char},
[ACCEL_IDX_ENABLE_VAL] = /* Accelerometer Enable Value */
{ACCEL_ENABLE_UUID, (PERM(RD, ENABLE) | PERM(WR, ENABLE)),
sizeof(uint8_t), 0, (uint8_t*) NULL},
...
};
But in type "attm_desc" there is only 16bit field reserved for UUID: uint16_t uuid;
然后用这个方法怎么办?
把s, Vesa
Hi Vesa,
You are right. This is for creating the 16 bit UUID.
For 128bit UUID creation, you can try to the below code:
//////char 1
//add char1 attribute
status = attmdb_add_attribute(sample128_env.sample128_shdl, ATT_UUID_128_LEN + 3, //Data size = 19 (ATT_UUID_128_LEN + 3)
ATT_UUID_16_LEN, (uint8_t*) &att_decl_char, PERM(RD, ENABLE),
&(char_hdl));
//add char1 val attribute
status = attmdb_add_attribute(sample128_env.sample128_shdl, 128, //Data size = 128
ATT_UUID_128_LEN, (uint8_t*)&sample128_1_val.uuid, PERM(RD, ENABLE) | PERM(WR, ENABLE)| PERM(NTF, ENABLE),
&(val_hdl));
memcpy(sample128_1_char.attr_hdl, &val_hdl, sizeof(uint16_t));
status = attmdb_att_set_value(char_hdl, sizeof(sample128_1_char), (uint8_t *)&sample128_1_char);
Hello WT,
thank you for the answer!
edit: one more thing, can you give details how you calculate size of attributes?
br, Vesa