---
android/gatt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index 986f435..19d9b60 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -6199,6 +6199,7 @@ static void register_gap_service(void)
gatt_db_service_set_active(gatt_db, gap_srvc_data.srvc , true);
/* SDP */
+ bt_uuid16_create(&uuid, 0x1800);
start = gap_srvc_data.srvc;
end = gatt_db_get_end_handle(gatt_db, gap_srvc_data.srvc);
gap_sdp_handle = add_sdp_record(&uuid, start, end,
@@ -6308,6 +6309,7 @@ static void register_device_info_service(void)
gatt_db_service_set_active(gatt_db, srvc_handle, true);
/* SDP */
+ bt_uuid16_create(&uuid, 0x180a);
end_handle = gatt_db_get_end_handle(gatt_db, srvc_handle);
dis_sdp_handle = add_sdp_record(&uuid, srvc_handle, end_handle,
"Device Information Service");
@@ -6404,6 +6406,7 @@ static void register_gatt_service(void)
gatt_db_service_set_active(gatt_db, srvc_handle, true);
/* SDP */
+ bt_uuid16_create(&uuid, 0x1801);
end_handle = gatt_db_get_end_handle(gatt_db, srvc_handle);
gatt_sdp_handle = add_sdp_record(&uuid, srvc_handle, end_handle,
"Generic Attribute Profile");
--
1.9.0
Hi Marcin,
On Thursday 17 of July 2014 10:42:43 Marcin Kraglak wrote:
> ---
> android/gatt.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 986f435..19d9b60 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -6199,6 +6199,7 @@ static void register_gap_service(void)
> gatt_db_service_set_active(gatt_db, gap_srvc_data.srvc , true);
>
> /* SDP */
> + bt_uuid16_create(&uuid, 0x1800);
> start = gap_srvc_data.srvc;
> end = gatt_db_get_end_handle(gatt_db, gap_srvc_data.srvc);
> gap_sdp_handle = add_sdp_record(&uuid, start, end,
> @@ -6308,6 +6309,7 @@ static void register_device_info_service(void)
> gatt_db_service_set_active(gatt_db, srvc_handle, true);
>
> /* SDP */
> + bt_uuid16_create(&uuid, 0x180a);
> end_handle = gatt_db_get_end_handle(gatt_db, srvc_handle);
> dis_sdp_handle = add_sdp_record(&uuid, srvc_handle, end_handle,
> "Device Information Service");
> @@ -6404,6 +6406,7 @@ static void register_gatt_service(void)
> gatt_db_service_set_active(gatt_db, srvc_handle, true);
>
> /* SDP */
> + bt_uuid16_create(&uuid, 0x1801);
> end_handle = gatt_db_get_end_handle(gatt_db, srvc_handle);
> gatt_sdp_handle = add_sdp_record(&uuid, srvc_handle, end_handle,
> "Generic Attribute Profile");
>
All patches applied, thanks.
--
Best regards,
Szymon Janc
Return all instances of services. It is not proper behaviour to
return only one instance of service with same uuid.
---
android/gatt.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index 19d9b60..4cd94b8 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1136,28 +1136,28 @@ static void discover_srvc_by_uuid_cb(uint8_t status, GSList *ranges,
}
bt_uuid_to_string(&cb_data->uuid, prim.uuid, sizeof(prim.uuid));
- /*
- * If multiple instances of the same service (as identified by UUID)
- * exist, the first instance of the service is returned.
- */
- memcpy(&prim.range, ranges->data, sizeof(prim.range));
- s = create_service(instance_id++, true, prim.uuid, &prim);
- if (!s) {
- gatt_status = GATT_FAILURE;
- goto reply;
- }
+ for (; ranges; ranges = ranges->next) {
+ memcpy(&prim.range, ranges->data, sizeof(prim.range));
- if (!queue_push_tail(dev->services, s)) {
- error("gatt: Cannot push primary service to the list");
- gatt_status = GATT_FAILURE;
- goto reply;
- }
+ s = create_service(instance_id++, true, prim.uuid, &prim);
+ if (!s) {
+ gatt_status = GATT_FAILURE;
+ goto reply;
+ }
+
+ if (!queue_push_tail(dev->services, s)) {
+ error("gatt: Cannot push primary service to the list");
+ destroy_service(s);
+ gatt_status = GATT_FAILURE;
+ goto reply;
+ }
- send_client_primary_notify(s, INT_TO_PTR(cb_data->conn->id));
+ send_client_primary_notify(s, INT_TO_PTR(cb_data->conn->id));
- DBG("attr handle = 0x%04x, end grp handle = 0x%04x uuid: %s",
- prim.range.start, prim.range.end, prim.uuid);
+ DBG("attr handle = 0x%04x, end grp handle = 0x%04x uuid: %s",
+ prim.range.start, prim.range.end, prim.uuid);
+ }
/* Partial search service scanning was performed */
dev->partial_srvc_search = true;
--
1.9.0
Attribute's value length can be 0, so fill read response and send.
---
android/gatt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index 002592c..4d16d1e 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -4488,7 +4488,7 @@ static void read_requested_attributes(void *data, void *user_data)
struct pending_request *resp_data = data;
struct request_processing_data *process_data = user_data;
uint32_t permissions;
- uint8_t *value, error;
+ uint8_t *value = NULL, error;
int value_len = 0;
if (!gatt_db_get_attribute_permissions(gatt_db, resp_data->handle,
@@ -4524,7 +4524,7 @@ static void read_requested_attributes(void *data, void *user_data)
error = ATT_ECODE_UNLIKELY;
/* We have value here already if no callback will be called */
- if (value_len > 0)
+ if (value_len >= 0)
fill_gatt_response(resp_data, resp_data->handle,
resp_data->offset, error, value_len,
value);
--
1.9.0
Use this permission if no read and write is allowed. It is now set
in service change characteristic.
---
android/gatt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/gatt.c b/android/gatt.c
index 4d16d1e..6253d28 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -68,6 +68,7 @@
#define GATT_PERM_WRITE_AUTHORIZATION 0x00000800
#define GATT_PERM_WRITE_SIGNED 0x00010000
#define GATT_PERM_WRITE_SIGNED_MITM 0x00020000
+#define GATT_PERM_NONE 0x10000000
#define GATT_CONN_TIMEOUT 2
@@ -6393,7 +6394,7 @@ static void register_gatt_service(void)
bt_uuid16_create(&uuid, GATT_CHARAC_SERVICE_CHANGED);
service_changed_handle = gatt_db_add_characteristic(gatt_db,
- srvc_handle, &uuid, 0,
+ srvc_handle, &uuid, GATT_PERM_NONE,
GATT_CHR_PROP_INDICATE, NULL, NULL,
NULL);
--
1.9.0
Pass proper status to upper layer.
---
android/gatt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/gatt.c b/android/gatt.c
index 6253d28..852c50b 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3140,12 +3140,13 @@ static void send_client_descr_read_notify(int32_t status, const uint8_t *pdu,
ev->status = status;
ev->conn_id = conn_id;
+ ev->data.status = ev->status;
element_id_to_hal_srvc_id(srvc, primary, &ev->data.srvc_id);
element_id_to_hal_gatt_id(ch, &ev->data.char_id);
element_id_to_hal_gatt_id(descr, &ev->data.descr_id);
- if (len && pdu) {
+ if (status == 0 && pdu) {
ssize_t ret;
ret = dec_read_resp(pdu, len, ev->data.value,
--
1.9.0
Pass correct status to upper layer.
---
android/gatt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/gatt.c b/android/gatt.c
index 852c50b..2ddbf29 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2769,11 +2769,12 @@ static void send_client_read_char_notify(int32_t status, const uint8_t *pdu,
ev->conn_id = conn_id;
ev->status = status;
+ ev->data.status = status;
element_id_to_hal_srvc_id(s_id, primary, &ev->data.srvc_id);
element_id_to_hal_gatt_id(ch_id, &ev->data.char_id);
- if (pdu) {
+ if (status == 0 && pdu) {
vlen = dec_read_resp(pdu, len, ev->data.value, sizeof(buf));
if (vlen < 0) {
error("gatt: Protocol error");
--
1.9.0
If error is returned from check_device_permissions, fill response
data and return. In case of read errors we didn't send error response.
Zero length data was send instead.
---
android/gatt.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index 4cd94b8..002592c 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -4508,8 +4508,11 @@ static void read_requested_attributes(void *data, void *user_data)
error = check_device_permissions(process_data->device,
process_data->opcode,
permissions);
- if (error)
- goto done;
+ if (error != 0) {
+ resp_data->error = error;
+ resp_data->state = REQUEST_DONE;
+ return;
+ }
resp_data->state = REQUEST_PENDING;
@@ -4517,12 +4520,9 @@ static void read_requested_attributes(void *data, void *user_data)
resp_data->offset,
process_data->opcode,
&process_data->device->bdaddr,
- &value, &value_len)) {
+ &value, &value_len))
error = ATT_ECODE_UNLIKELY;
- goto done;
- }
-done:
/* We have value here already if no callback will be called */
if (value_len > 0)
fill_gatt_response(resp_data, resp_data->handle,
--
1.9.0
Discover all attributes in given range. In same cases we ommited
last attribute in range.
---
attrib/gatt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/attrib/gatt.c b/attrib/gatt.c
index 27fb0b3..f8ff2a5 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -1004,7 +1004,7 @@ static void desc_discovered_cb(guint8 status, const guint8 *ipdu,
att_data_list_free(list);
- if (last + 1 < dd->end && !uuid_found) {
+ if (last < dd->end && !uuid_found) {
guint16 oplen;
size_t buflen;
uint8_t *buf;
--
1.9.0