Added STM32 power on/off and system off commands#9
Conversation
|
Don't forget to run pre-commit and regenerate and commit the stubs when we get to this one https://github.com/bitcraze/crazyflie-lib-python-v2/blob/main/README.md#regenerating-python-stubs |
There was a problem hiding this comment.
Pull request overview
Adds Python-exposed power-management commands for the Crazyflie’s STM32/deck power domain and full system power-off by extending the Rust/PyO3 bindings and updating the underlying crazyflie-lib dependency.
Changes:
- Add new async
Crazyfliestatic methods:power_off_stm32_domain,power_on_stm32_domain, andpower_off_all. - Bump
crazyflie-libfrom0.6.0to0.7.1to access the new power-control APIs. - Update
Cargo.lockto reflect the dependency upgrade.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
rust/src/crazyflie.rs |
Exposes new power control commands as async Python-callable static methods. |
rust/Cargo.toml |
Updates crazyflie-lib dependency to the version containing required APIs. |
rust/Cargo.lock |
Locks the new crazyflie-lib version/checksum and resolved deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn power_off_stm32_domain<'py>(py: Python<'py>, link_context: &LinkContext, uri: String) -> PyResult<Bound<'py, PyAny>> { | ||
| 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<Bound<'py, PyAny>> { | ||
| 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<Bound<'py, PyAny>> { | ||
| 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(()) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Pull request overview
This PR extends the Rust-backed Python Crazyflie API with new power-management commands (STM32 domain off/on and full system power off) by upgrading crazyflie-lib and exposing the new functions through the PyO3 bindings and generated type stubs.
Changes:
- Add
Crazyflie.power_off_stm32_domain(),Crazyflie.power_on_stm32_domain(), andCrazyflie.power_off_all()as async Python-callable staticmethods. - Bump
crazyflie-libdependency to0.7.1(and updateCargo.lockaccordingly). - Regenerate/update Python type stubs (
cflib2/_rust.pyi) to include the new APIs and docstrings.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rust/src/crazyflie.rs | Exposes new crazyflie-lib power commands as async PyO3 staticmethods. |
| rust/Cargo.toml | Updates crazyflie-lib dependency to a version that provides the new commands. |
| rust/Cargo.lock | Locks the updated crazyflie-lib version/checksum. |
| cflib2/_rust.pyi | Adds stub entries/docstrings for the new power APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.