Skip to content

Commit c77587a

Browse files
HaavardReikartben
authored andcommitted
Bluetooth: Host: Clarify use of identity in docs
Clarifies the use of identity in `bluetooth.h` by specifying whether the documentation refers to the identity address, i. e. the actual address `bt_addr_le_t`, or the identity handle, i. e. an index corresponding to a specific identity address. Signed-off-by: Håvard Reierstad <[email protected]>
1 parent a924b13 commit c77587a

File tree

2 files changed

+67
-71
lines changed

2 files changed

+67
-71
lines changed

include/zephyr/bluetooth/bluetooth.h

+65-69
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ extern "C" {
6161
*/
6262

6363
/**
64-
* Convenience macro for specifying the default identity. This helps
65-
* make the code more readable, especially when only one identity is
66-
* supported.
64+
* Identity handle referring to the first identity address. This is a convenience macro for
65+
* specifying the default identity address. This helps make the code more readable, especially when
66+
* only one identity address is supported.
6767
*/
6868
#define BT_ID_DEFAULT 0
6969

@@ -316,7 +316,7 @@ int bt_enable(bt_ready_cb_t cb);
316316
*
317317
* Disable Bluetooth. Can't be called before bt_enable has completed.
318318
*
319-
* This API will clear all configured identities and keys that are not persistently
319+
* This API will clear all configured identity addresses and keys that are not persistently
320320
* stored with @kconfig{CONFIG_BT_SETTINGS}. These can be restored
321321
* with settings_load() before reenabling the stack.
322322
*
@@ -396,36 +396,35 @@ uint16_t bt_get_appearance(void);
396396
int bt_set_appearance(uint16_t new_appearance);
397397

398398
/**
399-
* @brief Get the currently configured identities.
399+
* @brief Get the currently configured identity addresses.
400400
*
401401
* Returns an array of the currently configured identity addresses. To
402-
* make sure all available identities can be retrieved, the number of
402+
* make sure all available identity addresses can be retrieved, the number of
403403
* elements in the @a addrs array should be CONFIG_BT_ID_MAX. The identity
404-
* identifier that some APIs expect (such as advertising parameters) is
405-
* simply the index of the identity in the @a addrs array.
404+
* handle that some APIs expect (such as @ref bt_le_adv_param) is
405+
* simply the index of the identity address in the @a addrs array.
406406
*
407-
* If @a addrs is passed as NULL, then returned @a count contains the
408-
* count of all available identities that can be retrieved with a
407+
* If @a addrs is passed as NULL, then the returned @a count contains the
408+
* count of all available identity addresses that can be retrieved with a
409409
* subsequent call to this function with non-NULL @a addrs parameter.
410410
*
411-
* @note Deleted identities may show up as @ref BT_ADDR_LE_ANY in the returned
412-
* array.
411+
* @note Deleted identity addresses may show up as @ref BT_ADDR_LE_ANY in the returned array.
413412
*
414-
* @param addrs Array where to store the configured identities.
415-
* @param count Should be initialized to the array size. Once the function
416-
* returns it will contain the number of returned identities.
413+
* @param addrs Array where to store the configured identity addresses.
414+
* @param count Should be initialized to the array size. Once the function returns
415+
* it will contain the number of returned identity addresses.
417416
*/
418417
void bt_id_get(bt_addr_le_t *addrs, size_t *count);
419418

420419
/**
421-
* @brief Create a new identity.
420+
* @brief Create a new identity address.
422421
*
423-
* Create a new identity using the given address and IRK. This function can be
424-
* called before calling bt_enable(). However, the new identity will only be
422+
* Create a new identity address using the given address and IRK. This function can be
423+
* called before calling bt_enable(). However, the new identity address will only be
425424
* stored persistently in flash when this API is used after bt_enable(). The
426425
* reason is that the persistent settings are loaded after bt_enable() and would
427426
* therefore cause potential conflicts with the stack blindly overwriting what's
428-
* stored in flash. The identity will also not be written to flash in case a
427+
* stored in flash. The identity address will also not be written to flash in case a
429428
* pre-defined address is provided, since in such a situation the app clearly
430429
* has some place it got the address from and will be able to repeat the
431430
* procedure on every power cycle, i.e. it would be redundant to also store the
@@ -434,11 +433,11 @@ void bt_id_get(bt_addr_le_t *addrs, size_t *count);
434433
* Generating random static address or random IRK is not supported when calling
435434
* this function before bt_enable().
436435
*
437-
* If the application wants to have the stack randomly generate identities
436+
* If the application wants to have the stack randomly generate identity addresses
438437
* and store them in flash for later recovery, the way to do it would be
439438
* to first initialize the stack (using bt_enable), then call settings_load(),
440-
* and after that check with bt_id_get() how many identities were recovered.
441-
* If an insufficient amount of identities were recovered the app may then
439+
* and after that check with bt_id_get() how many identity addresses were recovered.
440+
* If an insufficient amount of identity addresses were recovered the app may then
442441
* call bt_id_create() to create new ones.
443442
*
444443
* If supported by the HCI driver (indicated by setting
@@ -447,71 +446,66 @@ void bt_id_get(bt_addr_le_t *addrs, size_t *count);
447446
* before calling bt_enable(). Subsequent calls always add/generate random
448447
* static addresses.
449448
*
450-
* @param addr Address to use for the new identity. If NULL or initialized
451-
* to BT_ADDR_LE_ANY the stack will generate a new random
452-
* static address for the identity and copy it to the given
453-
* parameter upon return from this function (in case the
454-
* parameter was non-NULL).
449+
* @param addr Address to use for the new identity address. If NULL or initialized
450+
* to BT_ADDR_LE_ANY the stack will generate a new random static address
451+
* for the identity address and copy it to the given parameter upon return
452+
* from this function (in case the parameter was non-NULL).
455453
* @param irk Identity Resolving Key (16 bytes) to be used with this
456-
* identity. If set to all zeroes or NULL, the stack will
457-
* generate a random IRK for the identity and copy it back
454+
* identity address. If set to all zeroes or NULL, the stack will
455+
* generate a random IRK for the identity address and copy it back
458456
* to the parameter upon return from this function (in case
459457
* the parameter was non-NULL). If privacy
460458
* @kconfig{CONFIG_BT_PRIVACY} is not enabled this parameter must
461459
* be NULL.
462460
*
463-
* @return Identity identifier (>= 0) in case of success, or a negative
464-
* error code on failure.
461+
* @return Identity handle (>= 0) in case of success, or a negative error code on failure.
465462
*/
466463
int bt_id_create(bt_addr_le_t *addr, uint8_t *irk);
467464

468465
/**
469-
* @brief Reset/reclaim an identity for reuse.
466+
* @brief Reset/reclaim an identity address for reuse.
470467
*
471468
* The semantics of the @a addr and @a irk parameters of this function
472469
* are the same as with bt_id_create(). The difference is the first
473-
* @a id parameter that needs to be an existing identity (if it doesn't
474-
* exist this function will return an error). When given an existing
475-
* identity this function will disconnect any connections created using it,
476-
* remove any pairing keys or other data associated with it, and then create
477-
* a new identity in the same slot, based on the @a addr and @a irk
478-
* parameters.
479-
*
480-
* @note the default identity (BT_ID_DEFAULT) cannot be reset, i.e. this
470+
* @a id parameter that needs to be an existing identity handle (if it doesn't
471+
* exist this function will return an error). When given an existing identity handle
472+
* this function will disconnect any connections (to the corresponding identity address)
473+
* created using it, remove any pairing keys or other data associated with it, and then
474+
* create a new identity address in the same slot, based on the @a addr and @a irk parameters.
475+
*
476+
* @note The default identity address (corresponding to BT_ID_DEFAULT) cannot be reset, and this
481477
* API will return an error if asked to do that.
482478
*
483-
* @param id Existing identity identifier.
484-
* @param addr Address to use for the new identity. If NULL or initialized
485-
* to BT_ADDR_LE_ANY the stack will generate a new static
486-
* random address for the identity and copy it to the given
487-
* parameter upon return from this function (in case the
488-
* parameter was non-NULL).
479+
* @param id Existing identity handle.
480+
* @param addr Address to use for the new identity address. If NULL or initialized
481+
* to BT_ADDR_LE_ANY the stack will generate a new static random
482+
* address for the identity address and copy it to the given
483+
* parameter upon return from this function.
489484
* @param irk Identity Resolving Key (16 bytes) to be used with this
490-
* identity. If set to all zeroes or NULL, the stack will
491-
* generate a random IRK for the identity and copy it back
485+
* identity address. If set to all zeroes or NULL, the stack will
486+
* generate a random IRK for the identity address and copy it back
492487
* to the parameter upon return from this function (in case
493488
* the parameter was non-NULL). If privacy
494489
* @kconfig{CONFIG_BT_PRIVACY} is not enabled this parameter must
495490
* be NULL.
496491
*
497-
* @return Identity identifier (>= 0) in case of success, or a negative
498-
* error code on failure.
492+
* @return Identity handle (>= 0) in case of success, or a negative error code on failure.
499493
*/
500494
int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk);
501495

