ble_mesh: stack: Rename mesh adv queue and relay queue
This commit is contained in:
parent
da068a639f
commit
2a6b0d68ce
|
@ -27,25 +27,19 @@
|
||||||
#include "mesh_bearer_adapt.h"
|
#include "mesh_bearer_adapt.h"
|
||||||
|
|
||||||
/* Convert from ms to 0.625ms units */
|
/* Convert from ms to 0.625ms units */
|
||||||
#define ADV_SCAN_UNIT(_ms) ((_ms) * 8 / 5)
|
#define ADV_SCAN_UNIT(_ms) ((_ms) * 8 / 5)
|
||||||
/* Convert from 0.625ms units to interval(ms) */
|
/* Convert from 0.625ms units to interval(ms) */
|
||||||
#define ADV_SCAN_INT(val) ((val) * 5 / 8)
|
#define ADV_SCAN_INT(val) ((val) * 5 / 8)
|
||||||
|
|
||||||
/* Window and Interval are equal for continuous scanning */
|
/* Window and Interval are equal for continuous scanning */
|
||||||
#define MESH_SCAN_INTERVAL 0x20
|
#define MESH_SCAN_INTERVAL 0x20
|
||||||
#define MESH_SCAN_WINDOW 0x20
|
#define MESH_SCAN_WINDOW 0x20
|
||||||
|
|
||||||
/* Pre-5.0 controllers enforce a minimum interval of 100ms
|
/* Pre-5.0 controllers enforce a minimum interval of 100ms
|
||||||
* whereas 5.0+ controllers can go down to 20ms.
|
* whereas 5.0+ controllers can go down to 20ms.
|
||||||
*/
|
*/
|
||||||
#define ADV_INT_DEFAULT_MS 100
|
#define ADV_INT_DEFAULT_MS 100
|
||||||
#define ADV_INT_FAST_MS 20
|
#define ADV_INT_FAST_MS 20
|
||||||
|
|
||||||
#if defined(CONFIG_BT_HOST_CRYPTO)
|
|
||||||
#define ADV_STACK_SIZE 1024
|
|
||||||
#else
|
|
||||||
#define ADV_STACK_SIZE 768
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const bt_mesh_addr_t *dev_addr;
|
static const bt_mesh_addr_t *dev_addr;
|
||||||
|
|
||||||
|
@ -62,19 +56,19 @@ NET_BUF_POOL_DEFINE(adv_buf_pool, CONFIG_BLE_MESH_ADV_BUF_COUNT,
|
||||||
static struct bt_mesh_adv adv_pool[CONFIG_BLE_MESH_ADV_BUF_COUNT];
|
static struct bt_mesh_adv adv_pool[CONFIG_BLE_MESH_ADV_BUF_COUNT];
|
||||||
|
|
||||||
struct bt_mesh_queue {
|
struct bt_mesh_queue {
|
||||||
QueueHandle_t queue;
|
QueueHandle_t handle;
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||||
StaticQueue_t *buffer;
|
StaticQueue_t *buffer;
|
||||||
u8_t *storage;
|
u8_t *storage;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct bt_mesh_queue xBleMeshQueue;
|
static struct bt_mesh_queue adv_queue;
|
||||||
/* We reserve one queue for bt_mesh_adv_update() */
|
/* We reserve one queue item for bt_mesh_adv_update() */
|
||||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||||
#define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1)
|
#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1)
|
||||||
#else
|
#else
|
||||||
#define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
|
#define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||||
|
@ -83,11 +77,11 @@ NET_BUF_POOL_DEFINE(relay_adv_buf_pool, CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT,
|
||||||
|
|
||||||
static struct bt_mesh_adv relay_adv_pool[CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT];
|
static struct bt_mesh_adv relay_adv_pool[CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT];
|
||||||
|
|
||||||
static struct bt_mesh_queue xBleMeshRelayQueue;
|
static struct bt_mesh_queue relay_queue;
|
||||||
#define BLE_MESH_RELAY_QUEUE_SIZE CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT
|
#define BLE_MESH_RELAY_QUEUE_SIZE CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT
|
||||||
|
|
||||||
static QueueSetHandle_t xBleMeshQueueSet;
|
static QueueSetHandle_t mesh_queue_set;
|
||||||
#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
|
#define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_ADV_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
|
||||||
|
|
||||||
#define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6)
|
#define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6)
|
||||||
#define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF
|
#define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF
|
||||||
|
@ -260,28 +254,28 @@ static void adv_thread(void *p)
|
||||||
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||||
while (!(*buf)) {
|
while (!(*buf)) {
|
||||||
s32_t timeout;
|
s32_t timeout;
|
||||||
BT_DBG("Mesh Proxy Advertising start");
|
BT_DBG("Mesh Proxy Advertising start");
|
||||||
timeout = bt_mesh_proxy_adv_start();
|
timeout = bt_mesh_proxy_adv_start();
|
||||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||||
xQueueReceive(xBleMeshQueue.queue, &msg, timeout);
|
xQueueReceive(adv_queue.handle, &msg, timeout);
|
||||||
BT_DBG("Mesh Proxy Advertising stop");
|
BT_DBG("Mesh Proxy Advertising stop");
|
||||||
bt_mesh_proxy_adv_stop();
|
bt_mesh_proxy_adv_stop();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
xQueueReceive(xBleMeshQueue.queue, &msg, portMAX_DELAY);
|
xQueueReceive(adv_queue.handle, &msg, portMAX_DELAY);
|
||||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||||
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, K_NO_WAIT);
|
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) {
|
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||||
} else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
} else if (uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||||
xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(relay_queue.handle, &msg, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!(*buf)) {
|
while (!(*buf)) {
|
||||||
|
@ -289,25 +283,25 @@ static void adv_thread(void *p)
|
||||||
BT_DBG("Mesh Proxy Advertising start");
|
BT_DBG("Mesh Proxy Advertising start");
|
||||||
timeout = bt_mesh_proxy_adv_start();
|
timeout = bt_mesh_proxy_adv_start();
|
||||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, timeout);
|
handle = xQueueSelectFromSet(mesh_queue_set, timeout);
|
||||||
BT_DBG("Mesh Proxy Advertising stop");
|
BT_DBG("Mesh Proxy Advertising stop");
|
||||||
bt_mesh_proxy_adv_stop();
|
bt_mesh_proxy_adv_stop();
|
||||||
if (handle) {
|
if (handle) {
|
||||||
if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) {
|
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||||
} else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
} else if (uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||||
xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(relay_queue.handle, &msg, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, portMAX_DELAY);
|
handle = xQueueSelectFromSet(mesh_queue_set, portMAX_DELAY);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
if (uxQueueMessagesWaiting(xBleMeshQueue.queue)) {
|
if (uxQueueMessagesWaiting(adv_queue.handle)) {
|
||||||
xQueueReceive(xBleMeshQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||||
} else if (uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
} else if (uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||||
xQueueReceive(xBleMeshRelayQueue.queue, &msg, K_NO_WAIT);
|
xQueueReceive(relay_queue.handle, &msg, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
|
||||||
|
@ -448,18 +442,18 @@ static void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout, bool front)
|
||||||
{
|
{
|
||||||
BT_DBG("%s", __func__);
|
BT_DBG("%s", __func__);
|
||||||
|
|
||||||
if (xBleMeshQueue.queue == NULL) {
|
if (adv_queue.handle == NULL) {
|
||||||
BT_ERR("%s, Invalid queue", __func__);
|
BT_ERR("%s, Invalid queue", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (front) {
|
if (front) {
|
||||||
if (xQueueSendToFront(xBleMeshQueue.queue, msg, timeout) != pdTRUE) {
|
if (xQueueSendToFront(adv_queue.handle, msg, timeout) != pdTRUE) {
|
||||||
BT_ERR("%s, Failed to send item to queue front", __func__);
|
BT_ERR("%s, Failed to send item to queue front", __func__);
|
||||||
bt_mesh_unref_buf(msg);
|
bt_mesh_unref_buf(msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (xQueueSend(xBleMeshQueue.queue, msg, timeout) != pdTRUE) {
|
if (xQueueSend(adv_queue.handle, msg, timeout) != pdTRUE) {
|
||||||
BT_ERR("%s, Failed to send item to queue back", __func__);
|
BT_ERR("%s, Failed to send item to queue back", __func__);
|
||||||
bt_mesh_unref_buf(msg);
|
bt_mesh_unref_buf(msg);
|
||||||
}
|
}
|
||||||
|
@ -532,12 +526,12 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||||
|
|
||||||
BT_DBG("%s", __func__);
|
BT_DBG("%s", __func__);
|
||||||
|
|
||||||
if (xBleMeshRelayQueue.queue == NULL) {
|
if (relay_queue.handle == NULL) {
|
||||||
BT_ERR("%s, Invalid relay queue", __func__);
|
BT_ERR("%s, Invalid relay queue", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xQueueSend(xBleMeshRelayQueue.queue, msg, timeout) == pdTRUE) {
|
if (xQueueSend(relay_queue.handle, msg, timeout) == pdTRUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,11 +539,11 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||||
* If failed to send packet to the relay queue(queue is full), we will
|
* If failed to send packet to the relay queue(queue is full), we will
|
||||||
* remove the oldest packet in the queue and put the new one into it.
|
* remove the oldest packet in the queue and put the new one into it.
|
||||||
*/
|
*/
|
||||||
handle = xQueueSelectFromSet(xBleMeshQueueSet, K_NO_WAIT);
|
handle = xQueueSelectFromSet(mesh_queue_set, K_NO_WAIT);
|
||||||
if (handle && uxQueueMessagesWaiting(xBleMeshRelayQueue.queue)) {
|
if (handle && uxQueueMessagesWaiting(relay_queue.handle)) {
|
||||||
BT_INFO("%s, Full queue, remove the oldest relay packet", __func__);
|
BT_INFO("%s, Full queue, remove the oldest relay packet", __func__);
|
||||||
/* Remove the oldest relay packet from queue */
|
/* Remove the oldest relay packet from queue */
|
||||||
if (xQueueReceive(xBleMeshRelayQueue.queue, &old_msg, K_NO_WAIT) != pdTRUE) {
|
if (xQueueReceive(relay_queue.handle, &old_msg, K_NO_WAIT) != pdTRUE) {
|
||||||
BT_ERR("%s, Failed to remove item from queue", __func__);
|
BT_ERR("%s, Failed to remove item from queue", __func__);
|
||||||
bt_mesh_unref_buf(msg);
|
bt_mesh_unref_buf(msg);
|
||||||
return;
|
return;
|
||||||
|
@ -557,7 +551,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||||
/* Unref buf used for the oldest relay packet */
|
/* Unref buf used for the oldest relay packet */
|
||||||
bt_mesh_unref_buf(&old_msg);
|
bt_mesh_unref_buf(&old_msg);
|
||||||
/* Send the latest relay packet to queue */
|
/* Send the latest relay packet to queue */
|
||||||
if (xQueueSend(xBleMeshRelayQueue.queue, msg, K_NO_WAIT) != pdTRUE) {
|
if (xQueueSend(relay_queue.handle, msg, K_NO_WAIT) != pdTRUE) {
|
||||||
BT_ERR("%s, Failed to send item to relay queue", __func__);
|
BT_ERR("%s, Failed to send item to relay queue", __func__);
|
||||||
bt_mesh_unref_buf(msg);
|
bt_mesh_unref_buf(msg);
|
||||||
return;
|
return;
|
||||||
|
@ -586,13 +580,13 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *c
|
||||||
msg.src = src;
|
msg.src = src;
|
||||||
msg.dst = dst;
|
msg.dst = dst;
|
||||||
msg.timestamp = k_uptime_get_32();
|
msg.timestamp = k_uptime_get_32();
|
||||||
/* Use K_NO_WAIT here, if xBleMeshRelayQueue is full return immediately */
|
/* Use K_NO_WAIT here, if relay_queue is full return immediately */
|
||||||
ble_mesh_relay_task_post(&msg, K_NO_WAIT);
|
ble_mesh_relay_task_post(&msg, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16_t bt_mesh_get_stored_relay_count(void)
|
u16_t bt_mesh_get_stored_relay_count(void)
|
||||||
{
|
{
|
||||||
return (u16_t)uxQueueMessagesWaiting(xBleMeshRelayQueue.queue);
|
return (u16_t)uxQueueMessagesWaiting(relay_queue.handle);
|
||||||
}
|
}
|
||||||
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||||
|
|
||||||
|
@ -798,50 +792,50 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
|
||||||
void bt_mesh_adv_init(void)
|
void bt_mesh_adv_init(void)
|
||||||
{
|
{
|
||||||
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||||
xBleMeshQueue.queue = xQueueCreate(BLE_MESH_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
adv_queue.handle = xQueueCreate(BLE_MESH_ADV_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||||
__ASSERT(xBleMeshQueue.queue, "Failed to create queue");
|
__ASSERT(adv_queue.handle, "Failed to create queue");
|
||||||
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||||
xBleMeshQueue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
adv_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||||
xBleMeshQueue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
adv_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#endif
|
#endif
|
||||||
__ASSERT(xBleMeshQueue.buffer, "Failed to create queue buffer");
|
__ASSERT(adv_queue.buffer, "Failed to create queue buffer");
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||||
xBleMeshQueue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
adv_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_ADV_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||||
xBleMeshQueue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
adv_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_ADV_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#endif
|
#endif
|
||||||
__ASSERT(xBleMeshQueue.storage, "Failed to create queue storage");
|
__ASSERT(adv_queue.storage, "Failed to create queue storage");
|
||||||
xBleMeshQueue.queue = xQueueCreateStatic(BLE_MESH_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)xBleMeshQueue.storage, xBleMeshQueue.buffer);
|
adv_queue.handle = xQueueCreateStatic(BLE_MESH_ADV_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)adv_queue.storage, adv_queue.buffer);
|
||||||
__ASSERT(xBleMeshQueue.queue, "Failed to create static queue");
|
__ASSERT(adv_queue.handle, "Failed to create static queue");
|
||||||
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||||
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||||
xBleMeshRelayQueue.queue = xQueueCreate(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
relay_queue.handle = xQueueCreate(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t));
|
||||||
__ASSERT(xBleMeshRelayQueue.queue, "Failed to create relay queue");
|
__ASSERT(relay_queue.handle, "Failed to create relay queue");
|
||||||
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||||
xBleMeshRelayQueue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
relay_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||||
xBleMeshRelayQueue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
relay_queue.buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#endif
|
#endif
|
||||||
__ASSERT(xBleMeshRelayQueue.buffer, "Failed to create relay queue buffer");
|
__ASSERT(relay_queue.buffer, "Failed to create relay queue buffer");
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||||
xBleMeshRelayQueue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
relay_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
|
||||||
xBleMeshRelayQueue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
relay_queue.storage = heap_caps_calloc_prefer(1, (BLE_MESH_RELAY_QUEUE_SIZE * sizeof(bt_mesh_msg_t)), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||||
#endif
|
#endif
|
||||||
__ASSERT(xBleMeshRelayQueue.storage, "Failed to create relay queue storage");
|
__ASSERT(relay_queue.storage, "Failed to create relay queue storage");
|
||||||
xBleMeshRelayQueue.queue = xQueueCreateStatic(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)xBleMeshRelayQueue.storage, xBleMeshRelayQueue.buffer);
|
relay_queue.handle = xQueueCreateStatic(BLE_MESH_RELAY_QUEUE_SIZE, sizeof(bt_mesh_msg_t), (uint8_t*)relay_queue.storage, relay_queue.buffer);
|
||||||
__ASSERT(xBleMeshRelayQueue.queue, "Failed to create static relay queue");
|
__ASSERT(relay_queue.handle, "Failed to create static relay queue");
|
||||||
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
|
||||||
|
|
||||||
xBleMeshQueueSet = xQueueCreateSet(BLE_MESH_QUEUE_SET_SIZE);
|
mesh_queue_set = xQueueCreateSet(BLE_MESH_QUEUE_SET_SIZE);
|
||||||
__ASSERT(xBleMeshQueueSet, "Failed to create queue set");
|
__ASSERT(mesh_queue_set, "Failed to create queue set");
|
||||||
xQueueAddToSet(xBleMeshQueue.queue, xBleMeshQueueSet);
|
xQueueAddToSet(adv_queue.handle, mesh_queue_set);
|
||||||
xQueueAddToSet(xBleMeshRelayQueue.queue, xBleMeshQueueSet);
|
xQueueAddToSet(relay_queue.handle, mesh_queue_set);
|
||||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||||
|
|
||||||
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
|
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
|
||||||
|
@ -863,7 +857,7 @@ void bt_mesh_adv_init(void)
|
||||||
|
|
||||||
void bt_mesh_adv_deinit(void)
|
void bt_mesh_adv_deinit(void)
|
||||||
{
|
{
|
||||||
if (xBleMeshQueue.queue == NULL) {
|
if (adv_queue.handle == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,32 +873,32 @@ void bt_mesh_adv_deinit(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||||
xQueueRemoveFromSet(xBleMeshQueue.queue, xBleMeshQueueSet);
|
xQueueRemoveFromSet(adv_queue.handle, mesh_queue_set);
|
||||||
xQueueRemoveFromSet(xBleMeshRelayQueue.queue, xBleMeshQueueSet);
|
xQueueRemoveFromSet(relay_queue.handle, mesh_queue_set);
|
||||||
|
|
||||||
vQueueDelete(xBleMeshRelayQueue.queue);
|
vQueueDelete(relay_queue.handle);
|
||||||
xBleMeshRelayQueue.queue = NULL;
|
relay_queue.handle = NULL;
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||||
heap_caps_free(xBleMeshRelayQueue.buffer);
|
heap_caps_free(relay_queue.buffer);
|
||||||
xBleMeshRelayQueue.buffer = NULL;
|
relay_queue.buffer = NULL;
|
||||||
heap_caps_free(xBleMeshRelayQueue.storage);
|
heap_caps_free(relay_queue.storage);
|
||||||
xBleMeshRelayQueue.storage = NULL;
|
relay_queue.storage = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bt_mesh_unref_buf_from_pool(&relay_adv_buf_pool);
|
bt_mesh_unref_buf_from_pool(&relay_adv_buf_pool);
|
||||||
memset(relay_adv_pool, 0, sizeof(relay_adv_pool));
|
memset(relay_adv_pool, 0, sizeof(relay_adv_pool));
|
||||||
|
|
||||||
vQueueDelete(xBleMeshQueueSet);
|
vQueueDelete(mesh_queue_set);
|
||||||
xBleMeshQueueSet = NULL;
|
mesh_queue_set = NULL;
|
||||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||||
|
|
||||||
vQueueDelete(xBleMeshQueue.queue);
|
vQueueDelete(adv_queue.handle);
|
||||||
xBleMeshQueue.queue = NULL;
|
adv_queue.handle = NULL;
|
||||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||||
heap_caps_free(xBleMeshQueue.buffer);
|
heap_caps_free(adv_queue.buffer);
|
||||||
xBleMeshQueue.buffer = NULL;
|
adv_queue.buffer = NULL;
|
||||||
heap_caps_free(xBleMeshQueue.storage);
|
heap_caps_free(adv_queue.storage);
|
||||||
xBleMeshQueue.storage = NULL;
|
adv_queue.storage = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bt_mesh_unref_buf_from_pool(&adv_buf_pool);
|
bt_mesh_unref_buf_from_pool(&adv_buf_pool);
|
||||||
|
|
Loading…
Reference in a new issue