core/gatt: Introduce encryption flags
Luiz Augusto von Dentz
maintainercover core/gatt: Introduce encryption flags
From: Luiz Augusto von Dentz <[email protected]>
This set introduce encryption flags to GattCharacteristic and GattDescriptor along with the necessary changes to bt_gatt_server to honor them.
In addition to that example-gatt-server has been updated to include attributes that makes use of the new flags.
The following is the output using bluetoothctl to navigate in the new attributes introduced to example-gatt-server:
[Vudentz's T440s:/service0016/char001c]# attribute-info Characteristic - Vendor specific
UUID: 12345678-1234-5678-1234-56789abcdef1 Service: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016 Notifying: no Flags: read Flags: write Flags: extended-properties Flags: writable-auxiliaries Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char001c/desc001e Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char001c/desc001f Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char001c/desc0020 [Vudentz's T440s:/service0016/char001c]# select-attribute /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017 [Vudentz's T440s:/service0016/char0017]# attribute-info Characteristic - Vendor specific UUID: 12345678-1234-5678-1234-56789abcdef3 Service: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016 Notifying: no Flags: read Flags: write Flags: extended-properties Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc0019 Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001b
[Vudentz's T440s:/service0016/char0017]# read
Attempting to read /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017
Failed to read: org.bluez.Error.NotPermitted
[Vudentz's T440s:/service0016/char0017]# write 00
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017
Failed to write: org.bluez.Error.NotPermitted
[Vudentz's T440s:/service0016/char0017]# select-attribute /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a [Vudentz's T440s:/service0016/char0017/desc001a]# attribute-info
Descriptor - Vendor specific
UUID: 12345678-1234-5678-1234-56789abcdef4 Characteristic: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017
[Vudentz's T440s:/service0016/char0017/desc001a]# read
Attempting to read /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a Failed to read: org.bluez.Error.NotPermitted
[Vudentz's T440s:/service0016/char0017/desc001a]# write 00
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a Failed to write: org.bluez.Error.NotPermitted
Luiz Augusto von Dentz (8):
doc/gatt-api: Add encryption flags core/gatt: Add support for encryption flags shared/att: Add own security definitions shared/gatt-server: Check attribute permissions doc/gatt-api: Add Flags property to GattDescriptor shared/gatt: Drop CHRC term of properties define core/gatt: Add Flags property to GattDescriptor test/example-gatt-server: Add encrypt attributes
doc/gatt-api.txt | 18 +++++ src/gatt-client.c | 32 ++++---- src/gatt-database.c | 185 +++++++++++++++++++++++++++++++++++------------ src/shared/att-types.h | 51 +++++++++---- src/shared/att.c | 2 +- src/shared/gatt-client.c | 4 +- src/shared/gatt-server.c | 93 +++++++++++++----------- test/example-gatt-server | 52 ++++++++++++- tools/btgatt-server.c | 14 ++-- unit/test-gatt.c | 148 ++++++++++++++++++------------------- 10 files changed, 392 insertions(+), 207 deletions(-)
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerPATCH 1/8 doc/gatt-api: Add encryption flags
From: Luiz Augusto von Dentz <[email protected]>
This add encryption flags which can be used when registering a service to require encryption when accessing a characteristic.
--- doc/gatt-api.txt | 4 ++++ 1 file changed, 4 insertions(+)
doc/gatt-api.txt +4 -0
@@ -148,6 +148,10 @@ Properties string UUID [read-only] "authenticated-signed-writes" "reliable-write" "writable-auxiliaries" + "encrypt-read" + "encrypt-write" + "encrypt-authenticated-read" + "encrypt-authenticated-write" array{object} Descriptors [read-only]
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerPATCH 2/8 core/gatt: Add support for encryption flags
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds support to encryption related flags as defined in the documentation.
--- src/gatt-database.c | 34 +++++++++++++++++++++++++++++++--- src/shared/att-types.h | 30 ++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 11 deletions(-)
src/gatt-database.c +31 -3
@@ -1241,7 +1241,19 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props) *ext_props |=BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ; else if (!strcmp("writable-auxiliaries", flag)) *ext_props |=BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX ; - else { + else if (!strcmp("encrypt-read", flag)) { + *props |=BT_GATT_CHRC_PROP_READ ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_ENC_READ ; + } else if (!strcmp("encrypt-write", flag)) { + *props |=BT_GATT_CHRC_PROP_WRITE ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_ENC_WRITE ; + } else if (!strcmp("encrypt-authenticated-read", flag)) { + *props |=BT_GATT_CHRC_PROP_READ ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_AUTH_READ ; + } else if (!strcmp("encrypt-authenticated-write", flag)) { + *props |=BT_GATT_CHRC_PROP_WRITE ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ; + } else {error ("Invalid characteristic flag: %s" , flag);return false; }
@@ -1668,12 +1680,28 @@ static uint32_t permissions_from_props(uint8_t props, uint8_t ext_props)if (props &BT_GATT_CHRC_PROP_WRITE || props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP || - ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ) + ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE || + ext_props &BT_GATT_CHRC_EXT_PROP_ENC_WRITE || + ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ) perm |=BT_ATT_PERM_WRITE ; -if (props &BT_GATT_CHRC_PROP_READ ) +if (props &BT_GATT_CHRC_PROP_READ || + ext_props &BT_GATT_CHRC_EXT_PROP_ENC_READ || + ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_READ ) perm |=BT_ATT_PERM_READ ; +if (ext_props &BT_GATT_CHRC_EXT_PROP_ENC_READ ) + perm |=BT_ATT_PERM_READ_ENCRYPT ; + +if (ext_props &BT_GATT_CHRC_EXT_PROP_ENC_WRITE ) + perm |=BT_ATT_PERM_WRITE_ENCRYPT ; + +if (ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_READ ) + perm |=BT_ATT_PERM_READ_AUTHEN ; + +if (ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ) + perm |=BT_ATT_PERM_WRITE_AUTHEN ; +return perm; }
src/shared/att-types.h +22 -8
@@ -106,12 +106,18 @@ struct bt_att_pdu_error_rsp {* "Access", "Encryption", "Authentication", and "Authorization". A bitmask of * permissions is a byte that encodes a combination of these. */ -#define BT_ATT_PERM_READ 0x01 -#define BT_ATT_PERM_WRITE 0x02 -#define BT_ATT_PERM_ENCRYPT 0x04 -#define BT_ATT_PERM_AUTHEN 0x08 -#define BT_ATT_PERM_AUTHOR 0x10 -#define BT_ATT_PERM_NONE 0x20 +#define BT_ATT_PERM_READ 0x01 +#define BT_ATT_PERM_WRITE 0x02 +#define BT_ATT_PERM_READ_ENCRYPT 0x04 +#define BT_ATT_PERM_WRITE_ENCRYPT 0x08 +#define BT_ATT_PERM_ENCRYPT BT_ATT_PERM_READ_ENCRYPT | \ + BT_ATT_PERM_WRITE_ENCRYPT +#define BT_ATT_PERM_READ_AUTHEN 0x10 +#define BT_ATT_PERM_WRITE_AUTHEN 0x20 +#define BT_ATT_PERM_AUTHEN BT_ATT_PERM_READ_AUTHEN | \ + BT_ATT_PERM_WRITE_AUTHEN +#define BT_ATT_PERM_AUTHOR 0x40 +#define BT_ATT_PERM_NONE 0x80/* GATT Characteristic Properties Bitfield values */ #define BT_GATT_CHRC_PROP_BROADCAST 0x01
@@ -124,5 +130,13 @@ struct bt_att_pdu_error_rsp {#define BT_GATT_CHRC_PROP_EXT_PROP 0x80/* GATT Characteristic Extended Properties Bitfield values */ -#define BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE 0x01 -#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02 +#define BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE 0x01 +#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02 +#define BT_GATT_CHRC_EXT_PROP_ENC_READ 0x04 +#define BT_GATT_CHRC_EXT_PROP_ENC_WRITE 0x08 +#define BT_GATT_CHRC_EXT_PROP_ENC BT_GATT_CHRC_EXT_PROP_ENC_READ | \ + BT_GATT_CHRC_EXT_PROP_ENC_WRITE +#define BT_GATT_CHRC_EXT_PROP_AUTH_READ 0x10 +#define BT_GATT_CHRC_EXT_PROP_AUTH_WRITE 0x20 +#define BT_GATT_CHRC_EXT_PROP_AUTH BT_GATT_CHRC_EXT_PROP_AUTH_READ | \ + BT_GATT_CHRC_EXT_PROP_AUTH_WRITE
Signature · 1 line
2.1.0
Re: [PATCH BlueZ 2/8] core/gatt: Add support for encryption flags
Hi Luiz,
Quoted 15 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds support to encryption related flags as defined in the documentation.
--- src/gatt-database.c | 34 +++++++++++++++++++++++++++++++--- src/shared/att-types.h | 30 ++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 11 deletions(-)src/gatt-database.c +0
-0
src/gatt-database.c static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props) · line 1246
Quoted 7 lines
src/gatt-database.c +3
-1@@ -1241,7 +1241,19 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props) *ext_props |=BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ; else if (!strcmp("writable-auxiliaries", flag)) *ext_props |=BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX ; - else { + else if (!strcmp("encrypt-read", flag)) { + *props |=BT_GATT_CHRC_PROP_READ ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_ENC_READ ;
You should store these flags separately, perhaps in a "permission_flags" variable. These shouldn't be part of ext_props as they are not part of the CS definition of "Characteristic Extended Properties". Plus, the ext_props variable serves the attribute value for the local "Characteristic Extended Properties" descriptor when it exists, so this logic will cause undefined values to be returned from that descriptor.
Quoted 79 lines
src/gatt-database.c +28
-2+ }else if (!strcmp ("encrypt-write" , flag)) { + *props |=BT_GATT_CHRC_PROP_WRITE ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_ENC_WRITE ; + }else if (!strcmp ("encrypt-authenticated-read" , flag)) { + *props |=BT_GATT_CHRC_PROP_READ ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_AUTH_READ ; + }else if (!strcmp ("encrypt-authenticated-write" , flag)) { + *props |=BT_GATT_CHRC_PROP_WRITE ; + *ext_props |=BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ; + }else {error ("Invalid characteristic flag: %s" , flag);return false; }@@ -1668,12 +1680,28 @@ static uint32_t permissions_from_props(uint8_t props, uint8_t ext_props)if (props &BT_GATT_CHRC_PROP_WRITE || props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP || - ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ) + ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE || + ext_props &BT_GATT_CHRC_EXT_PROP_ENC_WRITE || + ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ) perm |=BT_ATT_PERM_WRITE ; -if (props &BT_GATT_CHRC_PROP_READ ) +if (props &BT_GATT_CHRC_PROP_READ || + ext_props &BT_GATT_CHRC_EXT_PROP_ENC_READ || + ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_READ ) perm |=BT_ATT_PERM_READ ; +if (ext_props &BT_GATT_CHRC_EXT_PROP_ENC_READ ) + perm |=BT_ATT_PERM_READ_ENCRYPT ; + +if (ext_props &BT_GATT_CHRC_EXT_PROP_ENC_WRITE ) + perm |=BT_ATT_PERM_WRITE_ENCRYPT ; + +if (ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_READ ) + perm |=BT_ATT_PERM_READ_AUTHEN ; + +if (ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ) + perm |=BT_ATT_PERM_WRITE_AUTHEN ; +return perm; }src/shared/att-types.h +12
-8@@ -106,12 +106,18 @@ struct bt_att_pdu_error_rsp {* "Access", "Encryption", "Authentication", and "Authorization". A bitmask of * permissions is a byte that encodes a combination of these. */ -#define BT_ATT_PERM_READ 0x01 -#define BT_ATT_PERM_WRITE 0x02 -#define BT_ATT_PERM_ENCRYPT 0x04 -#define BT_ATT_PERM_AUTHEN 0x08 -#define BT_ATT_PERM_AUTHOR 0x10 -#define BT_ATT_PERM_NONE 0x20 +#define BT_ATT_PERM_READ 0x01 +#define BT_ATT_PERM_WRITE 0x02 +#define BT_ATT_PERM_READ_ENCRYPT 0x04 +#define BT_ATT_PERM_WRITE_ENCRYPT 0x08 +#define BT_ATT_PERM_ENCRYPT BT_ATT_PERM_READ_ENCRYPT | \ + BT_ATT_PERM_WRITE_ENCRYPT +#define BT_ATT_PERM_READ_AUTHEN 0x10 +#define BT_ATT_PERM_WRITE_AUTHEN 0x20 +#define BT_ATT_PERM_AUTHEN BT_ATT_PERM_READ_AUTHEN | \ + BT_ATT_PERM_WRITE_AUTHEN +#define BT_ATT_PERM_AUTHOR 0x40 +#define BT_ATT_PERM_NONE 0x80/* GATT Characteristic Properties Bitfield values */ #define BT_GATT_CHRC_PROP_BROADCAST 0x01@@ -124,5 +130,13 @@ struct bt_att_pdu_error_rsp {#define BT_GATT_CHRC_PROP_EXT_PROP 0x80/* GATT Characteristic Extended Properties Bitfield values */ -#define BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE 0x01 -#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02
src/shared/att-types.h struct bt_att_pdu_error_rsp { · line 142
Quoted 10 lines
src/shared/att-types.h +10
-0+#define BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE 0x01 +#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02 +#define BT_GATT_CHRC_EXT_PROP_ENC_READ 0x04 +#define BT_GATT_CHRC_EXT_PROP_ENC_WRITE 0x08 +#define BT_GATT_CHRC_EXT_PROP_ENC BT_GATT_CHRC_EXT_PROP_ENC_READ | \ + BT_GATT_CHRC_EXT_PROP_ENC_WRITE +#define BT_GATT_CHRC_EXT_PROP_AUTH_READ 0x10 +#define BT_GATT_CHRC_EXT_PROP_AUTH_WRITE 0x20 +#define BT_GATT_CHRC_EXT_PROP_AUTH BT_GATT_CHRC_EXT_PROP_AUTH_READ | \ + BT_GATT_CHRC_EXT_PROP_AUTH_WRITE
We should keep these new flags separate from the extended properties stored in ATT. The GATT/ATT spec doesn't define these as extended properties so these definitions don't really belong here; shared/att should be strictly for GATT/ATT as defined by the spec whereas the new permission flags are D-Bus API specific.. I'd define the D-Bus API flags that represent your new attribute permissions in src/gatt-database.h.
Quoted 7 lines
--
2.1.0--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Arman
Luiz Augusto von Dentz
maintainerPATCH 3/8 shared/att: Add own security definitions
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This defines security level at ATT level so it is not necessary to use transport specific defines.
--- src/shared/att-types.h | 5 +++++ src/shared/att.c | 2 +- unit/test-gatt.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
src/shared/att-types.h +5 -0
@@ -27,6 +27,11 @@#define __packed __attribute__((packed))#endif +#define BT_ATT_SECURITY_NONE 0 +#define BT_ATT_SECURITY_LOW 1 +#define BT_ATT_SECURITY_MEDIUM 2 +#define BT_ATT_SECURITY_HIGH 3 +#define BT_ATT_DEFAULT_LE_MTU 23#define BT_ATT_MAX_LE_MTU 517#define BT_ATT_MAX_VALUE_LEN 512
src/shared/att.c +1 -1
@@ -1364,7 +1364,7 @@ bool bt_att_set_sec_level(struct bt_att *att, int level) {struct bt_security sec; -if (!att || level <BT_SECURITY_LOW || level >BT_SECURITY_HIGH ) +if (!att || level <BT_ATT_SECURITY_LOW || level >BT_ATT_SECURITY_HIGH )return false;if (!att->io_on_l2cap) {
unit/test-gatt.c +1 -1
@@ -1002,7 +1002,7 @@ static void test_signed_write_seclevel(struct context *context)g_assert (bt_att_set_local_key (context->att, key, local_counter, context)); -g_assert (bt_att_set_sec_level (context->att,BT_SECURITY_MEDIUM )); +g_assert (bt_att_set_sec_level (context->att,BT_ATT_SECURITY_MEDIUM )); g_assert(bt_gatt_client_write_without_response(context->client, step->handle,
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerPATCH 4/8 shared/gatt-server: Check attribute permissions
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/att-types.h | 16 ++++----- src/shared/gatt-server.c | 93 ++++++++++++++++++++++++++---------------------- 2 files changed, 58 insertions(+), 51 deletions(-)
src/shared/att-types.h +8 -8
@@ -115,12 +115,12 @@ struct bt_att_pdu_error_rsp {#define BT_ATT_PERM_WRITE 0x02#define BT_ATT_PERM_READ_ENCRYPT 0x04#define BT_ATT_PERM_WRITE_ENCRYPT 0x08 -#define BT_ATT_PERM_ENCRYPT BT_ATT_PERM_READ_ENCRYPT | \ - BT_ATT_PERM_WRITE_ENCRYPT +#define BT_ATT_PERM_ENCRYPT (BT_ATT_PERM_READ_ENCRYPT | \ + BT_ATT_PERM_WRITE_ENCRYPT)#define BT_ATT_PERM_READ_AUTHEN 0x10#define BT_ATT_PERM_WRITE_AUTHEN 0x20 -#define BT_ATT_PERM_AUTHEN BT_ATT_PERM_READ_AUTHEN | \ - BT_ATT_PERM_WRITE_AUTHEN +#define BT_ATT_PERM_AUTHEN (BT_ATT_PERM_READ_AUTHEN | \ + BT_ATT_PERM_WRITE_AUTHEN)#define BT_ATT_PERM_AUTHOR 0x40#define BT_ATT_PERM_NONE 0x80
@@ -139,9 +139,9 @@ struct bt_att_pdu_error_rsp {#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02#define BT_GATT_CHRC_EXT_PROP_ENC_READ 0x04#define BT_GATT_CHRC_EXT_PROP_ENC_WRITE 0x08 -#define BT_GATT_CHRC_EXT_PROP_ENC BT_GATT_CHRC_EXT_PROP_ENC_READ | \ - BT_GATT_CHRC_EXT_PROP_ENC_WRITE +#define BT_GATT_CHRC_EXT_PROP_ENC (BT_GATT_CHRC_EXT_PROP_ENC_READ | \ + BT_GATT_CHRC_EXT_PROP_ENC_WRITE)#define BT_GATT_CHRC_EXT_PROP_AUTH_READ 0x10#define BT_GATT_CHRC_EXT_PROP_AUTH_WRITE 0x20 -#define BT_GATT_CHRC_EXT_PROP_AUTH BT_GATT_CHRC_EXT_PROP_AUTH_READ | \ - BT_GATT_CHRC_EXT_PROP_AUTH_WRITE +#define BT_GATT_CHRC_EXT_PROP_AUTH (BT_GATT_CHRC_EXT_PROP_AUTH_READ | \ + BT_GATT_CHRC_EXT_PROP_AUTH_WRITE)
src/shared/gatt-server.c +50 -43
164 lines not on this page · raw message
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerPATCH 5/8 doc/gatt-api: Add Flags property to GattDescriptor
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds Flags property to GattDescriptor so the server can define permissions and authentication requirements for descriptors.
--- doc/gatt-api.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
doc/gatt-api.txt +14 -0
@@ -210,6 +210,20 @@ Properties string UUID [read-only] gets updated only after a successful read request, upon which a PropertiesChanged signal will be emitted. + array{string} Flags [read-only] + + Defines how the descriptor value can be used. + + Possible values: + + "read" + "write-without-response" + "write" + "authenticated-signed-writes" + "encrypt-read" + "encrypt-write" + "encrypt-authenticated-read" + "encrypt-authenticated-write" Profile hierarcy ================
Signature · 1 line
2.1.0
Re: [PATCH BlueZ 5/8] doc/gatt-api: Add Flags property to GattDescriptor
Hi Luiz,
Quoted 17 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds Flags property to GattDescriptor so the server can define permissions and authentication requirements for descriptors.
--- doc/gatt-api.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)doc/gatt-api.txt +0
-0@@ -210,6 +210,20 @@ Properties string UUID [read-only] gets updated only after a successful read request, upon which a PropertiesChanged signal will be emitted.
doc/gatt-api.txt Properties string UUID [read-only] · line 222
Quoted 10 lines
doc/gatt-api.txt +10
-0+ array{string} Flags [read-only] + + Defines how the descriptor value can be used. + + Possible values: + + "read" + "write-without-response" + "write" + "authenticated-signed-writes"
These 4 above are defined as characteristic properties in the CS, so I'm not sure why they would be in a descriptor. The point of these properties (as defined by the Core Spec) is not to communicate attribute permissions but to tell the remote end what procedures a characteristic supports in general. So there's no point of including these in the descriptor as there is no way to communicate these over ATT (whereas these are returned in a characteristic declaration and extended properties descriptor value for characteristics). So maybe just keep read/write for the basic permissions.
Quoted 10 lines
doc/gatt-api.txt +4
-1+ "encrypt-read" + "encrypt-write" + "encrypt-authenticated-read" + "encrypt-authenticated-write" Profile hierarcy ================ --2.1.0
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Arman
Luiz Augusto von Dentz
maintainerPATCH 6/8 shared/gatt: Drop CHRC term of properties define
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Some of the properties will be reused by descriptors.
--- src/gatt-client.c | 32 +++++------ src/gatt-database.c | 80 +++++++++++++------------- src/shared/att-types.h | 36 ++++++------ src/shared/gatt-client.c | 4 +- tools/btgatt-server.c | 14 ++--- unit/test-gatt.c | 146 +++++++++++++++++++++++------------------------ 6 files changed, 156 insertions(+), 156 deletions(-)
src/gatt-client.c +16 -16
@@ -728,20 +728,20 @@ struct chrc_prop_data {static struct chrc_prop_data chrc_props[] = {/* Default Properties */ - {BT_GATT_CHRC_PROP_BROADCAST ,"broadcast" }, - {BT_GATT_CHRC_PROP_READ ,"read" }, - {BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP ,"write-without-response" }, - {BT_GATT_CHRC_PROP_WRITE ,"write" }, - {BT_GATT_CHRC_PROP_NOTIFY ,"notify" }, - {BT_GATT_CHRC_PROP_INDICATE ,"indicate" }, - {BT_GATT_CHRC_PROP_AUTH ,"authenticated-signed-writes" }, - {BT_GATT_CHRC_PROP_EXT_PROP ,"extended-properties" } + {BT_GATT_PROP_BROADCAST ,"broadcast" }, + {BT_GATT_PROP_READ ,"read" }, + {BT_GATT_PROP_WRITE_WITHOUT_RESP ,"write-without-response" }, + {BT_GATT_PROP_WRITE ,"write" }, + {BT_GATT_PROP_NOTIFY ,"notify" }, + {BT_GATT_PROP_INDICATE ,"indicate" }, + {BT_GATT_PROP_AUTH ,"authenticated-signed-writes" }, + {BT_GATT_PROP_EXT_PROP ,"extended-properties" } };static struct chrc_prop_data chrc_ext_props[] = {/* Extended Properties */ - {BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ,"reliable-write" }, - {BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX ,"writable-auxiliaries" } + {BT_GATT_EXT_PROP_RELIABLE_WRITE ,"reliable-write" }, + {BT_GATT_EXT_PROP_WRITABLE_AUX ,"writable-auxiliaries" } }; static gboolean characteristic_get_flags(const GDBusPropertyTable *property,
@@ -910,7 +910,7 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,* - If value is larger than MTU - 3: long-write * * "write-without-response" property set -> write command. */ -if ((chrc->ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE )) { +if ((chrc->ext_props &BT_GATT_EXT_PROP_RELIABLE_WRITE )) { supported = true; chrc->write_id = start_long_write(msg, chrc->value_handle, gatt, true, value, value_len,
@@ -919,7 +919,7 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,return NULL ; } -if (chrc->props &BT_GATT_CHRC_PROP_WRITE ) { +if (chrc->props &BT_GATT_PROP_WRITE ) {uint16_t mtu; supported = true;
@@ -942,13 +942,13 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,return NULL ; } -if (!(chrc->props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP )) +if (!(chrc->props &BT_GATT_PROP_WRITE_WITHOUT_RESP )) goto fail; supported = true; chrc->write_id =bt_gatt_client_write_without_response (gatt, chrc->value_handle, - chrc->props &BT_GATT_CHRC_PROP_AUTH , + chrc->props &BT_GATT_PROP_AUTH , value, value_len);if (chrc->write_id)return dbus_message_new_method_return (msg);
@@ -1152,8 +1152,8 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn,struct async_dbus_op *op;struct notify_client *client; -if (!(chrc->props &BT_GATT_CHRC_PROP_NOTIFY || - chrc->props &BT_GATT_CHRC_PROP_INDICATE )) +if (!(chrc->props &BT_GATT_PROP_NOTIFY || + chrc->props &BT_GATT_PROP_INDICATE ))return btd_error_not_supported (msg);/* Each client can only have one active notify session. */
src/gatt-database.c +40 -40
161 lines not on this page · raw message
src/shared/att-types.h +18 -18
@@ -125,23 +125,23 @@ struct bt_att_pdu_error_rsp {#define BT_ATT_PERM_NONE 0x80/* GATT Characteristic Properties Bitfield values */ -#define BT_GATT_CHRC_PROP_BROADCAST 0x01 -#define BT_GATT_CHRC_PROP_READ 0x02 -#define BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP 0x04 -#define BT_GATT_CHRC_PROP_WRITE 0x08 -#define BT_GATT_CHRC_PROP_NOTIFY 0x10 -#define BT_GATT_CHRC_PROP_INDICATE 0x20 -#define BT_GATT_CHRC_PROP_AUTH 0x40 -#define BT_GATT_CHRC_PROP_EXT_PROP 0x80 +#define BT_GATT_PROP_BROADCAST 0x01 +#define BT_GATT_PROP_READ 0x02 +#define BT_GATT_PROP_WRITE_WITHOUT_RESP 0x04 +#define BT_GATT_PROP_WRITE 0x08 +#define BT_GATT_PROP_NOTIFY 0x10 +#define BT_GATT_PROP_INDICATE 0x20 +#define BT_GATT_PROP_AUTH 0x40 +#define BT_GATT_PROP_EXT_PROP 0x80/* GATT Characteristic Extended Properties Bitfield values */ -#define BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE 0x01 -#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02 -#define BT_GATT_CHRC_EXT_PROP_ENC_READ 0x04 -#define BT_GATT_CHRC_EXT_PROP_ENC_WRITE 0x08 -#define BT_GATT_CHRC_EXT_PROP_ENC (BT_GATT_CHRC_EXT_PROP_ENC_READ | \ - BT_GATT_CHRC_EXT_PROP_ENC_WRITE) -#define BT_GATT_CHRC_EXT_PROP_AUTH_READ 0x10 -#define BT_GATT_CHRC_EXT_PROP_AUTH_WRITE 0x20 -#define BT_GATT_CHRC_EXT_PROP_AUTH (BT_GATT_CHRC_EXT_PROP_AUTH_READ | \ - BT_GATT_CHRC_EXT_PROP_AUTH_WRITE) +#define BT_GATT_EXT_PROP_RELIABLE_WRITE 0x01 +#define BT_GATT_EXT_PROP_WRITABLE_AUX 0x02 +#define BT_GATT_EXT_PROP_ENC_READ 0x04 +#define BT_GATT_EXT_PROP_ENC_WRITE 0x08 +#define BT_GATT_EXT_PROP_ENC (BT_GATT_EXT_PROP_ENC_READ | \ + BT_GATT_EXT_PROP_ENC_WRITE) +#define BT_GATT_EXT_PROP_AUTH_READ 0x10 +#define BT_GATT_EXT_PROP_AUTH_WRITE 0x20 +#define BT_GATT_EXT_PROP_AUTH (BT_GATT_EXT_PROP_AUTH_READ | \ + BT_GATT_EXT_PROP_AUTH_WRITE)
src/shared/gatt-client.c +2 -2
@@ -1392,10 +1392,10 @@ static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,/* Try to enable notifications and/or indications based on * whatever the characteristic supports. */ -if (notify_data->chrc->properties &BT_GATT_CHRC_PROP_NOTIFY ) +if (notify_data->chrc->properties &BT_GATT_PROP_NOTIFY ) pdu[2 ] =0x01 ; -if (notify_data->chrc->properties &BT_GATT_CHRC_PROP_INDICATE ) +if (notify_data->chrc->properties &BT_GATT_PROP_INDICATE ) pdu[2 ] |=0x02 ;if (!pdu[2 ])
tools/btgatt-server.c +7 -7
@@ -204,7 +204,7 @@ static void gap_device_name_ext_prop_read_cb(struct gatt_db_attribute *attrib,PRLOG ("Device Name Extended Properties Read called\n" ); - value[0 ] =BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ; + value[0 ] =BT_GATT_EXT_PROP_RELIABLE_WRITE ; value[1 ] =0 ;gatt_db_attribute_read_result (attrib, id,0 , value,sizeof (value));
@@ -419,7 +419,7 @@ static void populate_gap_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_DEVICE_NAME );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ , gap_device_name_read_cb, gap_device_name_write_cb, server);
@@ -436,7 +436,7 @@ static void populate_gap_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_APPEARANCE ); tmp =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ ,NULL ,NULL , server);/*
@@ -465,7 +465,7 @@ static void populate_gatt_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_SERVICE_CHANGED ); svc_chngd =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ |BT_GATT_CHRC_PROP_INDICATE , +BT_GATT_PROP_READ |BT_GATT_PROP_INDICATE , gatt_service_changed_cb,NULL , server); server->gatt_svc_chngd_handle =gatt_db_attribute_get_handle (svc_chngd);
@@ -494,7 +494,7 @@ static void populate_hr_service(struct server *server)bt_uuid16_create (&uuid,UUID_HEART_RATE_MSRMT ); hr_msrmt =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_NONE , -BT_GATT_CHRC_PROP_NOTIFY , +BT_GATT_PROP_NOTIFY ,NULL ,NULL ,NULL ); server->hr_msrmt_handle =gatt_db_attribute_get_handle (hr_msrmt);
@@ -511,7 +511,7 @@ static void populate_hr_service(struct server *server)bt_uuid16_create (&uuid,UUID_HEART_RATE_BODY ); body =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ ,NULL ,NULL , server); gatt_db_attribute_write(body, 0, (void *) &body_loc, sizeof(body_loc), BT_ATT_OP_WRITE_REQ,
@@ -522,7 +522,7 @@ static void populate_hr_service(struct server *server)bt_uuid16_create (&uuid,UUID_HEART_RATE_CTRL );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_WRITE ,NULL , hr_control_point_write_cb, server);
unit/test-gatt.c +73 -73
339 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [PATCH BlueZ 6/8] shared/gatt: Drop CHRC term of properties define
Hi Luiz,
Quoted 4 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Some of the properties will be reused by descriptors.
This patch doesn't make sense to me. Descriptors shouldn't reuse any of these properties as they are defined by the CS to be characteristic specific. Descriptors don't have such "properties" definitions.
Quoted 756 lines
--- src/gatt-client.c | 32 +++++------ src/gatt-database.c | 80 +++++++++++++------------- src/shared/att-types.h | 36 ++++++------ src/shared/gatt-client.c | 4 +- tools/btgatt-server.c | 14 ++--- unit/test-gatt.c | 146 +++++++++++++++++++++++------------------------ 6 files changed, 156 insertions(+), 156 deletions(-)src/gatt-client.c +16
-16@@ -728,20 +728,20 @@ struct chrc_prop_data {static struct chrc_prop_data chrc_props[] = {/* Default Properties */ - {BT_GATT_CHRC_PROP_BROADCAST ,"broadcast" }, - {BT_GATT_CHRC_PROP_READ ,"read" }, - {BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP ,"write-without-response" }, - {BT_GATT_CHRC_PROP_WRITE ,"write" }, - {BT_GATT_CHRC_PROP_NOTIFY ,"notify" }, - {BT_GATT_CHRC_PROP_INDICATE ,"indicate" }, - {BT_GATT_CHRC_PROP_AUTH ,"authenticated-signed-writes" }, - {BT_GATT_CHRC_PROP_EXT_PROP ,"extended-properties" } + {BT_GATT_PROP_BROADCAST ,"broadcast" }, + {BT_GATT_PROP_READ ,"read" }, + {BT_GATT_PROP_WRITE_WITHOUT_RESP ,"write-without-response" }, + {BT_GATT_PROP_WRITE ,"write" }, + {BT_GATT_PROP_NOTIFY ,"notify" }, + {BT_GATT_PROP_INDICATE ,"indicate" }, + {BT_GATT_PROP_AUTH ,"authenticated-signed-writes" }, + {BT_GATT_PROP_EXT_PROP ,"extended-properties" } };static struct chrc_prop_data chrc_ext_props[] = {/* Extended Properties */ - {BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ,"reliable-write" }, - {BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX ,"writable-auxiliaries" } + {BT_GATT_EXT_PROP_RELIABLE_WRITE ,"reliable-write" }, + {BT_GATT_EXT_PROP_WRITABLE_AUX ,"writable-auxiliaries" } }; static gboolean characteristic_get_flags(const GDBusPropertyTable *property,@@ -910,7 +910,7 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,* - If value is larger than MTU - 3: long-write * * "write-without-response" property set -> write command. */ -if ((chrc->ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE )) { +if ((chrc->ext_props &BT_GATT_EXT_PROP_RELIABLE_WRITE )) { supported = true; chrc->write_id = start_long_write(msg, chrc->value_handle, gatt, true, value, value_len,@@ -919,7 +919,7 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,return NULL ; } -if (chrc->props &BT_GATT_CHRC_PROP_WRITE ) { +if (chrc->props &BT_GATT_PROP_WRITE ) {uint16_t mtu; supported = true;@@ -942,13 +942,13 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,return NULL ; } -if (!(chrc->props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP )) +if (!(chrc->props &BT_GATT_PROP_WRITE_WITHOUT_RESP )) goto fail; supported = true; chrc->write_id =bt_gatt_client_write_without_response (gatt, chrc->value_handle, - chrc->props &BT_GATT_CHRC_PROP_AUTH , + chrc->props &BT_GATT_PROP_AUTH , value, value_len);if (chrc->write_id)return dbus_message_new_method_return (msg);@@ -1152,8 +1152,8 @@ static DBusMessage *characteristic_start_notify(DBusConnection *conn,struct async_dbus_op *op;struct notify_client *client; -if (!(chrc->props &BT_GATT_CHRC_PROP_NOTIFY || - chrc->props &BT_GATT_CHRC_PROP_INDICATE )) +if (!(chrc->props &BT_GATT_PROP_NOTIFY || + chrc->props &BT_GATT_PROP_INDICATE ))return btd_error_not_supported (msg);/* Each client can only have one active notify session. */ src/gatt-database.c +40
-40@@ -656,7 +656,7 @@ static void populate_gap_service(struct btd_gatt_database *database)*/ bt_uuid16_create (&uuid,GATT_CHARAC_DEVICE_NAME );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ , gap_device_name_read_cb,NULL , database);@@ -665,7 +665,7 @@ static void populate_gap_service(struct btd_gatt_database *database)*/ bt_uuid16_create (&uuid,GATT_CHARAC_APPEARANCE );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ , gap_appearance_read_cb,NULL , database);@@ -871,7 +871,7 @@ static void populate_gatt_service(struct btd_gatt_database *database)bt_uuid16_create (&uuid,GATT_CHARAC_SERVICE_CHANGED ); database->svc_chngd =gatt_db_service_add_characteristic (service, &uuid, -BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_INDICATE , +BT_ATT_PERM_READ ,BT_GATT_PROP_INDICATE ,NULL ,NULL , database); database->svc_chngd_ccc = service_add_ccc(service, database, NULL, NULL,@@ -1224,35 +1224,35 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props)dbus_message_iter_get_basic (&array, &flag);if (!strcmp ("broadcast" , flag)) - *props |=BT_GATT_CHRC_PROP_BROADCAST ; + *props |=BT_GATT_PROP_BROADCAST ;else if (!strcmp ("read" , flag)) - *props |=BT_GATT_CHRC_PROP_READ ; + *props |=BT_GATT_PROP_READ ;else if (!strcmp ("write-without-response" , flag)) - *props |=BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP ; + *props |=BT_GATT_PROP_WRITE_WITHOUT_RESP ;else if (!strcmp ("write" , flag)) - *props |=BT_GATT_CHRC_PROP_WRITE ; + *props |=BT_GATT_PROP_WRITE ;else if (!strcmp ("notify" , flag)) - *props |=BT_GATT_CHRC_PROP_NOTIFY ; + *props |=BT_GATT_PROP_NOTIFY ;else if (!strcmp ("indicate" , flag)) - *props |=BT_GATT_CHRC_PROP_INDICATE ; + *props |=BT_GATT_PROP_INDICATE ;else if (!strcmp ("authenticated-signed-writes" , flag)) - *props |=BT_GATT_CHRC_PROP_AUTH ; + *props |=BT_GATT_PROP_AUTH ;else if (!strcmp ("reliable-write" , flag)) - *ext_props |=BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_RELIABLE_WRITE ;else if (!strcmp ("writable-auxiliaries" , flag)) - *ext_props |=BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX ; + *ext_props |=BT_GATT_EXT_PROP_WRITABLE_AUX ;else if (!strcmp ("encrypt-read" , flag)) { - *props |=BT_GATT_CHRC_PROP_READ ; - *ext_props |=BT_GATT_CHRC_EXT_PROP_ENC_READ ; + *props |=BT_GATT_PROP_READ ; + *ext_props |=BT_GATT_EXT_PROP_ENC_READ ; }else if (!strcmp ("encrypt-write" , flag)) { - *props |=BT_GATT_CHRC_PROP_WRITE ; - *ext_props |=BT_GATT_CHRC_EXT_PROP_ENC_WRITE ; + *props |=BT_GATT_PROP_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_ENC_WRITE ; }else if (!strcmp ("encrypt-authenticated-read" , flag)) { - *props |=BT_GATT_CHRC_PROP_READ ; - *ext_props |=BT_GATT_CHRC_EXT_PROP_AUTH_READ ; + *props |=BT_GATT_PROP_READ ; + *ext_props |=BT_GATT_EXT_PROP_AUTH_READ ; }else if (!strcmp ("encrypt-authenticated-write" , flag)) { - *props |=BT_GATT_CHRC_PROP_WRITE ; - *ext_props |=BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ; + *props |=BT_GATT_PROP_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_AUTH_WRITE ; }else {error ("Invalid characteristic flag: %s" , flag);return false;@@ -1260,7 +1260,7 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props) }while (dbus_message_iter_next (&array));if (*ext_props) - *props |=BT_GATT_CHRC_PROP_EXT_PROP ; + *props |=BT_GATT_PROP_EXT_PROP ;return true; }@@ -1337,8 +1337,8 @@ static void proxy_added_cb(GDBusProxy *proxy, void *user_data)return ; } -if ((chrc->props &BT_GATT_CHRC_PROP_NOTIFY || - chrc->props &BT_GATT_CHRC_PROP_INDICATE ) && +if ((chrc->props &BT_GATT_PROP_NOTIFY || + chrc->props &BT_GATT_PROP_INDICATE ) && !incr_attr_count (service,1 )) {error ("Failed to increment attribute count for CCC" ); service->failed = true;@@ -1678,28 +1678,28 @@ static uint32_t permissions_from_props(uint8_t props, uint8_t ext_props) {uint32_t perm =0 ; -if (props &BT_GATT_CHRC_PROP_WRITE || - props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP || - ext_props &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE || - ext_props &BT_GATT_CHRC_EXT_PROP_ENC_WRITE || - ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ) +if (props &BT_GATT_PROP_WRITE || + props &BT_GATT_PROP_WRITE_WITHOUT_RESP || + ext_props &BT_GATT_EXT_PROP_RELIABLE_WRITE || + ext_props &BT_GATT_EXT_PROP_ENC_WRITE || + ext_props &BT_GATT_EXT_PROP_AUTH_WRITE ) perm |=BT_ATT_PERM_WRITE ; -if (props &BT_GATT_CHRC_PROP_READ || - ext_props &BT_GATT_CHRC_EXT_PROP_ENC_READ || - ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_READ ) +if (props &BT_GATT_PROP_READ || + ext_props &BT_GATT_EXT_PROP_ENC_READ || + ext_props &BT_GATT_EXT_PROP_AUTH_READ ) perm |=BT_ATT_PERM_READ ; -if (ext_props &BT_GATT_CHRC_EXT_PROP_ENC_READ ) +if (ext_props &BT_GATT_EXT_PROP_ENC_READ ) perm |=BT_ATT_PERM_READ_ENCRYPT ; -if (ext_props &BT_GATT_CHRC_EXT_PROP_ENC_WRITE ) +if (ext_props &BT_GATT_EXT_PROP_ENC_WRITE ) perm |=BT_ATT_PERM_WRITE_ENCRYPT ; -if (ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_READ ) +if (ext_props &BT_GATT_EXT_PROP_AUTH_READ ) perm |=BT_ATT_PERM_READ_AUTHEN ; -if (ext_props &BT_GATT_CHRC_EXT_PROP_AUTH_WRITE ) +if (ext_props &BT_GATT_EXT_PROP_AUTH_WRITE ) perm |=BT_ATT_PERM_WRITE_AUTHEN ;return perm;@@ -1741,8 +1741,8 @@ static uint8_t ccc_write_cb(uint16_t value, void *user_data)/* Don't support undefined CCC values yet */ if (value >2 || - (value ==1 && !(chrc->props &BT_GATT_CHRC_PROP_NOTIFY )) || - (value ==2 && !(chrc->props &BT_GATT_CHRC_PROP_INDICATE ))) + (value ==1 && !(chrc->props &BT_GATT_PROP_NOTIFY )) || + (value ==2 && !(chrc->props &BT_GATT_PROP_INDICATE )))return BT_ATT_ERROR_REQUEST_NOT_SUPPORTED ;/* @@ -1791,14 +1791,14 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name,gatt_db_attribute_get_handle (chrc->attrib), value, len,gatt_db_attribute_get_handle (chrc->ccc), - chrc->props & BT_GATT_CHRC_PROP_INDICATE); + chrc->props & BT_GATT_PROP_INDICATE); }static bool database_add_ccc (struct external_service *service,struct external_chrc *chrc) { -if (!(chrc->props &BT_GATT_CHRC_PROP_NOTIFY ) && - !(chrc->props &BT_GATT_CHRC_PROP_INDICATE )) +if (!(chrc->props &BT_GATT_PROP_NOTIFY ) && + !(chrc->props &BT_GATT_PROP_INDICATE ))return true; chrc->ccc = service_add_ccc(service->attrib, service->database,src/shared/att-types.h +18
-18@@ -125,23 +125,23 @@ struct bt_att_pdu_error_rsp {#define BT_ATT_PERM_NONE 0x80/* GATT Characteristic Properties Bitfield values */ -#define BT_GATT_CHRC_PROP_BROADCAST 0x01 -#define BT_GATT_CHRC_PROP_READ 0x02 -#define BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP 0x04 -#define BT_GATT_CHRC_PROP_WRITE 0x08 -#define BT_GATT_CHRC_PROP_NOTIFY 0x10 -#define BT_GATT_CHRC_PROP_INDICATE 0x20 -#define BT_GATT_CHRC_PROP_AUTH 0x40 -#define BT_GATT_CHRC_PROP_EXT_PROP 0x80 +#define BT_GATT_PROP_BROADCAST 0x01 +#define BT_GATT_PROP_READ 0x02 +#define BT_GATT_PROP_WRITE_WITHOUT_RESP 0x04 +#define BT_GATT_PROP_WRITE 0x08 +#define BT_GATT_PROP_NOTIFY 0x10 +#define BT_GATT_PROP_INDICATE 0x20 +#define BT_GATT_PROP_AUTH 0x40 +#define BT_GATT_PROP_EXT_PROP 0x80/* GATT Characteristic Extended Properties Bitfield values */ -#define BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE 0x01 -#define BT_GATT_CHRC_EXT_PROP_WRITABLE_AUX 0x02 -#define BT_GATT_CHRC_EXT_PROP_ENC_READ 0x04 -#define BT_GATT_CHRC_EXT_PROP_ENC_WRITE 0x08 -#define BT_GATT_CHRC_EXT_PROP_ENC (BT_GATT_CHRC_EXT_PROP_ENC_READ | \ - BT_GATT_CHRC_EXT_PROP_ENC_WRITE) -#define BT_GATT_CHRC_EXT_PROP_AUTH_READ 0x10 -#define BT_GATT_CHRC_EXT_PROP_AUTH_WRITE 0x20 -#define BT_GATT_CHRC_EXT_PROP_AUTH (BT_GATT_CHRC_EXT_PROP_AUTH_READ | \ - BT_GATT_CHRC_EXT_PROP_AUTH_WRITE) +#define BT_GATT_EXT_PROP_RELIABLE_WRITE 0x01 +#define BT_GATT_EXT_PROP_WRITABLE_AUX 0x02 +#define BT_GATT_EXT_PROP_ENC_READ 0x04 +#define BT_GATT_EXT_PROP_ENC_WRITE 0x08 +#define BT_GATT_EXT_PROP_ENC (BT_GATT_EXT_PROP_ENC_READ | \ + BT_GATT_EXT_PROP_ENC_WRITE) +#define BT_GATT_EXT_PROP_AUTH_READ 0x10 +#define BT_GATT_EXT_PROP_AUTH_WRITE 0x20 +#define BT_GATT_EXT_PROP_AUTH (BT_GATT_EXT_PROP_AUTH_READ | \ + BT_GATT_EXT_PROP_AUTH_WRITE)src/shared/gatt-client.c +2
-2@@ -1392,10 +1392,10 @@ static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,/* Try to enable notifications and/or indications based on * whatever the characteristic supports. */ -if (notify_data->chrc->properties &BT_GATT_CHRC_PROP_NOTIFY ) +if (notify_data->chrc->properties &BT_GATT_PROP_NOTIFY ) pdu[2 ] =0x01 ; -if (notify_data->chrc->properties &BT_GATT_CHRC_PROP_INDICATE ) +if (notify_data->chrc->properties &BT_GATT_PROP_INDICATE ) pdu[2 ] |=0x02 ;if (!pdu[2 ])tools/btgatt-server.c +7
-7@@ -204,7 +204,7 @@ static void gap_device_name_ext_prop_read_cb(struct gatt_db_attribute *attrib,PRLOG ("Device Name Extended Properties Read called\n" ); - value[0 ] =BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ; + value[0 ] =BT_GATT_EXT_PROP_RELIABLE_WRITE ; value[1 ] =0 ;gatt_db_attribute_read_result (attrib, id,0 , value,sizeof (value));@@ -419,7 +419,7 @@ static void populate_gap_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_DEVICE_NAME );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ , gap_device_name_read_cb, gap_device_name_write_cb, server);@@ -436,7 +436,7 @@ static void populate_gap_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_APPEARANCE ); tmp =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ ,NULL ,NULL , server);/* @@ -465,7 +465,7 @@ static void populate_gatt_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_SERVICE_CHANGED ); svc_chngd =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ |BT_GATT_CHRC_PROP_INDICATE , +BT_GATT_PROP_READ |BT_GATT_PROP_INDICATE , gatt_service_changed_cb,NULL , server); server->gatt_svc_chngd_handle =gatt_db_attribute_get_handle (svc_chngd);@@ -494,7 +494,7 @@ static void populate_hr_service(struct server *server)bt_uuid16_create (&uuid,UUID_HEART_RATE_MSRMT ); hr_msrmt =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_NONE , -BT_GATT_CHRC_PROP_NOTIFY , +BT_GATT_PROP_NOTIFY ,NULL ,NULL ,NULL ); server->hr_msrmt_handle =gatt_db_attribute_get_handle (hr_msrmt);@@ -511,7 +511,7 @@ static void populate_hr_service(struct server *server)bt_uuid16_create (&uuid,UUID_HEART_RATE_BODY ); body =gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ ,NULL ,NULL , server); gatt_db_attribute_write(body, 0, (void *) &body_loc, sizeof(body_loc), BT_ATT_OP_WRITE_REQ,@@ -522,7 +522,7 @@ static void populate_hr_service(struct server *server)bt_uuid16_create (&uuid,UUID_HEART_RATE_CTRL );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_WRITE ,NULL , hr_control_point_write_cb, server);unit/test-gatt.c +73
-74@@ -1414,14 +1414,14 @@ static struct gatt_db *make_service_data_1_db(void)const struct att_handle_spec specs[] = {PRIMARY_SERVICE (0x0001 ,GATT_UUID ,4 ),CHARACTERISTIC_STR (GATT_CHARAC_DEVICE_NAME ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,"BlueZ" ), +BT_GATT_PROP_READ ,"BlueZ" ),DESCRIPTOR_STR (GATT_CHARAC_USER_DESC_UUID ,BT_ATT_PERM_READ ,"Device Name" ),PRIMARY_SERVICE (0x0005 ,HEART_RATE_UUID ,4 ),CHARACTERISTIC_STR (GATT_CHARAC_MANUFACTURER_NAME_STRING ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE ,"" ), +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"" ),DESCRIPTOR_STR (GATT_CHARAC_USER_DESC_UUID ,BT_ATT_PERM_READ ,"Manufacturer Name" ), { }@@ -1459,15 +1459,15 @@ static struct gatt_db *make_service_data_2_db(void)const struct att_handle_spec specs[] = {PRIMARY_SERVICE (0x0001 ,GATT_UUID ,4 ),CHARACTERISTIC_STR (GATT_CHARAC_DEVICE_NAME ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,"BlueZ" ), +BT_GATT_PROP_READ ,"BlueZ" ),DESCRIPTOR_STR (GATT_CHARAC_USER_DESC_UUID ,BT_ATT_PERM_READ ,"Device Name" ),PRIMARY_SERVICE (0x0005 ,HEART_RATE_UUID ,6 ),CHARACTERISTIC_STR_AT (0x0008 ,GATT_CHARAC_MANUFACTURER_NAME_STRING ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE ,"" ), +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"" ),DESCRIPTOR_STR_AT (0x000a ,GATT_CHARAC_USER_DESC_UUID ,BT_ATT_PERM_READ ,"Manufacturer Name" ), { }@@ -1506,17 +1506,17 @@ static struct gatt_db *make_service_data_3_db(void)PRIMARY_SERVICE (0x0100 ,GAP_UUID ,0x0121 -0x0100 +1 ),CHARACTERISTIC_STR_AT (0x0111 ,GATT_CHARAC_DEVICE_NAME ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,"BlueZ" ), +BT_GATT_PROP_READ ,"BlueZ" ),CHARACTERISTIC_AT (0x0121 ,GATT_CHARAC_APPEARANCE ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,0x00 ,0x00 ), +BT_GATT_PROP_READ ,0x00 ,0x00 ),PRIMARY_SERVICE (0x0200 ,GATT_UUID ,0x0200 -0x0200 +1 ),PRIMARY_SERVICE (0x0300 ,HEART_RATE_UUID ,0x0320 -0x0300 +1 ),CHARACTERISTIC_STR_AT (0x0311 ,GATT_CHARAC_MANUFACTURER_NAME_STRING ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE ,"" ), +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"" ),DESCRIPTOR_AT (0x0320 ,GATT_CLIENT_CHARAC_CFG_UUID ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , 0x00, 0x00),@@ -1548,9 +1548,9 @@ static struct gatt_db *make_test_spec_small_db(void)CHARACTERISTIC_STR (GATT_CHARAC_MANUFACTURER_NAME_STRING ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_NOTIFY | -BT_GATT_CHRC_PROP_INDICATE , +BT_GATT_PROP_READ | +BT_GATT_PROP_NOTIFY | +BT_GATT_PROP_INDICATE ,"BlueZ" ),DESCRIPTOR (GATT_CLIENT_CHARAC_CFG_UUID ,BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, 0x00, 0x00),@@ -1559,13 +1559,13 @@ static struct gatt_db *make_test_spec_small_db(void)PRIMARY_SERVICE (0xF010 ,GAP_UUID ,8 ),INCLUDE (0x0001 ),CHARACTERISTIC_STR (GATT_CHARAC_DEVICE_NAME ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ ,"BlueZ Unit Tester" ), CHARACTERISTIC(0000B009-0000-0000-0123-456789abcdef,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ ,0x09 ), +BT_GATT_PROP_READ ,0x09 ),CHARACTERISTIC (GATT_CHARAC_APPEARANCE ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,0x00 ,0x00 ), +BT_GATT_PROP_READ ,0x00 ,0x00 ), PRIMARY_SERVICE(0xFFFF, DEVICE_INFORMATION_UUID, 1), { } };@@ -1605,8 +1605,8 @@ static struct gatt_db *make_test_spec_large_db_1(void)const struct att_handle_spec specs[] = {PRIMARY_SERVICE (0x0080 ,"a00b" ,6 ),CHARACTERISTIC (0xb008 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,0x08 ),DESCRIPTOR (0xb015 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,0x01 ),DESCRIPTOR (0xb016 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,0x02 ),@@ -1615,14 +1615,14 @@ static struct gatt_db *make_test_spec_large_db_1(void)SECONDARY_SERVICE (0x0001 ,"a00d" ,6 ),INCLUDE (0x0080 ), -CHARACTERISTIC (0xb00c ,BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ , +CHARACTERISTIC (0xb00c ,BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x0C ), CHARACTERISTIC(0000b00b-0000-0000-0123-456789abcdef, -BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ ,0x0B ), +BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x0B ),PRIMARY_SERVICE (0x0010 ,GATT_UUID ,4 ),CHARACTERISTIC (GATT_CHARAC_SERVICE_CHANGED ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_INDICATE , +BT_GATT_PROP_INDICATE ,0x01 ,0x00 ,0xFF ,0xFF ), DESCRIPTOR(GATT_CLIENT_CHARAC_CFG_UUID, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,@@ -1630,46 +1630,46 @@ static struct gatt_db *make_test_spec_large_db_1(void)PRIMARY_SERVICE (0x0020 ,"a00a" ,10 ),INCLUDE (0x0001 ), -CHARACTERISTIC (0xb001 ,BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ , +CHARACTERISTIC (0xb001 ,BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x01 ),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,STRING_512BYTES ),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_WRITE ,"1111122222333334444455555" "6666677777888889999900000" ),CHARACTERISTIC (0xb003 ,BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_WRITE ,0x03 ), +BT_GATT_PROP_WRITE ,0x03 ),PRIMARY_SERVICE (0x0030 ,"a00b" ,3 ),CHARACTERISTIC (0xb007 ,BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_WRITE ,0x07 ), +BT_GATT_PROP_WRITE ,0x07 ),PRIMARY_SERVICE (0x0040 ,GAP_UUID ,7 ),CHARACTERISTIC_STR (GATT_CHARAC_DEVICE_NAME ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ , +BT_GATT_PROP_READ ,"Test Database" ),CHARACTERISTIC (GATT_CHARAC_APPEARANCE ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,17 ), +BT_GATT_PROP_READ ,17 ),CHARACTERISTIC (GATT_CHARAC_PERIPHERAL_PREF_CONN , -BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ , +BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x64 ,0x00 ,0xC8 ,0x00 ,0x00 ,0x00 ,0x07 ,0xD0 ),PRIMARY_SERVICE (0x0050 ,"a00b" ,3 ),CHARACTERISTIC (0xb006 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE | -BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP | -BT_GATT_CHRC_PROP_NOTIFY | -BT_GATT_CHRC_PROP_INDICATE ,0x06 ), +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE | +BT_GATT_PROP_WRITE_WITHOUT_RESP | +BT_GATT_PROP_NOTIFY | +BT_GATT_PROP_INDICATE ,0x06 ),PRIMARY_SERVICE (0x0060 ,"a00b" ,12 ),CHARACTERISTIC (0xb004 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ |BT_GATT_CHRC_PROP_WRITE ,0x04 ), +BT_GATT_PROP_READ |BT_GATT_PROP_WRITE ,0x04 ),CHARACTERISTIC (0xb004 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ |BT_GATT_CHRC_PROP_WRITE ,0x04 ), +BT_GATT_PROP_READ |BT_GATT_PROP_WRITE ,0x04 ),DESCRIPTOR (GATT_SERVER_CHARAC_CFG_UUID ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , 0x00, 0x00),@@ -1680,7 +1680,7 @@ static struct gatt_db *make_test_spec_large_db_1(void) 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33), -CHARACTERISTIC (0xb004 ,BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ , +CHARACTERISTIC (0xb004 ,BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x04 ), DESCRIPTOR(0xb012, BT_ATT_PERM_READ, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22,@@ -1691,9 +1691,9 @@ static struct gatt_db *make_test_spec_large_db_1(void)PRIMARY_SERVICE (0x0070 ,"a00b" ,7 ),CHARACTERISTIC (0xb005 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE | -BT_GATT_CHRC_PROP_EXT_PROP , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE | +BT_GATT_PROP_EXT_PROP ,0x05 ),DESCRIPTOR (GATT_CHARAC_EXT_PROPER_UUID ,BT_ATT_PERM_READ ,0x03 , 0x00),@@ -1712,9 +1712,9 @@ static struct gatt_db *make_test_spec_large_db_1(void)INCLUDE (0x0001 ), CHARACTERISTIC(0000b009-0000-0000-0123-456789abcdef,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE | -BT_GATT_CHRC_PROP_EXT_PROP ,0x09 ), +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE | +BT_GATT_PROP_EXT_PROP ,0x09 ),DESCRIPTOR (GATT_CHARAC_EXT_PROPER_UUID ,BT_ATT_PERM_READ ,0x01 ,0x00 ), DESCRIPTOR(0000d9d2-0000-0000-0123-456789abcdef,@@ -1724,65 +1724,65 @@ static struct gatt_db *make_test_spec_large_db_1(void)PRIMARY_SERVICE (0x00a0 ,"a00f" ,18 ),CHARACTERISTIC_STR (0xb00e ,BT_ATT_PERM_READ , -BT_GATT_CHRC_PROP_READ ,"Length is " ), +BT_GATT_PROP_READ ,"Length is " ),DESCRIPTOR (GATT_CHARAC_FMT_UUID ,BT_ATT_PERM_READ ,0x19 ,0x00 ,0x00 ,0x30 ,0x01 ,0x00 ,0x00 ),CHARACTERISTIC (0xb00f ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE ,0x65 ), +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,0x65 ),DESCRIPTOR (GATT_CHARAC_FMT_UUID ,BT_ATT_PERM_READ ,0x04 ,0x00 ,0x01 ,0x27 ,0x01 ,0x01 ,0x00 ),CHARACTERISTIC (0xb006 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,0x34 ,0x12 ),DESCRIPTOR (GATT_CHARAC_FMT_UUID ,BT_ATT_PERM_READ ,0x06 ,0x00 ,0x10 ,0x27 ,0x01 ,0x02 ,0x00 ),CHARACTERISTIC (0xb007 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,0x04 ,0x03 ,0x02 ,0x01 ),DESCRIPTOR (GATT_CHARAC_FMT_UUID ,BT_ATT_PERM_READ ,0x08 ,0x00 ,0x17 ,0x27 ,0x01 ,0x03 ,0x00 ), -CHARACTERISTIC (0xb010 ,BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ , +CHARACTERISTIC (0xb010 ,BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x65 ,0x34 ,0x12 ,0x04 ,0x03 ,0x02 ,0x01 ),DESCRIPTOR (GATT_CHARAC_AGREG_FMT_UUID ,BT_ATT_PERM_READ ,0xA6 ,0x00 ,0xa9 ,0x00 ,0xac ,0x00 ),CHARACTERISTIC (0xb011 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_AUTH ,0x012 ), +BT_GATT_PROP_READ | +BT_GATT_PROP_AUTH ,0x012 ),PRIMARY_SERVICE (0x00C0 ,"0000a00c-0000-0000-0123-456789abcdef" ,30 ), -CHARACTERISTIC (0xb00a ,BT_ATT_PERM_READ ,BT_GATT_CHRC_PROP_READ , +CHARACTERISTIC (0xb00a ,BT_ATT_PERM_READ ,BT_GATT_PROP_READ ,0x0A ),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"111112222233333444445" ),DESCRIPTOR (0xb012 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 ,0x88 ,0x99 ,0x00 ,0x12 ,0x34 ,0x56 ,0x78 ,0x90 ,0x11 ),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"2222233333444445555566" ),DESCRIPTOR (0xb013 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 ,0x88 ,0x99 ,0x00 ,0x12 ,0x34 ,0x56 ,0x78 ,0x90 ,0x11 ,0x22 ),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"33333444445555566666777" ),DESCRIPTOR (0xb014 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 ,0x88 ,0x99 ,0x00 ,0x12 ,0x34 ,0x56 ,0x78 ,0x90 ,0x11 ,0x22 ,0x33 ), CHARACTERISTIC(0xb002, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, - BT_GATT_CHRC_PROP_READ | - BT_GATT_CHRC_PROP_WRITE, + BT_GATT_PROP_READ | + BT_GATT_PROP_WRITE, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,@@ -1800,8 +1800,8 @@ static struct gatt_db *make_test_spec_large_db_1(void) 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33), CHARACTERISTIC(0xb002, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, - BT_GATT_CHRC_PROP_READ | - BT_GATT_CHRC_PROP_WRITE, + BT_GATT_PROP_READ | + BT_GATT_PROP_WRITE, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,@@ -1819,8 +1819,8 @@ static struct gatt_db *make_test_spec_large_db_1(void) 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44), CHARACTERISTIC(0xb002, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, - BT_GATT_CHRC_PROP_READ | - BT_GATT_CHRC_PROP_WRITE, + BT_GATT_PROP_READ | + BT_GATT_PROP_WRITE, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,@@ -1838,8 +1838,8 @@ static struct gatt_db *make_test_spec_large_db_1(void) 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"1111122222333334444455555" "666667777788888999" ), DESCRIPTOR(0xb012, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,@@ -1850,8 +1850,8 @@ static struct gatt_db *make_test_spec_large_db_1(void) 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"2222233333444445555566666" "7777788888999990000" ), DESCRIPTOR(0xb013, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,@@ -1862,8 +1862,8 @@ static struct gatt_db *make_test_spec_large_db_1(void) 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44),CHARACTERISTIC_STR (0xb002 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_PROP_READ | +BT_GATT_PROP_WRITE ,"3333344444555556666677777" "88888999990000011111" ), DESCRIPTOR(0xb014, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, --2.1.0
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Arman
Luiz Augusto von Dentz
maintainerPATCH 7/8 core/gatt: Add Flags property to GattDescriptor
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds the implementation of Flags property to GattDescriptor interface and properly convert it to permissions when adding the descriptor to the database.
--- src/gatt-database.c | 107 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 21 deletions(-)
src/gatt-database.c +86 -21
@@ -119,6 +119,8 @@ struct external_desc {struct external_service *service;char *chrc_path;GDBusProxy *proxy; +uint8_t props; +uint8_t ext_props;struct gatt_db_attribute *attrib;bool handled;struct queue *pending_reads;
@@ -1202,26 +1204,16 @@ static bool check_service_path(GDBusProxy *proxy,return g_strcmp0 (service_path, service->path) ==0 ; } -static bool parse_flags (GDBusProxy *proxy,uint8_t *props,uint8_t *ext_props) +static bool parse_chrc_flags (DBusMessageIter *array,uint8_t *props, +uint8_t *ext_props) { -DBusMessageIter iter, array;const char *flag; - *props = *ext_props =0 ; - -if (!g_dbus_proxy_get_property (proxy,"Flags" , &iter)) -return false; - -if (dbus_message_iter_get_arg_type (&iter) !=DBUS_TYPE_ARRAY ) -return false; - -dbus_message_iter_recurse (&iter, &array); - do { - if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRING) + if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_STRING) return false; - dbus_message_iter_get_basic(&array, &flag); + dbus_message_iter_get_basic(array, &flag); if (!strcmp("broadcast", flag)) *props |= BT_GATT_PROP_BROADCAST;
@@ -1257,7 +1249,50 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props)error ("Invalid characteristic flag: %s" , flag);return false; } - }while (dbus_message_iter_next (&array)); + }while (dbus_message_iter_next (array)); + +if (*ext_props) + *props |=BT_GATT_PROP_EXT_PROP ; + +return true; +} + +static bool parse_desc_flags (DBusMessageIter *array,uint8_t *props, +uint8_t *ext_props) +{ +const char *flag; + +do { +if (dbus_message_iter_get_arg_type (array) !=DBUS_TYPE_STRING ) +return false; + +dbus_message_iter_get_basic (array, &flag); + +if (!strcmp ("read" , flag)) + *props |=BT_GATT_PROP_READ ; +else if (!strcmp ("write-without-response" , flag)) + *props |=BT_GATT_PROP_WRITE_WITHOUT_RESP ; +else if (!strcmp ("write" , flag)) + *props |=BT_GATT_PROP_WRITE ; +else if (!strcmp ("authenticated-signed-writes" , flag)) + *props |=BT_GATT_PROP_AUTH ; +else if (!strcmp ("encrypt-read" , flag)) { + *props |=BT_GATT_PROP_READ ; + *ext_props |=BT_GATT_EXT_PROP_ENC_READ ; + }else if (!strcmp ("encrypt-write" , flag)) { + *props |=BT_GATT_PROP_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_ENC_WRITE ; + }else if (!strcmp ("encrypt-authenticated-read" , flag)) { + *props |=BT_GATT_PROP_READ ; + *ext_props |=BT_GATT_EXT_PROP_AUTH_READ ; + }else if (!strcmp ("encrypt-authenticated-write" , flag)) { + *props |=BT_GATT_PROP_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_AUTH_WRITE ; + }else { +error ("Invalid descriptor flag: %s" , flag); +return false; + } + }while (dbus_message_iter_next (array));if (*ext_props) *props |=BT_GATT_PROP_EXT_PROP ;
@@ -1265,6 +1300,28 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props)return true; } +static bool parse_flags (GDBusProxy *proxy,uint8_t *props,uint8_t *ext_props) +{ +DBusMessageIter iter, array; +const char *iface; + + *props = *ext_props =0 ; + +if (!g_dbus_proxy_get_property (proxy,"Flags" , &iter)) +return false; + +if (dbus_message_iter_get_arg_type (&iter) !=DBUS_TYPE_ARRAY ) +return false; + +dbus_message_iter_recurse (&iter, &array); + + iface =g_dbus_proxy_get_interface (proxy); +if (!strcmp (iface,GATT_CHRC_IFACE )) +return parse_chrc_flags (&array, props, ext_props); + +return parse_desc_flags (&array, props, ext_props); +} +static void proxy_added_cb (GDBusProxy *proxy,void *user_data) {struct external_service *service = user_data;
@@ -1376,6 +1433,16 @@ static void proxy_added_cb(GDBusProxy *proxy, void *user_data)return ; } +/* +* Parse descriptors flags here since they are used to +* determine the permission the descriptor should have +*/ +if (!parse_flags (proxy, &desc->props, &desc->ext_props)) { +error ("Failed to parse characteristic properties" ); + service->failed = true; +return ; + } +queue_push_tail (service->descs, desc); }else {DBG ("Ignoring unrelated interface: %s" , iface);
@@ -1896,19 +1963,17 @@ static bool database_add_desc(struct external_service *service, struct external_desc *desc) {bt_uuid_t uuid; +uint32_t perm;if (!parse_uuid (desc->proxy, &uuid)) {error ("Failed to read \"UUID\" property of descriptor" );return false; } -/* -* TODO: Set permissions based on a D-Bus property of the external -* descriptor. -*/ + perm =permissions_from_props (desc->props, desc->ext_props); desc->attrib =gatt_db_service_add_descriptor (service->attrib, &uuid, -BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , - desc_read_cb, desc_write_cb, desc); + perm, desc_read_cb, + desc_write_cb, desc);if (!desc->attrib) {error ("Failed to create descriptor entry in database" );return false;
Signature · 1 line
2.1.0
Re: [PATCH BlueZ 7/8] core/gatt: Add Flags property to GattDescriptor
Hi Luiz,
Quoted 15 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This adds the implementation of Flags property to GattDescriptor interface and properly convert it to permissions when adding the descriptor to the database.
--- src/gatt-database.c | 107 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 21 deletions(-)src/gatt-database.c +0
-0
src/gatt-database.c struct external_desc { · line 123
Quoted 5 lines
src/gatt-database.c +2
-0@@ -119,6 +119,8 @@ struct external_desc {struct external_service *service;char *chrc_path;GDBusProxy *proxy; +uint8_t props; +uint8_t ext_props;
Again, it doesn't make much sense to store "props" and "ext_props" for descriptors as these are characteristic concepts. Just store the permissions in a "perms" variable or something similar.
Quoted 159 lines
src/gatt-database.c +84
-22struct gatt_db_attribute *attrib;bool handled;struct queue *pending_reads;@@ -1202,26 +1204,16 @@ static bool check_service_path(GDBusProxy *proxy,return g_strcmp0 (service_path, service->path) ==0 ; } -static bool parse_flags (GDBusProxy *proxy,uint8_t *props,uint8_t *ext_props) +static bool parse_chrc_flags (DBusMessageIter *array,uint8_t *props, +uint8_t *ext_props) { -DBusMessageIter iter, array;const char *flag; - *props = *ext_props =0 ; - -if (!g_dbus_proxy_get_property (proxy,"Flags" , &iter)) -return false; - -if (dbus_message_iter_get_arg_type (&iter) !=DBUS_TYPE_ARRAY ) -return false; - -dbus_message_iter_recurse (&iter, &array); - do { - if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_STRING) + if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_STRING) return false; - dbus_message_iter_get_basic(&array, &flag); + dbus_message_iter_get_basic(array, &flag); if (!strcmp("broadcast", flag)) *props |= BT_GATT_PROP_BROADCAST;@@ -1257,7 +1249,50 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props)error ("Invalid characteristic flag: %s" , flag);return false; } - }while (dbus_message_iter_next (&array)); + }while (dbus_message_iter_next (array)); + +if (*ext_props) + *props |=BT_GATT_PROP_EXT_PROP ; + +return true; +} + +static bool parse_desc_flags (DBusMessageIter *array,uint8_t *props, +uint8_t *ext_props) +{ +const char *flag; + +do { +if (dbus_message_iter_get_arg_type (array) !=DBUS_TYPE_STRING ) +return false; + +dbus_message_iter_get_basic (array, &flag); + +if (!strcmp ("read" , flag)) + *props |=BT_GATT_PROP_READ ; +else if (!strcmp ("write-without-response" , flag)) + *props |=BT_GATT_PROP_WRITE_WITHOUT_RESP ; +else if (!strcmp ("write" , flag)) + *props |=BT_GATT_PROP_WRITE ; +else if (!strcmp ("authenticated-signed-writes" , flag)) + *props |=BT_GATT_PROP_AUTH ; +else if (!strcmp ("encrypt-read" , flag)) { + *props |=BT_GATT_PROP_READ ; + *ext_props |=BT_GATT_EXT_PROP_ENC_READ ; + }else if (!strcmp ("encrypt-write" , flag)) { + *props |=BT_GATT_PROP_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_ENC_WRITE ; + }else if (!strcmp ("encrypt-authenticated-read" , flag)) { + *props |=BT_GATT_PROP_READ ; + *ext_props |=BT_GATT_EXT_PROP_AUTH_READ ; + }else if (!strcmp ("encrypt-authenticated-write" , flag)) { + *props |=BT_GATT_PROP_WRITE ; + *ext_props |=BT_GATT_EXT_PROP_AUTH_WRITE ; + }else { +error ("Invalid descriptor flag: %s" , flag); +return false; + } + }while (dbus_message_iter_next (array));if (*ext_props) *props |=BT_GATT_PROP_EXT_PROP ;@@ -1265,6 +1300,28 @@ static bool parse_flags(GDBusProxy *proxy, uint8_t *props, uint8_t *ext_props)return true; } +static bool parse_flags (GDBusProxy *proxy,uint8_t *props,uint8_t *ext_props) +{ +DBusMessageIter iter, array; +const char *iface; + + *props = *ext_props =0 ; + +if (!g_dbus_proxy_get_property (proxy,"Flags" , &iter)) +return false; + +if (dbus_message_iter_get_arg_type (&iter) !=DBUS_TYPE_ARRAY ) +return false; + +dbus_message_iter_recurse (&iter, &array); + + iface =g_dbus_proxy_get_interface (proxy); +if (!strcmp (iface,GATT_CHRC_IFACE )) +return parse_chrc_flags (&array, props, ext_props); + +return parse_desc_flags (&array, props, ext_props); +} +static void proxy_added_cb (GDBusProxy *proxy,void *user_data) {struct external_service *service = user_data;@@ -1376,6 +1433,16 @@ static void proxy_added_cb(GDBusProxy *proxy, void *user_data)return ; } +/* +* Parse descriptors flags here since they are used to +* determine the permission the descriptor should have +*/ +if (!parse_flags (proxy, &desc->props, &desc->ext_props)) { +error ("Failed to parse characteristic properties" ); + service->failed = true; +return ; + } +queue_push_tail (service->descs, desc); }else {DBG ("Ignoring unrelated interface: %s" , iface);@@ -1896,19 +1963,17 @@ static bool database_add_desc(struct external_service *service, struct external_desc *desc) {bt_uuid_t uuid; +uint32_t perm;if (!parse_uuid (desc->proxy, &uuid)) {error ("Failed to read \"UUID\" property of descriptor" );return false; } -/* -* TODO: Set permissions based on a D-Bus property of the external -* descriptor. -*/ + perm =permissions_from_props (desc->props, desc->ext_props); desc->attrib =gatt_db_service_add_descriptor (service->attrib, &uuid, -BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , - desc_read_cb, desc_write_cb, desc); + perm, desc_read_cb, + desc_write_cb, desc);if (!desc->attrib) {error ("Failed to create descriptor entry in database" );return false; --2.1.0
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Arman
Luiz Augusto von Dentz
maintainerPATCH 8/8 test/example-gatt-server: Add encrypt attributes
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds new attributes that requires encryption for TestService.
--- test/example-gatt-server | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-)
test/example-gatt-server +50 -2
@@ -172,10 +172,11 @@ class Characteristic(dbus.service.Object): class Descriptor(dbus.service.Object): - def __init__(self, bus, index, uuid, characteristic): + def __init__(self, bus, index, uuid, flags, characteristic): self.path = characteristic.path + '/desc' + str(index) self.bus = bus self.uuid = uuid + self.flags = flags self.chrc = characteristic dbus.service.Object.__init__(self, bus, self.path)
@@ -184,6 +185,7 @@ class Descriptor(dbus.service.Object): GATT_DESC_IFACE: { 'Characteristic': self.chrc.get_path(), 'UUID': self.uuid, + 'Flags': self.flags, } }
@@ -401,7 +403,7 @@ class TestService(Service): def __init__(self, bus, index): Service.__init__(self, bus, index, self.TEST_SVC_UUID, False) self.add_characteristic(TestCharacteristic(bus, 0, self)) - + self.add_characteristic(TestEncryptCharacteristic(bus, 1, self)) class TestCharacteristic(Characteristic): """
@@ -442,6 +444,7 @@ class TestDescriptor(Descriptor): Descriptor.__init__( self, bus, index, self.TEST_DESC_UUID, + ['read', 'write'], characteristic) def ReadValue(self):
@@ -464,6 +467,7 @@ class CharacteristicUserDescriptionDescriptor(Descriptor): Descriptor.__init__( self, bus, index, self.CUD_UUID, + ['read', 'write'], characteristic) def ReadValue(self):
@@ -474,6 +478,50 @@ class CharacteristicUserDescriptionDescriptor(Descriptor): raise NotPermittedException() self.value = value +class TestEncryptCharacteristic(Characteristic): + """ + Dummy test characteristic requiring encryption. + + """ + TEST_CHRC_UUID = '12345678-1234-5678-1234-56789abcdef3' + + def __init__(self, bus, index, service): + Characteristic.__init__( + self, bus, index, + self.TEST_CHRC_UUID, + ['encrypt-read', 'encrypt-write'], + service) + self.value = [] + self.add_descriptor(TestEncryptDescriptor(bus, 2, self)) + self.add_descriptor( + CharacteristicUserDescriptionDescriptor(bus, 3, self)) + + def ReadValue(self): + print('TestCharacteristic Read: ' + repr(self.value)) + return self.value + + def WriteValue(self, value): + print('TestCharacteristic Write: ' + repr(value)) + self.value = value + +class TestEncryptDescriptor(Descriptor): + """ + Dummy test descriptor requiring encryption. Returns a static value. + + """ + TEST_DESC_UUID = '12345678-1234-5678-1234-56789abcdef4' + + def __init__(self, bus, index, characteristic): + Descriptor.__init__( + self, bus, index, + self.TEST_DESC_UUID, + ['encrypt-read', 'encrypt-write'], + characteristic) + + def ReadValue(self): + return [ + dbus.Byte('T'), dbus.Byte('e'), dbus.Byte('s'), dbus.Byte('t') + ] def register_service_cb(): print('GATT service registered')
Signature · 1 line
2.1.0
Luiz Augusto von Dentz
maintainerHi,
Quoted 76 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This set introduce encryption flags to GattCharacteristic and GattDescriptor along with the necessary changes to
bt_gatt_serverto honor them.In addition to that example-gatt-server has been updated to include attributes that makes use of the new flags.
The following is the output using bluetoothctl to navigate in the new attributes introduced to example-gatt-server:
[Vudentz's T440s:/service0016/char001c]# attribute-info Characteristic - Vendor specific
UUID: 12345678-1234-5678-1234-56789abcdef1 Service: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016 Notifying: no Flags: read Flags: write Flags: extended-properties Flags: writable-auxiliaries Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char001c/desc001e Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char001c/desc001f Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char001c/desc0020 [Vudentz's T440s:/service0016/char001c]# select-attribute /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017 [Vudentz's T440s:/service0016/char0017]# attribute-info Characteristic - Vendor specific UUID: 12345678-1234-5678-1234-56789abcdef3 Service: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016 Notifying: no Flags: read Flags: write Flags: extended-properties Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc0019 Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a Descriptors: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001b[Vudentz's T440s:/service0016/char0017]# read
Attempting to read /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017
Failed to read: org.bluez.Error.NotPermitted
[Vudentz's T440s:/service0016/char0017]# write 00
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017
Failed to write: org.bluez.Error.NotPermitted
[Vudentz's T440s:/service0016/char0017]# select-attribute /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a [Vudentz's T440s:/service0016/char0017/desc001a]# attribute-info
Descriptor - Vendor specificUUID: 12345678-1234-5678-1234-56789abcdef4 Characteristic: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017[Vudentz's T440s:/service0016/char0017/desc001a]# read
Attempting to read /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a Failed to read: org.bluez.Error.NotPermitted
[Vudentz's T440s:/service0016/char0017/desc001a]# write 00
Attempting to write /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service0016/char0017/desc001a Failed to write: org.bluez.Error.NotPermittedLuiz Augusto von Dentz (8):
doc/gatt-api: Add encryption flags core/gatt: Add support for encryption flags shared/att: Add own security definitions shared/gatt-server: Check attribute permissions doc/gatt-api: Add Flags property to GattDescriptor shared/gatt: Drop CHRC term of properties define core/gatt: Add Flags property to GattDescriptor test/example-gatt-server: Add encrypt attributesdoc/gatt-api.txt | 18 +++++ src/gatt-client.c | 32 ++++---- src/gatt-database.c | 185 +++++++++++++++++++++++++++++++++++------------ src/shared/att-types.h | 51 +++++++++---- src/shared/att.c | 2 +- src/shared/gatt-client.c | 4 +- src/shared/gatt-server.c | 93 +++++++++++++----------- test/example-gatt-server | 52 ++++++++++++- tools/btgatt-server.c | 14 ++-- unit/test-gatt.c | 148 ++++++++++++++++++------------------- 10 files changed, 392 insertions(+), 207 deletions(-)
Quoted 2 lines
--
2.1.0
Ive applied this set after reworking the descriptor flag handling, the final version pushed contains only permission and don't reuse the defines of characteristic properties.
Signature · 1 line
Luiz Augusto von Dentz