2014-10-31 13:39:46

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ 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(+)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 6b5e84c..3ade7a9 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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;
+}
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 8d18434..15be67f 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -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



2014-10-31 21:06:17

by Michael Janssen

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 1/9] shared/gatt-db: Expose gatt_db_attribute

Hi Luiz,

On Fri, Oct 31, 2014 at 11:27 AM, Arman Uguray <[email protected]> wrote:
> Hi Luiz,
>
>> On Fri, Oct 31, 2014 at 6:39 AM, Luiz Augusto von Dentz <[email protected]> wrote:
>> 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(+)
>>
>> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
>> index 6b5e84c..3ade7a9 100644
>> --- a/src/shared/gatt-db.c
>> +++ b/src/shared/gatt-db.c
>> @@ -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;
>> +}
>> diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
>> index 8d18434..15be67f 100644
>> --- a/src/shared/gatt-db.h
>> +++ b/src/shared/gatt-db.h
>> @@ -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
>>
>> --
>> 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
> --
> 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.

--
Michael Janssen

2014-10-31 18:27:57

by Arman Uguray

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 1/9] shared/gatt-db: Expose gatt_db_attribute

Hi Luiz,

> On Fri, Oct 31, 2014 at 6:39 AM, Luiz Augusto von Dentz <[email protected]> wrote:
> 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(+)
>
> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
> index 6b5e84c..3ade7a9 100644
> --- a/src/shared/gatt-db.c
> +++ b/src/shared/gatt-db.c
> @@ -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;
> +}
> diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
> index 8d18434..15be67f 100644
> --- a/src/shared/gatt-db.h
> +++ b/src/shared/gatt-db.h
> @@ -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
>
> --
> 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

2014-10-31 13:39:54

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 9/9] shared/gatt-db: Add gatt_db_attribute_write

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index f6ce5f3..5855f5d 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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;
}
--
1.9.3


2014-10-31 13:39:53

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 8/9] shared/gatt-db: Add gatt_db_attribute_read

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index b447199..f6ce5f3 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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,
--
1.9.3


2014-10-31 13:39:52

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 7/9] shared/gatt-db: Add gatt_db_attribute_get_permissions

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index a2684d8..b447199 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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,
--
1.9.3


2014-10-31 13:39:51

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 6/9] shared/gatt-db: Add gatt_db_attribute_get_service_handles

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index e164055..a2684d8 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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,
--
1.9.3


2014-10-31 13:39:49

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 4/9] shared/gatt-db: Add gatt_db_attribute_get_handle

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index af1cde9..c24b643 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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,
--
1.9.3


2014-10-31 13:39:50

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 5/9] shared/gatt-db: Add gatt_db_attribute_get_service_uuid

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 45 +++++++++++++++++++++++++++++++++++++--------
1 file changed, 37 insertions(+), 8 deletions(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index c24b643..e164055 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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;
}

--
1.9.3


2014-10-31 13:39:48

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 3/9] shared/gatt-db: Add gatt_db_attribute_get_type

From: Luiz Augusto von Dentz <[email protected]>

---
src/shared/gatt-db.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index cc8e494..af1cde9 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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)
--
1.9.3


2014-10-31 13:39:47

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ 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(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 3ade7a9..cc8e494 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -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)
--
1.9.3


2014-11-03 08:57:47

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 1/9] shared/gatt-db: Expose gatt_db_attribute

Hi Arman,

On Mon, Nov 3, 2014 at 6:43 AM, Arman Uguray <[email protected]> wrote:
> Hi Luiz,
>
> On Sun, Nov 2, 2014 at 11:08 AM, Luiz Augusto von Dentz
> <[email protected]> wrote:
>> Hi,
>>
>> On Fri, Oct 31, 2014 at 11:06 PM, Michael Janssen <[email protected]> wrote:
>>> Hi Luiz,
>>>
>>> On Fri, Oct 31, 2014 at 11:27 AM, Arman Uguray <[email protected]> wrote:
>>>> Hi Luiz,
>>>>
>>>>> On Fri, Oct 31, 2014 at 6:39 AM, Luiz Augusto von Dentz <[email protected]> wrote:
>>>>> 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(+)
>>>>>
>>>>> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
>>>>> index 6b5e84c..3ade7a9 100644
>>>>> --- a/src/shared/gatt-db.c
>>>>> +++ b/src/shared/gatt-db.c
>>>>> @@ -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;
>>>>> +}
>>>>> diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
>>>>> index 8d18434..15be67f 100644
>>>>> --- a/src/shared/gatt-db.h
>>>>> +++ b/src/shared/gatt-db.h
>>>>> @@ -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
>>>>>
>>>>> --
>>>>> 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
>>>> --
>>>> 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.
>>>
>>> --
>>> Michael Janssen
>>
>> Pushed.
>>
>> --
>> 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.

Sure, that is what Im currently working on, hopefully latter today I
will have it in shape to send for review.


--
Luiz Augusto von Dentz

2014-11-03 04:43:16

by Arman Uguray

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 1/9] shared/gatt-db: Expose gatt_db_attribute

Hi Luiz,

On Sun, Nov 2, 2014 at 11:08 AM, Luiz Augusto von Dentz
<[email protected]> wrote:
> Hi,
>
> On Fri, Oct 31, 2014 at 11:06 PM, Michael Janssen <[email protected]> wrote:
>> Hi Luiz,
>>
>> On Fri, Oct 31, 2014 at 11:27 AM, Arman Uguray <[email protected]> wrote:
>>> Hi Luiz,
>>>
>>>> On Fri, Oct 31, 2014 at 6:39 AM, Luiz Augusto von Dentz <[email protected]> wrote:
>>>> 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(+)
>>>>
>>>> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
>>>> index 6b5e84c..3ade7a9 100644
>>>> --- a/src/shared/gatt-db.c
>>>> +++ b/src/shared/gatt-db.c
>>>> @@ -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;
>>>> +}
>>>> diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
>>>> index 8d18434..15be67f 100644
>>>> --- a/src/shared/gatt-db.h
>>>> +++ b/src/shared/gatt-db.h
>>>> @@ -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
>>>>
>>>> --
>>>> 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
>>> --
>>> 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.
>>
>> --
>> Michael Janssen
>
> Pushed.
>
> --
> 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

2014-11-02 19:08:19

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 1/9] shared/gatt-db: Expose gatt_db_attribute

Hi,

On Fri, Oct 31, 2014 at 11:06 PM, Michael Janssen <[email protected]> wrote:
> Hi Luiz,
>
> On Fri, Oct 31, 2014 at 11:27 AM, Arman Uguray <[email protected]> wrote:
>> Hi Luiz,
>>
>>> On Fri, Oct 31, 2014 at 6:39 AM, Luiz Augusto von Dentz <[email protected]> wrote:
>>> 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(+)
>>>
>>> diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
>>> index 6b5e84c..3ade7a9 100644
>>> --- a/src/shared/gatt-db.c
>>> +++ b/src/shared/gatt-db.c
>>> @@ -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;
>>> +}
>>> diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
>>> index 8d18434..15be67f 100644
>>> --- a/src/shared/gatt-db.h
>>> +++ b/src/shared/gatt-db.h
>>> @@ -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
>>>
>>> --
>>> 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
>> --
>> 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.
>
> --
> Michael Janssen

Pushed.

--
Luiz Augusto von Dentz