Skip to content

Commit 0865fbd

Browse files
committed
nrf5/modules/ubluepy: Register central GAP event handler before issuing connect to a peripheral. Has to be done before connect() function as a connected event will be propergated upon successfull connection. The handler will set the connection handle which gets connect function out of the busy loop waiting for connection to succeed.
1 parent 18e73d4 commit 0865fbd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

nrf5/modules/ubluepy/ubluepy_peripheral.c

+2
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ void static disc_add_char(mp_obj_t service_in, ble_drv_char_data_t * p_desc_data
342342
STATIC mp_obj_t peripheral_connect(mp_obj_t self_in, mp_obj_t dev_addr) {
343343
ubluepy_peripheral_obj_t * self = MP_OBJ_TO_PTR(self_in);
344344

345+
ble_drv_gap_event_handler_set(MP_OBJ_FROM_PTR(self), gap_event_handler);
346+
345347
if (MP_OBJ_IS_STR(dev_addr)) {
346348
GET_STR_DATA_LEN(dev_addr, str_data, str_len);
347349
if (str_len == 17) { // Example "11:22:33:aa:bb:cc"

0 commit comments

Comments
 (0)