10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_ADDR_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_ADDR_H_
28#define BT_ADDR_LE_PUBLIC 0x00
29#define BT_ADDR_LE_RANDOM 0x01
30#define BT_ADDR_LE_PUBLIC_ID 0x02
31#define BT_ADDR_LE_RANDOM_ID 0x03
32#define BT_ADDR_LE_UNRESOLVED 0xFE
35#define BT_ADDR_LE_ANONYMOUS 0xFF
49#define BT_ADDR_LE_SIZE 7
58#define BT_ADDR_ANY ((bt_addr_t[]) { { { 0, 0, 0, 0, 0, 0 } } })
60#define BT_ADDR_NONE ((bt_addr_t[]) { { \
61 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } } })
63#define BT_ADDR_LE_ANY ((bt_addr_le_t[]) { { 0, { { 0, 0, 0, 0, 0, 0 } } } })
65#define BT_ADDR_LE_NONE ((bt_addr_le_t[]) { { 0, \
66 { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } } } })
77 return memcmp(a, b,
sizeof(*a));
89 return memcmp(a, b,
sizeof(*a));
99 memcpy(dst, src,
sizeof(*dst));
113#define BT_ADDR_IS_RPA(a) (((a)->val[5] & 0xc0) == 0x40)
116#define BT_ADDR_IS_NRPA(a) (((a)->val[5] & 0xc0) == 0x00)
118#define BT_ADDR_IS_STATIC(a) (((a)->val[5] & 0xc0) == 0xc0)
121#define BT_ADDR_SET_RPA(a) ((a)->val[5] = (((a)->val[5] & 0x3f) | 0x40))
123#define BT_ADDR_SET_NRPA(a) ((a)->val[5] &= 0x3f)
125#define BT_ADDR_SET_STATIC(a) ((a)->val[5] |= 0xc0)
175#define BT_ADDR_STR_LEN 18
185#define BT_ADDR_LE_STR_LEN 30
199 return snprintk(str, len,
"%02X:%02X:%02X:%02X:%02X:%02X",
200 addr->
val[5], addr->
val[4], addr->
val[3],
201 addr->
val[2], addr->
val[1], addr->
val[0]);
219 switch (addr->
type) {
227 strcpy(type,
"public-id");
230 strcpy(type,
"random-id");
237 return snprintk(str, len,
"%02X:%02X:%02X:%02X:%02X:%02X (%s)",
#define BT_ADDR_IS_STATIC(a)
Definition: addr.h:114
static int bt_addr_to_str(const bt_addr_t *addr, char *str, size_t len)
Converts binary Bluetooth address to string.
Definition: addr.h:193
#define BT_ADDR_LE_PUBLIC
Definition: addr.h:28
#define BT_ADDR_LE_PUBLIC_ID
Definition: addr.h:30
int bt_addr_le_from_str(const char *str, const char *type, bt_addr_le_t *addr)
Convert LE Bluetooth address from string to binary.
#define BT_ADDR_IS_RPA(a)
Definition: addr.h:109
static int bt_addr_cmp(const bt_addr_t *a, const bt_addr_t *b)
Compare Bluetooth device addresses.
Definition: addr.h:71
static bool bt_addr_le_is_rpa(const bt_addr_le_t *addr)
Check if a Bluetooth LE address is a random private resolvable address.
Definition: addr.h:136
static int bt_addr_le_cmp(const bt_addr_le_t *a, const bt_addr_le_t *b)
Compare Bluetooth LE device addresses.
Definition: addr.h:83
static void bt_addr_copy(bt_addr_t *dst, const bt_addr_t *src)
Copy Bluetooth device address.
Definition: addr.h:93
#define BT_ADDR_SIZE
Definition: addr.h:36
#define BT_ADDR_LE_RANDOM
Definition: addr.h:29
static int bt_addr_le_to_str(const bt_addr_le_t *addr, char *str, size_t len)
Converts binary LE Bluetooth address to string.
Definition: addr.h:210
static bool bt_addr_le_is_identity(const bt_addr_le_t *addr)
Check if a Bluetooth LE address is valid identity address.
Definition: addr.h:154
static void bt_addr_le_copy(bt_addr_le_t *dst, const bt_addr_le_t *src)
Copy Bluetooth LE device address.
Definition: addr.h:103
int bt_addr_le_create_static(bt_addr_le_t *addr)
Create a Bluetooth LE random static address.
int bt_addr_from_str(const char *str, bt_addr_t *addr)
Convert Bluetooth address from string to binary.
int bt_addr_le_create_nrpa(bt_addr_le_t *addr)
Create a Bluetooth LE random non-resolvable private address.
#define BT_ADDR_LE_RANDOM_ID
Definition: addr.h:31
int snprintk(char *str, size_t size, const char *fmt,...)
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
char * strcpy(char *ZRESTRICT d, const char *ZRESTRICT s)
int memcmp(const void *m1, const void *m2, size_t n)
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
uint8_t type
Definition: addr.h:49
bt_addr_t a
Definition: addr.h:50
uint8_t val[6]
Definition: addr.h:40