Skip to content

Commit 1888e03

Browse files
HaavardReim-alperen-sener
authored andcommitted
[nrf fromtree] Bluetooth: testlib: Add addr string macro
Adds a macro returning a string representation of a Bluetooth address. This allows you to print multiple addresses in a single printk or LOG... call. Signed-off-by: Håvard Reierstad <[email protected]> (cherry picked from commit 997814c)
1 parent a8ac422 commit 1888e03

File tree

1 file changed

+14
-0
lines changed
  • tests/bluetooth/common/testlib/include/testlib

1 file changed

+14
-0
lines changed

tests/bluetooth/common/testlib/include/testlib/addr.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,18 @@
1717
.a = {{last, 0x00, 0x00, 0x00, 0x00, 0xc0}}, \
1818
})
1919

20+
static inline char *bt_testlib_get_addr_str(const bt_addr_le_t *addr,
21+
char addr_str[BT_ADDR_LE_STR_LEN])
22+
{
23+
bt_addr_le_to_str(addr, addr_str, BT_ADDR_LE_STR_LEN);
24+
25+
return addr_str;
26+
}
27+
28+
/** Macro to simplify printing of addresses. The returned pointer is valid until the end of the
29+
* scope this was called from, due to the use of a compound literal.
30+
*/
31+
#define bt_testlib_addr_to_str(addr) \
32+
bt_testlib_get_addr_str((addr), (char[BT_ADDR_LE_STR_LEN]) {0})
33+
2034
#endif /* ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_ADDR_H_ */

0 commit comments

Comments
 (0)