Skip to content

Commit

Permalink
Bluetooth: Mesh: Rename adv relay to adv simultaneous
Browse files Browse the repository at this point in the history
Since notice that simultaneous advertising is not only used
by relay message, provision over pb-adv can also be used.
so it was changed to a more general name.

refs:#48903

Signed-off-by: Lingao Meng <[email protected]>
  • Loading branch information
LingaoM authored and carlescufi committed Oct 20, 2023
1 parent b14d235 commit 141467a
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 107 deletions.
40 changes: 33 additions & 7 deletions subsys/bluetooth/mesh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ menuconfig BT_MESH_ADV_EXT

if BT_MESH_ADV_EXT

config BT_MESH_RELAY_ADV_SETS
int "Maximum of simultaneous relay message support"
config BT_MESH_SIMULT_ADV_SETS
int "Maximum number of parallel advertising sets that can be used by the Bluetooth Mesh stack"
default 0
range 0 BT_EXT_ADV_MAX_ADV_SET
depends on BT_MESH_RELAY
depends on BT_MESH_RELAY || BT_MESH_PB_ADV
help
Maximum of simultaneous relay message support. Requires controller support
Maximum of simultaneous message support. Requires controller support
multiple advertising sets.

config BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET
bool "Use the main advertising set to relay messages"
depends on BT_MESH_RELAY_ADV_SETS > 0
depends on BT_MESH_SIMULT_ADV_SETS > 0
help
When this option is enabled, there is a message that needs to be
relayed, all relay advertising sets defined by
CONFIG_BT_MESH_RELAY_ADV_SETS are busy with relaying messages
CONFIG_BT_MESH_SIMULT_ADV_SETS are busy with relaying messages
and the main advertising set is not busy with sending local
messages, the stack will use the main advertising set to relay
the message. This maximizes the utilization efficiency of
Expand Down Expand Up @@ -199,6 +199,32 @@ config BT_MESH_PB_ADV_RETRANS_TIMEOUT
help
Timeout value of retransmit provisioning PDUs.

config BT_MESH_PB_ADV_TRANS_PDU_RETRANSMIT_COUNT
int "Link Open and Transaction PDU retransmit count"
default 7 if BT_MESH_SIMULT_ADV_SETS > 0
default 0
range 0 7
help
Controls the number of retransmissions of original Link Open and Transaction PDU,
in addition to the first transmission.

config BT_MESH_PB_ADV_TRANS_ACK_RETRANSMIT_COUNT
int "Link Ack and Transaction Ack retransmit count"
default 2
range 0 7
help
Controls the number of retransmissions of original Link Open and Transaction Acknowledgment PDU,
in addition to the first transmission.

config BT_MESH_PB_ADV_LINK_CLOSE_RETRANSMIT_COUNT
int "Link Close retransmit count"
default 7 if BT_MESH_SIMULT_ADV_SETS > 0
default 2
range 0 7
help
Controls the number of retransmissions of original Link Close,
in addition to the first transmission.

endif # BT_MESH_PB_ADV

if BT_CONN
Expand Down Expand Up @@ -375,7 +401,7 @@ config BT_MESH_RELAY_BUF_COUNT
of packet drops. When considering the message latency, also consider
the values of BT_MESH_RELAY_RETRANSMIT_COUNT and
BT_MESH_RELAY_RETRANSMIT_INTERVAL. A higher number of
BT_MESH_RELAY_ADV_SETS allows the increase in the number of buffers
BT_MESH_SIMULT_ADV_SETS allows the increase in the number of buffers
while maintaining the latency.

endif # BT_MESH_RELAY
Expand Down
44 changes: 23 additions & 21 deletions subsys/bluetooth/mesh/adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const uint8_t bt_mesh_adv_type[BT_MESH_ADV_TYPES] = {

static bool active_scanning;
static K_FIFO_DEFINE(bt_mesh_adv_queue);
static K_FIFO_DEFINE(bt_mesh_relay_queue);
static K_FIFO_DEFINE(bt_mesh_simult_queue);
static K_FIFO_DEFINE(bt_mesh_friend_queue);

void bt_mesh_adv_send_start(uint16_t duration, int err, struct bt_mesh_adv *adv)
Expand Down Expand Up @@ -138,15 +138,15 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type,
uint8_t xmit, k_timeout_t timeout)
{
#if defined(CONFIG_BT_MESH_RELAY)
if (tag == BT_MESH_RELAY_ADV) {
if (tag == BT_MESH_ADV_TAG_RELAY) {
return bt_mesh_adv_create_from_pool(&relay_buf_pool,
adv_relay_pool, type,
tag, xmit, timeout);
}
#endif

#if defined(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE)
if (tag == BT_MESH_FRIEND_ADV) {
if (tag == BT_MESH_ADV_TAG_FRIEND) {
return bt_mesh_adv_create_from_pool(&friend_buf_pool,
adv_friend_pool, type,
tag, xmit, timeout);
Expand All @@ -157,7 +157,7 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type,
tag, xmit, timeout);
}

#if CONFIG_BT_MESH_RELAY_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE
#if CONFIG_BT_MESH_SIMULT_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE
static struct net_buf *process_events(struct k_poll_event *ev, int count)
{
for (; count; ev++, count--) {
Expand Down Expand Up @@ -189,7 +189,7 @@ struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout)
#if defined(CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET)
K_POLL_EVENT_STATIC_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE,
K_POLL_MODE_NOTIFY_ONLY,
&bt_mesh_relay_queue,
&bt_mesh_simult_queue,
0),
#endif /* CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET */
};
Expand All @@ -204,19 +204,20 @@ struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout)

struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tags tags, k_timeout_t timeout)
{
if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) && tags & BT_MESH_FRIEND_ADV_BIT) {
if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) &&
tags & BT_MESH_ADV_TAG_FRIEND_BIT) {
return net_buf_get(&bt_mesh_friend_queue, timeout);
}

#if CONFIG_BT_MESH_RELAY_ADV_SETS
if (tags & BT_MESH_RELAY_ADV_BIT) {
return net_buf_get(&bt_mesh_relay_queue, timeout);
if (tags & BT_MESH_ADV_TAG_LOCAL_BIT) {
return bt_mesh_adv_buf_get(timeout);
}
#endif

return bt_mesh_adv_buf_get(timeout);
#if CONFIG_BT_MESH_SIMULT_ADV_SETS
return net_buf_get(&bt_mesh_simult_queue, timeout);
#endif
}
#else /* !(CONFIG_BT_MESH_RELAY_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) */
#else /* !(CONFIG_BT_MESH_SIMULT_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) */
struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout)
{
return net_buf_get(&bt_mesh_adv_queue, timeout);
Expand All @@ -228,17 +229,17 @@ struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tags tags, k_timeout

return bt_mesh_adv_buf_get(timeout);
}
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE */
#endif /* CONFIG_BT_MESH_SIMULT_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE */

void bt_mesh_adv_buf_get_cancel(void)
{
LOG_DBG("");

k_fifo_cancel_wait(&bt_mesh_adv_queue);

#if CONFIG_BT_MESH_RELAY_ADV_SETS
k_fifo_cancel_wait(&bt_mesh_relay_queue);
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS */
#if CONFIG_BT_MESH_SIMULT_ADV_SETS
k_fifo_cancel_wait(&bt_mesh_simult_queue);
#endif /* CONFIG_BT_MESH_SIMULT_ADV_SETS */

if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE)) {
k_fifo_cancel_wait(&bt_mesh_friend_queue);
Expand All @@ -260,16 +261,17 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
}

if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) &&
BT_MESH_ADV(buf)->tag == BT_MESH_FRIEND_ADV) {
BT_MESH_ADV(buf)->tag == BT_MESH_ADV_TAG_FRIEND) {
net_buf_put(&bt_mesh_friend_queue, net_buf_ref(buf));
bt_mesh_adv_buf_friend_ready();
return;
}

#if CONFIG_BT_MESH_RELAY_ADV_SETS
if (BT_MESH_ADV(buf)->tag == BT_MESH_RELAY_ADV) {
net_buf_put(&bt_mesh_relay_queue, net_buf_ref(buf));
bt_mesh_adv_buf_relay_ready();
#if CONFIG_BT_MESH_SIMULT_ADV_SETS
if (BT_MESH_ADV(buf)->tag == BT_MESH_ADV_TAG_RELAY ||
BT_MESH_ADV(buf)->tag == BT_MESH_ADV_TAG_PROV) {
net_buf_put(&bt_mesh_simult_queue, net_buf_ref(buf));
bt_mesh_adv_buf_simult_ready();
return;
}
#endif
Expand Down
22 changes: 13 additions & 9 deletions subsys/bluetooth/mesh/adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ enum bt_mesh_adv_type {
};

enum bt_mesh_adv_tag {
BT_MESH_LOCAL_ADV,
BT_MESH_RELAY_ADV,
BT_MESH_PROXY_ADV,
BT_MESH_FRIEND_ADV,
BT_MESH_ADV_TAG_LOCAL,
BT_MESH_ADV_TAG_RELAY,
BT_MESH_ADV_TAG_PROXY,
BT_MESH_ADV_TAG_FRIEND,
BT_MESH_ADV_TAG_PROV,
};

enum bt_mesh_adv_tags {
BT_MESH_LOCAL_ADV_BIT = BIT(BT_MESH_LOCAL_ADV),
BT_MESH_RELAY_ADV_BIT = BIT(BT_MESH_RELAY_ADV),
BT_MESH_PROXY_ADV_BIT = BIT(BT_MESH_PROXY_ADV),
BT_MESH_FRIEND_ADV_BIT = BIT(BT_MESH_FRIEND_ADV),
BT_MESH_ADV_TAG_LOCAL_BIT = BIT(BT_MESH_ADV_TAG_LOCAL),
BT_MESH_ADV_TAG_RELAY_BIT = BIT(BT_MESH_ADV_TAG_RELAY),
BT_MESH_ADV_TAG_PROXY_BIT = BIT(BT_MESH_ADV_TAG_PROXY),
BT_MESH_ADV_TAG_FRIEND_BIT = BIT(BT_MESH_ADV_TAG_FRIEND),
BT_MESH_ADV_TAG_PROV_BIT = BIT(BT_MESH_ADV_TAG_PROV),
};

struct bt_mesh_adv {
Expand Down Expand Up @@ -80,7 +82,9 @@ int bt_mesh_adv_enable(void);

void bt_mesh_adv_buf_local_ready(void);

void bt_mesh_adv_buf_relay_ready(void);
void bt_mesh_adv_buf_simult_ready(void);

void bt_mesh_adv_buf_terminate(struct net_buf *buf);

void bt_mesh_adv_buf_friend_ready(void);

Expand Down
Loading

0 comments on commit 141467a

Please sign in to comment.