diff options
Diffstat (limited to 'plugins/bluetooth.c')
-rw-r--r-- | plugins/bluetooth.c | 22 |
1 files changed, 22 insertions, 0 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, |