linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v3 1/5] tools/btpclient: Move string to address conversion to helper
@ 2017-12-28 13:11 Grzegorz Kolodziejczyk
  2017-12-28 13:11 ` [PATCH BlueZ v3 2/5] tools/btpclient: Add advertising proxy to adapter Grzegorz Kolodziejczyk
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Grzegorz Kolodziejczyk @ 2017-12-28 13:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Grzegorz Kolodziejczyk

From: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl>

This patch makes local helper with string to address conversion.
---
 tools/btpclient.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/btpclient.c b/tools/btpclient.c
index 9ea6249..2cb5719 100644
--- a/tools/btpclient.c
+++ b/tools/btpclient.c
@@ -52,6 +52,12 @@ static struct btp *btp;
 
 static bool gap_service_registered;
 
+static bool str2addr(const char *str, uint8_t *addr)
+{
+	return sscanf(str,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[5], &addr[4],
+				&addr[3], &addr[2], &addr[1], &addr[0]) == 6;
+}
+
 static struct btp_adapter *find_adapter_by_proxy(struct l_dbus_proxy *proxy)
 {
 	const struct l_queue_entry *entry;
@@ -171,9 +177,7 @@ static void btp_gap_read_info(uint8_t index, const void *param, uint16_t length,
 	if (!l_dbus_proxy_get_property(adapter->proxy, "Address", "s", &str))
 		goto failed;
 
-	if (sscanf(str,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-			&rp.address[5], &rp.address[4], &rp.address[3],
-			&rp.address[2], &rp.address[1], &rp.address[0]) != 6)
+	if (!str2addr(str, rp.address))
 		goto failed;
 
 	if (!l_dbus_proxy_get_property(adapter->proxy, "Name", "s", &str)) {
-- 
2.7.4


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

end of thread, other threads:[~2018-01-02  9:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-28 13:11 [PATCH BlueZ v3 1/5] tools/btpclient: Move string to address conversion to helper Grzegorz Kolodziejczyk
2017-12-28 13:11 ` [PATCH BlueZ v3 2/5] tools/btpclient: Add advertising proxy to adapter Grzegorz Kolodziejczyk
2017-12-28 13:11 ` [PATCH BlueZ v3 3/5] tools/btpclient: Add device found event Grzegorz Kolodziejczyk
2017-12-28 13:11 ` [PATCH BlueZ v3 4/5] tools/btpclient: Add start, stop discovery commands Grzegorz Kolodziejczyk
2017-12-28 13:11 ` [PATCH BlueZ v3 5/5] tools/btpclient: Add set connectable command Grzegorz Kolodziejczyk
2018-01-02  9:20 ` [PATCH BlueZ v3 1/5] tools/btpclient: Move string to address conversion to helper Szymon Janc

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).