12#include "prov_bearer.h"
13#include "nimble/porting/nimble/include/os/os_mbuf.h"
14#include "../include/mesh/mesh.h"
15#include "nimble/nimble/host/src/ble_hs_conn_priv.h"
17#define PROV_ERR_NONE 0x00
18#define PROV_ERR_NVAL_PDU 0x01
19#define PROV_ERR_NVAL_FMT 0x02
20#define PROV_ERR_UNEXP_PDU 0x03
21#define PROV_ERR_CFM_FAILED 0x04
22#define PROV_ERR_RESOURCES 0x05
23#define PROV_ERR_DECRYPT 0x06
24#define PROV_ERR_UNEXP_ERR 0x07
25#define PROV_ERR_ADDR 0x08
27#define AUTH_METHOD_NO_OOB 0x00
28#define AUTH_METHOD_STATIC 0x01
29#define AUTH_METHOD_OUTPUT 0x02
30#define AUTH_METHOD_INPUT 0x03
32#define OUTPUT_OOB_BLINK 0x00
33#define OUTPUT_OOB_BEEP 0x01
34#define OUTPUT_OOB_VIBRATE 0x02
35#define OUTPUT_OOB_NUMBER 0x03
36#define OUTPUT_OOB_STRING 0x04
38#define INPUT_OOB_PUSH 0x00
39#define INPUT_OOB_TWIST 0x01
40#define INPUT_OOB_NUMBER 0x02
41#define INPUT_OOB_STRING 0x03
43#define PUB_KEY_NO_OOB 0x00
44#define PUB_KEY_OOB 0x01
46#define PROV_INVITE 0x00
47#define PROV_CAPABILITIES 0x01
48#define PROV_START 0x02
49#define PROV_PUB_KEY 0x03
50#define PROV_INPUT_COMPLETE 0x04
51#define PROV_CONFIRM 0x05
52#define PROV_RANDOM 0x06
54#define PROV_COMPLETE 0x08
55#define PROV_FAILED 0x09
57#define PROV_NO_PDU 0xff
59#define PDU_LEN_INVITE 1
60#define PDU_LEN_CAPABILITIES 11
61#define PDU_LEN_START 5
62#define PDU_LEN_PUB_KEY 64
63#define PDU_LEN_INPUT_COMPLETE 0
64#define PDU_LEN_CONFIRM 16
65#define PDU_LEN_RANDOM 16
66#define PDU_LEN_DATA 33
67#define PDU_LEN_COMPLETE 0
68#define PDU_LEN_FAILED 1
72#define PROV_ALG_P256 0x00
74#define PROV_IO_OOB_SIZE_MAX 8
76#define PROV_BUF(len) \
77 NET_BUF_SIMPLE(PROV_BEARER_BUF_HEADROOM + PDU_OP_LEN + len)
84 NOTIFY_INPUT_COMPLETE,
100 void (*link_opened)(void);
102 void (*link_closed)(void);
104 void (*error)(uint8_t reason);
106 void (*input_complete)(void);
108 void (*op[10])(
const uint8_t *data);
111struct bt_mesh_prov_link {
122 uint8_t dhkey[BT_DH_KEY_LEN];
127 uint8_t conf_salt[16];
128 uint8_t conf_key[16];
131 uint8_t invite[PDU_LEN_INVITE];
132 uint8_t capabilities[PDU_LEN_CAPABILITIES];
133 uint8_t start[PDU_LEN_START];
134 uint8_t pub_key_provisioner[PDU_LEN_PUB_KEY];
135 uint8_t pub_key_device[PDU_LEN_PUB_KEY];
137 uint8_t prov_salt[16];
140extern struct bt_mesh_prov_link bt_mesh_prov_link;
143static inline int bt_mesh_prov_send(
struct os_mbuf *buf,
144 prov_bearer_send_complete_t cb)
146 return bt_mesh_prov_link.bearer->send(buf, cb, NULL);
149static inline void bt_mesh_prov_buf_init(
struct os_mbuf *buf, uint8_t type)
151 net_buf_reserve(buf, PROV_BEARER_BUF_HEADROOM);
152 net_buf_simple_add_u8(buf, type);
155int bt_mesh_prov_reset_state(
void (*func)(
const uint8_t key[BT_PUB_KEY_LEN]));
157bool bt_mesh_prov_active(
void);
159int bt_mesh_prov_auth(
bool is_provisioner, uint8_t method, uint8_t action, uint8_t size);
161int bt_mesh_pb_gatt_open(uint16_t conn_handle);
162int bt_mesh_pb_gatt_close(uint16_t conn_handle);
163int bt_mesh_pb_gatt_recv(uint16_t conn_handle,
struct os_mbuf *buf);
167void bt_mesh_prov_reset_link(
void);
169void bt_mesh_prov_complete(uint16_t net_idx, uint16_t addr);
170void bt_mesh_prov_reset(
void);
174void bt_mesh_pb_adv_recv(
struct os_mbuf *buf);
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition atomic.h:274
Definition prov_bearer.h:30
Definition prov_bearer.h:47