From 51ac4f530ab298995682e482406cf344484a1034 Mon Sep 17 00:00:00 2001 From: Oliver Ruiz Dorantes Date: Mon, 30 Jun 2008 21:43:21 +0000 Subject: [PATCH] Patch by Mika Lindqvist FromString Implementation for the bdaddr utils class git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26182 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/bluetooth/bdaddrUtils.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/headers/os/bluetooth/bdaddrUtils.h b/headers/os/bluetooth/bdaddrUtils.h index 710c99458b..140fb0e70b 100644 --- a/headers/os/bluetooth/bdaddrUtils.h +++ b/headers/os/bluetooth/bdaddrUtils.h @@ -15,7 +15,7 @@ namespace Bluetooth { class bdaddrUtils { - + public: static inline bdaddr_t NullAddress() { @@ -58,7 +58,24 @@ class bdaddrUtils { return str; } - + + static bdaddr_t FromString(const char * addr) + { + int b0, b1, b2, b3, b4, b5; + size_t count = sscanf(addr, "%2X:%2X:%2X:%2X:%2X:%2X", + &b0, + &b1, + &b2, + &b3, + &b4, + &b5); + + if (count == 6) + return ((bdaddr_t) {{b0, b1, b2, b3, b4, b5}}); + + return NullAddress(); + } + }; }