27
27
#include "mesh_bearer_adapt.h"
28
28
29
29
/* Convert from ms to 0.625ms units */
30
- #define ADV_SCAN_UNIT (_ms ) ((_ms) * 8 / 5)
30
+ #define ADV_SCAN_UNIT (_ms ) ((_ms) * 8 / 5)
31
31
/* Convert from 0.625ms units to interval(ms) */
32
- #define ADV_SCAN_INT (val ) ((val) * 5 / 8)
32
+ #define ADV_SCAN_INT (val ) ((val) * 5 / 8)
33
33
34
34
/* Window and Interval are equal for continuous scanning */
35
- #define MESH_SCAN_INTERVAL 0x20
36
- #define MESH_SCAN_WINDOW 0x20
35
+ #define MESH_SCAN_INTERVAL 0x20
36
+ #define MESH_SCAN_WINDOW 0x20
37
37
38
38
/* Pre-5.0 controllers enforce a minimum interval of 100ms
39
39
* whereas 5.0+ controllers can go down to 20ms.
40
40
*/
41
- #define ADV_INT_DEFAULT_MS 100
42
- #define ADV_INT_FAST_MS 20
43
-
44
- #if defined(CONFIG_BT_HOST_CRYPTO )
45
- #define ADV_STACK_SIZE 1024
46
- #else
47
- #define ADV_STACK_SIZE 768
48
- #endif
41
+ #define ADV_INT_DEFAULT_MS 100
42
+ #define ADV_INT_FAST_MS 20
49
43
50
44
static const bt_mesh_addr_t * dev_addr ;
51
45
@@ -62,19 +56,19 @@ NET_BUF_POOL_DEFINE(adv_buf_pool, CONFIG_BLE_MESH_ADV_BUF_COUNT,
62
56
static struct bt_mesh_adv adv_pool [CONFIG_BLE_MESH_ADV_BUF_COUNT ];
63
57
64
58
struct bt_mesh_queue {
65
- QueueHandle_t queue ;
59
+ QueueHandle_t handle ;
66
60
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
67
61
StaticQueue_t * buffer ;
68
62
u8_t * storage ;
69
63
#endif
70
64
};
71
65
72
- static struct bt_mesh_queue xBleMeshQueue ;
73
- /* We reserve one queue for bt_mesh_adv_update() */
66
+ static struct bt_mesh_queue adv_queue ;
67
+ /* We reserve one queue item for bt_mesh_adv_update() */
74
68
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
75
- #define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1)
69
+ #define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT + 1)
76
70
#else
77
- #define BLE_MESH_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
71
+ #define BLE_MESH_ADV_QUEUE_SIZE (CONFIG_BLE_MESH_ADV_BUF_COUNT + 1)
78
72
#endif
79
73
80
74
#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,
83
77
84
78
static struct bt_mesh_adv relay_adv_pool [CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT ];
85
79
86
- static struct bt_mesh_queue xBleMeshRelayQueue ;
80
+ static struct bt_mesh_queue relay_queue ;
87
81
#define BLE_MESH_RELAY_QUEUE_SIZE CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT
88
82
89
- static QueueSetHandle_t xBleMeshQueueSet ;
90
- #define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
83
+ static QueueSetHandle_t mesh_queue_set ;
84
+ #define BLE_MESH_QUEUE_SET_SIZE (BLE_MESH_ADV_QUEUE_SIZE + BLE_MESH_RELAY_QUEUE_SIZE)
91
85
92
86
#define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6)
93
87
#define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF
@@ -260,54 +254,54 @@ static void adv_thread(void *p)
260
254
#if !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF )
261
255
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT ) || \
262
256
CONFIG_BLE_MESH_GATT_PROXY_SERVER
263
- xQueueReceive (xBleMeshQueue . queue , & msg , K_NO_WAIT );
257
+ xQueueReceive (adv_queue . handle , & msg , K_NO_WAIT );
264
258
while (!(* buf )) {
265
259
s32_t timeout ;
266
260
BT_DBG ("Mesh Proxy Advertising start" );
267
261
timeout = bt_mesh_proxy_adv_start ();
268
262
BT_DBG ("Mesh Proxy Advertising up to %d ms" , timeout );
269
- xQueueReceive (xBleMeshQueue . queue , & msg , timeout );
263
+ xQueueReceive (adv_queue . handle , & msg , timeout );
270
264
BT_DBG ("Mesh Proxy Advertising stop" );
271
265
bt_mesh_proxy_adv_stop ();
272
266
}
273
267
#else
274
- xQueueReceive (xBleMeshQueue . queue , & msg , portMAX_DELAY );
268
+ xQueueReceive (adv_queue . handle , & msg , portMAX_DELAY );
275
269
#endif /* (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_SERVER */
276
270
#else /* !defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
277
271
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT ) || \
278
272
CONFIG_BLE_MESH_GATT_PROXY_SERVER
279
- handle = xQueueSelectFromSet (xBleMeshQueueSet , K_NO_WAIT );
273
+ handle = xQueueSelectFromSet (mesh_queue_set , K_NO_WAIT );
280
274
if (handle ) {
281
- if (uxQueueMessagesWaiting (xBleMeshQueue . queue )) {
282
- xQueueReceive (xBleMeshQueue . queue , & msg , K_NO_WAIT );
283
- } else if (uxQueueMessagesWaiting (xBleMeshRelayQueue . queue )) {
284
- xQueueReceive (xBleMeshRelayQueue . queue , & msg , K_NO_WAIT );
275
+ if (uxQueueMessagesWaiting (adv_queue . handle )) {
276
+ xQueueReceive (adv_queue . handle , & msg , K_NO_WAIT );
277
+ } else if (uxQueueMessagesWaiting (relay_queue . handle )) {
278
+ xQueueReceive (relay_queue . handle , & msg , K_NO_WAIT );
285
279
}
286
280
} else {
287
281
while (!(* buf )) {
288
282
s32_t timeout = 0 ;
289
283
BT_DBG ("Mesh Proxy Advertising start" );
290
284
timeout = bt_mesh_proxy_adv_start ();
291
285
BT_DBG ("Mesh Proxy Advertising up to %d ms" , timeout );
292
- handle = xQueueSelectFromSet (xBleMeshQueueSet , timeout );
286
+ handle = xQueueSelectFromSet (mesh_queue_set , timeout );
293
287
BT_DBG ("Mesh Proxy Advertising stop" );
294
288
bt_mesh_proxy_adv_stop ();
295
289
if (handle ) {
296
- if (uxQueueMessagesWaiting (xBleMeshQueue . queue )) {
297
- xQueueReceive (xBleMeshQueue . queue , & msg , K_NO_WAIT );
298
- } else if (uxQueueMessagesWaiting (xBleMeshRelayQueue . queue )) {
299
- xQueueReceive (xBleMeshRelayQueue . queue , & msg , K_NO_WAIT );
290
+ if (uxQueueMessagesWaiting (adv_queue . handle )) {
291
+ xQueueReceive (adv_queue . handle , & msg , K_NO_WAIT );
292
+ } else if (uxQueueMessagesWaiting (relay_queue . handle )) {
293
+ xQueueReceive (relay_queue . handle , & msg , K_NO_WAIT );
300
294
}
301
295
}
302
296
}
303
297
}
304
298
#else
305
- handle = xQueueSelectFromSet (xBleMeshQueueSet , portMAX_DELAY );
299
+ handle = xQueueSelectFromSet (mesh_queue_set , portMAX_DELAY );
306
300
if (handle ) {
307
- if (uxQueueMessagesWaiting (xBleMeshQueue . queue )) {
308
- xQueueReceive (xBleMeshQueue . queue , & msg , K_NO_WAIT );
309
- } else if (uxQueueMessagesWaiting (xBleMeshRelayQueue . queue )) {
310
- xQueueReceive (xBleMeshRelayQueue . queue , & msg , K_NO_WAIT );
301
+ if (uxQueueMessagesWaiting (adv_queue . handle )) {
302
+ xQueueReceive (adv_queue . handle , & msg , K_NO_WAIT );
303
+ } else if (uxQueueMessagesWaiting (relay_queue . handle )) {
304
+ xQueueReceive (relay_queue . handle , & msg , K_NO_WAIT );
311
305
}
312
306
}
313
307
#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)
448
442
{
449
443
BT_DBG ("%s" , __func__ );
450
444
451
- if (xBleMeshQueue . queue == NULL ) {
445
+ if (adv_queue . handle == NULL ) {
452
446
BT_ERR ("%s, Invalid queue" , __func__ );
453
447
return ;
454
448
}
455
449
456
450
if (front ) {
457
- if (xQueueSendToFront (xBleMeshQueue . queue , msg , timeout ) != pdTRUE ) {
451
+ if (xQueueSendToFront (adv_queue . handle , msg , timeout ) != pdTRUE ) {
458
452
BT_ERR ("%s, Failed to send item to queue front" , __func__ );
459
453
bt_mesh_unref_buf (msg );
460
454
}
461
455
} else {
462
- if (xQueueSend (xBleMeshQueue . queue , msg , timeout ) != pdTRUE ) {
456
+ if (xQueueSend (adv_queue . handle , msg , timeout ) != pdTRUE ) {
463
457
BT_ERR ("%s, Failed to send item to queue back" , __func__ );
464
458
bt_mesh_unref_buf (msg );
465
459
}
@@ -532,32 +526,32 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
532
526
533
527
BT_DBG ("%s" , __func__ );
534
528
535
- if (xBleMeshRelayQueue . queue == NULL ) {
529
+ if (relay_queue . handle == NULL ) {
536
530
BT_ERR ("%s, Invalid relay queue" , __func__ );
537
531
return ;
538
532
}
539
533
540
- if (xQueueSend (xBleMeshRelayQueue . queue , msg , timeout ) == pdTRUE ) {
534
+ if (xQueueSend (relay_queue . handle , msg , timeout ) == pdTRUE ) {
541
535
return ;
542
536
}
543
537
544
538
/**
545
539
* If failed to send packet to the relay queue(queue is full), we will
546
540
* remove the oldest packet in the queue and put the new one into it.
547
541
*/
548
- handle = xQueueSelectFromSet (xBleMeshQueueSet , K_NO_WAIT );
549
- if (handle && uxQueueMessagesWaiting (xBleMeshRelayQueue . queue )) {
542
+ handle = xQueueSelectFromSet (mesh_queue_set , K_NO_WAIT );
543
+ if (handle && uxQueueMessagesWaiting (relay_queue . handle )) {
550
544
BT_INFO ("%s, Full queue, remove the oldest relay packet" , __func__ );
551
545
/* Remove the oldest relay packet from queue */
552
- if (xQueueReceive (xBleMeshRelayQueue . queue , & old_msg , K_NO_WAIT ) != pdTRUE ) {
546
+ if (xQueueReceive (relay_queue . handle , & old_msg , K_NO_WAIT ) != pdTRUE ) {
553
547
BT_ERR ("%s, Failed to remove item from queue" , __func__ );
554
548
bt_mesh_unref_buf (msg );
555
549
return ;
556
550
}
557
551
/* Unref buf used for the oldest relay packet */
558
552
bt_mesh_unref_buf (& old_msg );
559
553
/* Send the latest relay packet to queue */
560
- if (xQueueSend (xBleMeshRelayQueue . queue , msg , K_NO_WAIT ) != pdTRUE ) {
554
+ if (xQueueSend (relay_queue . handle , msg , K_NO_WAIT ) != pdTRUE ) {
561
555
BT_ERR ("%s, Failed to send item to relay queue" , __func__ );
562
556
bt_mesh_unref_buf (msg );
563
557
return ;
@@ -586,13 +580,13 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *c
586
580
msg .src = src ;
587
581
msg .dst = dst ;
588
582
msg .timestamp = k_uptime_get_32 ();
589
- /* Use K_NO_WAIT here, if xBleMeshRelayQueue is full return immediately */
583
+ /* Use K_NO_WAIT here, if relay_queue is full return immediately */
590
584
ble_mesh_relay_task_post (& msg , K_NO_WAIT );
591
585
}
592
586
593
587
u16_t bt_mesh_get_stored_relay_count (void )
594
588
{
595
- return (u16_t )uxQueueMessagesWaiting (xBleMeshRelayQueue . queue );
589
+ return (u16_t )uxQueueMessagesWaiting (relay_queue . handle );
596
590
}
597
591
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
598
592
@@ -798,50 +792,50 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
798
792
void bt_mesh_adv_init (void )
799
793
{
800
794
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
801
- xBleMeshQueue . queue = xQueueCreate (BLE_MESH_QUEUE_SIZE , sizeof (bt_mesh_msg_t ));
802
- __ASSERT (xBleMeshQueue . queue , "Failed to create queue" );
795
+ adv_queue . handle = xQueueCreate (BLE_MESH_ADV_QUEUE_SIZE , sizeof (bt_mesh_msg_t ));
796
+ __ASSERT (adv_queue . handle , "Failed to create queue" );
803
797
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
804
798
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
805
- xBleMeshQueue .buffer = heap_caps_calloc_prefer (1 , sizeof (StaticQueue_t ), 2 , MALLOC_CAP_SPIRAM |MALLOC_CAP_8BIT , MALLOC_CAP_INTERNAL |MALLOC_CAP_8BIT );
799
+ adv_queue .buffer = heap_caps_calloc_prefer (1 , sizeof (StaticQueue_t ), 2 , MALLOC_CAP_SPIRAM |MALLOC_CAP_8BIT , MALLOC_CAP_INTERNAL |MALLOC_CAP_8BIT );
806
800
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
807
- xBleMeshQueue .buffer = heap_caps_calloc_prefer (1 , sizeof (StaticQueue_t ), 2 , MALLOC_CAP_INTERNAL |MALLOC_CAP_IRAM_8BIT , MALLOC_CAP_INTERNAL |MALLOC_CAP_8BIT );
801
+ 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 );
808
802
#endif
809
- __ASSERT (xBleMeshQueue .buffer , "Failed to create queue buffer" );
803
+ __ASSERT (adv_queue .buffer , "Failed to create queue buffer" );
810
804
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
811
- 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 );
805
+ 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 );
812
806
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
813
- 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 );
807
+ 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 );
814
808
#endif
815
- __ASSERT (xBleMeshQueue .storage , "Failed to create queue storage" );
816
- xBleMeshQueue . queue = xQueueCreateStatic (BLE_MESH_QUEUE_SIZE , sizeof (bt_mesh_msg_t ), (uint8_t * )xBleMeshQueue .storage , xBleMeshQueue .buffer );
817
- __ASSERT (xBleMeshQueue . queue , "Failed to create static queue" );
809
+ __ASSERT (adv_queue .storage , "Failed to create queue storage" );
810
+ adv_queue . handle = xQueueCreateStatic (BLE_MESH_ADV_QUEUE_SIZE , sizeof (bt_mesh_msg_t ), (uint8_t * )adv_queue .storage , adv_queue .buffer );
811
+ __ASSERT (adv_queue . handle , "Failed to create static queue" );
818
812
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
819
813
820
814
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF )
821
815
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
822
- xBleMeshRelayQueue . queue = xQueueCreate (BLE_MESH_RELAY_QUEUE_SIZE , sizeof (bt_mesh_msg_t ));
823
- __ASSERT (xBleMeshRelayQueue . queue , "Failed to create relay queue" );
816
+ relay_queue . handle = xQueueCreate (BLE_MESH_RELAY_QUEUE_SIZE , sizeof (bt_mesh_msg_t ));
817
+ __ASSERT (relay_queue . handle , "Failed to create relay queue" );
824
818
#else /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
825
819
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
826
- xBleMeshRelayQueue .buffer = heap_caps_calloc_prefer (1 , sizeof (StaticQueue_t ), 2 , MALLOC_CAP_SPIRAM |MALLOC_CAP_8BIT , MALLOC_CAP_INTERNAL |MALLOC_CAP_8BIT );
820
+ relay_queue .buffer = heap_caps_calloc_prefer (1 , sizeof (StaticQueue_t ), 2 , MALLOC_CAP_SPIRAM |MALLOC_CAP_8BIT , MALLOC_CAP_INTERNAL |MALLOC_CAP_8BIT );
827
821
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
828
- xBleMeshRelayQueue .buffer = heap_caps_calloc_prefer (1 , sizeof (StaticQueue_t ), 2 , MALLOC_CAP_INTERNAL |MALLOC_CAP_IRAM_8BIT , MALLOC_CAP_INTERNAL |MALLOC_CAP_8BIT );
822
+ 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 );
829
823
#endif
830
- __ASSERT (xBleMeshRelayQueue .buffer , "Failed to create relay queue buffer" );
824
+ __ASSERT (relay_queue .buffer , "Failed to create relay queue buffer" );
831
825
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
832
- 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 );
826
+ 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 );
833
827
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
834
- 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 );
828
+ 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 );
835
829
#endif
836
- __ASSERT (xBleMeshRelayQueue .storage , "Failed to create relay queue storage" );
837
- xBleMeshRelayQueue . queue = xQueueCreateStatic (BLE_MESH_RELAY_QUEUE_SIZE , sizeof (bt_mesh_msg_t ), (uint8_t * )xBleMeshRelayQueue .storage , xBleMeshRelayQueue .buffer );
838
- __ASSERT (xBleMeshRelayQueue . queue , "Failed to create static relay queue" );
830
+ __ASSERT (relay_queue .storage , "Failed to create relay queue storage" );
831
+ relay_queue . handle = xQueueCreateStatic (BLE_MESH_RELAY_QUEUE_SIZE , sizeof (bt_mesh_msg_t ), (uint8_t * )relay_queue .storage , relay_queue .buffer );
832
+ __ASSERT (relay_queue . handle , "Failed to create static relay queue" );
839
833
#endif /* !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
840
834
841
- xBleMeshQueueSet = xQueueCreateSet (BLE_MESH_QUEUE_SET_SIZE );
842
- __ASSERT (xBleMeshQueueSet , "Failed to create queue set" );
843
- xQueueAddToSet (xBleMeshQueue . queue , xBleMeshQueueSet );
844
- xQueueAddToSet (xBleMeshRelayQueue . queue , xBleMeshQueueSet );
835
+ mesh_queue_set = xQueueCreateSet (BLE_MESH_QUEUE_SET_SIZE );
836
+ __ASSERT (mesh_queue_set , "Failed to create queue set" );
837
+ xQueueAddToSet (adv_queue . handle , mesh_queue_set );
838
+ xQueueAddToSet (relay_queue . handle , mesh_queue_set );
845
839
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
846
840
847
841
#if (CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && \
@@ -863,7 +857,7 @@ void bt_mesh_adv_init(void)
863
857
864
858
void bt_mesh_adv_deinit (void )
865
859
{
866
- if (xBleMeshQueue . queue == NULL ) {
860
+ if (adv_queue . handle == NULL ) {
867
861
return ;
868
862
}
869
863
@@ -879,32 +873,32 @@ void bt_mesh_adv_deinit(void)
879
873
#endif
880
874
881
875
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF )
882
- xQueueRemoveFromSet (xBleMeshQueue . queue , xBleMeshQueueSet );
883
- xQueueRemoveFromSet (xBleMeshRelayQueue . queue , xBleMeshQueueSet );
876
+ xQueueRemoveFromSet (adv_queue . handle , mesh_queue_set );
877
+ xQueueRemoveFromSet (relay_queue . handle , mesh_queue_set );
884
878
885
- vQueueDelete (xBleMeshRelayQueue . queue );
886
- xBleMeshRelayQueue . queue = NULL ;
879
+ vQueueDelete (relay_queue . handle );
880
+ relay_queue . handle = NULL ;
887
881
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
888
- heap_caps_free (xBleMeshRelayQueue .buffer );
889
- xBleMeshRelayQueue .buffer = NULL ;
890
- heap_caps_free (xBleMeshRelayQueue .storage );
891
- xBleMeshRelayQueue .storage = NULL ;
882
+ heap_caps_free (relay_queue .buffer );
883
+ relay_queue .buffer = NULL ;
884
+ heap_caps_free (relay_queue .storage );
885
+ relay_queue .storage = NULL ;
892
886
#endif
893
887
894
888
bt_mesh_unref_buf_from_pool (& relay_adv_buf_pool );
895
889
memset (relay_adv_pool , 0 , sizeof (relay_adv_pool ));
896
890
897
- vQueueDelete (xBleMeshQueueSet );
898
- xBleMeshQueueSet = NULL ;
891
+ vQueueDelete (mesh_queue_set );
892
+ mesh_queue_set = NULL ;
899
893
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
900
894
901
- vQueueDelete (xBleMeshQueue . queue );
902
- xBleMeshQueue . queue = NULL ;
895
+ vQueueDelete (adv_queue . handle );
896
+ adv_queue . handle = NULL ;
903
897
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
904
- heap_caps_free (xBleMeshQueue .buffer );
905
- xBleMeshQueue .buffer = NULL ;
906
- heap_caps_free (xBleMeshQueue .storage );
907
- xBleMeshQueue .storage = NULL ;
898
+ heap_caps_free (adv_queue .buffer );
899
+ adv_queue .buffer = NULL ;
900
+ heap_caps_free (adv_queue .storage );
901
+ adv_queue .storage = NULL ;
908
902
#endif
909
903
910
904
bt_mesh_unref_buf_from_pool (& adv_buf_pool );
0 commit comments