Skip to content

Added STM32 power on/off and system off commands#9

Merged
evoggy merged 3 commits intomainfrom
evoggy/nrf-pm-commands
Mar 19, 2026
Merged

Added STM32 power on/off and system off commands#9
evoggy merged 3 commits intomainfrom
evoggy/nrf-pm-commands

Conversation

@evoggy
Copy link
Copy Markdown
Member

@evoggy evoggy commented Mar 18, 2026

No description provided.

@gemenerik
Copy link
Copy Markdown
Member

gemenerik commented Mar 18, 2026

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

@evoggy evoggy marked this pull request as ready for review March 19, 2026 09:54
@evoggy evoggy requested review from Copilot and gemenerik March 19, 2026 09:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Crazyflie static methods: power_off_stm32_domain, power_on_stm32_domain, and power_off_all.
  • Bump crazyflie-lib from 0.6.0 to 0.7.1 to access the new power-control APIs.
  • Update Cargo.lock to 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.

Comment on lines +134 to +170
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(())
})
}
@evoggy evoggy requested a review from Copilot March 19, 2026 10:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(), and Crazyflie.power_off_all() as async Python-callable staticmethods.
  • Bump crazyflie-lib dependency to 0.7.1 (and update Cargo.lock accordingly).
  • 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.

@evoggy evoggy merged commit ab6ece1 into main Mar 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants