Skip to content

Commit d50f930

Browse files
authored
Merge pull request #2358 from dhalbert/idempotent-bleio-disconnect
Make _bleio.Connection.disconnect() idempotent
2 parents 19dc219 + e30dde0 commit d50f930

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

shared-bindings/_bleio/Connection.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@ STATIC void ensure_connected(bleio_connection_obj_t *self) {
8080
//|
8181
//| .. method:: disconnect()
8282
//|
83-
//| Disconnects from the remote peripheral.
83+
//| Disconnects from the remote peripheral. Does nothing if already disconnected.
8484
//|
8585
STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) {
8686
bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in);
87-
ensure_connected(self);
88-
87+
// common_hal_bleio_connection_disconnect() does nothing if already disconnected.
8988
common_hal_bleio_connection_disconnect(self->connection);
90-
9189
return mp_const_none;
9290
}
9391
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connection_disconnect);

0 commit comments

Comments
 (0)