Skip to content

Commit 868a03f

Browse files
committed
Fixed empty characteristic issue with bleio+nimble.
- Based on espressif/nimble's blecent example code. Confirms that the characteristic is not empty before trying to catalogue its descriptors. - Running ble_gattc_disc_all_dscs on empty (no length) characteristics fails with the (not-very-informative) BLE_HS_EINVAL error if this check is not performed.
1 parent 4e6fa55 commit 868a03f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ports/espressif/common-hal/_bleio/Connection.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
394394
? service->end_handle
395395
: next_characteristic->def_handle - 1;
396396

397+
// Pre-check if characteristic is empty so descriptor discovery doesn't fail
398+
if (end_handle <= characteristic->handle) {
399+
continue;
400+
}
401+
397402
_last_discovery_status = BLE_ERR_SUCCESS;
398403
CHECK_NIMBLE_ERROR(ble_gattc_disc_all_dscs(self->conn_handle, characteristic->handle,
399404
end_handle,

0 commit comments

Comments
 (0)