NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
transport.h
1/* Bluetooth Mesh */
2
3/*
4 * Copyright (c) 2017 Intel Corporation
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9#include "nimble/porting/nimble/include/syscfg/syscfg.h"
10#include "../include/mesh/mesh.h"
11
12#define TRANS_SEQ_AUTH_NVAL 0xffffffffffffffff
13
14#define BT_MESH_SDU_UNSEG_MAX 11
15#define BT_MESH_CTL_SEG_SDU_MAX 8
16#define BT_MESH_RX_CTL_MAX (CONFIG_BT_MESH_RX_SEG_MAX * BT_MESH_CTL_SEG_SDU_MAX)
17
18#define TRANS_SEQ_ZERO_MASK ((uint16_t)BIT_MASK(13))
19#define TRANS_CTL_OP_MASK ((uint8_t)BIT_MASK(7))
20#define TRANS_CTL_OP(data) ((data)[0] & TRANS_CTL_OP_MASK)
21#define TRANS_CTL_HDR(op, seg) ((op & TRANS_CTL_OP_MASK) | (seg << 7))
22
23#define TRANS_CTL_OP_ACK 0x00
24#define TRANS_CTL_OP_FRIEND_POLL 0x01
25#define TRANS_CTL_OP_FRIEND_UPDATE 0x02
26#define TRANS_CTL_OP_FRIEND_REQ 0x03
27#define TRANS_CTL_OP_FRIEND_OFFER 0x04
28#define TRANS_CTL_OP_FRIEND_CLEAR 0x05
29#define TRANS_CTL_OP_FRIEND_CLEAR_CFM 0x06
30#define TRANS_CTL_OP_FRIEND_SUB_ADD 0x07
31#define TRANS_CTL_OP_FRIEND_SUB_REM 0x08
32#define TRANS_CTL_OP_FRIEND_SUB_CFM 0x09
33#define TRANS_CTL_OP_HEARTBEAT 0x0a
34
35struct bt_mesh_ctl_friend_poll {
36 uint8_t fsn;
37}__attribute__((__packed__));
38
39struct bt_mesh_ctl_friend_update {
40 uint8_t flags;
41 uint32_t iv_index;
42 uint8_t md;
43}__attribute__((__packed__));
44
45struct bt_mesh_ctl_friend_req {
46 uint8_t criteria;
47 uint8_t recv_delay;
48 uint8_t poll_to[3];
49 uint16_t prev_addr;
50 uint8_t num_elem;
51 uint16_t lpn_counter;
52}__attribute__((__packed__));
53
54struct bt_mesh_ctl_friend_offer {
55 uint8_t recv_win;
56 uint8_t queue_size;
57 uint8_t sub_list_size;
58 int8_t rssi;
59 uint16_t frnd_counter;
60}__attribute__((__packed__));
61
62struct bt_mesh_ctl_friend_clear {
63 uint16_t lpn_addr;
64 uint16_t lpn_counter;
65}__attribute__((__packed__));
66
67struct bt_mesh_ctl_friend_clear_confirm {
68 uint16_t lpn_addr;
69 uint16_t lpn_counter;
70}__attribute__((__packed__));
71
72#define BT_MESH_FRIEND_SUB_MIN_LEN (1 + 2)
73struct bt_mesh_ctl_friend_sub {
74 uint8_t xact;
75 uint16_t addr_list[5];
76}__attribute__((__packed__));
77
78struct bt_mesh_ctl_friend_sub_confirm {
79 uint8_t xact;
80}__attribute__((__packed__));
81
82bool bt_mesh_tx_in_progress(void);
83
84void bt_mesh_rx_reset(void);
85
86int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data,
87 size_t data_len, const struct bt_mesh_send_cb *cb, void *cb_data);
88
89int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct os_mbuf *msg,
90 const struct bt_mesh_send_cb *cb, void *cb_data);
91
92int bt_mesh_trans_recv(struct os_mbuf *buf, struct bt_mesh_net_rx *rx);
93
94void bt_mesh_trans_init(void);
95
96void bt_mesh_trans_reset(void);
97
98uint8_t bt_mesh_va_add(const uint8_t uuid[16], uint16_t *addr);
99
100uint8_t bt_mesh_va_del(const uint8_t uuid[16], uint16_t *addr);
101
102uint8_t *bt_mesh_va_label_get(uint16_t addr);
103
104void bt_mesh_va_pending_store(void);
105
106void bt_mesh_va_init(void);
Definition os_mbuf.h:86