502496
/**
503-
* @brief Delete an identity.
497+
* @brief Delete an identity address.
504498
*
505-
* When given a valid identity this function will disconnect any connections
506-
* created using it, remove any pairing keys or other data associated with
507-
* it, and then flag is as deleted, so that it can not be used for any
508-
* operations. To take back into use the slot the identity was occupying the
509-
* bt_id_reset() API needs to be used.
499+
* When given a valid identity handle this function will disconnect any connections
500+
* (to the corresponding identity address) created using it, remove any pairing keys
501+
* or other data associated with it, and then flag is as deleted, so that it can not
502+
* be used for any operations. To take back into use the slot the identity address was
503+
* occupying, the bt_id_reset() API needs to be used.
510504
*
511-
* @note the default identity (BT_ID_DEFAULT) cannot be deleted, i.e. this
505+
* @note The default identity address (corresponding to BT_ID_DEFAULT) cannot be deleted, and this
512506
* API will return an error if asked to do that.
513507
*
514-
* @param id Existing identity identifier.
508+
* @param id Existing identity handle.
515509
*
516510
* @return 0 in case of success, or a negative error code on failure.
517511
*/
@@ -908,7 +902,7 @@ enum advertising_options {
908902
BT_LE_ADV_OPT_CODED = BIT(12),
909903

910904
/**
911-
* @brief Advertise without a device address (identity or RPA).
905+
* @brief Advertise without a device address (identity address or RPA).
912906
*
913907
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV bit (see @ref advertising_options field) to be
914908
* set as @ref bt_le_adv_param.options.
@@ -997,7 +991,9 @@ enum advertising_options {
997991
/** LE Advertising Parameters. */
998992
struct bt_le_adv_param {
999993
/**
1000-
* @brief Local identity.
994+
* @brief Local identity handle.
995+
*
996+
* The index of the identity address in the local Bluetooth controller.
1001997
*
1002998
* @note When extended advertising @kconfig{CONFIG_BT_EXT_ADV} is not
1003999
* enabled or not supported by the controller it is not possible
@@ -1714,7 +1710,7 @@ uint8_t bt_le_ext_adv_get_index(struct bt_le_ext_adv *adv);
17141710

17151711
/** @brief Advertising set info structure. */
17161712
struct bt_le_ext_adv_info {
1717-
/* Local identity */
1713+
/** Local identity handle. */
17181714
uint8_t id;
17191715

17201716
/** Currently selected Transmit Power (dBM). */
@@ -2748,7 +2744,7 @@ BUILD_ASSERT(BT_GAP_SCAN_FAST_WINDOW == BT_GAP_SCAN_FAST_INTERVAL_MIN,
27482744
*
27492745
* @note The LE scanner by default does not use the Identity Address of the
27502746
* local device when @kconfig{CONFIG_BT_PRIVACY} is disabled. This is to
2751-
* prevent the active scanner from disclosing the identity information
2747+
* prevent the active scanner from disclosing the identity address information
27522748
* when requesting additional information from advertisers.
27532749
* In order to enable directed advertiser reports then
27542750
* @kconfig{CONFIG_BT_SCAN_WITH_IDENTITY} must be enabled.
@@ -2937,12 +2933,12 @@ struct bt_le_oob {
29372933
* - Creating a connection in progress, wait for the connected callback.
29382934
* In addition when extended advertising @kconfig{CONFIG_BT_EXT_ADV} is
29392935
* not enabled or not supported by the controller:
2940-
* - Advertiser is enabled using a Random Static Identity Address for a
2941-
* different local identity.
2942-
* - The local identity conflicts with the local identity used by other
2936+
* - Advertiser is enabled using a Random Static Identity Address as a
2937+
* different local identity address.
2938+
* - The local identity address conflicts with the local identity address used by other
29432939
* roles.
29442940
*
2945-
* @param[in] id Local identity, in most cases BT_ID_DEFAULT.
2941+
* @param[in] id Local identity handle, in most cases BT_ID_DEFAULT.
29462942
* @param[out] oob LE OOB information
29472943
*
29482944
* @return Zero on success or error code otherwise, positive in case of
@@ -2980,7 +2976,7 @@ int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv,
29802976
/**
29812977
* @brief Clear pairing information.
29822978
*
2983-
* @param id Local identity (mostly just BT_ID_DEFAULT).
2979+
* @param id Local identity handle (mostly just BT_ID_DEFAULT).
29842980
* @param addr Remote address, NULL or BT_ADDR_LE_ANY to clear all remote
29852981
* devices.
29862982
*
@@ -2997,7 +2993,7 @@ struct bt_bond_info {
29972993
/**
29982994
* @brief Iterate through all existing bonds.
29992995
*
3000-
* @param id Local identity (mostly just BT_ID_DEFAULT).
2996+
* @param id Local identity handle (mostly just BT_ID_DEFAULT).
30012997
* @param func Function to call for each bond.
30022998
* @param user_data Data to pass to the callback function.
30032999
*/
@@ -3121,7 +3117,7 @@ int bt_le_per_adv_set_response_data(struct bt_le_per_adv_sync *per_adv_sync,
31213117
* @details Valid Bluetooth LE identity addresses are either public address or random static
31223118
* address.
31233119
*
3124-
* @param id Local identity (typically @ref BT_ID_DEFAULT).
3120+
* @param id Local identity handle (typically @ref BT_ID_DEFAULT).
31253121
* @param addr Bluetooth LE device address.
31263122
*
31273123
* @return true if @p addr is bonded with local @p id

subsys/bluetooth/host/shell/bt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ static int cmd_id_reset(const struct shell *sh, size_t argc, char *argv[])
15001500
int err;
15011501

15021502
if (argc < 2) {
1503-
shell_error(sh, "Identity identifier not specified");
1503+
shell_error(sh, "Identity handle not specified");
15041504
return -ENOEXEC;
15051505
}
15061506

@@ -1534,7 +1534,7 @@ static int cmd_id_delete(const struct shell *sh, size_t argc, char *argv[])
15341534
int err;
15351535

15361536
if (argc < 2) {
1537-
shell_error(sh, "Identity identifier not specified");
1537+
shell_error(sh, "Identity handle not specified");
15381538
return -ENOEXEC;
15391539
}
15401540

0 commit comments

Comments
 (0)