1 // Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef _PROVISIONER_PROXY_H_ 16 #define _PROVISIONER_PROXY_H_ 17 18 #include <net/buf.h> 19 20 21 //#include "mesh_def.h" 22 //#include "port/mesh_hal_ble.h" 23 24 #define BT_MESH_PROXY_NET_PDU 0x00 25 #define BT_MESH_PROXY_BEACON 0x01 26 #define BT_MESH_PROXY_CONFIG 0x02 27 #define BT_MESH_PROXY_PROV 0x03 28 29 /** 30 * @brief This function is called to send proxy protocol messages. 31 * 32 * @param[in] conn: Pointer to bt_conn structure 33 * @param[in] type: Proxy protocol message type 34 * @param[in] msg: Pointer to the buffer contains sending message. 35 * 36 * @return Zero-success, other-fail 37 */ 38 int provisioner_proxy_send(struct bt_conn * conn, u8_t type, struct net_buf_simple *msg); 39 40 /** 41 * @brief This function is called to parse received node identity and net 42 * id adv pkts and create connection if deceided to. 43 * 44 * @param[in] buf: Pointer to the buffer contains received message. 45 * 46 * @return None 47 */ 48 void provisioner_proxy_srv_data_recv(struct net_buf_simple *buf, const bt_addr_le_t *addr); 49 50 /** 51 * @brief This function is called to initialize proxy provisioner structure 52 * and register proxy connection related callbacks. 53 * 54 * @return Zero-success, other-fail 55 */ 56 int provisioner_proxy_init(void); 57 58 /** 59 * @brief This function is called to enable dealing with proxy provisioning 60 * messages. 61 * 62 * @return Zero-success, other-fail 63 */ 64 int provisioner_pb_gatt_enable(void); 65 66 /** 67 * @brief This function is called to disable dealing with proxy provisioning 68 * messages and if proxy provisioning connections exist, the connections 69 * will be disconnected. 70 * 71 * @return Zero-success, other-fail 72 */ 73 int provisioner_pb_gatt_disable(void); 74 75 /* The following APIs are for application use */ 76 /** 77 * @brief This function is called to enable receiving node identity and net 78 * id adv pkts. 79 * 80 * @return Zero-success, other-fail 81 */ 82 int bt_mesh_provisioner_proxy_enable(void); 83 84 /** 85 * @brief This function is called to disable receiving node identity and net 86 * id adv pkts, and if proxy connections exist, these connections will 87 * be disconnected. 88 * 89 * @return Zero-success, other-fail 90 */ 91 int bt_mesh_provisioner_proxy_disable(void); 92 93 int provisioner_proxy_pdu_send(struct net_buf_simple *msg); 94 95 #endif /* _PROVISIONER_PROXY_H_ */ 96