You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This omits static allocation (`StaticCell`), executor wiring for async tasks, and controller setup, for clarity.
23
+
24
+
### Realistic skeleton (matches the sample projects)
25
+
26
+
Refer to the [Battery implementation example](../../guide/how/ec/battery/10-service_registry.html) or the [examples in the embedded-services repository](https://github.com/OpenDevicePartnership/embedded-services/blob/main/examples/std/src/bin/battery.rs#L474) for more concrete examples.
-`BatteryDevice` wraps the actual component (e.g., a `MockBattery`) and implements required traits.
39
+
// Controller setup is covered in the next section.
40
+
```
41
+
_Semantics note_: In ODP, “Device” types are __handles__ to a single underlying component; the service runtime serializes access. Introducing the controller simply gives policy logic a dedicated handle to act on; it does not create a second owner of the hardware.
23
42
24
-
-`BatteryController` implements the `Service` trait and delegates operations to the device.
43
+
### Bringing in the Controller
25
44
26
-
-`SERVICE_REGISTRY` stores the controller and makes it accessible to both the async executor and message routing infrastructure.
The controller is given a handle to the inner `MockBattery` (`inner_battery()`), not a second owner of the hardware. All access is serialized through the service runtime.
27
51
28
52
### What Registration Enables
29
53
| Feature | Enabled by Registration |
@@ -50,12 +74,15 @@ flowchart TD
50
74
Once a controller is registered, the service registry allows the comms system to route incoming events to the correct service based on:
51
75
- The __device ID__
52
76
- The __message type__
53
-
- The controller's implementation of the `handle()` function (_as defined by Service_)
77
+
- The controller's implementation of the `handle()` function (_as defined by ServiceTraits_)
54
78
55
79
When a message is emitted (e.g. `BatteryEvent::UpdateStatus`), the comms channel looks up the appropriate service and dispatches the message.
56
80
81
+
Where `ServiceTraits` represent the service traits that define a Controller action,
82
+
implementation may look something like this (in this case, `ServiceTraits` defines a function
83
+
named `handle`, and it calls upon a local function defined in the device implementation):
0 commit comments