nrf5/modules/ubluepy: Continue characteristic discovery until nothing more is found during connect proceedure.
This commit is contained in:
parent
653f4a86d5
commit
78c0821216
|
@ -402,7 +402,7 @@ STATIC mp_obj_t peripheral_connect(mp_uint_t n_args, const mp_obj_t *pos_args, m
|
||||||
|
|
||||||
service_disc_retval = ble_drv_discover_services(self,
|
service_disc_retval = ble_drv_discover_services(self,
|
||||||
self->conn_handle,
|
self->conn_handle,
|
||||||
p_service->end_handle,
|
p_service->end_handle + 1,
|
||||||
disc_add_service);
|
disc_add_service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,15 +413,28 @@ STATIC mp_obj_t peripheral_connect(mp_uint_t n_args, const mp_obj_t *pos_args, m
|
||||||
|
|
||||||
for (uint16_t s = 0; s < num_services; s++) {
|
for (uint16_t s = 0; s < num_services; s++) {
|
||||||
ubluepy_service_obj_t * p_service = (ubluepy_service_obj_t *)services[s];
|
ubluepy_service_obj_t * p_service = (ubluepy_service_obj_t *)services[s];
|
||||||
|
bool char_disc_retval = ble_drv_discover_characteristic(p_service,
|
||||||
|
self->conn_handle,
|
||||||
|
p_service->start_handle,
|
||||||
|
p_service->end_handle,
|
||||||
|
disc_add_char);
|
||||||
|
// continue discovery of characteristics ...
|
||||||
|
while (char_disc_retval) {
|
||||||
|
mp_obj_t * characteristics = NULL;
|
||||||
|
mp_uint_t num_chars;
|
||||||
|
mp_obj_get_array(p_service->char_list, &num_chars, &characteristics);
|
||||||
|
|
||||||
bool retval = ble_drv_discover_characteristic(p_service,
|
ubluepy_characteristic_obj_t * p_char = (ubluepy_characteristic_obj_t *)characteristics[num_chars - 1];
|
||||||
self->conn_handle,
|
uint16_t next_handle = p_char->handle + 1;
|
||||||
p_service->start_handle,
|
if ((next_handle) < p_service->end_handle) {
|
||||||
p_service->end_handle,
|
char_disc_retval = ble_drv_discover_characteristic(p_service,
|
||||||
disc_add_char);
|
self->conn_handle,
|
||||||
if (retval != true) {
|
next_handle,
|
||||||
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
|
p_service->end_handle,
|
||||||
"Error during characteristic discovery"));
|
disc_add_char);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue