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 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 fdca6b2..1b2b4f9 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_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_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_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_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_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_domain(&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> {