1 /* Bluetooth Mesh */ 2 3 /* 4 * Copyright (c) 2017 Intel Corporation 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 */ 8 9 /* Maximum advertising data payload for a single data type */ 10 #define BT_MESH_ADV_DATA_SIZE 29 11 12 /* The user data is a pointer (4 bytes) to struct bt_mesh_adv */ 13 #define BT_MESH_ADV_USER_DATA_SIZE 4 14 15 #define BT_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf)) 16 17 enum bt_mesh_adv_type { 18 BT_MESH_ADV_PROV, 19 BT_MESH_ADV_DATA, 20 BT_MESH_ADV_BEACON, 21 BT_MESH_ADV_URI, 22 }; 23 24 typedef void (*bt_mesh_adv_func_t)(struct net_buf *buf, u16_t duration, int err, void *user_data); 25 26 struct bt_mesh_adv { 27 const struct bt_mesh_send_cb *cb; 28 void *cb_data; 29 30 u8_t type:2, busy:1; 31 u8_t xmit; 32 #ifdef GENIE_ULTRA_PROV 33 u8_t tiny_adv; 34 #endif 35 union { 36 /* Address, used e.g. for Friend Queue messages */ 37 u16_t addr; 38 39 /* For transport layer segment sending */ 40 struct { 41 u8_t attempts; 42 } seg; 43 }; 44 }; 45 46 typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id); 47 48 typedef void (*vendor_beacon_cb)(const bt_addr_le_t *addr, s8_t rssi, u8_t adv_type, void *user_data, uint16_t len); 49 50 /* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */ 51 struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit, bt_s32_t timeout); 52 53 struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, bt_mesh_adv_alloc_t get_id, 54 enum bt_mesh_adv_type type, u8_t xmit, bt_s32_t timeout); 55 56 void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, void *cb_data); 57 58 void bt_mesh_adv_update(void); 59 60 void bt_mesh_adv_init(void); 61 62 int bt_mesh_scan_enable(void); 63 64 int bt_mesh_scan_disable(void); 65 66 int bt_mesh_adv_enable(const struct bt_le_adv_param *param, const struct bt_data *ad, size_t ad_len, 67 const struct bt_data *sd, size_t sd_len); 68 int bt_mesh_adv_disable(); 69 int bt_mesh_adv_scan_update(); 70 int bt_mesh_scan_enable(void); 71 int bt_mesh_adv_vnd_scan_register(vendor_beacon_cb); 72