Skip to main content

BLE Characteristics Permission

1 week ago

BLE Characteristics Permission

Posted byPsomvanshi45 points 2 replies
0 upvotes

I was going through the tutorialCreate a Custom GATT Profile Characteristic on DA14531 and DA14585/DA14586 devices。While adding the new characteristic declaration, value and description in the custom server’s database attributes, we write:

// Control Point Characteristic Declaration [SVC1_IDX_CONTROL_POINT_CHAR] = {(uint8_t*)&att_decl_char, ATT_UUID_16_LEN, PERM(RD, ENABLE), 0, 0, NULL}, // Control Point Characteristic Value [SVC1_IDX_CONTROL_POINT_VAL] = {SVC1_CTRL_POINT_UUID_128, ATT_UUID_128_LEN, PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE), DEF_SVC1_CTRL_POINT_CHAR_LEN, 0, NULL}, // Control Point Characteristic User Description [SVC1_IDX_CONTROL_POINT_USER_DESC] = {(uint8_t*)&att_desc_user_desc, ATT_UUID_16_LEN, PERM(RD, ENABLE), sizeof(DEF_SVC1_CONTROL_POINT_USER_DESC) - 1, sizeof(DEF_SVC1_CONTROL_POINT_USER_DESC) - 1, (uint8_t *) DEF_SVC1_CONTROL_POINT_USER_DESC},

I understand that PERM (RD, ENABLE) makes the declaration readable. But what does PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE) imply? Is there a document containing all possible parameters for PERM and what each of them means?

Moreover, what does the 0 and NULL specify in the characteristic declaration. From this snippet, I understand that characteristic declaration, value and description conform to a particular format. What is this format exactly?

accepted answer!

1 week ago

PM_Dialog

Hi Psomvanshi,

谢谢你的问题。

>>> But what does PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE) imply

According to attm.h header file, the WRITE_REQ is a mask that indicates that the Write Request permission is enabled and the WR indicates that the characteristic is writable. You can use a generic BLE mobile application in order to connect and read all the permission for each characteristic.

>>>Moreover, what does the 0 and NULL specify in the characteristic declaration.

Please check attm_desc_128 structure in attm_db_128.h which holds all the attributes description for the database generation. The 0 either the attribute maximum size or the current length of the element and the NULL is the value of the characteristic.

Thanks, PM_Dialog

1 week ago

Psomvanshi 45 points

Hi PM_Dialog,

Thank you for the answer.