|
PebbleOS
|
Persistent BLE bondings, CCCDs and local Bluetooth settings. More...
Typedefs | |
| typedef void(* | BtPersistBondingChangeHandler) (pbl_bt_bonding_id_t affected_bonding, BtPersistBondingOp operation) |
| Handler of bonding database changes. | |
| typedef void(* | BtPersistBondingDBEachBLE) (struct pbl_bt_device_internal *device, struct pbl_bt_sm_key *irk, const char *name, pbl_bt_bonding_id_t *id, void *context) |
| Callback for bt_persistent_storage_for_each_ble_pairing(). | |
Enumerations | |
| enum | BtPersistBondingOp { BtPersistBondingOpInvalid = -1 , BtPersistBondingOpDidAdd , BtPersistBondingOpDidChange , BtPersistBondingOpWillDelete } |
| Change made to a bonding. More... | |
| enum | BtPersistBondingType { BtPersistBondingTypeBTClassic , BtPersistBondingTypeBLE , BtPersistBondingNumTypes } |
| Transport of a bonding. More... | |
Functions | |
| bool | bt_persistent_storage_has_pinned_ble_pairings (void) |
| Check whether any BLE bonding requires address pinning. | |
| bool | bt_persistent_storage_set_ble_pinned_address (const struct pbl_bt_addr *address) |
| Store the pinned local BLE address. | |
| bool | bt_persistent_storage_get_ble_pinned_address (struct pbl_bt_addr *address_out) |
| Get the pinned local BLE address. | |
| pbl_bt_bonding_id_t | bt_persistent_storage_store_ble_pairing (const struct pbl_bt_sm_pairing_info *pairing_info, bool is_gateway, const char *device_name, bool requires_address_pinning, uint8_t flags) |
| Add or update a BLE bonding. | |
| bool | bt_persistent_storage_update_ble_device_name (pbl_bt_bonding_id_t bonding, const char *device_name) |
| Update the name of a BLE bonding. | |
| void | bt_persistent_storage_delete_ble_pairing_by_id (pbl_bt_bonding_id_t) |
| Delete the BLE bonding with the given ID, with its CCCDs. | |
| void | bt_persistent_storage_delete_ble_pairing_by_addr (const struct pbl_bt_device_internal *device) |
| Delete the BLE bonding with an identity address, with its CCCDs. | |
| bool | bt_persistent_storage_get_ble_pairing_by_id (pbl_bt_bonding_id_t bonding, struct pbl_bt_sm_key *IRK_out, struct pbl_bt_device_internal *device_out, char *name_out) |
| Look up a BLE bonding by ID. | |
| bool | bt_persistent_storage_get_ble_pairing_by_addr (const struct pbl_bt_device_internal *device, struct pbl_bt_sm_key *IRK_out, char name_out[PBL_BT_DEVICE_NAME_BUFFER_SIZE]) |
| Look up a BLE bonding by identity address. | |
| pbl_bt_bonding_id_t | bt_persistent_storage_get_ble_ancs_bonding (void) |
| Get the first BLE bonding that supports ANCS. | |
| bool | bt_persistent_storage_is_ble_ancs_bonding (pbl_bt_bonding_id_t bonding) |
| Check whether a bonding is a BLE bonding that supports ANCS. | |
| bool | bt_persistent_storage_has_ble_ancs_bonding (void) |
| Check whether any BLE bonding supports ANCS. | |
| bool | bt_persistent_storage_has_active_ble_gateway_bonding (void) |
| Check whether the active gateway is a BLE bonding. | |
| void | bt_persistent_storage_for_each_ble_pairing (BtPersistBondingDBEachBLE cb, void *context) |
| Call a function for each BLE bonding. | |
| void | bt_persistent_storage_register_existing_ble_bondings (void) |
| Register all stored BLE bondings and CCCDs with the Bluetooth driver. | |
| pbl_bt_cccd_id_t | bt_persistent_storage_store_cccd (const struct pbl_bt_cccd *cccd) |
| Store a CCCD, replacing the one for the same peer and characteristic. | |
| bool | bt_persistent_storage_delete_cccd (const struct pbl_bt_device_internal *peer, uint16_t chr_val_handle) |
| Delete a stored CCCD. | |
| void | bt_persistent_storage_set_active_gateway (pbl_bt_bonding_id_t bonding) |
| Set the active gateway, the bonding that implements Pebble Protocol. | |
| bool | bt_persistent_storage_get_active_gateway (pbl_bt_bonding_id_t *bonding_out, BtPersistBondingType *type_out) |
| Get the active gateway. | |
| bool | bt_persistent_storage_is_unfaithful (void) |
| Check whether the watch is unfaithful. | |
| void | bt_persistent_storage_set_unfaithful (bool is_unfaithful) |
| Set whether the watch is unfaithful. | |
| bool | bt_persistent_storage_get_root_key (enum pbl_bt_sm_root_key_type key_type, struct pbl_bt_sm_key *key_out) |
| Get a BLE root key. | |
| void | bt_persistent_storage_set_root_keys (struct pbl_bt_sm_key *keys_in) |
| Store the BLE root keys. | |
| bool | bt_persistent_storage_get_local_device_name (char *local_device_name_out, size_t max_size) |
| Get the stored local device name. | |
| void | bt_persistent_storage_set_local_device_name (char *local_device_name, size_t max_size) |
| Store the local device name. | |
| bool | bt_persistent_storage_get_airplane_mode_enabled (void) |
| Get the stored airplane mode setting. | |
| void | bt_persistent_storage_set_airplane_mode_enabled (bool enable) |
| Store the airplane mode setting. | |
| void | bt_persistent_storage_get_cached_system_capabilities (PebbleProtocolCapabilities *capabilities_out) |
| Get the cached capabilities of the last system session. | |
| void | bt_persistent_storage_set_cached_system_capabilities (const PebbleProtocolCapabilities *capabilities) |
| Cache the capabilities of the system session. | |
| void | bt_persistent_storage_init (void) |
| Initialize the database, before the Bluetooth stack starts. | |
| void | bt_persistent_storage_delete_all_pairings (void) |
| Delete all bondings, keeping the local device settings. | |
| int | bt_persistent_storage_get_raw_data (const void *key, size_t key_len, void *data_out, size_t buf_len) |
| Read a raw database record, for unit tests. | |
Persistent BLE bondings, CCCDs and local Bluetooth settings.
Normal firmware keeps them in a settings file and mirrors the gateway pairing, root keys, device name and pinned address to shared PRF storage. Recovery firmware uses shared PRF storage directly, with a single bonding slot. Only one BLE bonding is kept: storing a new one replaces the others.
Bonding changes are announced on KernelMain to the address, connection and client modules.
| typedef void(* BtPersistBondingChangeHandler) (pbl_bt_bonding_id_t affected_bonding, BtPersistBondingOp operation) |
Handler of bonding database changes.
| affected_bonding | Bonding that changed. |
| operation | Change made. |
| typedef void(* BtPersistBondingDBEachBLE) (struct pbl_bt_device_internal *device, struct pbl_bt_sm_key *irk, const char *name, pbl_bt_bonding_id_t *id, void *context) |
Callback for bt_persistent_storage_for_each_ble_pairing().
| device | Remote identity address. |
| irk | Remote identity resolving key. |
| name | Remote device name. |
| id | Bonding ID. |
| context | User context. |
| enum BtPersistBondingOp |
| enum BtPersistBondingType |
| void bt_persistent_storage_delete_all_pairings | ( | void | ) |
Delete all bondings, keeping the local device settings.
| void bt_persistent_storage_delete_ble_pairing_by_addr | ( | const struct pbl_bt_device_internal * | device | ) |
Delete the BLE bonding with an identity address, with its CCCDs.
| device | Remote identity address. |
| void bt_persistent_storage_delete_ble_pairing_by_id | ( | pbl_bt_bonding_id_t | ) |
Delete the BLE bonding with the given ID, with its CCCDs.
| bool bt_persistent_storage_delete_cccd | ( | const struct pbl_bt_device_internal * | peer, |
| uint16_t | chr_val_handle | ||
| ) |
Delete a stored CCCD.
| peer | Peer identity address. |
| chr_val_handle | Characteristic value handle. |
| void bt_persistent_storage_for_each_ble_pairing | ( | BtPersistBondingDBEachBLE | cb, |
| void * | context | ||
| ) |
Call a function for each BLE bonding.
cb must not take bt_lock(), or it may deadlock.
| cb | Callback. |
| context | User context passed to cb. |
| bool bt_persistent_storage_get_active_gateway | ( | pbl_bt_bonding_id_t * | bonding_out, |
| BtPersistBondingType * | type_out | ||
| ) |
Get the active gateway.
| [out] | bonding_out | Bonding ID, may be NULL. |
| [out] | type_out | Bonding type, may be NULL. |
| bool bt_persistent_storage_get_airplane_mode_enabled | ( | void | ) |
Get the stored airplane mode setting.
| pbl_bt_bonding_id_t bt_persistent_storage_get_ble_ancs_bonding | ( | void | ) |
Get the first BLE bonding that supports ANCS.
PBL_BT_BONDING_ID_INVALID if none. | bool bt_persistent_storage_get_ble_pairing_by_addr | ( | const struct pbl_bt_device_internal * | device, |
| struct pbl_bt_sm_key * | IRK_out, | ||
| char | name_out[PBL_BT_DEVICE_NAME_BUFFER_SIZE] | ||
| ) |
Look up a BLE bonding by identity address.
| device | Remote identity address. | |
| [out] | IRK_out | Remote identity resolving key, may be NULL. |
| [out] | name_out | Remote name, may be NULL. |
| bool bt_persistent_storage_get_ble_pairing_by_id | ( | pbl_bt_bonding_id_t | bonding, |
| struct pbl_bt_sm_key * | IRK_out, | ||
| struct pbl_bt_device_internal * | device_out, | ||
| char * | name_out | ||
| ) |
Look up a BLE bonding by ID.
| bonding | Bonding ID. | |
| [out] | IRK_out | Remote identity resolving key, may be NULL. |
| [out] | device_out | Remote identity address, may be NULL. |
| [out] | name_out | Remote name, PBL_BT_DEVICE_NAME_BUFFER_SIZE bytes, may be NULL. |
| bool bt_persistent_storage_get_ble_pinned_address | ( | struct pbl_bt_addr * | address_out | ) |
Get the pinned local BLE address.
| [out] | address_out | Pinned address, may be NULL. |
| void bt_persistent_storage_get_cached_system_capabilities | ( | PebbleProtocolCapabilities * | capabilities_out | ) |
Get the cached capabilities of the last system session.
Prefer comm_session_get_capabilities() when connected.
| [out] | capabilities_out | Capabilities, zero if none cached. Ignored if NULL. |
| bool bt_persistent_storage_get_local_device_name | ( | char * | local_device_name_out, |
| size_t | max_size | ||
| ) |
Get the stored local device name.
| [out] | local_device_name_out | Destination buffer. |
| max_size | Size of local_device_name_out in bytes. |
| int bt_persistent_storage_get_raw_data | ( | const void * | key, |
| size_t | key_len, | ||
| void * | data_out, | ||
| size_t | buf_len | ||
| ) |
Read a raw database record, for unit tests.
| key | Record key. | |
| key_len | Length of key in bytes. | |
| [out] | data_out | Destination buffer. |
| buf_len | Size of data_out in bytes. |
| bool bt_persistent_storage_get_root_key | ( | enum pbl_bt_sm_root_key_type | key_type, |
| struct pbl_bt_sm_key * | key_out | ||
| ) |
Get a BLE root key.
| key_type | Encryption root (ER) or identity root (IR). | |
| [out] | key_out | Key, may be NULL. |
| bool bt_persistent_storage_has_active_ble_gateway_bonding | ( | void | ) |
Check whether the active gateway is a BLE bonding.
| bool bt_persistent_storage_has_ble_ancs_bonding | ( | void | ) |
Check whether any BLE bonding supports ANCS.
| bool bt_persistent_storage_has_pinned_ble_pairings | ( | void | ) |
Check whether any BLE bonding requires address pinning.
| void bt_persistent_storage_init | ( | void | ) |
Initialize the database, before the Bluetooth stack starts.
Merges data from shared PRF storage and loads the cached capabilities.
| bool bt_persistent_storage_is_ble_ancs_bonding | ( | pbl_bt_bonding_id_t | bonding | ) |
Check whether a bonding is a BLE bonding that supports ANCS.
| bonding | Bonding ID. |
| bool bt_persistent_storage_is_unfaithful | ( | void | ) |
Check whether the watch is unfaithful.
The watch becomes unfaithful when its gateway changes, until the next sync.
| void bt_persistent_storage_register_existing_ble_bondings | ( | void | ) |
Register all stored BLE bondings and CCCDs with the Bluetooth driver.
| void bt_persistent_storage_set_active_gateway | ( | pbl_bt_bonding_id_t | bonding | ) |
Set the active gateway, the bonding that implements Pebble Protocol.
On change, marks the watch unfaithful and clears the cached system capabilities.
| bonding | Bonding ID. |
| void bt_persistent_storage_set_airplane_mode_enabled | ( | bool | enable | ) |
Store the airplane mode setting.
| enable | Airplane mode state. |
| bool bt_persistent_storage_set_ble_pinned_address | ( | const struct pbl_bt_addr * | address | ) |
| void bt_persistent_storage_set_cached_system_capabilities | ( | const PebbleProtocolCapabilities * | capabilities | ) |
Cache the capabilities of the system session.
When they change, they are persisted and a capabilities changed event is emitted.
| capabilities | Capabilities, or NULL to clear the cache. |
| void bt_persistent_storage_set_local_device_name | ( | char * | local_device_name, |
| size_t | max_size | ||
| ) |
Store the local device name.
| local_device_name | Name to store. Ignored if NULL. |
| max_size | Number of bytes to store. |
| void bt_persistent_storage_set_root_keys | ( | struct pbl_bt_sm_key * | keys_in | ) |
Store the BLE root keys.
| keys_in | Array of PBL_BT_SM_ROOT_KEY_TYPE_NUM keys, indexed by key type. Ignored if NULL. |
| void bt_persistent_storage_set_unfaithful | ( | bool | is_unfaithful | ) |
Set whether the watch is unfaithful.
| is_unfaithful | New state. |
| pbl_bt_bonding_id_t bt_persistent_storage_store_ble_pairing | ( | const struct pbl_bt_sm_pairing_info * | pairing_info, |
| bool | is_gateway, | ||
| const char * | device_name, | ||
| bool | requires_address_pinning, | ||
| uint8_t | flags | ||
| ) |
Add or update a BLE bonding.
An existing bonding with the same identity is updated; otherwise a new one is added, the watch is marked unfaithful and any other BLE bonding is deleted.
| pairing_info | Pairing info; empty pairing info is rejected. |
| is_gateway | True if the device is the phone running the Pebble app. |
| device_name | Remote device name, may be NULL. |
| requires_address_pinning | True if the remote needs a stable local address. |
| flags | Bonding flags, passed back to the Bluetooth driver. |
PBL_BT_BONDING_ID_INVALID on failure. | pbl_bt_cccd_id_t bt_persistent_storage_store_cccd | ( | const struct pbl_bt_cccd * | cccd | ) |
Store a CCCD, replacing the one for the same peer and characteristic.
| cccd | CCCD to store. |
PBL_BT_CCCD_ID_INVALID on failure. | bool bt_persistent_storage_update_ble_device_name | ( | pbl_bt_bonding_id_t | bonding, |
| const char * | device_name | ||
| ) |
Update the name of a BLE bonding.
| bonding | Bonding ID. |
| device_name | New name. |