linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] android/debug: Export print uuid function
@ 2013-11-05 14:06 Andrei Emeltchenko
  2013-11-05 14:06 ` [PATCH 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko
  2013-11-05 16:56 ` [PATCH 1/2] android/debug: Export print uuid function Marcel Holtmann
  0 siblings, 2 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-05 14:06 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

The function will be reused in socket HAL.
---
 android/client/textconv.c |    2 +-
 android/client/textconv.h |    1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/android/client/textconv.c b/android/client/textconv.c
index 9a2f7e6..e6f327f 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
 	return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
 }
 
-static char *btuuid2str(const bt_uuid_t *uuid)
+char *btuuid2str(const bt_uuid_t *uuid)
 {
 	static char buf[MAX_UUID_STR_LEN];
 
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 1c848ef..7520b04 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
 
 char *btproperty2str(const bt_property_t *property);
 char *bdaddr2str(const bt_bdaddr_t *bd_addr);
+char *btuuid2str(const bt_uuid_t *uuid);
 
 DECINTMAP(bt_status_t);
 DECINTMAP(bt_state_t);
-- 
1.7.10.4


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

* [PATCH 2/2] android/hal: Add UUID debug print in socket HAL
  2013-11-05 14:06 [PATCH 1/2] android/debug: Export print uuid function Andrei Emeltchenko
@ 2013-11-05 14:06 ` Andrei Emeltchenko
  2013-11-05 16:56 ` [PATCH 1/2] android/debug: Export print uuid function Marcel Holtmann
  1 sibling, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-05 14:06 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/hal-sock.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/android/hal-sock.c b/android/hal-sock.c
index 131877a..5e64409 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -25,6 +25,8 @@
 #include "hal-msg.h"
 #include "hal.h"
 
+#include "client/textconv.h"
+
 static bt_status_t sock_listen_rfcomm(const char *service_name,
 					const uint8_t *uuid, int chan,
 					int *sock, int flags)
@@ -49,13 +51,14 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
 					int *sock, int flags)
 {
 	if ((!uuid && chan <= 0) || !sock) {
-		error("%s: invalid params: uuid %p, chan %d, sock %p",
-						__func__, uuid, chan, sock);
+		error("Invalid params: uuid %s, chan %d, sock %p",
+				btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d service_name %s",
-					uuid, chan, sock, type, service_name);
+	DBG("uuid %s chan %d sock %p type %d service_name %s",
+				btuuid2str((bt_uuid_t *) uuid), chan,
+				sock, type, service_name);
 
 	switch (type) {
 	case BTSOCK_RFCOMM:
@@ -76,12 +79,13 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
 	struct hal_op_sock_connect cmd;
 
 	if ((!uuid && chan <= 0) || !bdaddr || !sock) {
-		error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
-					bdaddr, uuid, chan, sock);
+		error("Invalid params: bd_addr %p, uuid %s, chan %d, sock %p",
+			bdaddr, btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
+	DBG("uuid %s chan %d sock %p type %d", btuuid2str((bt_uuid_t *) uuid),
+							chan, sock, type);
 
 	cmd.flags = flags;
 	cmd.type = type;
-- 
1.7.10.4


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

* Re: [PATCH 1/2] android/debug: Export print uuid function
  2013-11-05 14:06 [PATCH 1/2] android/debug: Export print uuid function Andrei Emeltchenko
  2013-11-05 14:06 ` [PATCH 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko
@ 2013-11-05 16:56 ` Marcel Holtmann
  2013-11-06  8:32   ` Andrei Emeltchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Marcel Holtmann @ 2013-11-05 16:56 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org development

Hi Andrei,

> The function will be reused in socket HAL.
> ---
> android/client/textconv.c |    2 +-
> android/client/textconv.h |    1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/android/client/textconv.c b/android/client/textconv.c
> index 9a2f7e6..e6f327f 100644
> --- a/android/client/textconv.c
> +++ b/android/client/textconv.c
> @@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
> 	return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
> }
> 
> -static char *btuuid2str(const bt_uuid_t *uuid)
> +char *btuuid2str(const bt_uuid_t *uuid)
> {
> 	static char buf[MAX_UUID_STR_LEN];
> 
> diff --git a/android/client/textconv.h b/android/client/textconv.h
> index 1c848ef..7520b04 100644
> --- a/android/client/textconv.h
> +++ b/android/client/textconv.h
> @@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
> 
> char *btproperty2str(const bt_property_t *property);
> char *bdaddr2str(const bt_bdaddr_t *bd_addr);
> +char *btuuid2str(const bt_uuid_t *uuid);

this is totally backwards then. The HAL should not depend on client code.

Regards

Marcel


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

* Re: [PATCH 1/2] android/debug: Export print uuid function
  2013-11-05 16:56 ` [PATCH 1/2] android/debug: Export print uuid function Marcel Holtmann
@ 2013-11-06  8:32   ` Andrei Emeltchenko
  2013-11-06  8:42     ` Marcel Holtmann
  0 siblings, 1 reply; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-06  8:32 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org development

Hi Marcel,

On Tue, Nov 05, 2013 at 05:56:08PM +0100, Marcel Holtmann wrote:
> Hi Andrei,
> 
> > The function will be reused in socket HAL.
> > ---
> > android/client/textconv.c |    2 +-
> > android/client/textconv.h |    1 +
> > 2 files changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/android/client/textconv.c b/android/client/textconv.c
> > index 9a2f7e6..e6f327f 100644
> > --- a/android/client/textconv.c
> > +++ b/android/client/textconv.c
> > @@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
> > 	return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
> > }
> > 
> > -static char *btuuid2str(const bt_uuid_t *uuid)
> > +char *btuuid2str(const bt_uuid_t *uuid)
> > {
> > 	static char buf[MAX_UUID_STR_LEN];
> > 
> > diff --git a/android/client/textconv.h b/android/client/textconv.h
> > index 1c848ef..7520b04 100644
> > --- a/android/client/textconv.h
> > +++ b/android/client/textconv.h
> > @@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
> > 
> > char *btproperty2str(const bt_property_t *property);
> > char *bdaddr2str(const bt_bdaddr_t *bd_addr);
> > +char *btuuid2str(const bt_uuid_t *uuid);
> 
> this is totally backwards then. The HAL should not depend on client code.
> 

So shall the function be moved to utils.c inside android or even better
src/shared?

Best regards 
Andrei Emeltchenko 

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

* Re: [PATCH 1/2] android/debug: Export print uuid function
  2013-11-06  8:32   ` Andrei Emeltchenko
@ 2013-11-06  8:42     ` Marcel Holtmann
  2013-11-06 14:07       ` [PATCHv2 1/2] android: Create debug utils helpers Andrei Emeltchenko
  2013-11-06 15:10       ` [PATCHv3 1/2] android: Create debug hal-utils helpers Andrei Emeltchenko
  0 siblings, 2 replies; 9+ messages in thread
From: Marcel Holtmann @ 2013-11-06  8:42 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org development

Hi Andrei,

>>> The function will be reused in socket HAL.
>>> ---
>>> android/client/textconv.c |    2 +-
>>> android/client/textconv.h |    1 +
>>> 2 files changed, 2 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/android/client/textconv.c b/android/client/textconv.c
>>> index 9a2f7e6..e6f327f 100644
>>> --- a/android/client/textconv.c
>>> +++ b/android/client/textconv.c
>>> @@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
>>> 	return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
>>> }
>>> 
>>> -static char *btuuid2str(const bt_uuid_t *uuid)
>>> +char *btuuid2str(const bt_uuid_t *uuid)
>>> {
>>> 	static char buf[MAX_UUID_STR_LEN];
>>> 
>>> diff --git a/android/client/textconv.h b/android/client/textconv.h
>>> index 1c848ef..7520b04 100644
>>> --- a/android/client/textconv.h
>>> +++ b/android/client/textconv.h
>>> @@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
>>> 
>>> char *btproperty2str(const bt_property_t *property);
>>> char *bdaddr2str(const bt_bdaddr_t *bd_addr);
>>> +char *btuuid2str(const bt_uuid_t *uuid);
>> 
>> this is totally backwards then. The HAL should not depend on client code.
>> 
> 
> So shall the function be moved to utils.c inside android or even better
> src/shared?

keep it inside android/ directory.

Regards

Marcel


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

* [PATCHv2 1/2] android: Create debug utils helpers
  2013-11-06  8:42     ` Marcel Holtmann
@ 2013-11-06 14:07       ` Andrei Emeltchenko
  2013-11-06 14:07         ` [PATCHv2 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko
  2013-11-06 15:10       ` [PATCHv3 1/2] android: Create debug hal-utils helpers Andrei Emeltchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-06 14:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Create debug-utils helpers which helps to decode packets Android
sends through HAL interface.
---
 android/Android.mk        |    2 ++
 android/Makefile.am       |    3 ++-
 android/client/if-gatt.c  |    1 +
 android/client/textconv.c |   42 ++------------------------------
 android/client/textconv.h |    2 --
 android/debug-utils.c     |   58 +++++++++++++++++++++++++++++++++++++++++++++
 android/debug-utils.h     |   26 ++++++++++++++++++++
 7 files changed, 91 insertions(+), 43 deletions(-)
 create mode 100644 android/debug-utils.c
 create mode 100644 android/debug-utils.h

diff --git a/android/Android.mk b/android/Android.mk
index d76dfaf..0a8bd6c 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -88,6 +88,7 @@ LOCAL_SRC_FILES := \
 	hal-pan.c \
 	hal-av.c \
 	client/textconv.c \
+	debug-utils.c \
 
 LOCAL_C_INCLUDES += \
 	$(call include-path-for, system-core) \
@@ -125,6 +126,7 @@ LOCAL_SRC_FILES := \
 	client/if-hh.c \
 	client/if-pan.c \
 	client/if-sock.c \
+	debug-utils.c \
 
 ANDROID_4_3_OR_ABOVE := $(shell echo 0 | awk -v v=$(PLATFORM_SDK_VERSION) 'END {print (v > 17) ? 1 : 0}')
 
diff --git a/android/Makefile.am b/android/Makefile.am
index 3c51390..e29da08 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -68,7 +68,8 @@ android_haltest_SOURCES = android/client/haltest.c \
 				android/client/if-hh.c \
 				android/client/if-pan.c \
 				android/client/if-sock.c \
-				android/client/hwmodule.c
+				android/client/hwmodule.c \
+				android/debug-utils.h android/debug-utils.c
 
 android_haltest_LDADD = android/libhal-internal.la
 
diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index b2b20cb..eb049c1 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -17,6 +17,7 @@
 
 #include <hardware/bluetooth.h>
 
+#include "../debug-utils.h"
 #include "if-main.h"
 
 const btgatt_interface_t *if_gatt = NULL;
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 4def3da..07924ac 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <hardware/bluetooth.h>
 
+#include "../debug-utils.h"
+
 #include "textconv.h"
 
 /*
@@ -154,39 +156,6 @@ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr)
 				&p[0], &p[1], &p[2], &p[3], &p[4], &p[5]);
 }
 
-static const char BT_BASE_UUID[] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
-	0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
-};
-
-/*
- * converts uuid to string
- * buf should be at least 39 bytes
- *
- * returns string representation of uuid
- */
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
-{
-	int shift = 0;
-	int i;
-	int is_bt;
-
-	is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
-
-	for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
-		if (i == 4 && is_bt)
-			break;
-
-		if (i == 4 || i == 6 || i == 8 || i == 10) {
-			buf[i * 2 + shift] = '-';
-			shift++;
-		}
-		sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
-	}
-
-	return buf;
-}
-
 /* converts string to uuid */
 void str2bt_uuid_t(const char *str, bt_uuid_t *uuid)
 {
@@ -234,13 +203,6 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
 	return bt_bdaddr_t2str(bd_addr, buf);
 }
 
-static char *btuuid2str(const bt_uuid_t *uuid)
-{
-	static char buf[MAX_UUID_STR_LEN];
-
-	return bt_uuid_t2str(uuid, buf);
-}
-
 char *btproperty2str(const bt_property_t *property)
 {
 	static char buf[4096];
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 1c848ef..837eb4e 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -103,8 +103,6 @@ static struct int2str __##type##2str[] = {
 char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf);
 void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
 
-#define MAX_UUID_STR_LEN 37
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
 void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
 
 char *btproperty2str(const bt_property_t *property);
diff --git a/android/debug-utils.c b/android/debug-utils.c
new file mode 100644
index 0000000..07bfb27
--- /dev/null
+++ b/android/debug-utils.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <hardware/bluetooth.h>
+
+#include "debug-utils.h"
+
+/*
+ * converts uuid to string
+ * buf should be at least 39 bytes
+ *
+ * returns string representation of uuid
+ */
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
+{
+	int shift = 0;
+	int i;
+	int is_bt;
+
+	is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
+
+	for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
+		if (i == 4 && is_bt)
+			break;
+
+		if (i == 4 || i == 6 || i == 8 || i == 10) {
+			buf[i * 2 + shift] = '-';
+			shift++;
+		}
+		sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
+	}
+
+	return buf;
+}
+
+char *btuuid2str(const bt_uuid_t *uuid)
+{
+	static char buf[MAX_UUID_STR_LEN];
+
+	return bt_uuid_t2str(uuid, buf);
+}
diff --git a/android/debug-utils.h b/android/debug-utils.h
new file mode 100644
index 0000000..d40b430
--- /dev/null
+++ b/android/debug-utils.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define MAX_UUID_STR_LEN 37
+
+static const char BT_BASE_UUID[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+	0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
+};
+
+char *btuuid2str(const bt_uuid_t *uuid);
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
-- 
1.7.10.4


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

* [PATCHv2 2/2] android/hal: Add UUID debug print in socket HAL
  2013-11-06 14:07       ` [PATCHv2 1/2] android: Create debug utils helpers Andrei Emeltchenko
@ 2013-11-06 14:07         ` Andrei Emeltchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-06 14:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/hal-sock.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/android/hal-sock.c b/android/hal-sock.c
index 32c7939..750cf5b 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -25,6 +25,8 @@
 #include "hal-msg.h"
 #include "hal.h"
 
+#include "debug-utils.h"
+
 static bt_status_t sock_listen_rfcomm(const char *service_name,
 					const uint8_t *uuid, int chan,
 					int *sock, int flags)
@@ -49,13 +51,14 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
 					int *sock, int flags)
 {
 	if ((!uuid && chan <= 0) || !sock) {
-		error("%s: invalid params: uuid %p, chan %d, sock %p",
-						__func__, uuid, chan, sock);
+		error("Invalid params: uuid %s, chan %d, sock %p",
+				btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d service_name %s",
-					uuid, chan, sock, type, service_name);
+	DBG("uuid %s chan %d sock %p type %d service_name %s",
+				btuuid2str((bt_uuid_t *) uuid), chan,
+				sock, type, service_name);
 
 	switch (type) {
 	case BTSOCK_RFCOMM:
@@ -76,12 +79,13 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
 	struct hal_cmd_sock_connect cmd;
 
 	if ((!uuid && chan <= 0) || !bdaddr || !sock) {
-		error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
-					bdaddr, uuid, chan, sock);
+		error("Invalid params: bd_addr %p, uuid %s, chan %d, sock %p",
+			bdaddr, btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
+	DBG("uuid %s chan %d sock %p type %d", btuuid2str((bt_uuid_t *) uuid),
+							chan, sock, type);
 
 	if (type != BTSOCK_RFCOMM) {
 		error("Socket type %u not supported", type);
-- 
1.7.10.4


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

* [PATCHv3 1/2] android: Create debug hal-utils helpers
  2013-11-06  8:42     ` Marcel Holtmann
  2013-11-06 14:07       ` [PATCHv2 1/2] android: Create debug utils helpers Andrei Emeltchenko
@ 2013-11-06 15:10       ` Andrei Emeltchenko
  2013-11-06 15:10         ` [PATCHv3 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-06 15:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Create hal-utils helpers which helps to decode packets Android
sends through HAL interface.
---
 android/Android.mk        |    2 ++
 android/Makefile.am       |    3 ++-
 android/client/if-gatt.c  |    1 +
 android/client/textconv.c |   42 ++------------------------------
 android/client/textconv.h |    2 --
 android/hal-utils.c       |   58 +++++++++++++++++++++++++++++++++++++++++++++
 android/hal-utils.h       |   26 ++++++++++++++++++++
 7 files changed, 91 insertions(+), 43 deletions(-)
 create mode 100644 android/hal-utils.c
 create mode 100644 android/hal-utils.h

diff --git a/android/Android.mk b/android/Android.mk
index d76dfaf..32bb591 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -88,6 +88,7 @@ LOCAL_SRC_FILES := \
 	hal-pan.c \
 	hal-av.c \
 	client/textconv.c \
+	hal-utils.c \
 
 LOCAL_C_INCLUDES += \
 	$(call include-path-for, system-core) \
@@ -125,6 +126,7 @@ LOCAL_SRC_FILES := \
 	client/if-hh.c \
 	client/if-pan.c \
 	client/if-sock.c \
+	hal-utils.c \
 
 ANDROID_4_3_OR_ABOVE := $(shell echo 0 | awk -v v=$(PLATFORM_SDK_VERSION) 'END {print (v > 17) ? 1 : 0}')
 
diff --git a/android/Makefile.am b/android/Makefile.am
index 8619641..e4adf6c 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -68,7 +68,8 @@ android_haltest_SOURCES = android/client/haltest.c \
 				android/client/if-hh.c \
 				android/client/if-pan.c \
 				android/client/if-sock.c \
-				android/client/hwmodule.c
+				android/client/hwmodule.c \
+				android/hal-utils.h android/hal-utils.c
 
 android_haltest_LDADD = android/libhal-internal.la
 
diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
index b2b20cb..bb53952 100644
--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -17,6 +17,7 @@
 
 #include <hardware/bluetooth.h>
 
+#include "../hal-utils.h"
 #include "if-main.h"
 
 const btgatt_interface_t *if_gatt = NULL;
diff --git a/android/client/textconv.c b/android/client/textconv.c
index 4def3da..469b2c3 100644
--- a/android/client/textconv.c
+++ b/android/client/textconv.c
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <hardware/bluetooth.h>
 
+#include "../hal-utils.h"
+
 #include "textconv.h"
 
 /*
@@ -154,39 +156,6 @@ void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr)
 				&p[0], &p[1], &p[2], &p[3], &p[4], &p[5]);
 }
 
-static const char BT_BASE_UUID[] = {
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
-	0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
-};
-
-/*
- * converts uuid to string
- * buf should be at least 39 bytes
- *
- * returns string representation of uuid
- */
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
-{
-	int shift = 0;
-	int i;
-	int is_bt;
-
-	is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
-
-	for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
-		if (i == 4 && is_bt)
-			break;
-
-		if (i == 4 || i == 6 || i == 8 || i == 10) {
-			buf[i * 2 + shift] = '-';
-			shift++;
-		}
-		sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
-	}
-
-	return buf;
-}
-
 /* converts string to uuid */
 void str2bt_uuid_t(const char *str, bt_uuid_t *uuid)
 {
@@ -234,13 +203,6 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
 	return bt_bdaddr_t2str(bd_addr, buf);
 }
 
-static char *btuuid2str(const bt_uuid_t *uuid)
-{
-	static char buf[MAX_UUID_STR_LEN];
-
-	return bt_uuid_t2str(uuid, buf);
-}
-
 char *btproperty2str(const bt_property_t *property)
 {
 	static char buf[4096];
diff --git a/android/client/textconv.h b/android/client/textconv.h
index 1c848ef..837eb4e 100644
--- a/android/client/textconv.h
+++ b/android/client/textconv.h
@@ -103,8 +103,6 @@ static struct int2str __##type##2str[] = {
 char *bt_bdaddr_t2str(const bt_bdaddr_t *bd_addr, char *buf);
 void str2bt_bdaddr_t(const char *str, bt_bdaddr_t *bd_addr);
 
-#define MAX_UUID_STR_LEN 37
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
 void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
 
 char *btproperty2str(const bt_property_t *property);
diff --git a/android/hal-utils.c b/android/hal-utils.c
new file mode 100644
index 0000000..84cfad1
--- /dev/null
+++ b/android/hal-utils.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <hardware/bluetooth.h>
+
+#include "hal-utils.h"
+
+/*
+ * converts uuid to string
+ * buf should be at least 39 bytes
+ *
+ * returns string representation of uuid
+ */
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
+{
+	int shift = 0;
+	int i;
+	int is_bt;
+
+	is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
+
+	for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
+		if (i == 4 && is_bt)
+			break;
+
+		if (i == 4 || i == 6 || i == 8 || i == 10) {
+			buf[i * 2 + shift] = '-';
+			shift++;
+		}
+		sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
+	}
+
+	return buf;
+}
+
+char *btuuid2str(const bt_uuid_t *uuid)
+{
+	static char buf[MAX_UUID_STR_LEN];
+
+	return bt_uuid_t2str(uuid, buf);
+}
diff --git a/android/hal-utils.h b/android/hal-utils.h
new file mode 100644
index 0000000..d40b430
--- /dev/null
+++ b/android/hal-utils.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#define MAX_UUID_STR_LEN 37
+
+static const char BT_BASE_UUID[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+	0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
+};
+
+char *btuuid2str(const bt_uuid_t *uuid);
+char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
-- 
1.7.10.4


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

* [PATCHv3 2/2] android/hal: Add UUID debug print in socket HAL
  2013-11-06 15:10       ` [PATCHv3 1/2] android: Create debug hal-utils helpers Andrei Emeltchenko
@ 2013-11-06 15:10         ` Andrei Emeltchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andrei Emeltchenko @ 2013-11-06 15:10 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 android/hal-sock.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/android/hal-sock.c b/android/hal-sock.c
index 32c7939..1d198ac 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -25,6 +25,8 @@
 #include "hal-msg.h"
 #include "hal.h"
 
+#include "hal-utils.h"
+
 static bt_status_t sock_listen_rfcomm(const char *service_name,
 					const uint8_t *uuid, int chan,
 					int *sock, int flags)
@@ -49,13 +51,14 @@ static bt_status_t sock_listen(btsock_type_t type, const char *service_name,
 					int *sock, int flags)
 {
 	if ((!uuid && chan <= 0) || !sock) {
-		error("%s: invalid params: uuid %p, chan %d, sock %p",
-						__func__, uuid, chan, sock);
+		error("Invalid params: uuid %s, chan %d, sock %p",
+				btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d service_name %s",
-					uuid, chan, sock, type, service_name);
+	DBG("uuid %s chan %d sock %p type %d service_name %s",
+				btuuid2str((bt_uuid_t *) uuid), chan,
+				sock, type, service_name);
 
 	switch (type) {
 	case BTSOCK_RFCOMM:
@@ -76,12 +79,13 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
 	struct hal_cmd_sock_connect cmd;
 
 	if ((!uuid && chan <= 0) || !bdaddr || !sock) {
-		error("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
-					bdaddr, uuid, chan, sock);
+		error("Invalid params: bd_addr %p, uuid %s, chan %d, sock %p",
+			bdaddr, btuuid2str((bt_uuid_t *) uuid), chan, sock);
 		return BT_STATUS_PARM_INVALID;
 	}
 
-	DBG("uuid %p chan %d sock %p type %d", uuid, chan, sock, type);
+	DBG("uuid %s chan %d sock %p type %d", btuuid2str((bt_uuid_t *) uuid),
+							chan, sock, type);
 
 	if (type != BTSOCK_RFCOMM) {
 		error("Socket type %u not supported", type);
-- 
1.7.10.4


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

end of thread, other threads:[~2013-11-06 15:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-05 14:06 [PATCH 1/2] android/debug: Export print uuid function Andrei Emeltchenko
2013-11-05 14:06 ` [PATCH 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko
2013-11-05 16:56 ` [PATCH 1/2] android/debug: Export print uuid function Marcel Holtmann
2013-11-06  8:32   ` Andrei Emeltchenko
2013-11-06  8:42     ` Marcel Holtmann
2013-11-06 14:07       ` [PATCHv2 1/2] android: Create debug utils helpers Andrei Emeltchenko
2013-11-06 14:07         ` [PATCHv2 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko
2013-11-06 15:10       ` [PATCHv3 1/2] android: Create debug hal-utils helpers Andrei Emeltchenko
2013-11-06 15:10         ` [PATCHv3 2/2] android/hal: Add UUID debug print in socket HAL Andrei Emeltchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).