Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Device Address

Bluetooth device address definitions and utilities. More...

Data Structures

struct  bt_addr_t
 Bluetooth Device Address. More...
 
struct  bt_addr_le_t
 Bluetooth LE Device Address. More...
 

Macros

#define BT_ADDR_LE_PUBLIC   0x00
 
#define BT_ADDR_LE_RANDOM   0x01
 
#define BT_ADDR_LE_PUBLIC_ID   0x02
 
#define BT_ADDR_LE_RANDOM_ID   0x03
 
#define BT_ADDR_LE_UNRESOLVED
 
#define BT_ADDR_LE_ANONYMOUS
 
#define BT_ADDR_SIZE   6
 Length in bytes of a standard Bluetooth address.
 
#define BT_ADDR_LE_SIZE   7
 Length in bytes of an LE Bluetooth address.
 
#define BT_ADDR_ANY   (&bt_addr_any)
 Bluetooth device "any" address, not a valid address.
 
#define BT_ADDR_NONE   (&bt_addr_none)
 Bluetooth device "none" address, not a valid address.
 
#define BT_ADDR_LE_ANY   (&bt_addr_le_any)
 Bluetooth LE device "any" address, not a valid address.
 
#define BT_ADDR_LE_NONE   (&bt_addr_le_none)
 Bluetooth LE device "none" address, not a valid address.
 
#define BT_ADDR_IS_RPA(a)   (((a)->val[5] & 0xc0) == 0x40)
 Check if a Bluetooth LE random address is resolvable private address.
 
#define BT_ADDR_IS_NRPA(a)   (((a)->val[5] & 0xc0) == 0x00)
 Check if a Bluetooth LE random address is a non-resolvable private address.
 
#define BT_ADDR_IS_STATIC(a)   (((a)->val[5] & 0xc0) == 0xc0)
 Check if a Bluetooth LE random address is a static address.
 
#define BT_ADDR_SET_RPA(a)   ((a)->val[5] = (((a)->val[5] & 0x3f) | 0x40))
 Set a Bluetooth LE random address as a resolvable private address.
 
#define BT_ADDR_SET_NRPA(a)   ((a)->val[5] &= 0x3f)
 Set a Bluetooth LE random address as a non-resolvable private address.
 
#define BT_ADDR_SET_STATIC(a)   ((a)->val[5] |= 0xc0)
 Set a Bluetooth LE random address as a static address.
 
#define BT_ADDR_STR_LEN   18
 Recommended length of user string buffer for Bluetooth address.
 
#define BT_ADDR_LE_STR_LEN   30
 Recommended length of user string buffer for Bluetooth LE address.
 

Functions

static int bt_addr_cmp (const bt_addr_t *a, const bt_addr_t *b)
 Compare Bluetooth device addresses.
 
static bool bt_addr_eq (const bt_addr_t *a, const bt_addr_t *b)
 Determine equality of two Bluetooth device addresses.
 
static int bt_addr_le_cmp (const bt_addr_le_t *a, const bt_addr_le_t *b)
 Compare Bluetooth LE device addresses.
 
static bool bt_addr_le_eq (const bt_addr_le_t *a, const bt_addr_le_t *b)
 Determine equality of two Bluetooth LE device addresses.
 
static void bt_addr_copy (bt_addr_t *dst, const bt_addr_t *src)
 Copy Bluetooth device address.
 
static void bt_addr_le_copy (bt_addr_le_t *dst, const bt_addr_le_t *src)
 Copy Bluetooth LE device address.
 
int bt_addr_le_create_nrpa (bt_addr_le_t *addr)
 Create a Bluetooth LE random non-resolvable private address.
 
int bt_addr_le_create_static (bt_addr_le_t *addr)
 Create a Bluetooth LE random static address.
 
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.
 
static bool bt_addr_le_is_identity (const bt_addr_le_t *addr)
 Check if a Bluetooth LE address is valid identity address.
 
static int bt_addr_to_str (const bt_addr_t *addr, char *str, size_t len)
 Converts binary Bluetooth address to string.
 
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.
 
int bt_addr_from_str (const char *str, bt_addr_t *addr)
 Convert Bluetooth address from string to binary.
 
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.
 

Variables

const bt_addr_t bt_addr_any
 
const bt_addr_t bt_addr_none
 
const bt_addr_le_t bt_addr_le_any
 
const bt_addr_le_t bt_addr_le_none
 

Detailed Description

Bluetooth device address definitions and utilities.

Macro Definition Documentation

◆ BT_ADDR_ANY

#define BT_ADDR_ANY   (&bt_addr_any)

#include <zephyr/bluetooth/addr.h>

Bluetooth device "any" address, not a valid address.

