|
14 | 14 |
|
15 | 15 | #include <zephyr/bluetooth/hci.h>
|
16 | 16 |
|
17 |
| -#if defined(CONFIG_BT_CONN) |
18 |
| -#if defined(CONFIG_BT_ISO) |
19 |
| -#define MAX_EVENT_COUNT CONFIG_BT_MAX_CONN + CONFIG_BT_ISO_MAX_CHAN |
20 |
| -#else |
21 |
| -#define MAX_EVENT_COUNT CONFIG_BT_MAX_CONN |
22 |
| -#endif /* CONFIG_BT_ISO */ |
23 |
| -#elif defined(CONFIG_BT_ISO) |
24 |
| -#define MAX_EVENT_COUNT CONFIG_BT_ISO_MAX_CHAN |
25 |
| -#endif /* CONFIG_BT_CONN */ |
26 |
| - |
27 |
| -#if defined(CONFIG_BT_CONN) || defined(CONFIG_BT_ISO) |
28 |
| -#define NUM_COMLETE_EVENT_SIZE BT_BUF_EVT_SIZE( \ |
29 |
| - sizeof(struct bt_hci_cp_host_num_completed_packets) + \ |
30 |
| - MAX_EVENT_COUNT * sizeof(struct bt_hci_handle_count)) |
| 17 | +/* Events have a length field of 1 byte. This size fits all events. |
| 18 | + * |
| 19 | + * It's true that we don't put all kinds of events there (yet). However, the |
| 20 | + * command complete event has an arbitrary payload, depending on opcode. |
| 21 | + */ |
| 22 | +#define SYNC_EVT_SIZE (BT_BUF_RESERVE + BT_HCI_EVT_HDR_SIZE + 255) |
31 | 23 |
|
32 | 24 | /* Pool for RX HCI buffers that are always freed by `bt_recv`
|
33 | 25 | * before it returns.
|
|
37 | 29 | * the HCI transport to fill buffers in parallel with `bt_recv`
|
38 | 30 | * consuming them.
|
39 | 31 | */
|
40 |
| -#define SYNC_EVT_SIZE NUM_COMLETE_EVENT_SIZE |
41 | 32 | NET_BUF_POOL_FIXED_DEFINE(sync_evt_pool, 1, SYNC_EVT_SIZE, sizeof(struct bt_buf_data), NULL);
|
42 |
| -#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */ |
43 | 33 |
|
44 | 34 | NET_BUF_POOL_FIXED_DEFINE(discardable_pool, CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT,
|
45 | 35 | BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE),
|
@@ -96,9 +86,11 @@ struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable,
|
96 | 86 | switch (evt) {
|
97 | 87 | #if defined(CONFIG_BT_CONN) || defined(CONFIG_BT_ISO)
|
98 | 88 | case BT_HCI_EVT_NUM_COMPLETED_PACKETS:
|
| 89 | +#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */ |
| 90 | + case BT_HCI_EVT_CMD_STATUS: |
| 91 | + case BT_HCI_EVT_CMD_COMPLETE: |
99 | 92 | buf = net_buf_alloc(&sync_evt_pool, timeout);
|
100 | 93 | break;
|
101 |
| -#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */ |
102 | 94 | default:
|
103 | 95 | if (discardable) {
|
104 | 96 | buf = net_buf_alloc(&discardable_pool, timeout);
|
|
0 commit comments