Bluetooth: Mesh: Extend advertising API with helpers for Friend support

These extensions prepare the way of implementing full Friend support.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-10-31 13:59:25 +02:00 committed by Johan Hedberg
commit 6047ccd2a1
2 changed files with 20 additions and 3 deletions

View file

@ -168,13 +168,15 @@ void bt_mesh_adv_update(void)
k_fifo_cancel_wait(&adv_queue); k_fifo_cancel_wait(&adv_queue);
} }
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count, struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
u8_t xmit_int, s32_t timeout) enum bt_mesh_adv_type type,
u8_t xmit_count, u8_t xmit_int,
s32_t timeout)
{ {
struct bt_mesh_adv *adv; struct bt_mesh_adv *adv;
struct net_buf *buf; struct net_buf *buf;
buf = net_buf_alloc(&adv_buf_pool, timeout); buf = net_buf_alloc(pool, timeout);
if (!buf) { if (!buf) {
return NULL; return NULL;
} }
@ -189,6 +191,13 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count,
return buf; return buf;
} }
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count,
u8_t xmit_int, s32_t timeout)
{
return bt_mesh_adv_create_from_pool(&adv_buf_pool, type, xmit_count,
xmit_int, timeout);
}
void bt_mesh_adv_send(struct net_buf *buf, bt_mesh_adv_func_t sent) void bt_mesh_adv_send(struct net_buf *buf, bt_mesh_adv_func_t sent)
{ {
BT_DBG("type 0x%02x len %u: %s", BT_MESH_ADV(buf)->type, buf->len, BT_DBG("type 0x%02x len %u: %s", BT_MESH_ADV(buf)->type, buf->len,

View file

@ -29,6 +29,9 @@ struct bt_mesh_adv {
/* Generic User Data */ /* Generic User Data */
u8_t user_data[2]; u8_t user_data[2];
/* Address, used e.g. for Friend Queue messages */
u16_t addr;
/* For transport layer segment sending */ /* For transport layer segment sending */
struct { struct {
u8_t tx_id; u8_t tx_id;
@ -43,6 +46,11 @@ struct bt_mesh_adv {
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count, struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count,
u8_t xmit_int, s32_t timeout); u8_t xmit_int, s32_t timeout);
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
enum bt_mesh_adv_type type,
u8_t xmit_count, u8_t xmit_int,
s32_t timeout);
void bt_mesh_adv_send(struct net_buf *buf, bt_mesh_adv_func_t sent); void bt_mesh_adv_send(struct net_buf *buf, bt_mesh_adv_func_t sent);
void bt_mesh_adv_update(void); void bt_mesh_adv_update(void);