@@ -27,8 +27,7 @@ LOG_MODULE_REGISTER(esp32_ble_npl, CONFIG_LOG_DEFAULT_LEVEL);
27
27
#define BLE_HOST_SEM_COUNT (0)
28
28
#define BLE_HOST_MUTEX_COUNT (0)
29
29
30
- #define MAX_EVENTS 64 /* TODO: evaluate this in the future */
31
- static char evq_buffer [sizeof (struct ble_npl_event ) * MAX_EVENTS ];
30
+ static struct ble_npl_event * * evq_buffer ;
32
31
33
32
struct os_mempool ble_zephyr_ev_pool ;
34
33
static os_membuf_t * ble_zephyr_ev_buf = NULL ;
@@ -100,8 +99,10 @@ void npl_zephyr_eventq_init(struct ble_npl_eventq *evq)
100
99
eventq = (struct ble_npl_eventq_zephyr * )evq -> eventq ;
101
100
BLE_LL_ASSERT (eventq );
102
101
memset (eventq , 0 , sizeof (* eventq ));
103
- /* point at our statically-allocated array of pointers */
104
- k_msgq_init (& eventq -> q , evq_buffer , sizeof (struct ble_npl_event * ),
102
+ evq_buffer = bt_osi_mem_malloc_internal (
103
+ ble_zephyr_total_event_cnt * sizeof (struct ble_npl_event * ));
104
+ BLE_LL_ASSERT (evq_buffer );
105
+ k_msgq_init (& eventq -> q , (char * )evq_buffer , sizeof (struct ble_npl_event * ),
105
106
ble_zephyr_total_event_cnt );
106
107
} else {
107
108
eventq = (struct ble_npl_eventq_zephyr * )evq -> eventq ;
@@ -117,6 +118,7 @@ void npl_zephyr_eventq_deinit(struct ble_npl_eventq *evq)
117
118
return ;
118
119
}
119
120
k_free (eventq );
121
+ k_free (evq_buffer );
120
122
evq -> eventq = NULL ;
121
123
}
122
124
0 commit comments