Skip to content

Commit 878e545

Browse files
committed
pbio/drv/bluetooth: Support multiple peripherals.
This completes the recent overhaul to clean up references to peripheral singletons. We keep supporting only one on Move Hub, City Hub, and Technic Hub due to hardware limitations with their Bluetooth chips.
1 parent 31f24f4 commit 878e545

16 files changed

Lines changed: 178 additions & 97 deletions

File tree

lib/pbio/drv/bluetooth/bluetooth.c

Lines changed: 68 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -147,31 +147,29 @@ pbio_error_t pbdrv_bluetooth_send_event_notification(pbio_os_state_t *state, pbi
147147
// Functions related to connections to peripherals.
148148
//
149149

150-
pbdrv_bluetooth_peripheral_t peripheral_singleton;
151-
152150
pbio_error_t pbdrv_bluetooth_peripheral_get_available(pbdrv_bluetooth_peripheral_t **peripheral, void *user) {
153-
// Only a single peripheral instance supported for now.
154-
*peripheral = &peripheral_singleton;
155-
156-
if (/* Already connected. */
157-
pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL) ||
158-
/* A different user is still claiming this resource. */
159-
(*peripheral)->user ||
160-
/* Busy. Could be connecting but not connected yet. */
161-
(*peripheral)->func) {
162-
return PBIO_ERROR_BUSY;
163-
}
164151

165-
// Claim this device for new user.
166-
(*peripheral)->user = user;
152+
for (uint8_t i = 0; i < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; i++) {
153+
pbdrv_bluetooth_peripheral_t *peri = pbdrv_bluetooth_peripheral_get_by_index(i);
167154

168-
return PBIO_SUCCESS;
155+
// Test if not already in use, not connected, and not busy.
156+
if (!pbdrv_bluetooth_peripheral_is_connected(peri) && !peri->user && !peri->func) {
157+
// Claim this device for new user.
158+
peri->user = user;
159+
*peripheral = peri;
160+
return PBIO_SUCCESS;
161+
}
162+
}
163+
164+
// All instances are in use.
165+
*peripheral = NULL;
166+
return PBIO_ERROR_BUSY;
169167
}
170168

