summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/bluetooth.c22
-rw-r--r--plugins/bluetooth.h3
-rw-r--r--plugins/hfp.c25
3 files changed, 26 insertions, 24 deletions
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 254fe5be..20621dfc 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -40,6 +40,28 @@ static DBusConnection *connection;
static GHashTable *uuid_hash = NULL;
static GHashTable *adapter_address_hash = NULL;
+void bluetooth_create_path(const char *dev_addr, const char *adapter_addr, char *buf, int size)
+{
+ int i, j;
+
+ for (i = 0, j = 0; adapter_addr[j] && i < size - 1; j++)
+ if (adapter_addr[j] >= '0' && adapter_addr[j] <= '9')
+ buf[i++] = adapter_addr[j];
+ else if (adapter_addr[j] >= 'A' && adapter_addr[j] <= 'F')
+ buf[i++] = adapter_addr[j];
+
+ if (i < size - 1)
+ buf[i++] = '_';
+
+ for (j = 0; dev_addr[j] && i < size - 1; j++)
+ if (dev_addr[j] >= '0' && dev_addr[j] <= '9')
+ buf[i++] = dev_addr[j];
+ else if (dev_addr[j] >= 'A' && dev_addr[j] <= 'F')
+ buf[i++] = dev_addr[j];
+
+ buf[i] = '\0';
+}
+
static int send_method_call_with_reply(const char *dest, const char *path,
const char *interface, const char *method,
DBusPendingCallNotifyFunction cb,
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 94ebaf69..430f4cf3 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -40,3 +40,6 @@ int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
+void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
+ char *buf, int size);
+
diff --git a/plugins/hfp.c b/plugins/hfp.c
index a49e4af6..4c72181a 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -566,29 +566,6 @@ static GDBusMethodTable agent_methods[] = {
{ NULL, NULL, NULL, NULL }
};
-static void create_path(const char *dev_addr, const char *adapter_addr,
- char *buf, int size)
-{
- int i, j;
-
- for (i = 0, j = 0; adapter_addr[j] && i < size - 1; j++)
- if (adapter_addr[j] >= '0' && adapter_addr[j] <= '9')
- buf[i++] = adapter_addr[j];
- else if (adapter_addr[j] >= 'A' && adapter_addr[j] <= 'F')
- buf[i++] = adapter_addr[j];
-
- if (i < size - 1)
- buf[i++] = '_';
-
- for (j = 0; dev_addr[j] && i < size - 1; j++)
- if (dev_addr[j] >= '0' && dev_addr[j] <= '9')
- buf[i++] = dev_addr[j];
- else if (dev_addr[j] >= 'A' && dev_addr[j] <= 'F')
- buf[i++] = dev_addr[j];
-
- buf[i] = '\0';
-}
-
static int hfp_create_modem(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
@@ -600,7 +577,7 @@ static int hfp_create_modem(const char *device, const char *dev_addr,
device, dev_addr, adapter_addr);
strcpy(buf, "hfp/");
- create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+ bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
modem = ofono_modem_create(buf, "hfp");
if (modem == NULL)