Skip to content

Commit 7ff2e5a

Browse files
committed
pybricks.iodevices.LWP3Device: Set LWP3 handle if connection skipped.
When we skip discovery, we'll still need the handle. There is only one handle for LWP3 devices, so we can reuse it. We might revisit this to skip only the connection but redo the discovery phase for generality.
1 parent 98ba9d3 commit 7ff2e5a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

pybricks/iodevices/pb_type_iodevices_lwp3device.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,12 @@ static void pb_lwp3device_intialize_connection(mp_obj_t self_in, mp_obj_t connec
539539
else if (err == PBIO_SUCCESS && !want_connection) {
540540
pb_lwp3device_disconnect(self_in);
541541
}
542-
// Other combinations are already in the desired state, so do nothing else.
542+
543+
// If we have reconnected virtually, we're skipping the discovery phase,
544+
// so use the result from last time.
545+
if (pbdrv_bluetooth_peripheral_is_connected(self->peripheral)) {
546+
self->lwp3_char_handle = pbdrv_bluetooth_peripheral_discover_characteristic_get_result(self->peripheral);
547+
}
543548
}
544549

545550

0 commit comments

Comments
 (0)