PebbleOS
Loading...
Searching...
No Matches
Modules | Functions
Bluetooth utilities

Stack independent helpers for Bluetooth devices, UUIDs and pairing data (lib/btutil). More...

Modules

 Bluetooth UUIDs
 Expand 16-bit and 32-bit Bluetooth UUIDs to 128 bits.
 
 Pairing information helpers
 Compare and inspect struct pbl_bt_sm_pairing_info.
 

Functions

struct pbl_bt_device bt_device_init_with_address (struct pbl_bt_addr address, bool is_random)
 Create an LE device from its address.
 
struct pbl_bt_addr bt_device_get_address (struct pbl_bt_device device)
 Get the address of a device.
 
bool bt_device_address_equal (const struct pbl_bt_addr *addr1, const struct pbl_bt_addr *addr2)
 Compare two addresses.
 
bool bt_device_address_is_invalid (const struct pbl_bt_addr *addr)
 Check whether an address is invalid.
 
bool bt_device_internal_equal (const struct pbl_bt_device_internal *device1_int, const struct pbl_bt_device_internal *device2_int)
 Compare two devices: address, address type and transport.
 
bool bt_device_equal (const struct pbl_bt_device *device1, const struct pbl_bt_device *device2)
 Compare two devices, see bt_device_internal_equal().
 
bool bt_device_is_invalid (const struct pbl_bt_device *device)
 Check whether a device is invalid, such as one returned by an API that found no device.
 

Detailed Description

Stack independent helpers for Bluetooth devices, UUIDs and pairing data (lib/btutil).

struct pbl_bt_device dev = bt_device_init_with_address(addr, false);
if (!bt_device_is_invalid(&dev)) {
}
Uuid hrs = bt_uuid_expand_16bit(0x180D); // 0000180D-0000-1000-8000-00805F9B34FB
Remote Bluetooth device, as exposed to applications.
Definition types.h:302
Bluetooth device address.
Definition types.h:251
#define PBL_BT_ADDR_FMT
printf() format of an address, as XX:XX:XX:XX:XX:XX.
Definition types.h:264
#define PBL_BT_ADDR_XPLODE(a)
Expand an address into the printf() arguments of PBL_BT_ADDR_FMT, most significant octet first.
Definition types.h:286
Uuid bt_uuid_expand_16bit(uint16_t uuid16)
Expand a 16-bit UUID with the Bluetooth Base UUID, 0000xxxx-0000-1000-8000-00805F9B34FB.
bool bt_device_is_invalid(const struct pbl_bt_device *device)
Check whether a device is invalid, such as one returned by an API that found no device.
struct pbl_bt_addr bt_device_get_address(struct pbl_bt_device device)
Get the address of a device.
struct pbl_bt_device bt_device_init_with_address(struct pbl_bt_addr address, bool is_random)
Create an LE device from its address.
#define PBL_LOG_DBG(fmt,...)
Log a routine debug message, possibly queued.
Definition logging.h:570
A 128-bit UUID, with its bytes in the order they are written in string form.
Definition uuid.h:32

Function Documentation

◆ bt_device_address_equal()

bool bt_device_address_equal ( const struct pbl_bt_addr *  addr1,
const struct pbl_bt_addr *  addr2 
)

Compare two addresses.

Parameters
addr1First address, may be NULL.
addr2Second address, may be NULL.
Returns
true if both are non-NULL and equal.

◆ bt_device_address_is_invalid()

bool bt_device_address_is_invalid ( const struct pbl_bt_addr *  addr)

Check whether an address is invalid.

Parameters
addrThe address, may be NULL.
Returns
true if addr is NULL or all zeros.

◆ bt_device_equal()

bool bt_device_equal ( const struct pbl_bt_device *  device1,
const struct pbl_bt_device *  device2 
)

Compare two devices, see bt_device_internal_equal().

Parameters
device1First device, may be NULL.
device2Second device, may be NULL.
Returns
true if both are non-NULL and refer to the same device.

◆ bt_device_get_address()

struct pbl_bt_addr bt_device_get_address ( struct pbl_bt_device  device)

Get the address of a device.

Parameters
deviceThe device.
Returns
The address.

◆ bt_device_init_with_address()

struct pbl_bt_device bt_device_init_with_address ( struct pbl_bt_addr  address,
bool  is_random 
)

Create an LE device from its address.

Parameters
addressThe address.
is_randomtrue for a random address, false for the public address (BD_ADDR).
Returns
The device.

◆ bt_device_internal_equal()

bool bt_device_internal_equal ( const struct pbl_bt_device_internal *  device1_int,
const struct pbl_bt_device_internal *  device2_int 
)

Compare two devices: address, address type and transport.

Parameters
device1_intFirst device, may be NULL.
device2_intSecond device, may be NULL.
Returns
true if both are non-NULL and refer to the same device.

◆ bt_device_is_invalid()

bool bt_device_is_invalid ( const struct pbl_bt_device *  device)

Check whether a device is invalid, such as one returned by an API that found no device.

Parameters
deviceThe device.
Returns
true if device equals PBL_BT_DEVICE_INVALID.