◆ BT_ADDR_IS_NRPA

#define BT_ADDR_IS_NRPA (   a)    (((a)->val[5] & 0xc0) == 0x00)

#include <zephyr/bluetooth/addr.h>

Check if a Bluetooth LE random address is a non-resolvable private address.

◆ BT_ADDR_IS_RPA

#define BT_ADDR_IS_RPA (   a)    (((a)->val[5] & 0xc0) == 0x40)

#include <zephyr/bluetooth/addr.h>

Check if a Bluetooth LE random address is resolvable private address.

◆ BT_ADDR_IS_STATIC

#define BT_ADDR_IS_STATIC (   a)    (((a)->val[5] & 0xc0) == 0xc0)

#include <zephyr/bluetooth/addr.h>

Check if a Bluetooth LE random address is a static address.

◆ BT_ADDR_LE_ANONYMOUS

#define BT_ADDR_LE_ANONYMOUS

#include <zephyr/bluetooth/addr.h>

Value:
0xFF /* No address provided
* (anonymous advertisement)
*/

◆ BT_ADDR_LE_ANY

#define BT_ADDR_LE_ANY   (&bt_addr_le_any)

#include <zephyr/bluetooth/addr.h>

Bluetooth LE device "any" address, not a valid address.

◆ BT_ADDR_LE_NONE

#define BT_ADDR_LE_NONE   (&bt_addr_le_none)

#include <zephyr/bluetooth/addr.h>

Bluetooth LE device "none" address, not a valid address.

◆ BT_ADDR_LE_PUBLIC

#define BT_ADDR_LE_PUBLIC   0x00

◆ BT_ADDR_LE_PUBLIC_ID

#define BT_ADDR_LE_PUBLIC_ID   0x02

◆ BT_ADDR_LE_RANDOM

#define BT_ADDR_LE_RANDOM   0x01

◆ BT_ADDR_LE_RANDOM_ID

#define BT_ADDR_LE_RANDOM_ID   0x03

◆ BT_ADDR_LE_SIZE

#define BT_ADDR_LE_SIZE   7

#include <zephyr/bluetooth/addr.h>

Length in bytes of an LE Bluetooth address.

Not packed, so no sizeof()

◆ BT_ADDR_LE_STR_LEN

#define BT_ADDR_LE_STR_LEN   30

#include <zephyr/bluetooth/addr.h>

Recommended length of user string buffer for Bluetooth LE address.

The recommended length guarantee the output of address conversion will not lose valuable information about address being processed.

◆ BT_ADDR_LE_UNRESOLVED

#define BT_ADDR_LE_UNRESOLVED

#include <zephyr/bluetooth/addr.h>

Value:
0xFE /* Resolvable Private Address
* (Controller unable to resolve)
*/

◆ BT_ADDR_NONE

#define BT_ADDR_NONE   (&bt_addr_none)

#include <zephyr/bluetooth/addr.h>

Bluetooth device "none" address, not a valid address.

◆ BT_ADDR_SET_NRPA

#define BT_ADDR_SET_NRPA (   a)    ((a)->val[5] &= 0x3f)

#include <zephyr/bluetooth/addr.h>

Set a Bluetooth LE random address as a non-resolvable private address.

◆ BT_ADDR_SET_RPA

#define BT_ADDR_SET_RPA (   a)    ((a)->val[5] = (((a)->val[5] & 0x3f) | 0x40))

#include <zephyr/bluetooth/addr.h>

Set a Bluetooth LE random address as a resolvable private address.

◆ BT_ADDR_SET_STATIC

#define BT_ADDR_SET_STATIC (   a)    ((a)->val[5] |= 0xc0)

#include <zephyr/bluetooth/addr.h>

Set a Bluetooth LE random address as a static address.

◆ BT_ADDR_SIZE

#define BT_ADDR_SIZE   6

#include <zephyr/bluetooth/addr.h>

Length in bytes of a standard Bluetooth address.

◆ BT_ADDR_STR_LEN

#define BT_ADDR_STR_LEN   18

#include <zephyr/bluetooth/addr.h>

Recommended length of user string buffer for Bluetooth address.

The recommended length guarantee the output of address conversion will not lose valuable information about address being processed.

Function Documentation

◆ bt_addr_cmp()

