14#define BT_MESH_IV_UPDATE(flags) ((flags >> 1) & 0x01)
15#define BT_MESH_KEY_REFRESH(flags) (flags & 0x01)
19#include "../include/mesh/mesh.h"
20#include "../include/mesh/glue.h"
23#define BT_MESH_IVU_MIN_HOURS 96
24#define BT_MESH_IVU_HOURS (BT_MESH_IVU_MIN_HOURS / \
25 CONFIG_BT_MESH_IVU_DIVIDER)
26#define BT_MESH_IVU_TIMEOUT K_HOURS(BT_MESH_IVU_HOURS)
34#define BT_MESH_NET_MIN_PDU_LEN (BT_MESH_NET_HDR_LEN + 1 + 8)
39#define BT_MESH_NET_MAX_PDU_LEN (BT_MESH_NET_HDR_LEN + 16 + 4)
50#if MYNEWT_VAL(BLE_MESH_FRIEND)
51#define FRIEND_SEG_RX MYNEWT_VAL(BLE_MESH_FRIEND_SEG_RX)
52#define FRIEND_SUB_LIST_SIZE MYNEWT_VAL(BLE_MESH_FRIEND_SUB_LIST_SIZE)
54#define FRIEND_SEG_RX 0
55#define FRIEND_SUB_LIST_SIZE 0
58struct bt_mesh_friend {
75 uint16_t sub_list[FRIEND_SUB_LIST_SIZE];
77 struct k_work_delayable timer;
79 struct bt_mesh_friend_seg {
80 struct net_buf_slist_t queue;
91 struct net_buf_slist_t queue;
99 struct k_work_delayable timer;
103#if (MYNEWT_VAL(BLE_MESH_LOW_POWER))
104#define LPN_GROUPS CONFIG_BT_MESH_LPN_GROUPS
112 BT_MESH_LPN_DISABLED,
116 BT_MESH_LPN_REQ_WAIT,
117 BT_MESH_LPN_WAIT_OFFER,
118 BT_MESH_LPN_ESTABLISHED,
119 BT_MESH_LPN_RECV_DELAY,
120 BT_MESH_LPN_WAIT_UPDATE,
125 uint8_t xact_pending;
136 uint8_t req_attempts;
138 int32_t poll_timeout;
140 uint8_t groups_changed:1,
151 uint16_t frnd_counter;
154 uint16_t lpn_counter;
160 uint16_t adv_duration;
163 struct k_work_delayable timer;
166 uint16_t groups[LPN_GROUPS];
182 BT_MESH_IVU_IN_PROGRESS,
183 BT_MESH_IVU_INITIATOR,
204 struct ble_npl_callout local_work;
205 struct net_buf_slist_t local_queue;
207#if MYNEWT_VAL(BLE_MESH_FRIEND)
209 struct bt_mesh_friend frnd[MYNEWT_VAL(BLE_MESH_FRIEND_LPN_COUNT)];
212#if (MYNEWT_VAL(BLE_MESH_LOW_POWER))
213 struct bt_mesh_lpn lpn;
217 uint8_t ivu_duration;
224 struct k_work_delayable ivu_timer;
232 BT_MESH_NET_IF_LOCAL,
233 BT_MESH_NET_IF_PROXY,
234 BT_MESH_NET_IF_PROXY_CFG,
238struct bt_mesh_net_rx {
249 uint16_t msg_cache_idx;
253struct bt_mesh_net_tx {
258 uint8_t friend_cred:1,
263extern struct bt_mesh_net bt_mesh;
265#define BT_MESH_NET_IVI_TX (bt_mesh.iv_index - \
266 atomic_test_bit(bt_mesh.flags, \
267 BT_MESH_IVU_IN_PROGRESS))
268#define BT_MESH_NET_IVI_RX(rx) (bt_mesh.iv_index - (rx)->old_iv)
270#define BT_MESH_NET_HDR_LEN 9
272static inline void *net_buf_user_data(
const struct os_mbuf *buf)
282int bt_mesh_net_create(uint16_t idx, uint8_t flags,
const uint8_t key[16],
285bool bt_mesh_net_iv_update(uint32_t iv_index,
bool iv_update);
287int bt_mesh_net_encode(
struct bt_mesh_net_tx *tx,
struct os_mbuf *buf,
290int bt_mesh_net_decode(
struct os_mbuf *in,
enum bt_mesh_net_if net_if,
291 struct bt_mesh_net_rx *rx,
struct os_mbuf *out);
293int bt_mesh_net_send(
struct bt_mesh_net_tx *tx,
struct os_mbuf *buf,
294 const struct bt_mesh_send_cb *cb,
void *cb_data);
296void bt_mesh_net_recv(
struct os_mbuf *data, int8_t rssi,
297 enum bt_mesh_net_if net_if);
299void bt_mesh_net_loopback_clear(uint16_t net_idx);
301uint32_t bt_mesh_next_seq(
void);
303void bt_mesh_net_init(
void);
304void bt_mesh_net_header_parse(
struct os_mbuf *buf,
305 struct bt_mesh_net_rx *rx);
306void bt_mesh_net_pending_net_store(
void);
307void bt_mesh_net_pending_iv_store(
void);
308void bt_mesh_net_pending_seq_store(
void);
309void bt_mesh_net_clear(
void);
310void bt_mesh_net_settings_commit(
void);
312static inline void send_cb_finalize(
const struct bt_mesh_send_cb *cb,
320 cb->start(0, 0, cb_data);
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:274
uint16_t omp_databuf_len
Definition os_mbuf.h:57
struct os_mbuf_pool * om_omp
Definition os_mbuf.h:107
uint8_t * om_data
Definition os_mbuf.h:90