From df7af301d8fd2d92347f9cbcf81273641bfff1b5 Mon Sep 17 00:00:00 2001 From: Marcus Eliasson Date: Wed, 18 Mar 2026 10:27:58 +0100 Subject: [PATCH 1/3] Added STM32 power on/off and system off commands --- rust/src/crazyflie.rs | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/rust/src/crazyflie.rs b/rust/src/crazyflie.rs index fdca6b2..4a6fcfb 100644 --- a/rust/src/crazyflie.rs +++ b/rust/src/crazyflie.rs @@ -124,6 +124,51 @@ impl Crazyflie { }) } + /// Power off the STM32 and deck subsystem + /// + /// Cuts power to the STM32 and decks while keeping the nRF51 powered. + /// The Crazyflie can be powered on again using `power_on_stm32()`. + /// This does not require a full connection. + #[staticmethod] + #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] + fn power_off_stm32<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { + let inner = link_context.inner.clone(); + pyo3_async_runtimes::tokio::future_into_py(py, async move { + crazyflie_lib::Crazyflie::power_off_stm32(&inner, &uri).await.map_err(to_pyerr)?; + Ok(()) + }) + } + + /// Power on the STM32 and deck subsystem + /// + /// Powers the STM32 and decks back on after a `power_off_stm32()`. + /// This does not require a full connection. + #[staticmethod] + #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] + fn power_on_stm32<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { + let inner = link_context.inner.clone(); + pyo3_async_runtimes::tokio::future_into_py(py, async move { + crazyflie_lib::Crazyflie::power_on_stm32(&inner, &uri).await.map_err(to_pyerr)?; + Ok(()) + }) + } + + /// Power off the Crazyflie completely + /// + /// Powers off the nRF51, STM32, and deck subsystem. Equivalent to + /// pressing the power button. The Crazyflie cannot be woken up via + /// radio after this. + /// This does not require a full connection. + #[staticmethod] + #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] + fn power_off_all<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { + let inner = link_context.inner.clone(); + pyo3_async_runtimes::tokio::future_into_py(py, async move { + crazyflie_lib::Crazyflie::power_off_all(&inner, &uri).await.map_err(to_pyerr)?; + Ok(()) + }) + } + /// Disconnect from the Crazyflie #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] fn disconnect<'py>(&self, py: Python<'py>) -> PyResult> { From 6a9e2e7f903086d51564b6520db5c9f2004c63d5 Mon Sep 17 00:00:00 2001 From: Marcus Eliasson Date: Thu, 19 Mar 2026 10:54:10 +0100 Subject: [PATCH 2/3] Dump to version 0.7.1 --- rust/Cargo.lock | 4 ++-- rust/Cargo.toml | 2 +- rust/src/crazyflie.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 784257d..a64f593 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -167,9 +167,9 @@ dependencies = [ [[package]] name = "crazyflie-lib" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fc2cb8f0c7a428e980d9abe632f1263da4cb2d6acf83f1855e69d4cdb28cb8" +checksum = "69d54f64d51934a7f2941df5f98efb858fb68ed1e075c1b6f164e50598825279" dependencies = [ "async-broadcast", "async-stream", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index c2b6220..9aa5abc 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -14,7 +14,7 @@ extension-module = ["pyo3/extension-module"] [dependencies] pyo3 = { version = "0.26" } pyo3-async-runtimes = { version = "0.26", features = ["tokio-runtime"] } -crazyflie-lib = "0.6.0" +crazyflie-lib = "0.7.1" crazyflie-link = "0.4.2" tokio = { version = "1.48", features = ["full"] } futures = "0.3.31" diff --git a/rust/src/crazyflie.rs b/rust/src/crazyflie.rs index 4a6fcfb..1b2b4f9 100644 --- a/rust/src/crazyflie.rs +++ b/rust/src/crazyflie.rs @@ -127,28 +127,28 @@ impl Crazyflie { /// Power off the STM32 and deck subsystem /// /// Cuts power to the STM32 and decks while keeping the nRF51 powered. - /// The Crazyflie can be powered on again using `power_on_stm32()`. + /// The Crazyflie can be powered on again using `power_on_stm32_domain()`. /// This does not require a full connection. #[staticmethod] #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] - fn power_off_stm32<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { + fn power_off_stm32_domain<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { let inner = link_context.inner.clone(); pyo3_async_runtimes::tokio::future_into_py(py, async move { - crazyflie_lib::Crazyflie::power_off_stm32(&inner, &uri).await.map_err(to_pyerr)?; + crazyflie_lib::Crazyflie::power_off_stm32_domain(&inner, &uri).await.map_err(to_pyerr)?; Ok(()) }) } /// Power on the STM32 and deck subsystem /// - /// Powers the STM32 and decks back on after a `power_off_stm32()`. + /// Powers the STM32 and decks back on after a `power_off_stm32_domain()`. /// This does not require a full connection. #[staticmethod] #[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, None]"))] - fn power_on_stm32<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { + fn power_on_stm32_domain<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult> { let inner = link_context.inner.clone(); pyo3_async_runtimes::tokio::future_into_py(py, async move { - crazyflie_lib::Crazyflie::power_on_stm32(&inner, &uri).await.map_err(to_pyerr)?; + crazyflie_lib::Crazyflie::power_on_stm32_domain(&inner, &uri).await.map_err(to_pyerr)?; Ok(()) }) } From b32d1aaaa9d8defd7a61dbee72ca37c267a0dcee Mon Sep 17 00:00:00 2001 From: Marcus Eliasson Date: Thu, 19 Mar 2026 11:01:27 +0100 Subject: [PATCH 3/3] Regenreated stubs --- cflib2/_rust.pyi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cflib2/_rust.pyi b/cflib2/_rust.pyi index bcab1cc..ce5611b 100644 --- a/cflib2/_rust.pyi +++ b/cflib2/_rust.pyi @@ -320,6 +320,37 @@ class Crazyflie: Returns: Connected Crazyflie instance """ + @staticmethod + async def power_off_stm32_domain( + link_context: LinkContext, uri: builtins.str + ) -> None: + r""" + Power off the STM32 and deck subsystem + + Cuts power to the STM32 and decks while keeping the nRF51 powered. + The Crazyflie can be powered on again using `power_on_stm32_domain()`. + This does not require a full connection. + """ + @staticmethod + async def power_on_stm32_domain( + link_context: LinkContext, uri: builtins.str + ) -> None: + r""" + Power on the STM32 and deck subsystem + + Powers the STM32 and decks back on after a `power_off_stm32_domain()`. + This does not require a full connection. + """ + @staticmethod + async def power_off_all(link_context: LinkContext, uri: builtins.str) -> None: + r""" + Power off the Crazyflie completely + + Powers off the nRF51, STM32, and deck subsystem. Equivalent to + pressing the power button. The Crazyflie cannot be woken up via + radio after this. + This does not require a full connection. + """ async def disconnect(self) -> None: r""" Disconnect from the Crazyflie