xref: /nrf52832-nimble/packages/NimBLE-latest/docs/ble_hs/ble_hs_id.rst (revision 042d53a763ad75cb1465103098bb88c245d95138)
1*042d53a7SEvalZeroNimBLE Host Identity Reference
2*042d53a7SEvalZero------------------------------
3*042d53a7SEvalZero
4*042d53a7SEvalZeroIntroduction
5*042d53a7SEvalZero~~~~~~~~~~~~
6*042d53a7SEvalZero
7*042d53a7SEvalZeroThe identity API provides facilities for querying and configuring your device's addresses. BLE's addressing scheme is
8*042d53a7SEvalZeroquite involved; the summary that follows is only a brief introduction.
9*042d53a7SEvalZero
10*042d53a7SEvalZeroBLE defines four address types:
11*042d53a7SEvalZero
12*042d53a7SEvalZero+---------------------------------+---------------------------------------------------------------------------------------------------+-------------+----------------------------------------------+
13*042d53a7SEvalZero| Type                            | Description                                                                                       | Identity?   | Configured with                              |
14*042d53a7SEvalZero+=================================+===================================================================================================+=============+==============================================+
15*042d53a7SEvalZero| Public                          | Address assigned by manufacturer; the three most significant bytes form the manufacturer's OUI.   | Yes         | N/A; read from controller at startup.        |
16*042d53a7SEvalZero+---------------------------------+---------------------------------------------------------------------------------------------------+-------------+----------------------------------------------+
17*042d53a7SEvalZero| Static random                   | Randomly generated address.                                                                       | Yes         | *ble_hs_id_set_rnd()*                        |
18*042d53a7SEvalZero+---------------------------------+---------------------------------------------------------------------------------------------------+-------------+----------------------------------------------+
19*042d53a7SEvalZero| Resolvable private (RPA)        | Address randomly generated from an identity address and an identity resolving key (IRK).          | No          | N/A; generated by controller periodically.   |
20*042d53a7SEvalZero+---------------------------------+---------------------------------------------------------------------------------------------------+-------------+----------------------------------------------+
21*042d53a7SEvalZero| Non-resolvable private (NRPA)   | Randomly generated address.                                                                       | No          | *ble_hs_id_set_rnd()*                        |
22*042d53a7SEvalZero+---------------------------------+---------------------------------------------------------------------------------------------------+-------------+----------------------------------------------+
23*042d53a7SEvalZero
24*042d53a7SEvalZeroIdentity Addresses
25*042d53a7SEvalZero^^^^^^^^^^^^^^^^^^
26*042d53a7SEvalZero
27*042d53a7SEvalZeroThe third column in the above table indicates the *identity* property of each address type. An identity address never
28*042d53a7SEvalZerochanges, and a device can be identified by one of its unique identity addresses.
29*042d53a7SEvalZero
30*042d53a7SEvalZeroNon-identity addresses are used by devices supporting BLE privacy. A device using the privacy feature frequently changes
31*042d53a7SEvalZeroits own address to a newly-generated non-identity address. By cycling its address, the device makes it impossible for
32*042d53a7SEvalZeroeavesdroppers to track its location.
33*042d53a7SEvalZero
34*042d53a7SEvalZeroA device can have up to two identity addresses at once: one public and one static random. As indicated in the above table,
35*042d53a7SEvalZerothe public identity address cannot be configured; the static random identity address can be set by calling *ble_hs_id_set_rnd()*.
36*042d53a7SEvalZero
37*042d53a7SEvalZeroThe address type is selected on a per-GAP-procedure basis. Each time you initiate a GAP procedure, you indicate which
38*042d53a7SEvalZeroaddress type the device should use for the duration of the procedure.
39*042d53a7SEvalZero
40*042d53a7SEvalZeroHeader
41*042d53a7SEvalZero~~~~~~
42*042d53a7SEvalZero
43*042d53a7SEvalZero.. code-block:: cpp
44*042d53a7SEvalZero
45*042d53a7SEvalZero    #include "host/ble_hs.h"
46