2019-01-07 07:16:47 +00:00
|
|
|
/* Bluetooth Mesh */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel Corporation
|
|
|
|
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ADV_H_
|
|
|
|
#define _ADV_H_
|
|
|
|
|
2020-01-19 10:57:13 +00:00
|
|
|
#include "mesh_access.h"
|
2019-01-07 07:16:47 +00:00
|
|
|
#include "mesh_bearer_adapt.h"
|
|
|
|
|
2020-04-10 03:31:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-01-07 07:16:47 +00:00
|
|
|
/* Maximum advertising data payload for a single data type */
|
|
|
|
#define BLE_MESH_ADV_DATA_SIZE 29
|
|
|
|
|
|
|
|
/* The user data is a pointer (4 bytes) to struct bt_mesh_adv */
|
|
|
|
#define BLE_MESH_ADV_USER_DATA_SIZE 4
|
|
|
|
|
|
|
|
#define BLE_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf))
|
|
|
|
|
|
|
|
typedef struct bt_mesh_msg {
|
2019-09-17 11:30:35 +00:00
|
|
|
bool relay; /* Flag indicates if the packet is a relayed one */
|
|
|
|
void *arg; /* Pointer to the struct net_buf */
|
|
|
|
u16_t src; /* Source address for relay packets */
|
|
|
|
u16_t dst; /* Destination address for relay packets */
|
|
|
|
u32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */
|
2019-01-07 07:16:47 +00:00
|
|
|
} bt_mesh_msg_t;
|
|
|
|
|
|
|
|
enum bt_mesh_adv_type {
|
|
|
|
BLE_MESH_ADV_PROV,
|
|
|
|
BLE_MESH_ADV_DATA,
|
|
|
|
BLE_MESH_ADV_BEACON,
|
|
|
|
BLE_MESH_ADV_URI,
|
2020-02-13 11:41:42 +00:00
|
|
|
BLE_MESH_ADV_BLE,
|
2019-01-07 07:16:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*bt_mesh_adv_func_t)(struct net_buf *buf, u16_t duration,
|
|
|
|
int err, void *user_data);
|
|
|
|
|
|
|
|
struct bt_mesh_adv {
|
|
|
|
const struct bt_mesh_send_cb *cb;
|
|
|
|
void *cb_data;
|
|
|
|
|
2020-03-26 09:01:03 +00:00
|
|
|
u8_t type:3,
|
|
|
|
busy:1;
|
2019-01-07 07:16:47 +00:00
|
|
|
u8_t xmit;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id);
|
|
|
|
|
|
|
|
/* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */
|
|
|
|
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
|
|
|
s32_t timeout);
|
|
|
|
|
2019-11-26 12:14:31 +00:00
|
|
|
typedef enum {
|
|
|
|
BLE_MESH_BUF_REF_EQUAL,
|
|
|
|
BLE_MESH_BUF_REF_SMALL,
|
|
|
|
BLE_MESH_BUF_REF_MAX,
|
|
|
|
} bt_mesh_buf_ref_flag_t;
|
|
|
|
|
|
|
|
void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf,
|
|
|
|
u8_t ref_cmp, bt_mesh_buf_ref_flag_t flag);
|
|
|
|
|
2019-01-07 07:16:47 +00:00
|
|
|
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
|
|
|
bt_mesh_adv_alloc_t get_id,
|
|
|
|
enum bt_mesh_adv_type type,
|
|
|
|
u8_t xmit, s32_t timeout);
|
|
|
|
|
2020-01-19 10:57:13 +00:00
|
|
|
void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool);
|
|
|
|
|
2019-01-07 07:16:47 +00:00
|
|
|
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
|
|
|
void *cb_data);
|
|
|
|
|
|
|
|
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void);
|
|
|
|
|
2019-09-17 11:30:35 +00:00
|
|
|
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
2019-10-21 14:53:25 +00:00
|
|
|
s32_t timeout);
|
2019-09-17 11:30:35 +00:00
|
|
|
|
|
|
|
void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
|
|
|
void *cb_data, u16_t src, u16_t dst);
|
|
|
|
|
|
|
|
u16_t bt_mesh_get_stored_relay_count(void);
|
|
|
|
|
2019-01-07 07:16:47 +00:00
|
|
|
void bt_mesh_adv_update(void);
|
|
|
|
|
|
|
|
void bt_mesh_adv_init(void);
|
2020-01-19 10:57:13 +00:00
|
|
|
void bt_mesh_adv_deinit(void);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
|
|
|
int bt_mesh_scan_enable(void);
|
|
|
|
|
|
|
|
int bt_mesh_scan_disable(void);
|
|
|
|
|
2020-03-11 04:01:57 +00:00
|
|
|
int bt_mesh_scan_with_wl_enable(void);
|
|
|
|
|
2020-02-13 11:41:42 +00:00
|
|
|
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
|
|
|
int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
|
|
|
const struct bt_mesh_ble_adv_data *data, u8_t *index);
|
|
|
|
|
|
|
|
int bt_mesh_stop_ble_advertising(u8_t index);
|
|
|
|
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
|
|
|
|
2020-04-10 03:31:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-01-07 07:16:47 +00:00
|
|
|
#endif /* _ADV_H_ */
|