summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/glib-helper.c18
-rw-r--r--common/glib-helper.h3
-rw-r--r--serial/port.c14
3 files changed, 19 insertions, 16 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index 1812cc6d..17a8cb45 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -486,7 +486,7 @@ static struct {
{ }
};
-uint16_t bt_string2class(const char *pattern)
+uint16_t bt_name2class(const char *pattern)
{
int i;
@@ -498,6 +498,20 @@ uint16_t bt_string2class(const char *pattern)
return 0;
}
+char *bt_name2string(const char *pattern)
+{
+ uuid_t uuid;
+ uint16_t uuid16;
+
+ uuid16 = bt_name2class(pattern);
+ if (!uuid16)
+ return NULL;
+
+ sdp_uuid16_create(&uuid, uuid16);
+
+ return bt_uuid2string(&uuid);
+}
+
int bt_string2uuid(uuid_t *uuid, const char *string)
{
uint32_t data0, data4;
@@ -530,7 +544,7 @@ int bt_string2uuid(uuid_t *uuid, const char *string)
return 0;
} else {
- uint16_t class = bt_string2class(string);
+ uint16_t class = bt_name2class(string);
if (class) {
sdp_uuid16_create(uuid, class);
return 0;
diff --git a/common/glib-helper.h b/common/glib-helper.h
index ee63b2d7..794d296c 100644
--- a/common/glib-helper.h
+++ b/common/glib-helper.h
@@ -38,7 +38,8 @@ int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst,
int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst);
gchar *bt_uuid2string(uuid_t *uuid);
-uint16_t bt_string2class(const char *string);
+uint16_t bt_name2class(const char *string);
+char *bt_name2string(const char *string);
int bt_string2uuid(uuid_t *uuid, const char *string);
gchar *bt_list2string(GSList *list);
GSList *bt_string2list(const gchar *str);
diff --git a/serial/port.c b/serial/port.c
index c4fa644c..1f62b5e4 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -101,8 +101,6 @@ static struct serial_port *find_port(GSList *ports, const char *pattern)
for (l = ports; l != NULL; l = l->next) {
struct serial_port *port = l->data;
- uuid_t uuid;
- uint16_t uuid16;
char *uuid_str;
int ret;
@@ -112,17 +110,7 @@ static struct serial_port *find_port(GSList *ports, const char *pattern)
if (port->dev && !strcmp(port->dev, pattern))
return port;
- /* The following steps converts a potential friendly-name to a
- * UUID-128 string and compares it with the port UUID (which is
- * also stored as a UUID-128 string */
-
- uuid16 = bt_string2class(pattern);
- if (!uuid16)
- continue;
-
- sdp_uuid16_create(&uuid, uuid16);
-
- uuid_str = bt_uuid2string(&uuid);
+ uuid_str = bt_name2string(pattern);
if (!uuid_str)
continue;