171169
void pbdrv_bluetooth_peripheral_release(pbdrv_bluetooth_peripheral_t *peripheral, void *user) {
172170
// Only release if the user matches. A new user may have already safely
173171
// claimed it, and this call to release may come from an orphaned user.
174-
if (peripheral->user != user) {
172+
if (!peripheral || peripheral->user != user) {
175173
return;
176174
}
177175
peripheral->user = NULL;
@@ -188,7 +186,7 @@ pbio_error_t pbdrv_bluetooth_peripheral_scan_and_connect(pbdrv_bluetooth_periphe
188186
}
189187

190188
// Can't connect if already connected or already busy.
191-
if (pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL) || peri->func) {
189+
if (pbdrv_bluetooth_peripheral_is_connected(peri) || peri->func) {
192190
return PBIO_ERROR_BUSY;
193191
}
194192

@@ -219,7 +217,7 @@ pbio_error_t pbdrv_bluetooth_peripheral_disconnect(pbdrv_bluetooth_peripheral_t
219217
}
220218

221219
// Pass silently for already disconnected.
222-
if (!pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL)) {
220+
if (!pbdrv_bluetooth_peripheral_is_connected(peri)) {
223221
peri->err = PBIO_SUCCESS;
224222
return PBIO_SUCCESS;
225223
}
@@ -233,7 +231,7 @@ pbio_error_t pbdrv_bluetooth_peripheral_disconnect(pbdrv_bluetooth_peripheral_t
233231

234232
pbio_error_t pbdrv_bluetooth_peripheral_discover_characteristic(pbdrv_bluetooth_peripheral_t *peri, pbdrv_bluetooth_peripheral_char_t *characteristic) {
235233

236-
if (!pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL)) {
234+
if (!pbdrv_bluetooth_peripheral_is_connected(peri)) {
237235
return PBIO_ERROR_NO_DEV;
238236
}
239237
if (peri->func) {
@@ -251,7 +249,7 @@ pbio_error_t pbdrv_bluetooth_peripheral_discover_characteristic(pbdrv_bluetooth_
251249

252250
pbio_error_t pbdrv_bluetooth_peripheral_read_characteristic(pbdrv_bluetooth_peripheral_t *peri, pbdrv_bluetooth_peripheral_char_t *characteristic) {
253251

254-
if (!pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL)) {
252+
if (!pbdrv_bluetooth_peripheral_is_connected(peri)) {
255253
return PBIO_ERROR_NO_DEV;
256254
}
257255
if (peri->func) {
@@ -272,7 +270,7 @@ size_t pbdrv_bluetooth_char_write_size;
272270

273271
pbio_error_t pbdrv_bluetooth_peripheral_write_characteristic(pbdrv_bluetooth_peripheral_t *peri, uint16_t handle, const uint8_t *data, size_t size) {
274272

275-
if (!pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL)) {
273+
if (!pbdrv_bluetooth_peripheral_is_connected(peri)) {
276274
return PBIO_ERROR_NO_DEV;
277275
}
278276
if (peri->func) {
@@ -307,7 +305,10 @@ pbio_error_t pbdrv_bluetooth_await_peripheral_command(pbio_os_state_t *state, vo
307305
void pbdrv_bluetooth_cancel_operation_request(void) {
308306
// Only some peripheral actions support cancellation.
309307
DEBUG_PRINT("Bluetooth operation cancel requested.\n");
310-
peripheral_singleton.cancel = true;
308+
for (uint8_t i = 0; i < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; i++) {
309+
pbdrv_bluetooth_peripheral_t *peri = pbdrv_bluetooth_peripheral_get_by_index(i);
310+
peri->cancel = true;
311+
}
311312
}
312313

313314
//
@@ -523,7 +524,10 @@ pbio_error_t pbdrv_bluetooth_process_thread(pbio_os_state_t *state, void *contex
523524

524525
// Shorthand notation accessible throughout.
525526
bool can_send = pbdrv_bluetooth_is_connected(PBDRV_BLUETOOTH_CONNECTION_PYBRICKS);
526-
pbdrv_bluetooth_peripheral_t *peri = &peripheral_singleton;
527+
528+
// For looping over peripherals.
529+
static uint8_t peri_index;
530+
static pbdrv_bluetooth_peripheral_t *peri;
527531

528532
PBIO_OS_ASYNC_BEGIN(state);
529533

@@ -565,18 +569,21 @@ pbio_error_t pbdrv_bluetooth_process_thread(pbio_os_state_t *state, void *contex
565569
advertising_or_scan_func = NULL;
566570
}
567571

568-
// Handle pending peripheral task, if any.
569-
if (peri->func) {
572+
// Handle pending peripheral tasks, one at a time.
573+
for (peri_index = 0; peri_index < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; peri_index++) {
574+
peri = pbdrv_bluetooth_peripheral_get_by_index(peri_index);
575+
if (peri->func) {
570576

571-
// If currently observing, stop if we need to scan for a peripheral.
572-
if (pbdrv_bluetooth_is_observing && peri->func == pbdrv_bluetooth_peripheral_scan_and_connect_func) {
573-
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_stop_observing_func(&sub, NULL));
574-
observe_restart_requested = true;
575-
}
577+
// If currently observing, stop if we need to scan for a peripheral.
578+
if (pbdrv_bluetooth_is_observing && peri->func == pbdrv_bluetooth_peripheral_scan_and_connect_func) {
579+
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_stop_observing_func(&sub, NULL));
580+
observe_restart_requested = true;
581+
}
576582

577-
PBIO_OS_AWAIT(state, &sub, peri->err = peri->func(&sub, peri));
578-
peri->func = NULL;
579-
peri->cancel = false;
583+
PBIO_OS_AWAIT(state, &sub, peri->err = peri->func(&sub, peri));
584+
peri->func = NULL;
585+
peri->cancel = false;
586+
}
580587
}
581588

582589
// Restart if we stopped it temporarily to scan for a peripheral or
@@ -606,21 +613,32 @@ pbio_error_t pbdrv_bluetooth_close_user_tasks(pbio_os_state_t *state, pbio_os_ti
606613

607614
static pbio_os_state_t sub;
608615

616+
// For looping over peripherals.
617+
static uint8_t peri_index;
618+
static pbdrv_bluetooth_peripheral_t *peri;
619+
609620
if (pbio_os_timer_is_expired(timer)) {
610621
return PBIO_ERROR_TIMEDOUT;
611622
}
612623

613624
PBIO_OS_ASYNC_BEGIN(state);
614625

626+
// Requests peripheral operations to cancel, if they support it.
615627
pbdrv_bluetooth_cancel_operation_request();
616628

617-
// Let ongoing user tasks finish first.
618-
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_await_peripheral_command(&sub, &peripheral_singleton));
619-
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_await_advertise_or_scan_command(&sub, NULL));
629+
for (peri_index = 0; peri_index < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; peri_index++) {
630+
peri = pbdrv_bluetooth_peripheral_get_by_index(peri_index);
631+
632+
// Await ongoing peripheral user task.
633+
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_await_peripheral_command(&sub, peri));
634+
635+
// Disconnect peripheral.
636+
pbdrv_bluetooth_peripheral_disconnect(peri);
637+
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_await_peripheral_command(&sub, peri));
638+
}
620639

621-
// Disconnect peripheral.
622-
pbdrv_bluetooth_peripheral_disconnect(&peripheral_singleton);
623-
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_await_peripheral_command(&sub, &peripheral_singleton));
640+
// Let ongoing user task finish first.
641+
PBIO_OS_AWAIT(state, &sub, pbdrv_bluetooth_await_advertise_or_scan_command(&sub, NULL));
624642

625643
// Stop scanning.
626644
pbdrv_bluetooth_start_observing(NULL);
@@ -643,7 +661,16 @@ void pbdrv_bluetooth_deinit(void) {
643661
// Under normal operation ::pbdrv_bluetooth_close_user_tasks completes
644662
// normally and there should be no user activity at this point. If there
645663
// is, a task got stuck, so exit forcefully.
646-
if (advertising_or_scan_err == PBIO_ERROR_AGAIN || peripheral_singleton.err == PBIO_ERROR_AGAIN) {
664+
bool failed_to_stop = advertising_or_scan_err == PBIO_ERROR_AGAIN;
665+
for (uint8_t i = 0; i < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; i++) {
666+
pbdrv_bluetooth_peripheral_t *peri = pbdrv_bluetooth_peripheral_get_by_index(i);
667+
if (peri->err == PBIO_ERROR_AGAIN) {
668+
failed_to_stop = true;
669+
break;
670+
}
671+
}
672+
673+
if (failed_to_stop) {
647674
// Hard reset without waiting on completion of any process.
648675
DEBUG_PRINT("Bluetooth deinit: forcing hard reset due to busy tasks.\n");
649676
pbdrv_bluetooth_controller_reset_hard();

lib/pbio/drv/bluetooth/bluetooth.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ pbio_error_t pbdrv_bluetooth_controller_reset(pbio_os_state_t *state, pbio_os_ti
2727
pbio_error_t pbdrv_bluetooth_controller_initialize(pbio_os_state_t *state, pbio_os_timer_t *timer);
2828

2929
pbio_error_t pbdrv_bluetooth_start_broadcasting_func(pbio_os_state_t *state, void *context);
30+
pbio_error_t pbdrv_bluetooth_start_advertising_func(pbio_os_state_t *state, void *context);
31+
pbio_error_t pbdrv_bluetooth_stop_advertising_func(pbio_os_state_t *state, void *context);
32+
pbio_error_t pbdrv_bluetooth_start_observing_func(pbio_os_state_t *state, void *context);
33+
pbio_error_t pbdrv_bluetooth_stop_observing_func(pbio_os_state_t *state, void *context);
34+
35+
pbdrv_bluetooth_peripheral_t *pbdrv_bluetooth_peripheral_get_by_index(uint8_t index);
3036
pbio_error_t pbdrv_bluetooth_peripheral_disconnect_func(pbio_os_state_t *state, void *context);
3137
pbio_error_t pbdrv_bluetooth_peripheral_discover_characteristic_func(pbio_os_state_t *state, void *context);
3238
pbio_error_t pbdrv_bluetooth_peripheral_read_characteristic_func(pbio_os_state_t *state, void *context);
3339
pbio_error_t pbdrv_bluetooth_peripheral_scan_and_connect_func(pbio_os_state_t *state, void *context);
3440
pbio_error_t pbdrv_bluetooth_peripheral_write_characteristic_func(pbio_os_state_t *state, void *context);
35-
pbio_error_t pbdrv_bluetooth_start_advertising_func(pbio_os_state_t *state, void *context);
36-
pbio_error_t pbdrv_bluetooth_stop_advertising_func(pbio_os_state_t *state, void *context);
37-
pbio_error_t pbdrv_bluetooth_start_observing_func(pbio_os_state_t *state, void *context);
38-
pbio_error_t pbdrv_bluetooth_stop_observing_func(pbio_os_state_t *state, void *context);
3941

4042
pbio_error_t pbdrv_bluetooth_send_pybricks_value_notification(pbio_os_state_t *state, const uint8_t *data, uint16_t size);
4143

4244
extern pbdrv_bluetooth_receive_handler_t pbdrv_bluetooth_receive_handler;
4345

44-
extern pbdrv_bluetooth_peripheral_t peripheral_singleton;
45-
4646
extern uint16_t pbdrv_bluetooth_char_write_handle;
4747
extern uint8_t pbdrv_bluetooth_char_write_data[PBDRV_BLUETOOTH_MAX_CHAR_SIZE];
4848
extern size_t pbdrv_bluetooth_char_write_size;

lib/pbio/drv/bluetooth/bluetooth_btstack.c

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ static struct _pbdrv_bluetooth_peripheral_platform_state_t {
8989
* are set up such that only one char is discovered at a time
9090
*/
9191
gatt_client_characteristic_t current_char;
92-
} peripheral_platform_state;
92+
} peripheral_platform_state[PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS];
93+
94+
static pbdrv_bluetooth_peripheral_t _peripherals[PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS];
95+
96+
pbdrv_bluetooth_peripheral_t *pbdrv_bluetooth_peripheral_get_by_index(uint8_t index) {
97+
if (index >= PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS) {
98+
return NULL;
99+
}
100+
return &_peripherals[index];
101+
}
102+
93103
#endif // PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE
94104

95105
// hub name goes in special section so that it can be modified when flashing firmware
@@ -183,7 +193,7 @@ static void pbdrv_bluetooth_peripheral_disconnect_now(pbdrv_bluetooth_peripheral
183193
/**
184194
* Checks if the given peripheral is connected.
185195
*/
186-
static bool pbdrv_bluetooth_peripheral_is_connected(pbdrv_bluetooth_peripheral_t *peri) {
196+
bool pbdrv_bluetooth_peripheral_is_connected(pbdrv_bluetooth_peripheral_t *peri) {
187197
return peri->con_handle != HCI_CON_HANDLE_INVALID;
188198
}
189199

@@ -236,9 +246,6 @@ bool pbdrv_bluetooth_is_connected(pbdrv_bluetooth_connection_t connection) {
236246
return true;
237247
}
238248

239-
if (connection == PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL && peripheral_singleton.con_handle != HCI_CON_HANDLE_INVALID) {
240-
return true;
241-
}
242249
#endif // PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE
243250

244251
return false;
@@ -307,10 +314,6 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
307314
// Platform-specific platform handler has priority.
308315
pbdrv_bluetooth_btstack_platform_packet_handler(packet_type, channel, packet, size);
309316

310-
#if PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE
311-
pbdrv_bluetooth_peripheral_t *peri = &peripheral_singleton;
312-
#endif // PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE
313-
314317
switch (hci_event_packet_get_type(packet)) {
315318
case HCI_EVENT_COMMAND_COMPLETE: {
316319
const uint8_t *rp = hci_event_command_complete_get_return_parameters(packet);
@@ -343,17 +346,19 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
343346
case GATT_EVENT_QUERY_COMPLETE:
344347
DEBUG_PRINT("GATT_EVENT_QUERY_COMPLETE\n");
345348
break;
346-
case GATT_EVENT_NOTIFICATION: {
347-
if (gatt_event_notification_get_handle(packet) != peri->con_handle) {
348-
break;
349-
}
350-
if (peri->config->notification_handler) {
351-
uint16_t length = gatt_event_notification_get_value_length(packet);
352-
const uint8_t *value = gatt_event_notification_get_value(packet);
353-
peri->config->notification_handler(peri->user, value, length);
349+
case GATT_EVENT_NOTIFICATION:
350+
for (uint8_t i = 0; i < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; i++) {
351+
pbdrv_bluetooth_peripheral_t *peri = pbdrv_bluetooth_peripheral_get_by_index(i);
352+
if (!peri || !peri->config || !peri->config->notification_handler) {
353+
continue;
354+
}
355+
if (gatt_event_notification_get_handle(packet) == peri->con_handle) {
356+
uint16_t length = gatt_event_notification_get_value_length(packet);
357+
const uint8_t *value = gatt_event_notification_get_value(packet);
358+
peri->config->notification_handler(peri->user, value, length);
359+
}
354360
}
355361
break;
356-
}
357362
case HCI_EVENT_LE_META:
358363
if (hci_event_le_meta_get_subevent_code(packet) != HCI_SUBEVENT_LE_CONNECTION_COMPLETE) {
359364
break;
@@ -374,10 +379,15 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
374379
le_con_handle = HCI_CON_HANDLE_INVALID;
375380
pybricks_con_handle = HCI_CON_HANDLE_INVALID;
376381
uart_con_handle = HCI_CON_HANDLE_INVALID;
377-
} else if (hci_event_disconnection_complete_get_connection_handle(packet) == peri->con_handle) {
378-
DEBUG_PRINT("Peripheral disconnected\n");
379-
gatt_client_stop_listening_for_characteristic_value_updates(&peri->platform_state->notification);
380-
peri->con_handle = HCI_CON_HANDLE_INVALID;
382+
} else {
383+
for (uint8_t i = 0; i < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; i++) {
384+
pbdrv_bluetooth_peripheral_t *peri = pbdrv_bluetooth_peripheral_get_by_index(i);
385+
if (peri && hci_event_disconnection_complete_get_connection_handle(packet) == peri->con_handle) {
386+
DEBUG_PRINT("Peripheral %u with handle %u disconnected\n", i, peri->con_handle);
387+
gatt_client_stop_listening_for_characteristic_value_updates(&peri->platform_state->notification);
388+
peri->con_handle = HCI_CON_HANDLE_INVALID;
389+
}
390+
}
381391
}
382392
break;
383393

@@ -1065,6 +1075,12 @@ pbio_error_t pbdrv_bluetooth_stop_observing_func(pbio_os_state_t *state, void *c
10651075
pbio_error_t pbdrv_bluetooth_start_broadcasting_func(pbio_os_state_t *state, void *context) {
10661076
return PBIO_ERROR_NOT_SUPPORTED;
10671077
}
1078+
bool pbdrv_bluetooth_peripheral_is_connected(pbdrv_bluetooth_peripheral_t *peri) {
1079+
return false;
1080+
}
1081+
pbdrv_bluetooth_peripheral_t *pbdrv_bluetooth_peripheral_get_by_index(uint8_t index) {
1082+
return NULL;
1083+
}
10681084
pbio_error_t pbdrv_bluetooth_peripheral_disconnect_func(pbio_os_state_t *state, void *context) {
10691085
return PBIO_ERROR_NOT_SUPPORTED;
10701086
}
@@ -1264,9 +1280,12 @@ void pbdrv_bluetooth_init_hci(void) {
12641280
static btstack_packet_callback_registration_t hci_event_callback_registration;
12651281

12661282
#if PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE
1267-
// don't need to init the whole struct, so doing this here
1268-
peripheral_singleton.platform_state = &peripheral_platform_state;
1269-
peripheral_singleton.con_handle = HCI_CON_HANDLE_INVALID;
1283+
// Attach btstack platform state to peripherals.
1284+
for (uint8_t i = 0; i < PBDRV_CONFIG_BLUETOOTH_NUM_PERIPHERALS; i++) {
1285+
pbdrv_bluetooth_peripheral_t *peri = pbdrv_bluetooth_peripheral_get_by_index(i);
1286+
peri->platform_state = &peripheral_platform_state[i];
1287+
peri->con_handle = HCI_CON_HANDLE_INVALID;
1288+
}
12701289
#endif
12711290

12721291
btstack_memory_init();

lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ static const pbdrv_gpio_t mosi_gpio = { .bank = GPIOC, .pin = 3 };
124124
static const pbdrv_gpio_t miso_gpio = { .bank = GPIOC, .pin = 2 };
125125
static const pbdrv_gpio_t sck_gpio = { .bank = GPIOB, .pin = 13 };
126126

127+
static pbdrv_bluetooth_peripheral_t peripheral_singleton;
128+
129+
pbdrv_bluetooth_peripheral_t *pbdrv_bluetooth_peripheral_get_by_index(uint8_t index) {
130+
// This platform supports only a single peripheral instance. Some of its
131+
// states are global variables listed above. This single instance is used
132+
// troughout the event handler.
133+
return &peripheral_singleton;
134+
}
135+
136+
bool pbdrv_bluetooth_peripheral_is_connected(pbdrv_bluetooth_peripheral_t *peri) {
137+
return peri == &peripheral_singleton && peri->con_handle != 0;
138+
}
139+
127140
/**
128141
* Converts a BlueNRG-MS error code to a PBIO error code.
129142
* @param [in] status The BlueNRG-MS error code.
@@ -307,10 +320,6 @@ bool pbdrv_bluetooth_is_connected(pbdrv_bluetooth_connection_t connection) {
307320
return true;
308321
}
309322

310-
if (connection == PBDRV_BLUETOOTH_CONNECTION_PERIPHERAL && peripheral_singleton.con_handle) {
311-
return true;
312-
}
313-
314323
return false;
315324
}
316325

@@ -950,7 +959,6 @@ static void handle_event(hci_event_pckt *event) {
950959

951960
case EVT_BLUE_GATT_NOTIFICATION: {
952961
evt_gatt_attr_notification *subevt = (void *)evt->data;
953-
pbdrv_bluetooth_peripheral_t *peri = &peripheral_singleton;
954962
if (peri->config->notification_handler) {
955963
peri->config->notification_handler(peri->user, subevt->attr_value, subevt->event_data_length - 2);
956964
}

0 commit comments

Comments
 (0)