shared/gatt-db: Expose gatt_db_attribute
Luiz Augusto von Dentz
maintainerPATCH v4 1/9 shared/gatt-db: Expose gatt_db_attribute
From: Luiz Augusto von Dentz <[email protected]>
This is the new API to reduce the lookups in gatt_db and make it a little bit more convenient for batch operations, so the general idea is to be able to get a hold of it via gatt_db_get_attribute but also replace the handles in the queues with proper attributes so the server code don't have to lookup again when reading/writing, checking permissions, or any other operation that can be done directly.
---
v2: Address problems gatt_db_attribute_read and gatt_db_attribute_write pointed out by Arman.
v3: Allow gatt_db_attribute_read to work if offset equals to value length.
v4: Fix using attribute handle for service related operations.
src/shared/gatt-db.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)
src/shared/gatt-db.c +51 -0
@@ -802,3 +802,54 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,return true; } + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +return NULL ; +} + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) +{ +return NULL ; +} + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) +{ +return 0 ; +} + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid) +{ +return false; +} + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle) +{ +return false; +} + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions) +{ +return false; +} + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data) +{ +return false; +} + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data) +{ +return false; +}
src/shared/gatt-db.h +36 -0
@@ -96,3 +96,39 @@ bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,bool gatt_db_get_attribute_permissions (struct gatt_db *db,uint16_t handle,uint32_t *permissions); + +struct gatt_db_attribute ; + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle); + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib); + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib); + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid); + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle); + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions); + +typedef void (*gatt_db_attribute_read_t ) (struct gatt_db_attribute *attrib, +int err,uint8_t *value,size_t length, +void *user_data); + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data); + +typedef void (*gatt_db_attribute_write_t ) (struct gatt_db_attribute *attrib, +int err,void *user_data); + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data);
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 2/9 shared/gatt-db: Add gatt_db_get_attribute
From: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +19 -1
@@ -806,7 +806,25 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db,uint16_t handle) { -return NULL ; +struct gatt_db_service *service; +uint16_t service_handle; + +if (!db || !handle) +return NULL ; + + service =queue_find (db->services, find_service_for_handle, +UINT_TO_PTR (handle)); +if (!service) +return NULL ; + + service_handle = service->attributes[0 ]->handle; + +/* +* We can safely get attribute from attributes array with offset, +* because find_service_for_handle() check if given handle is +* in service range. +*/ +return service->attributes[handle - service_handle]; }const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib)
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 3/9 shared/gatt-db: Add gatt_db_attribute_get_type
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +4 -1
@@ -829,7 +829,10 @@ struct gatt_db_attribute *gatt_db_get_attribute(struct gatt_db *db,const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) { -return NULL ; +if (!attrib) +return NULL ; + +return &attrib->uuid; }uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib)
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 4/9 shared/gatt-db: Add gatt_db_attribute_get_handle
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +4 -1
@@ -837,7 +837,10 @@ const bt_uuid_t *gatt_db_attribute_get_type(struct gatt_db_attribute *attrib)uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) { -return 0 ; +if (!attrib) +return 0 ; + +return attrib->handle; } bool gatt_db_attribute_get_service_uuid(struct gatt_db_attribute *attrib,
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 5/9 shared/gatt-db: Add gatt_db_attribute_get_service_uuid
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-)
src/shared/gatt-db.c +37 -8
@@ -46,6 +46,7 @@ struct gatt_db { };struct gatt_db_attribute { +struct gatt_db_service *service;uint16_t handle;bt_uuid_t uuid;uint32_t permissions;
@@ -70,7 +71,8 @@ static bool match_service_by_handle(const void *data, const void *user_data)return service->attributes[0 ]->handle ==PTR_TO_UINT (user_data); } -static struct gatt_db_attribute *new_attribute (const bt_uuid_t *type, +static struct gatt_db_attribute *new_attribute (struct gatt_db_service *service, +const bt_uuid_t *type,const uint8_t *val,uint16_t len) {
@@ -80,6 +82,7 @@ static struct gatt_db_attribute *new_attribute(const bt_uuid_t *type,if (!attribute)return NULL ; + attribute->service = service; attribute->uuid = *type; attribute->value_len = len;if (len) {
@@ -187,7 +190,7 @@ uint16_t gatt_db_add_service(struct gatt_db *db, const bt_uuid_t *uuid, len =uuid_to_le (uuid, value); - service->attributes[0 ] =new_attribute (type, value, len); + service->attributes[0 ] =new_attribute (service, type, value, len);if (!service->attributes[0 ]) {gatt_db_service_destroy (service);return 0 ;
@@ -297,14 +300,14 @@ uint16_t gatt_db_add_characteristic(struct gatt_db *db, uint16_t handle, len +=sizeof (uint16_t ); len +=uuid_to_le (uuid, &value[3 ]); - service->attributes[i] =new_attribute (&characteristic_uuid, value, - len); + service->attributes[i] =new_attribute (service, &characteristic_uuid, + value, len);if (!service->attributes[i])return 0 ;update_attribute_handle (service, i++); - service->attributes[i] =new_attribute (uuid,NULL ,0 ); + service->attributes[i] =new_attribute (service, uuid,NULL ,0 );if (!service->attributes[i]) {free (service->attributes[i -1 ]);return 0 ;
@@ -335,7 +338,7 @@ uint16_t gatt_db_add_char_descriptor(struct gatt_db *db, uint16_t handle,if (!i)return 0 ; - service->attributes[i] =new_attribute (uuid,NULL ,0 ); + service->attributes[i] =new_attribute (service, uuid,NULL ,0 );if (!service->attributes[i])return 0 ;
@@ -385,8 +388,9 @@ uint16_t gatt_db_add_included_service(struct gatt_db *db, uint16_t handle,if (!index)return 0 ; - service->attributes[index] =new_attribute (&included_service_uuid, - value, len); + service->attributes[index] =new_attribute (service, + &included_service_uuid, + value, len);if (!service->attributes[index])return 0 ;
@@ -846,6 +850,31 @@ uint16_t gatt_db_attribute_get_handle(struct gatt_db_attribute *attrib)bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib,bt_uuid_t *uuid) { +struct gatt_db_service *service; + +if (!attrib || !uuid) +return false; + + service = attrib->service; + +if (service->attributes[0 ]->value_len ==sizeof (uint16_t )) { +uint16_t value; + + value =get_le16 (service->attributes[0 ]->value); +bt_uuid16_create (uuid, value); + +return true; + } + +if (service->attributes[0 ]->value_len ==sizeof (uint128_t)) { +uint128_t value; + +bswap_128 (service->attributes[0 ]->value, &value); +bt_uuid128_create (uuid, value); + +return true; + } +return false; }
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 6/9 shared/gatt-db: Add gatt_db_attribute_get_service_handles
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +15 -1
@@ -882,7 +882,21 @@ bool gatt_db_attribute_get_service_handles(struct gatt_db_attribute *attrib,uint16_t *start_handle, uint16_t *end_handle) { -return false; + struct gatt_db_service *service; + +if (!attrib) +return false; + + service = attrib->service; + +if (start_handle) + *start_handle = service->attributes[0 ]->handle; + +if (end_handle) + *end_handle = service->attributes[0 ]->handle + + service->num_handles -1 ; + +return true; } bool gatt_db_attribute_get_permissions(struct gatt_db_attribute *attrib,
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 7/9 shared/gatt-db: Add gatt_db_attribute_get_permissions
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +6 -1
@@ -902,7 +902,12 @@ bool gatt_db_attribute_get_service_handles(struct gatt_db_attribute *attrib,bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib,uint32_t *permissions) { -return false; +if (!attrib || !permissions) +return false; + + *permissions = attrib->permissions; + +return true; } bool gatt_db_attribute_read(struct gatt_db_attribute *attrib, uint16_t offset,
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 8/9 shared/gatt-db: Add gatt_db_attribute_read
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +22 -1
@@ -914,7 +914,28 @@ bool gatt_db_attribute_read(struct gatt_db_attribute *attrib, uint16_t offset, uint8_t opcode, bdaddr_t *bdaddr, gatt_db_attribute_read_t func, void *user_data) { - return false; + uint8_t *value; + +if (!attrib || !func) +return false; + +if (attrib->read_func) { +/* TODO: Pass callback function to read_func */ + attrib->read_func (attrib->handle, offset, opcode, bdaddr, + attrib->user_data); +return true; + } + +/* Check boundary if value is stored in the db */ +if (offset > attrib->value_len) +return false; + +/* Guard against invalid access if offset equals to value length */ + value = offset == attrib->value_len ?NULL : &attrib->value[offset]; + +func (attrib,0 , value, attrib->value_len - offset, user_data); + +return true; } bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v4 9/9 shared/gatt-db: Add gatt_db_attribute_write
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- src/shared/gatt-db.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
src/shared/gatt-db.c +26 -1
@@ -944,5 +944,30 @@ bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset, gatt_db_attribute_write_t func, void *user_data) { -return false; +if (!attrib || !func) +return false; + +if (attrib->write_func) { + attrib->write_func (attrib->handle, offset, value, len, opcode, + bdaddr, attrib->user_data); +return true; + } + +/* For values stored in db allocate on demand */ +if (!attrib->value || offset >= attrib->value_len || + len > (unsigned ) (attrib->value_len - offset)) { + attrib->value =realloc (attrib->value, len + offset); +if (!attrib->value) +return false; +/* Init data in the first allocation */ +if (!attrib->value_len) +memset (attrib->value,0 , offset); + attrib->value_len = len + offset; + } + +memcpy (&attrib->value[offset], value, len); + +func (attrib,0 , user_data); + +return true; }
Signature · 1 line
1.9.3
Hi Luiz,
Quoted 125 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This is the new API to reduce the lookups in
gatt_dband make it a little bit more convenient for batch operations, so the general idea is to be able to get a hold of it viagatt_db_get_attributebut also replace the handles in the queues with proper attributes so the server code don't have to lookup again when reading/writing, checking permissions, or any other operation that can be done directly.
---
v2: Address problemsgatt_db_attribute_readandgatt_db_attribute_writepointed out by Arman.
v3: Allowgatt_db_attribute_readto work if offset equals to value length.
v4: Fix using attribute handle for service related operations.src/shared/gatt-db.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)src/shared/gatt-db.c +51
-0@@ -802,3 +802,54 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,return true; } + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +return NULL ; +} + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) +{ +return NULL ; +} + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) +{ +return 0 ; +} + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid) +{ +return false; +} + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle) +{ +return false; +} + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions) +{ +return false; +} + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data) +{ +return false; +} + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data) +{ +return false; +}src/shared/gatt-db.h +36
-1@@ -96,3 +96,39 @@ bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,bool gatt_db_get_attribute_permissions (struct gatt_db *db,uint16_t handle,uint32_t *permissions); + +struct gatt_db_attribute ; + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle); + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib); + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib); + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid); + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle); + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions); + +typedef void (*gatt_db_attribute_read_t ) (struct gatt_db_attribute *attrib, +int err,uint8_t *value,size_t length, +void *user_data); + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data); + +typedef void (*gatt_db_attribute_write_t ) (struct gatt_db_attribute *attrib, +int err,void *user_data); + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data); --1.9.3
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
Patch set looks good to me. You can go ahead and apply if Michael, Marcin, and others are also fine with it.
Cheers,
Arman
Hi Luiz,
Quoted 135 lines · Arman Uguray
Hi Luiz,
Quoted 125 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This is the new API to reduce the lookups in
gatt_dband make it a little bit more convenient for batch operations, so the general idea is to be able to get a hold of it viagatt_db_get_attributebut also replace the handles in the queues with proper attributes so the server code don't have to lookup again when reading/writing, checking permissions, or any other operation that can be done directly.
---
v2: Address problemsgatt_db_attribute_readandgatt_db_attribute_writepointed out by Arman.
v3: Allowgatt_db_attribute_readto work if offset equals to value length.
v4: Fix using attribute handle for service related operations.src/shared/gatt-db.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)src/shared/gatt-db.c +51
-0@@ -802,3 +802,54 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,return true; } + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +return NULL ; +} + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) +{ +return NULL ; +} + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) +{ +return 0 ; +} + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid) +{ +return false; +} + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle) +{ +return false; +} + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions) +{ +return false; +} + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data) +{ +return false; +} + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data) +{ +return false; +}src/shared/gatt-db.h +36
-1@@ -96,3 +96,39 @@ bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,bool gatt_db_get_attribute_permissions (struct gatt_db *db,uint16_t handle,uint32_t *permissions); + +struct gatt_db_attribute ; + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle); + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib); + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib); + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid); + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle); + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions); + +typedef void (*gatt_db_attribute_read_t ) (struct gatt_db_attribute *attrib, +int err,uint8_t *value,size_t length, +void *user_data); + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data); + +typedef void (*gatt_db_attribute_write_t ) (struct gatt_db_attribute *attrib, +int err,void *user_data); + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data); --1.9.3
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.htmlPatch set looks good to me. You can go ahead and apply if Michael, Marcin, and others are also fine with it.
Quoted 6 lines
Cheers,
Arman
--
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
These patches look good with the changes, unless Marcin has problems go for it.
Signature · 1 line
Michael Janssen
Luiz Augusto von Dentz
maintainerHi,
Quoted 145 lines · Michael Janssen
Hi Luiz,
Quoted 135 lines · Arman Uguray
Hi Luiz,
Quoted 125 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This is the new API to reduce the lookups in
gatt_dband make it a little bit more convenient for batch operations, so the general idea is to be able to get a hold of it viagatt_db_get_attributebut also replace the handles in the queues with proper attributes so the server code don't have to lookup again when reading/writing, checking permissions, or any other operation that can be done directly.
---
v2: Address problemsgatt_db_attribute_readandgatt_db_attribute_writepointed out by Arman.
v3: Allowgatt_db_attribute_readto work if offset equals to value length.
v4: Fix using attribute handle for service related operations.src/shared/gatt-db.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)src/shared/gatt-db.c +51
-0@@ -802,3 +802,54 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,return true; } + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +return NULL ; +} + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) +{ +return NULL ; +} + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) +{ +return 0 ; +} + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid) +{ +return false; +} + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle) +{ +return false; +} + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions) +{ +return false; +} + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data) +{ +return false; +} + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data) +{ +return false; +}src/shared/gatt-db.h +36
-1@@ -96,3 +96,39 @@ bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,bool gatt_db_get_attribute_permissions (struct gatt_db *db,uint16_t handle,uint32_t *permissions); + +struct gatt_db_attribute ; + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle); + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib); + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib); + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid); + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle); + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions); + +typedef void (*gatt_db_attribute_read_t ) (struct gatt_db_attribute *attrib, +int err,uint8_t *value,size_t length, +void *user_data); + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data); + +typedef void (*gatt_db_attribute_write_t ) (struct gatt_db_attribute *attrib, +int err,void *user_data); + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data); --1.9.3
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.htmlPatch set looks good to me. You can go ahead and apply if Michael, Marcin, and others are also fine with it.
Quoted 6 lines
Cheers,
Arman
--
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
Quoted 4 lines
These patches look good with the changes, unless Marcin has problems go for it.
--
Michael Janssen
Pushed.
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
Quoted 150 lines · Luiz Augusto von Dentz
Hi,
Quoted 147 lines · Michael Janssen
Hi Luiz,
Quoted 135 lines · Arman Uguray
Hi Luiz,
Quoted 125 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This is the new API to reduce the lookups in
gatt_dband make it a little bit more convenient for batch operations, so the general idea is to be able to get a hold of it viagatt_db_get_attributebut also replace the handles in the queues with proper attributes so the server code don't have to lookup again when reading/writing, checking permissions, or any other operation that can be done directly.
---
v2: Address problemsgatt_db_attribute_readandgatt_db_attribute_writepointed out by Arman.
v3: Allowgatt_db_attribute_readto work if offset equals to value length.
v4: Fix using attribute handle for service related operations.src/shared/gatt-db.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)src/shared/gatt-db.c +51
-0@@ -802,3 +802,54 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,return true; } + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +return NULL ; +} + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) +{ +return NULL ; +} + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) +{ +return 0 ; +} + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid) +{ +return false; +} + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle) +{ +return false; +} + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions) +{ +return false; +} + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data) +{ +return false; +} + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data) +{ +return false; +}src/shared/gatt-db.h +36
-1@@ -96,3 +96,39 @@ bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,bool gatt_db_get_attribute_permissions (struct gatt_db *db,uint16_t handle,uint32_t *permissions); + +struct gatt_db_attribute ; + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle); + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib); + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib); + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid); + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle); + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions); + +typedef void (*gatt_db_attribute_read_t ) (struct gatt_db_attribute *attrib, +int err,uint8_t *value,size_t length, +void *user_data); + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data); + +typedef void (*gatt_db_attribute_write_t ) (struct gatt_db_attribute *attrib, +int err,void *user_data); + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data); --1.9.3
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.htmlPatch set looks good to me. You can go ahead and apply if Michael, Marcin, and others are also fine with it.
Quoted 6 lines
Cheers,
Arman
--
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.htmlThese patches look good with the changes, unless Marcin has problems go for it.
Quoted 7 lines
Quoted 2 lines
--
Michael JanssenPushed.
--
Luiz Augusto von Dentz
Now, the next bit that my gatt-server implementation is blocked on is passing the result callback to gatt_db_read_t and gatt_db_write_t. If we just get that part done first then I can rebase and reupload my gatt-server patches.
Cheers,
Arman
Luiz Augusto von Dentz
maintainerHi Arman,
Quoted 159 lines · Arman Uguray
Hi Luiz,
Quoted 155 lines · Luiz Augusto von Dentz
Hi,
Quoted 145 lines · Michael Janssen
Hi Luiz,
Quoted 135 lines · Arman Uguray
Hi Luiz,
Quoted 125 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This is the new API to reduce the lookups in
gatt_dband make it a little bit more convenient for batch operations, so the general idea is to be able to get a hold of it viagatt_db_get_attributebut also replace the handles in the queues with proper attributes so the server code don't have to lookup again when reading/writing, checking permissions, or any other operation that can be done directly.
---
v2: Address problemsgatt_db_attribute_readandgatt_db_attribute_writepointed out by Arman.
v3: Allowgatt_db_attribute_readto work if offset equals to value length.
v4: Fix using attribute handle for service related operations.src/shared/gatt-db.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+)src/shared/gatt-db.c +51
-0@@ -802,3 +802,54 @@ bool gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle,return true; } + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +return NULL ; +} + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib) +{ +return NULL ; +} + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib) +{ +return 0 ; +} + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid) +{ +return false; +} + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle) +{ +return false; +} + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions) +{ +return false; +} + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data) +{ +return false; +} + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data) +{ +return false; +}src/shared/gatt-db.h +36
-1@@ -96,3 +96,39 @@ bool gatt_db_get_service_uuid(struct gatt_db *db, uint16_t handle,bool gatt_db_get_attribute_permissions (struct gatt_db *db,uint16_t handle,uint32_t *permissions); + +struct gatt_db_attribute ; + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle); + +const bt_uuid_t *gatt_db_attribute_get_type (struct gatt_db_attribute *attrib); + +uint16_t gatt_db_attribute_get_handle (struct gatt_db_attribute *attrib); + +bool gatt_db_attribute_get_service_uuid (struct gatt_db_attribute *attrib, +bt_uuid_t *uuid); + +bool gatt_db_attribute_get_service_handles (struct gatt_db_attribute *attrib, +uint16_t *start_handle, +uint16_t *end_handle); + +bool gatt_db_attribute_get_permissions (struct gatt_db_attribute *attrib, +uint32_t *permissions); + +typedef void (*gatt_db_attribute_read_t ) (struct gatt_db_attribute *attrib, +int err,uint8_t *value,size_t length, +void *user_data); + +bool gatt_db_attribute_read (struct gatt_db_attribute *attrib,uint16_t offset, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_read_t func,void *user_data); + +typedef void (*gatt_db_attribute_write_t ) (struct gatt_db_attribute *attrib, +int err,void *user_data); + +bool gatt_db_attribute_write (struct gatt_db_attribute *attrib,uint16_t offset, +const uint8_t *value,size_t len, +uint8_t opcode,bdaddr_t *bdaddr, +gatt_db_attribute_write_t func, +void *user_data); --1.9.3
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.htmlPatch set looks good to me. You can go ahead and apply if Michael, Marcin, and others are also fine with it.
Quoted 6 lines
Cheers,
Arman
--
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.htmlQuoted 4 lines
These patches look good with the changes, unless Marcin has problems go for it.
--
Michael JanssenPushed.
Quoted 7 lines
Quoted 2 lines
--
Luiz Augusto von DentzNow, the next bit that my gatt-server implementation is blocked on is passing the result callback to
gatt_db_read_tandgatt_db_write_t. If we just get that part done first then I can rebase and reupload my gatt-server patches.
Sure, that is what Im currently working on, hopefully latter today I will have it in shape to send for review.
Signature · 1 line
Luiz Augusto von Dentz