Bluetooth: Mesh: Rename adv relay to adv simultaneous
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:https://github.com/zephyrproject-rtos/zephyr/pull/48903 Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
b14d235c31
commit
141467a261
14 changed files with 185 additions and 107 deletions
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
@ -138,7 +138,7 @@ 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);
|
||||
|
@ -146,7 +146,7 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type,
|
|||
#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);
|
||||
|
@ -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--) {
|
||||
|
@ -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 */
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -228,7 +229,7 @@ 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)
|
||||
{
|
||||
|
@ -236,9 +237,9 @@ void bt_mesh_adv_buf_get_cancel(void)
|
|||
|
||||
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);
|
||||
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ LOG_MODULE_REGISTER(bt_mesh_adv_ext);
|
|||
/* Convert from ms to 0.625ms units */
|
||||
#define ADV_INT_FAST_MS 20
|
||||
|
||||
#ifndef CONFIG_BT_MESH_RELAY_ADV_SETS
|
||||
#define CONFIG_BT_MESH_RELAY_ADV_SETS 0
|
||||
#ifndef CONFIG_BT_MESH_SIMULT_ADV_SETS
|
||||
#define CONFIG_BT_MESH_SIMULT_ADV_SETS 0
|
||||
#endif
|
||||
|
||||
enum {
|
||||
|
@ -72,32 +72,40 @@ static bool schedule_send(struct bt_mesh_ext_adv *adv);
|
|||
static STRUCT_SECTION_ITERABLE(bt_mesh_ext_adv, adv_main) = {
|
||||
.tags = (
|
||||
#if !defined(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE)
|
||||
BT_MESH_FRIEND_ADV_BIT |
|
||||
BT_MESH_ADV_TAG_FRIEND_BIT |
|
||||
#endif
|
||||
#if !defined(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE)
|
||||
BT_MESH_PROXY_ADV_BIT |
|
||||
BT_MESH_ADV_TAG_PROXY_BIT |
|
||||
#endif /* !CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */
|
||||
#if defined(CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET)
|
||||
BT_MESH_RELAY_ADV_BIT |
|
||||
BT_MESH_ADV_TAG_RELAY_BIT |
|
||||
#endif /* CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET */
|
||||
BT_MESH_LOCAL_ADV_BIT),
|
||||
BT_MESH_ADV_TAG_LOCAL_BIT),
|
||||
|
||||
.work = Z_WORK_DELAYABLE_INITIALIZER(send_pending_adv),
|
||||
};
|
||||
|
||||
#if CONFIG_BT_MESH_RELAY_ADV_SETS
|
||||
static STRUCT_SECTION_ITERABLE_ARRAY(bt_mesh_ext_adv, adv_relay, CONFIG_BT_MESH_RELAY_ADV_SETS) = {
|
||||
[0 ... CONFIG_BT_MESH_RELAY_ADV_SETS - 1] = {
|
||||
.tags = BT_MESH_RELAY_ADV_BIT,
|
||||
#if CONFIG_BT_MESH_SIMULT_ADV_SETS
|
||||
static STRUCT_SECTION_ITERABLE_ARRAY(bt_mesh_ext_adv, adv_relay, CONFIG_BT_MESH_SIMULT_ADV_SETS) = {
|
||||
[0 ... CONFIG_BT_MESH_SIMULT_ADV_SETS - 1] = {
|
||||
.tags = (
|
||||
#if defined(CONFIG_BT_MESH_RELAY)
|
||||
BT_MESH_ADV_TAG_RELAY_BIT |
|
||||
#endif /* CONFIG_BT_MESH_RELAY */
|
||||
#if defined(CONFIG_BT_MESH_PB_ADV)
|
||||
BT_MESH_ADV_TAG_PROV_BIT |
|
||||
#endif /* CONFIG_BT_MESH_PB_ADV */
|
||||
0),
|
||||
|
||||
.work = Z_WORK_DELAYABLE_INITIALIZER(send_pending_adv),
|
||||
}
|
||||
};
|
||||
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS */
|
||||
#endif /* CONFIG_BT_MESH_SIMULT_ADV_SETS */
|
||||
|
||||
#if defined(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE)
|
||||
#define ADV_EXT_FRIEND 1
|
||||
static STRUCT_SECTION_ITERABLE(bt_mesh_ext_adv, adv_friend) = {
|
||||
.tags = BT_MESH_FRIEND_ADV_BIT,
|
||||
.tags = BT_MESH_ADV_TAG_FRIEND_BIT,
|
||||
.work = Z_WORK_DELAYABLE_INITIALIZER(send_pending_adv),
|
||||
};
|
||||
#else /* CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE */
|
||||
|
@ -107,25 +115,25 @@ static STRUCT_SECTION_ITERABLE(bt_mesh_ext_adv, adv_friend) = {
|
|||
#if defined(CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE)
|
||||
#define ADV_EXT_GATT 1
|
||||
static STRUCT_SECTION_ITERABLE(bt_mesh_ext_adv, adv_gatt) = {
|
||||
.tags = BT_MESH_PROXY_ADV_BIT,
|
||||
.tags = BT_MESH_ADV_TAG_PROXY_BIT,
|
||||
.work = Z_WORK_DELAYABLE_INITIALIZER(send_pending_adv),
|
||||
};
|
||||
#else /* CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */
|
||||
#define ADV_EXT_GATT 0
|
||||
#endif /* CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */
|
||||
|
||||
#define BT_MESH_ADV_COUNT (1 + CONFIG_BT_MESH_RELAY_ADV_SETS + ADV_EXT_FRIEND + ADV_EXT_GATT)
|
||||
#define BT_MESH_ADV_COUNT (1 + CONFIG_BT_MESH_SIMULT_ADV_SETS + ADV_EXT_FRIEND + ADV_EXT_GATT)
|
||||
|
||||
BUILD_ASSERT(CONFIG_BT_EXT_ADV_MAX_ADV_SET >= BT_MESH_ADV_COUNT,
|
||||
"Insufficient adv instances");
|
||||
|
||||
static inline struct bt_mesh_ext_adv *relay_adv_get(void)
|
||||
{
|
||||
#if CONFIG_BT_MESH_RELAY_ADV_SETS
|
||||
#if CONFIG_BT_MESH_SIMULT_ADV_SETS
|
||||
return adv_relay;
|
||||
#else /* !CONFIG_BT_MESH_RELAY_ADV_SETS */
|
||||
#else /* !CONFIG_BT_MESH_SIMULT_ADV_SETS */
|
||||
return &adv_main;
|
||||
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS */
|
||||
#endif /* CONFIG_BT_MESH_SIMULT_ADV_SETS */
|
||||
}
|
||||
|
||||
static inline struct bt_mesh_ext_adv *gatt_adv_get(void)
|
||||
|
@ -234,20 +242,13 @@ static int buf_send(struct bt_mesh_ext_adv *adv, struct net_buf *buf)
|
|||
return err;
|
||||
}
|
||||
|
||||
static const char *adv_tag_to_str(enum bt_mesh_adv_tags tags)
|
||||
{
|
||||
if (tags & BT_MESH_LOCAL_ADV_BIT) {
|
||||
return "local adv";
|
||||
} else if (tags & BT_MESH_PROXY_ADV_BIT) {
|
||||
return "proxy adv";
|
||||
} else if (tags & BT_MESH_RELAY_ADV_BIT) {
|
||||
return "relay adv";
|
||||
} else if (tags & BT_MESH_FRIEND_ADV_BIT) {
|
||||
return "friend adv";
|
||||
} else {
|
||||
return "(unknown tags)";
|
||||
}
|
||||
}
|
||||
static const char * const adv_tag_to_str[] = {
|
||||
[BT_MESH_ADV_TAG_LOCAL] = "local adv",
|
||||
[BT_MESH_ADV_TAG_RELAY] = "relay adv",
|
||||
[BT_MESH_ADV_TAG_PROXY] = "proxy adv",
|
||||
[BT_MESH_ADV_TAG_FRIEND] = "friend adv",
|
||||
[BT_MESH_ADV_TAG_PROV] = "prov adv",
|
||||
};
|
||||
|
||||
static void send_pending_adv(struct k_work *work)
|
||||
{
|
||||
|
@ -264,8 +265,9 @@ static void send_pending_adv(struct k_work *work)
|
|||
*/
|
||||
int64_t duration = k_uptime_delta(&adv->timestamp);
|
||||
|
||||
LOG_DBG("Advertising stopped after %u ms for (%u) %s", (uint32_t)duration, adv->tags,
|
||||
adv_tag_to_str(adv->tags));
|
||||
LOG_DBG("Advertising stopped after %u ms for %s", (uint32_t)duration,
|
||||
adv->buf ? adv_tag_to_str[BT_MESH_ADV(adv->buf)->tag] :
|
||||
adv_tag_to_str[BT_MESH_ADV_TAG_PROXY]);
|
||||
|
||||
atomic_clear_bit(adv->flags, ADV_FLAG_ACTIVE);
|
||||
atomic_clear_bit(adv->flags, ADV_FLAG_PROXY);
|
||||
|
@ -301,7 +303,7 @@ static void send_pending_adv(struct k_work *work)
|
|||
}
|
||||
|
||||
if (!IS_ENABLED(CONFIG_BT_MESH_GATT_SERVER) ||
|
||||
!(adv->tags & BT_MESH_RELAY_ADV_BIT)) {
|
||||
!(adv->tags & BT_MESH_ADV_TAG_PROXY_BIT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -344,8 +346,9 @@ static bool schedule_send(struct bt_mesh_ext_adv *adv)
|
|||
|
||||
atomic_clear_bit(adv->flags, ADV_FLAG_SCHEDULE_PENDING);
|
||||
|
||||
if ((IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) && adv->tags & BT_MESH_FRIEND_ADV_BIT) ||
|
||||
(CONFIG_BT_MESH_RELAY_ADV_SETS > 0 && adv->tags & BT_MESH_RELAY_ADV_BIT)) {
|
||||
if ((IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) &&
|
||||
adv->tags & BT_MESH_ADV_TAG_FRIEND_BIT) ||
|
||||
(CONFIG_BT_MESH_SIMULT_ADV_SETS > 0 && adv->tags & BT_MESH_ADV_TAG_RELAY_BIT)) {
|
||||
k_work_reschedule(&adv->work, K_NO_WAIT);
|
||||
} else {
|
||||
/* The controller will send the next advertisement immediately.
|
||||
|
@ -369,11 +372,11 @@ void bt_mesh_adv_buf_local_ready(void)
|
|||
(void)schedule_send(&adv_main);
|
||||
}
|
||||
|
||||
void bt_mesh_adv_buf_relay_ready(void)
|
||||
void bt_mesh_adv_buf_simult_ready(void)
|
||||
{
|
||||
struct bt_mesh_ext_adv *adv = relay_adv_get();
|
||||
|
||||
for (int i = 0; i < CONFIG_BT_MESH_RELAY_ADV_SETS; i++) {
|
||||
for (int i = 0; i < CONFIG_BT_MESH_SIMULT_ADV_SETS; i++) {
|
||||
if (schedule_send(&adv[i])) {
|
||||
return;
|
||||
}
|
||||
|
@ -392,6 +395,36 @@ void bt_mesh_adv_buf_friend_ready(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void bt_mesh_adv_buf_terminate(struct net_buf *buf)
|
||||
{
|
||||
int err;
|
||||
|
||||
STRUCT_SECTION_FOREACH(bt_mesh_ext_adv, adv) {
|
||||
if (adv->buf != buf) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!atomic_test_bit(adv->flags, ADV_FLAG_ACTIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
err = bt_le_ext_adv_stop(adv->instance);
|
||||
if (err) {
|
||||
LOG_ERR("Failed to stop adv %d", err);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do not call `cb:end`, since this user action */
|
||||
BT_MESH_ADV(adv->buf)->cb = NULL;
|
||||
|
||||
atomic_set_bit(adv->flags, ADV_FLAG_SENT);
|
||||
|
||||
k_work_submit(&adv->work.work);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_adv_init(void)
|
||||
{
|
||||
struct bt_le_adv_param adv_param = {
|
||||
|
|
|
@ -195,7 +195,7 @@ void bt_mesh_adv_buf_local_ready(void)
|
|||
/* Will be handled automatically */
|
||||
}
|
||||
|
||||
void bt_mesh_adv_buf_relay_ready(void)
|
||||
void bt_mesh_adv_buf_simult_ready(void)
|
||||
{
|
||||
/* Will be handled automatically */
|
||||
}
|
||||
|
@ -205,6 +205,12 @@ void bt_mesh_adv_gatt_update(void)
|
|||
bt_mesh_adv_buf_get_cancel();
|
||||
}
|
||||
|
||||
void bt_mesh_adv_buf_terminate(struct net_buf *buf)
|
||||
{
|
||||
/* todo */
|
||||
ARG_UNUSED(buf);
|
||||
}
|
||||
|
||||
void bt_mesh_adv_init(void)
|
||||
{
|
||||
k_thread_create(&adv_thread_data, adv_thread_stack,
|
||||
|
|
|
@ -271,7 +271,7 @@ static bool net_beacon_send(struct bt_mesh_subnet *sub, struct bt_mesh_beacon *b
|
|||
return false;
|
||||
}
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, BT_MESH_LOCAL_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, BT_MESH_ADV_TAG_LOCAL,
|
||||
PROV_XMIT, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
LOG_ERR("Unable to allocate beacon buffer");
|
||||
|
@ -335,7 +335,7 @@ static int unprovisioned_beacon_send(void)
|
|||
|
||||
LOG_DBG("");
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, BT_MESH_LOCAL_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, BT_MESH_ADV_TAG_LOCAL,
|
||||
UNPROV_XMIT, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
LOG_ERR("Unable to allocate beacon buffer");
|
||||
|
@ -362,7 +362,7 @@ static int unprovisioned_beacon_send(void)
|
|||
if (prov->uri) {
|
||||
size_t len;
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_URI, BT_MESH_LOCAL_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_URI, BT_MESH_ADV_TAG_LOCAL,
|
||||
UNPROV_XMIT, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
LOG_ERR("Unable to allocate URI buffer");
|
||||
|
|
|
@ -1281,7 +1281,7 @@ static void friend_timeout(struct k_work *work)
|
|||
frnd->queue_size--;
|
||||
|
||||
send_last:
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_FRIEND_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_ADV_TAG_FRIEND,
|
||||
FRIEND_XMIT, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
LOG_ERR("Unable to allocate friend adv buffer");
|
||||
|
|
|
@ -712,7 +712,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
|
|||
transmit = bt_mesh_net_transmit_get();
|
||||
}
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_RELAY_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_ADV_TAG_RELAY,
|
||||
transmit, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
LOG_DBG("Out of relay buffers");
|
||||
|
|
|
@ -55,11 +55,11 @@ LOG_MODULE_REGISTER(bt_mesh_pb_adv);
|
|||
|
||||
/* Acked messages, will do retransmissions manually, taking acks into account:
|
||||
*/
|
||||
#define RETRANSMITS_RELIABLE 0
|
||||
#define RETRANSMITS_RELIABLE CONFIG_BT_MESH_PB_ADV_TRANS_PDU_RETRANSMIT_COUNT
|
||||
/* PDU acks: */
|
||||
#define RETRANSMITS_ACK 2
|
||||
#define RETRANSMITS_ACK CONFIG_BT_MESH_PB_ADV_TRANS_ACK_RETRANSMIT_COUNT
|
||||
/* Link close retransmits: */
|
||||
#define RETRANSMITS_LINK_CLOSE 2
|
||||
#define RETRANSMITS_LINK_CLOSE CONFIG_BT_MESH_PB_ADV_LINK_CLOSE_RETRANSMIT_COUNT
|
||||
|
||||
enum {
|
||||
ADV_LINK_ACTIVE, /* Link has been opened */
|
||||
|
@ -178,8 +178,15 @@ static void free_segments(void)
|
|||
}
|
||||
|
||||
link.tx.buf[i] = NULL;
|
||||
/* Mark as canceled */
|
||||
BT_MESH_ADV(buf)->busy = 0U;
|
||||
|
||||
/* Terminate active adv */
|
||||
if (BT_MESH_ADV(buf)->busy == 0U) {
|
||||
bt_mesh_adv_buf_terminate(buf);
|
||||
} else {
|
||||
/* Mark as canceled */
|
||||
BT_MESH_ADV(buf)->busy = 0U;
|
||||
}
|
||||
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +258,7 @@ static struct net_buf *adv_buf_create(uint8_t retransmits)
|
|||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_PROV, BT_MESH_LOCAL_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_PROV, BT_MESH_ADV_TAG_PROV,
|
||||
BT_MESH_TRANSMIT(retransmits, 20),
|
||||
BUF_TIMEOUT);
|
||||
if (!buf) {
|
||||
|
|
|
@ -24,22 +24,22 @@ void bt_mesh_stat_reset(void)
|
|||
|
||||
void bt_mesh_stat_planned_count(struct bt_mesh_adv *adv)
|
||||
{
|
||||
if (adv->tag == BT_MESH_LOCAL_ADV) {
|
||||
if (adv->tag == BT_MESH_ADV_TAG_LOCAL) {
|
||||
stat.tx_local_planned++;
|
||||
} else if (adv->tag == BT_MESH_RELAY_ADV) {
|
||||
} else if (adv->tag == BT_MESH_ADV_TAG_RELAY) {
|
||||
stat.tx_adv_relay_planned++;
|
||||
} else if (adv->tag == BT_MESH_FRIEND_ADV) {
|
||||
} else if (adv->tag == BT_MESH_ADV_TAG_FRIEND) {
|
||||
stat.tx_friend_planned++;
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_stat_succeeded_count(struct bt_mesh_adv *adv)
|
||||
{
|
||||
if (adv->tag == BT_MESH_LOCAL_ADV) {
|
||||
if (adv->tag == BT_MESH_ADV_TAG_LOCAL) {
|
||||
stat.tx_local_succeeded++;
|
||||
} else if (adv->tag == BT_MESH_RELAY_ADV) {
|
||||
} else if (adv->tag == BT_MESH_ADV_TAG_RELAY) {
|
||||
stat.tx_adv_relay_succeeded++;
|
||||
} else if (adv->tag == BT_MESH_FRIEND_ADV) {
|
||||
} else if (adv->tag == BT_MESH_ADV_TAG_FRIEND) {
|
||||
stat.tx_friend_succeeded++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu,
|
|||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_ADV_TAG_LOCAL,
|
||||
tx->xmit, BUF_TIMEOUT);
|
||||
if (!buf) {
|
||||
LOG_ERR("Out of network buffers");
|
||||
|
@ -414,7 +414,7 @@ static void seg_tx_send_unacked(struct seg_tx *tx)
|
|||
continue;
|
||||
}
|
||||
|
||||
seg = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV,
|
||||
seg = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_ADV_TAG_LOCAL,
|
||||
tx->xmit, BUF_TIMEOUT);
|
||||
if (!seg) {
|
||||
LOG_DBG("Allocating segment failed");
|
||||
|
|
|
@ -131,7 +131,7 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu,
|
|||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV,
|
||||
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_ADV_TAG_LOCAL,
|
||||
tx->xmit, BUF_TIMEOUT);
|
||||
if (!buf) {
|
||||
LOG_ERR("Out of network buffers");
|
||||
|
@ -401,7 +401,7 @@ static void seg_tx_send_unacked(struct seg_tx *tx)
|
|||
continue;
|
||||
}
|
||||
|
||||
seg = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_LOCAL_ADV,
|
||||
seg = bt_mesh_adv_create(BT_MESH_ADV_DATA, BT_MESH_ADV_TAG_LOCAL,
|
||||
tx->xmit, BUF_TIMEOUT);
|
||||
if (!seg) {
|
||||
LOG_DBG("Allocating segment failed");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue