Battery-service: convert to uniform init / external resources#759
Draft
williampMSFT wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
Draft
Battery-service: convert to uniform init / external resources#759williampMSFT wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
williampMSFT wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
Conversation
Contributor
There was a problem hiding this comment.
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-serviceto exposeResources<N>,InitParams<'hw, N>,Service<'hw, N>(control handle), andRunner<'hw, N>, removing the standalonetaskmodule. - Updates battery examples (
std,pico-de-gallo) to initialize/spawn the service viaspawn_service!or manualService::new(...).await+runner.run(). - Adds
odp-service-commonas 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, | ||
| } |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.