NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_hs_pvcy.h
1/*
2 * Copyright 2020 Espressif Systems (Shanghai) PTE LTD
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22#ifndef H_BLE_HS_PVCY_
23#define H_BLE_HS_PVCY_
24
25#include "ble_hs.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#if MYNEWT_VAL(BLE_HOST_BASED_PRIVACY)
32
33#define NIMBLE_HOST_DISABLE_PRIVACY 0x00
34#define NIMBLE_HOST_ENABLE_RPA 0x01
35#define NIMBLE_HOST_ENABLE_NRPA 0x02
36
37/* Called to configure local(own) privacy (RPA/NRPA) when using Host based privacy.
38 * In Host based privacy, as controller is not aware of RPA/NRPA address is in use,
39 * we do it through 'BLE_ADDR_RANDOM (0x01)' addr_type route. This is necessary
40 * so as to set the private address as random address in controller.
41 * Remember to configure `BLE_SM_PAIR_KEY_DIST_ID` in our & their
42 * key distributions for using RPA. For NRPA part of privacy it is not
43 * necessary to configure key distributions in host, as anyway NRPA is non-resolvable.
44 * Please call this API once host-controller are synced as we set the private
45 * (RPA/NRPA) address using host-controller HCI commands.
46 *
47 * To give brief information on how to use this feature,
48 * please refer to following steps while using RPA feature:
49 *
50 * 1. Include "host/ble_hs_pvcy.h".
51 * 2. Set own_addr_type to `BLE_OWN_ADDR_RANDOM`.
52 * 3. Add `BLE_SM_PAIR_KEY_DIST_ID` to key distribution in
53 * `ble_hs_cfg.sm_our_key_dist` & `ble_hs_cfg.sm_their_key_dist`.
54 * 4. Call `ble_hs_pvcy_rpa_config(1)` in Host-Controller sync callback.
55 *
56 * In case of NRPA, steps 1, 2 and calling ble_hs_pvcy_rpa_config(2) will
57 * suffice.
58 *
59 * @param enable RPA when param = 1 (NIMBLE_HOST_ENABLE_RPA)
60 * enable NRPA when param = 2 (NIMBLE_HOST_ENABLE_NRPA)
61 * disable privacy when param = 0 (NIMBLE_HOST_DISABLE_PRIVACY)
62 *
63 * @return return 0 when successful.
64 * return appropriate error code otherwise
65 */
66int ble_hs_pvcy_rpa_config(uint8_t enable);
67
68void ble_hs_resolv_deinit(void);
69#endif
70
71int ble_hs_pvcy_set_resolve_enabled(int enable);
72void ble_hs_set_rpa_timeout(uint16_t timeout);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif