Skip to content

Battery-service: convert to uniform init / external resources#759

Draft
williampMSFT wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
williampMSFT:battery-uniforminit
Draft

Battery-service: convert to uniform init / external resources#759
williampMSFT wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
williampMSFT:battery-uniforminit

Conversation

@williampMSFT
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 20, 2026 00:22
Copy link
Contributor

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

Updates battery-service and its examples to use the repo’s uniform runnable-service initialization pattern with caller-provided resources, aligning it with odp-service-common’s Service/Runner/Resources model.

Changes:

  • Refactors battery-service to expose Resources<N>, InitParams<'hw, N>, Service<'hw, N> (control handle), and Runner<'hw, N>, removing the standalone task module.
  • Updates battery examples (std, pico-de-gallo) to initialize/spawn the service via spawn_service! or manual Service::new(...).await + runner.run().
  • Adds odp-service-common as a dependency where needed and updates lockfiles.

Reviewed changes

Copilot reviewed 6 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
examples/std/src/bin/battery.rs Switches to spawn_service! and passes the new Service<'static, 1> control handle into the app task.
examples/std/Cargo.toml Adds odp-service-common dependency for spawn_service!.
examples/std/Cargo.lock Locks odp-service-common for the std examples workspace.
examples/rt633/Cargo.lock Locks odp-service-common for the rt633 examples workspace.
examples/pico-de-gallo/src/bin/battery.rs Migrates to external Resources<1> + Service::new(...).await and runs runner.run() alongside wrapper/app tasks.
examples/pico-de-gallo/Cargo.toml Adds odp-service-common dependency.
examples/pico-de-gallo/Cargo.lock Locks odp-service-common for the pico-de-gallo examples workspace.
battery-service/src/task.rs Removes the old standalone task-based runner implementation.
battery-service/src/mock.rs Updates helper functions to accept &Service<'_, N> instead of &'static Service.
battery-service/src/lib.rs Implements runnable-service pattern (Resources, InitParams, Runner, Service) and moves init + comms endpoint registration into Service::new.
battery-service/Cargo.toml Adds workspace dependency on odp-service-common.
Cargo.lock Locks odp-service-common at the workspace root.

Comment on lines +156 to +162
/// Errors that can occur during battery service initialization.
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum InitError {
DeviceRegistrationFailed,
CommsRegistrationFailed,
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

InitError::DeviceRegistrationFailed no longer includes which device(s) failed to register (the previous init path returned the failing DeviceId list). Losing that information makes field debugging harder; consider storing the failing DeviceId (or a bounded Vec) in the error variant.

Copilot uses AI. Check for mistakes.
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.

2 participants