Skip to content

Commit 8eb5e6f

Browse files
dhalbertclaude
andcommitted
espressif/_bleio: restore CIRCUITPY_VERBOSE_BLE discovery prints
Restore the verbose prints dropped when discovery object construction moved off the NimBLE host task, and add matching error prints to all three discovery callbacks for consistency (only the descriptor callback had one before). The object prints now live in _build_characteristic() and _build_descriptor(), which run on the VM task. Also print the step status in _check_discovery_status(), which covers the timeout and ring-full errors that never pass through a callback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 97cf5c5 commit 8eb5e6f

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ static void _set_discovery_step_status(int status) {
193193
}
194194

195195
static void _check_discovery_status(int status) {
196+
#if CIRCUITPY_VERBOSE_BLE
197+
mp_printf(&mp_plat_print, "discovery step status: %d\n", status);
198+
#endif
199+
196200
if (status == BLE_HS_EDONE) {
197201
return;
198202
}
@@ -268,6 +272,11 @@ static int _discovered_service_cb(uint16_t conn_handle,
268272
const struct ble_gatt_svc *svc,
269273
void *arg) {
270274
if (error->status != 0) {
275+
#if CIRCUITPY_VERBOSE_BLE
276+
mp_printf(&mp_plat_print, "_discovered_service_cb error->status: %d, handle: %d\n",
277+
error->status, error->att_handle);
278+
#endif
279+
271280
// BLE_HS_EDONE or some error has occurred.
272281
_set_discovery_step_status(error->status);
273282
return 0;
@@ -285,6 +294,11 @@ static int _discovered_characteristic_cb(uint16_t conn_handle,
285294
const struct ble_gatt_chr *chr,
286295
void *arg) {
287296
if (error->status != 0) {
297+
#if CIRCUITPY_VERBOSE_BLE
298+
mp_printf(&mp_plat_print, "_discovered_characteristic_cb error->status: %d, handle: %d\n",
299+
error->status, error->att_handle);
300+
#endif
301+
288302
// BLE_HS_EDONE or some error has occurred.
289303
_set_discovery_step_status(error->status);
290304
return 0;
@@ -303,6 +317,11 @@ static int _discovered_descriptor_cb(uint16_t conn_handle,
303317
const struct ble_gatt_dsc *dsc,
304318
void *arg) {
305319
if (error->status != 0) {
320+
#if CIRCUITPY_VERBOSE_BLE
321+
mp_printf(&mp_plat_print, "_discovered_descriptor_cb error->status: %d, handle: %d\n",
322+
error->status, error->att_handle);
323+
#endif
324+
306325
// BLE_HS_EDONE or some error has occurred.
307326
_set_discovery_step_status(error->status);
308327
return 0;
@@ -412,6 +431,10 @@ static void _build_characteristic(void *ctx, const void *record) {
412431
// Set def_handle directly since it is only used in discovery.
413432
characteristic->def_handle = chr->def_handle;
414433

434+
#if CIRCUITPY_VERBOSE_BLE
435+
mp_printf(&mp_plat_print, "_build_characteristic: char handle: %d\n", characteristic->handle);
436+
#endif
437+
415438
mp_obj_list_append(MP_OBJ_FROM_PTR(service->characteristic_list),
416439
MP_OBJ_FROM_PTR(characteristic));
417440
}
@@ -449,6 +472,11 @@ static void _build_descriptor(void *ctx, const void *record) {
449472
GATT_MAX_DATA_LENGTH, false, mp_const_empty_bytes);
450473
descriptor->handle = dsc->handle;
451474

475+
#if CIRCUITPY_VERBOSE_BLE
476+
mp_printf(&mp_plat_print, "_build_descriptor: char handle: %d, desc handle: %d, uuid type: %d, u16 value: 0x%x\n",
477+
characteristic->handle, descriptor->handle, dsc->uuid.u.type, dsc->uuid.u16.value);
478+
#endif
479+
452480
mp_obj_list_append(MP_OBJ_FROM_PTR(characteristic->descriptor_list),
453481
MP_OBJ_FROM_PTR(descriptor));
454482
}

0 commit comments

Comments
 (0)