1 /* Bluetooth Mesh */ 2 3 /* 4 * SPDX-FileCopyrightText: 2017 Intel Corporation 5 * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD 6 * 7 * SPDX-License-Identifier: Apache-2.0 8 */ 9 10 #ifndef _PROXY_H_ 11 #define _PROXY_H_ 12 13 #include "net.h" 14 #include "mesh_bearer_adapt.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #define BLE_MESH_PROXY_NET_PDU 0x00 21 #define BLE_MESH_PROXY_BEACON 0x01 22 #define BLE_MESH_PROXY_CONFIG 0x02 23 #define BLE_MESH_PROXY_PROV 0x03 24 25 #if CONFIG_BLE_MESH_PROXY 26 /** 27 * Device Name Characteristic: 28 * 1. For iOS, when it tries to get the value of Device Name Characteristic, the PDU 29 * "Read By Type Request" will be used, and the valid length of corresponding 30 * response is 19 (23 - 1 - 1 - 2). 31 * 2. For Android, when it tries to get the value of Device Name Characteristic, the 32 * PDU "Read Request" will be used, and the valid length of corresponding response 33 * is 22 (23 - 1). 34 */ 35 #define DEVICE_NAME_SIZE MIN((BLE_MESH_GATT_DEF_MTU_SIZE - 4), (BLE_MESH_GAP_ADV_MAX_LEN - 2)) 36 #else 37 /* For Scan Response Data, the maximum length is 29 (31 - 1 - 1) currently. */ 38 #define DEVICE_NAME_SIZE (BLE_MESH_GAP_ADV_MAX_LEN - 2) 39 #endif 40 41 typedef void (*proxy_server_connect_cb_t)(uint8_t conn_handle); 42 typedef void (*proxy_server_disconnect_cb_t)(uint8_t conn_handle, uint8_t reason); 43 44 int bt_mesh_set_device_name(const char *name); 45 46 int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, uint8_t type, 47 struct net_buf_simple *msg); 48 49 int bt_mesh_proxy_server_prov_enable(void); 50 int bt_mesh_proxy_server_prov_disable(bool disconnect); 51 52 void bt_mesh_proxy_server_set_conn_cb(proxy_server_connect_cb_t cb); 53 void bt_mesh_proxy_server_set_disconn_cb(proxy_server_disconnect_cb_t cb); 54 55 int bt_mesh_proxy_server_gatt_enable(void); 56 int bt_mesh_proxy_server_gatt_disable(void); 57 58 void bt_mesh_proxy_server_gatt_disconnect(void); 59 60 void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub); 61 62 struct net_buf_simple *bt_mesh_proxy_server_get_buf(void); 63 64 int32_t bt_mesh_proxy_server_adv_start(void); 65 void bt_mesh_proxy_server_adv_stop(void); 66 67 void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub); 68 void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub); 69 70 bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, uint16_t dst); 71 void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, uint16_t addr); 72 73 int bt_mesh_proxy_server_init(void); 74 int bt_mesh_proxy_server_deinit(void); 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 #endif /* _PROXY_H_ */ 81