nRF5 SDK for Mesh v5.0.0
mesh_opt_core.h
1 /* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form, except as embedded into a Nordic
11  * Semiconductor ASA integrated circuit in a product or a software update for
12  * such product, must reproduce the above copyright notice, this list of
13  * conditions and the following disclaimer in the documentation and/or other
14  * materials provided with the distribution.
15  *
16  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17  * contributors may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * 4. This software, with or without modification, must only be used with a
21  * Nordic Semiconductor ASA integrated circuit.
22  *
23  * 5. Any software provided in binary form under this license must not be reverse
24  * engineered, decompiled, modified and/or disassembled.
25  *
26  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef MESH_OPT_CORE_H__
39 #define MESH_OPT_CORE_H__
40 
41 #include "mesh_opt.h"
42 #include "radio_config.h"
43 #include "ble.h"
44 #include "core_tx.h"
45 
57 #if MESH_FEATURE_RELAY_ENABLED
58 #define MESH_OPT_CORE_ADV_COUNT 2
59 #else
60 #define MESH_OPT_CORE_ADV_COUNT 1
61 #endif
62 /* CORE_TX_ROLE_COUNT should be equal to MESH_OPT_CORE_ADV_COUNT */
63 NRF_MESH_STATIC_ASSERT(MESH_OPT_CORE_ADV_COUNT == CORE_TX_ROLE_COUNT);
64 
65 enum
66 {
67  MESH_OPT_CORE_ADV_RECORD_START = MESH_OPT_CORE_ID_START,
68  MESH_OPT_CORE_ADV_RECORD_END = MESH_OPT_CORE_ADV_RECORD_START + MESH_OPT_CORE_ADV_COUNT - 1,
69  MESH_OPT_CORE_TX_POWER_RECORD_START,
70  MESH_OPT_CORE_TX_POWER_RECORD_END = MESH_OPT_CORE_TX_POWER_RECORD_START + MESH_OPT_CORE_ADV_COUNT - 1,
71  MESH_OPT_CORE_ADV_ADDR_RECORD_START,
72  MESH_OPT_CORE_ADV_ADDR_RECORD_END = MESH_OPT_CORE_ADV_ADDR_RECORD_START + MESH_OPT_CORE_ADV_COUNT - 1,
73  MESH_OPT_CORE_SEC_NWK_BCN_RECORD,
74  MESH_OPT_CORE_HB_PUBLICATION_RECORD,
75  MESH_OPT_CORE_RECORDS_COUNT
76 };
77 
78 /* The last record in the core options shouldn't go past the end of its range. */
79 NRF_MESH_STATIC_ASSERT((MESH_OPT_CORE_RECORDS_COUNT - 1) <= MESH_OPT_CORE_ID_END);
80 
81 
83 #define MESH_OPT_CORE_ADV_EID MESH_OPT_CORE_ID(MESH_OPT_CORE_ADV_RECORD_START)
84 
85 #define MESH_OPT_CORE_TX_POWER_EID MESH_OPT_CORE_ID(MESH_OPT_CORE_TX_POWER_RECORD_START)
86 
87 #define MESH_OPT_CORE_ADV_ADDR_EID MESH_OPT_CORE_ID(MESH_OPT_CORE_ADV_ADDR_RECORD_START)
88 
89 #define MESH_OPT_CORE_SEC_NWK_BCN_EID MESH_OPT_CORE_ID(MESH_OPT_CORE_SEC_NWK_BCN_RECORD)
90 
91 #define MESH_OPT_CORE_HB_PUBLICATION_EID MESH_OPT_CORE_ID(MESH_OPT_CORE_HB_PUBLICATION_RECORD)
92 
93 #define MESH_OPT_CORE_ADV_ENTRY_ID_TO_ROLE(ID) ((core_tx_role_t) ((ID).record - MESH_OPT_CORE_ADV_RECORD_START))
94 #define MESH_OPT_CORE_ADV_ROLE_TO_ENTRY_ID(ROLE) (MESH_OPT_CORE_ID(MESH_OPT_CORE_ADV_RECORD_START + (ROLE)))
95 
98 typedef struct
99 {
100  bool enabled;
101  uint8_t tx_count;
102  uint16_t tx_interval_ms;
104 
116 uint32_t mesh_opt_core_adv_set(core_tx_role_t role, const mesh_opt_core_adv_t * p_entry);
117 
128 uint32_t mesh_opt_core_adv_get(core_tx_role_t role, mesh_opt_core_adv_t * p_entry);
129 
130 
141 uint32_t mesh_opt_core_tx_power_set(core_tx_role_t role, radio_tx_power_t tx_power);
142 
153 uint32_t mesh_opt_core_tx_power_get(core_tx_role_t role, radio_tx_power_t * p_tx_power);
154 
155 
167 uint32_t mesh_opt_core_adv_addr_set(core_tx_role_t role, const ble_gap_addr_t * p_adv_addr);
168 
179 uint32_t mesh_opt_core_adv_addr_get(core_tx_role_t role, ble_gap_addr_t * p_adv_addr);
180 
183 #endif /* MESH_OPT_CORE_H__ */
uint32_t mesh_opt_core_adv_set(core_tx_role_t role, const mesh_opt_core_adv_t *p_entry)
Sets the advertisement options for the given role.
bool enabled
Advertiser enabled.
uint32_t mesh_opt_core_adv_addr_set(core_tx_role_t role, const ble_gap_addr_t *p_adv_addr)
Sets the advertisement address for the given role.
uint16_t tx_interval_ms
Advertisement interval in milliseconds.
uint8_t tx_count
Number of transmissions for each packet.
uint32_t mesh_opt_core_tx_power_get(core_tx_role_t role, radio_tx_power_t *p_tx_power)
Gets the TX power level for the given role.
uint32_t mesh_opt_core_adv_addr_get(core_tx_role_t role, ble_gap_addr_t *p_adv_addr)
Gets the advertisement address for the given role.
uint32_t mesh_opt_core_tx_power_set(core_tx_role_t role, radio_tx_power_t tx_power)
Sets the TX power level for the given role.
uint32_t mesh_opt_core_adv_get(core_tx_role_t role, mesh_opt_core_adv_t *p_entry)
Gets the advertisement options for the given role.
#define NRF_MESH_STATIC_ASSERT(...)
Compile-time assertion.

Documentation feedback | Developer Zone | Subscribe | Updated