summaryrefslogtreecommitdiff
path: root/lib/bluetooth.c
diff options
context:
space:
mode:
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>2019-12-02 17:03:57 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2019-12-03 18:36:34 +0200
commitcf48a5870a7044c66821238fd83df707096114b0 (patch)
tree3df644c88ae6f2779392632f60a7cb1364d1f3c7 /lib/bluetooth.c
parent73401290cfe79853d4957a2d603237b1e73c4b71 (diff)
downloadbluez-cf48a5870a7044c66821238fd83df707096114b0.tar.gz
lib: Add ba2strlc to match kernel printk format
When the kernel prints the bluetooth address (via %pMR), it prints the address in lower case. ba2strlc should be used in cases where we should match the kernel casing (i.e. addresses assigned to /dev/uhid and /dev/uinput)
Diffstat (limited to 'lib/bluetooth.c')
-rw-r--r--lib/bluetooth.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/bluetooth.c b/lib/bluetooth.c
index effc7f49d..7cba509d8 100644
--- a/lib/bluetooth.c
+++ b/lib/bluetooth.c
@@ -81,6 +81,13 @@ int ba2str(const bdaddr_t *ba, char *str)
ba->b[5], ba->b[4], ba->b[3], ba->b[2], ba->b[1], ba->b[0]);
}
+/* Match kernel's lowercase printing of mac address (%pMR) */
+int ba2strlc(const bdaddr_t *ba, char *str)
+{
+ return sprintf(str, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
+ ba->b[5], ba->b[4], ba->b[3], ba->b[2], ba->b[1], ba->b[0]);
+}
+
int str2ba(const char *str, bdaddr_t *ba)
{
int i;