All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] shared/gatt-helper: Consolidate error checking
@ 2015-03-17 15:19 Luiz Augusto von Dentz
  2015-03-17 15:19 ` [PATCH BlueZ 2/2] core/device: Enable bt_gatt_client debug Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17 15:19 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This consolidate the error checking for attribute not found in
discover_op_complete.
---
 src/shared/gatt-helpers.c | 47 ++++++-----------------------------------------
 1 file changed, 6 insertions(+), 41 deletions(-)

diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
index 2d6088e..45c620c 100644
--- a/src/shared/gatt-helpers.c
+++ b/src/shared/gatt-helpers.c
@@ -625,6 +625,10 @@ static void async_req_unref(void *data)
 static void discovery_op_complete(struct bt_gatt_request *op, bool success,
 								uint8_t ecode)
 {
+	/* Reset success if there is some result to report */
+	if (ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND && op->result_head)
+		success = true;
+
 	if (op->callback)
 		op->callback(success, ecode, success ? op->result_head : NULL,
 								op->user_data);
@@ -650,11 +654,6 @@ static void read_by_grp_type_cb(uint8_t opcode, const void *pdu,
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
 		success = false;
 		att_ecode = process_error(pdu, length);
-
-		if (att_ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND &&
-								op->result_head)
-			goto success;
-
 		goto done;
 	}
 
@@ -718,7 +717,6 @@ static void read_by_grp_type_cb(uint8_t opcode, const void *pdu,
 		put_le16(op->end_handle,
 				cur_result->pdu + length - data_length + 1);
 
-success:
 	success = true;
 
 done:
@@ -736,11 +734,6 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
 		success = false;
 		att_ecode = process_error(pdu, length);
-
-		if (att_ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND &&
-								op->result_head)
-			goto success;
-
 		goto done;
 	}
 
@@ -785,8 +778,7 @@ static void find_by_type_val_cb(uint8_t opcode, const void *pdu,
 		goto done;
 	}
 
-success:
-	success = true;
+	success = false;
 
 done:
 	discovery_op_complete(op, success, att_ecode);
@@ -1047,11 +1039,6 @@ static void discover_included_cb(uint8_t opcode, const void *pdu,
 
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
 		att_ecode = process_error(pdu, length);
-
-		if (att_ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND &&
-							op->result_head)
-			goto done;
-
 		success = false;
 		goto failed;
 	}
@@ -1118,7 +1105,6 @@ static void discover_included_cb(uint8_t opcode, const void *pdu,
 		goto failed;
 	}
 
-done:
 	success = true;
 
 failed:
@@ -1174,11 +1160,6 @@ static void discover_chrcs_cb(uint8_t opcode, const void *pdu,
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
 		success = false;
 		att_ecode = process_error(pdu, length);
-
-		if (att_ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND &&
-							op->result_head)
-			goto success;
-
 		goto done;
 	}
 
@@ -1228,9 +1209,6 @@ static void discover_chrcs_cb(uint8_t opcode, const void *pdu,
 		goto done;
 	}
 
-success:
-	success = true;
-
 done:
 	discovery_op_complete(op, success, att_ecode);
 }
@@ -1283,13 +1261,7 @@ static void read_by_type_cb(uint8_t opcode, const void *pdu,
 
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
 		att_ecode = process_error(pdu, length);
-
-		if (att_ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND &&
-							op->result_head)
-			success = true;
-		else
-			success = false;
-
+		success = false;
 		goto done;
 	}
 
@@ -1389,11 +1361,6 @@ static void discover_descs_cb(uint8_t opcode, const void *pdu,
 	if (opcode == BT_ATT_OP_ERROR_RSP) {
 		success = false;
 		att_ecode = process_error(pdu, length);
-
-		if (att_ecode == BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND &&
-								op->result_head)
-			goto success;
-
 		goto done;
 	}
 
@@ -1445,10 +1412,8 @@ static void discover_descs_cb(uint8_t opcode, const void *pdu,
 			return;
 
 		success = false;
-		goto done;
 	}
 
-success:
 	success = true;
 
 done:
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH BlueZ 2/2] core/device: Enable bt_gatt_client debug
  2015-03-17 15:19 [PATCH BlueZ 1/2] shared/gatt-helper: Consolidate error checking Luiz Augusto von Dentz
@ 2015-03-17 15:19 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-17 15:19 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This enables bt_gatt_client debug and use BDG to print out.
---
 src/device.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/device.c b/src/device.c
index aaa9f43..6a23adc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3989,6 +3989,11 @@ static void gatt_client_service_changed(uint16_t start_handle,
 	DBG("start 0x%04x, end: 0x%04x", start_handle, end_handle);
 }
 
+static void gatt_debug(const char *str, void *user_data)
+{
+	DBG("%s", str);
+}
+
 static void gatt_client_init(struct btd_device *device)
 {
 	gatt_client_cleanup(device);
@@ -4000,6 +4005,8 @@ static void gatt_client_init(struct btd_device *device)
 		return;
 	}
 
+	bt_gatt_client_set_debug(device->client, gatt_debug, NULL, NULL);
+
 	/* Notify attio so it can react to notifications */
 	g_slist_foreach(device->attios, attio_connected, device->attrib);
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-17 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17 15:19 [PATCH BlueZ 1/2] shared/gatt-helper: Consolidate error checking Luiz Augusto von Dentz
2015-03-17 15:19 ` [PATCH BlueZ 2/2] core/device: Enable bt_gatt_client debug Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.