static int bt_addr_cmp ( const bt_addr_t a,
const bt_addr_t b 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Compare Bluetooth device addresses.

Parameters
aFirst Bluetooth device address to compare
bSecond Bluetooth device address to compare
Returns
negative value if a < b, 0 if a == b, else positive

◆ bt_addr_copy()

static void bt_addr_copy ( bt_addr_t dst,
const bt_addr_t src 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Copy Bluetooth device address.

Parameters
dstBluetooth device address destination buffer.
srcBluetooth device address source buffer.

◆ bt_addr_eq()

static bool bt_addr_eq ( const bt_addr_t a,
const bt_addr_t b 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Determine equality of two Bluetooth device addresses.

Return values
trueif the two addresses are equal
falseotherwise

◆ bt_addr_from_str()

int bt_addr_from_str ( const char *  str,
bt_addr_t addr 
)

#include <zephyr/bluetooth/addr.h>

Convert Bluetooth address from string to binary.

Parameters
[in]strThe string representation of a Bluetooth address.
[out]addrAddress of buffer to store the Bluetooth address
Return values
0Success. The parsed address is stored in addr.
Returns
-EINVAL Invalid address string. str is not a well-formed Bluetooth address.

◆ bt_addr_le_cmp()

static int bt_addr_le_cmp ( const bt_addr_le_t a,
const bt_addr_le_t b 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Compare Bluetooth LE device addresses.

Parameters
aFirst Bluetooth LE device address to compare
bSecond Bluetooth LE device address to compare
Returns
negative value if a < b, 0 if a == b, else positive
See also
bt_addr_le_eq

◆ bt_addr_le_copy()

static void bt_addr_le_copy ( bt_addr_le_t dst,
const bt_addr_le_t src 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Copy Bluetooth LE device address.

Parameters
dstBluetooth LE device address destination buffer.
srcBluetooth LE device address source buffer.

◆ bt_addr_le_create_nrpa()

int bt_addr_le_create_nrpa ( bt_addr_le_t addr)

#include <zephyr/bluetooth/addr.h>

Create a Bluetooth LE random non-resolvable private address.

◆ bt_addr_le_create_static()

int bt_addr_le_create_static ( bt_addr_le_t addr)

#include <zephyr/bluetooth/addr.h>

Create a Bluetooth LE random static address.

◆ bt_addr_le_eq()

static bool bt_addr_le_eq ( const bt_addr_le_t a,
const bt_addr_le_t b 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Determine equality of two Bluetooth LE device addresses.

The Bluetooth LE addresses are equal iff both the types and the 48-bit addresses are numerically equal.

Return values
trueif the two addresses are equal
falseotherwise

◆ bt_addr_le_from_str()

int bt_addr_le_from_str ( const char *  str,
const char *  type,
bt_addr_le_t addr 
)

#include <zephyr/bluetooth/addr.h>

Convert LE Bluetooth address from string to binary.

Parameters
[in]strThe string representation of an LE Bluetooth address.
[in]typeThe string representation of the LE Bluetooth address type.
[out]addrAddress of buffer to store the LE Bluetooth address
Returns
Zero on success or (negative) error code otherwise.

◆ bt_addr_le_is_identity()

static bool bt_addr_le_is_identity ( const bt_addr_le_t addr)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Check if a Bluetooth LE address is valid identity address.

Valid Bluetooth LE identity addresses are either public address or random static address.

Parameters
addrBluetooth LE device address.
Returns
true if address is a valid identity address.

◆ bt_addr_le_is_rpa()

static bool bt_addr_le_is_rpa ( const bt_addr_le_t addr)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Check if a Bluetooth LE address is a random private resolvable address.

Parameters
addrBluetooth LE device address.
Returns
true if address is a random private resolvable address.

◆ bt_addr_le_to_str()

static int bt_addr_le_to_str ( const bt_addr_le_t addr,
char *  str,
size_t  len 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Converts binary LE Bluetooth address to string.

Parameters
addrAddress of buffer containing binary LE Bluetooth address.
strAddress of user buffer with enough room to store formatted string containing binary LE address.
lenLength of data to be copied to user string buffer. Refer to BT_ADDR_LE_STR_LEN about recommended value.
Returns
Number of successfully formatted bytes from binary address.

◆ bt_addr_to_str()

static int bt_addr_to_str ( const bt_addr_t addr,
char *  str,
size_t  len 
)
inlinestatic

#include <zephyr/bluetooth/addr.h>

Converts binary Bluetooth address to string.

Parameters
addrAddress of buffer containing binary Bluetooth address.
strAddress of user buffer with enough room to store formatted string containing binary address.
lenLength of data to be copied to user string buffer. Refer to BT_ADDR_STR_LEN about recommended value.
Returns
Number of successfully formatted bytes from binary address.

Variable Documentation

◆ bt_addr_any

const bt_addr_t bt_addr_any
extern

◆ bt_addr_le_any

const bt_addr_le_t bt_addr_le_any
extern

◆ bt_addr_le_none

const bt_addr_le_t bt_addr_le_none
extern

◆ bt_addr_none

const bt_addr_t bt_addr_none
extern