From f57ec1c1a17ce278f6cd9bd45ec3552be8aebb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Narajowski?= Date: Fri, 3 Nov 2017 11:56:51 +0100 Subject: [PATCH] mesh: Extend advertising API with helpers for Friend support These extensions prepare the way of implementing full Friend support. X-Original-Commit: a811e5d30d1322e32c6387de31991ed363c2f4d2 --- nimble/host/mesh/src/adv.c | 16 +++++++++++++--- nimble/host/mesh/src/adv.h | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/nimble/host/mesh/src/adv.c b/nimble/host/mesh/src/adv.c index a05333819..8c30f4406 100644 --- a/nimble/host/mesh/src/adv.c +++ b/nimble/host/mesh/src/adv.c @@ -175,13 +175,15 @@ void bt_mesh_adv_update(void) os_eventq_put(&adv_queue, &ev); } -struct os_mbuf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count, - u8_t xmit_int, s32_t timeout) +struct os_mbuf *bt_mesh_adv_create_from_pool(struct os_mbuf_pool *pool, + enum bt_mesh_adv_type type, + u8_t xmit_count, u8_t xmit_int, + s32_t timeout) { struct os_mbuf *adv_data; struct bt_mesh_adv *adv; - adv_data = os_mbuf_get_pkthdr(&adv_os_mbuf_pool, sizeof(struct bt_mesh_adv)); + adv_data = os_mbuf_get_pkthdr(pool, sizeof(struct bt_mesh_adv)); if (!adv_data) { return NULL; } @@ -197,6 +199,14 @@ struct os_mbuf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count, return adv_data; } +struct os_mbuf *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_os_mbuf_pool, + type, xmit_count, + xmit_int, timeout); +} + void bt_mesh_adv_send(struct os_mbuf *buf, bt_mesh_adv_func_t sent) { BT_DBG("buf %p, type 0x%02x len %u: %s", buf, BT_MESH_ADV(buf)->type, buf->om_len, diff --git a/nimble/host/mesh/src/adv.h b/nimble/host/mesh/src/adv.h index 2f9f94b54..31d68296f 100644 --- a/nimble/host/mesh/src/adv.h +++ b/nimble/host/mesh/src/adv.h @@ -37,6 +37,9 @@ struct bt_mesh_adv /* Generic User Data */ u8_t user_data[2]; + /* Address, used e.g. for Friend Queue messages */ + u16_t addr; + /* For transport layer segment sending */ struct { @@ -53,6 +56,11 @@ struct bt_mesh_adv struct os_mbuf * bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count, u8_t xmit_int, s32_t timeout); +struct os_mbuf *bt_mesh_adv_create_from_pool(struct os_mbuf_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 os_mbuf *buf, bt_mesh_adv_func_t sent); void bt_mesh_adv_update(void);