<br />

Added: HEAD

## **PROTOCOLS**

## Battery

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=203)*

Diagnostic and telemetry interface for battery hardware.

This is a read-only protocol that supports multiple concurrent clients.

<br />

### ConfigureWatch

Configures the fields of interest and wake triggers for this client connection.

The driver filters the requested masks against hardware capabilities and returns the
effective configuration in `effective_options`.

- **Partially supported options** : If some requested fields are supported and others are not (e.g., requesting passive fields like `voltage_uv` or `current_ua` that do not support active interrupt notifications), the driver enables the supported fields and returns the active subset in `effective_options`. The call succeeds (`Ok`).
- **Fully unsupported options** : If non-empty masks were specified but NONE of the requested fields are supported, the driver returns `NOT_SUPPORTED`.

If `ConfigureWatch` is never called, `Watch` defaults to returning on ANY supported field
change. The driver aggregates constraints across all clients to determine hardware reporting
rates.

`ConfigureWatch` may be called at any time, including while a `Watch` is pending. The new
masks take effect immediately and apply to that pending call. Change detection continues to
compare against the status last delivered on this connection, so a field that changed
before the reconfiguration can still resolve the pending `Watch`.

Parameters:

- `options`: Requested watch options. Both `interest` and `wake_on` are optional.

Returns:

- `effective_options`: The subset of requested options supported and enabled by the driver.

Errors:

- `NOT_SUPPORTED`: Non-empty options were requested, but none of the requested interest/wake fields or periodic sampling are supported by the driver.

On error the connection's configuration is left unchanged; a failed call never partially
applies.

#### Request

| Name | Type |
|---|---|
| `options` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#WatchOptions` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_ConfigureWatch_Result` |

### GetSpec

Retrieves the static specification of the battery.

Returns:

- `spec`: Static hardware characteristics and driver capabilities of the battery.

Errors:

- `NOT_SUPPORTED`: Hardware does not supply a static specification.
- `IO`: Communication failure with the fuel gauge hardware (e.g. I2C transfer failure).
- `INTERNAL`: Internal driver error.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_GetSpec_Result` |

### GetStatus

Retrieves an instantaneous snapshot of the battery status.

Returns:

- `status`: Complete current telemetry snapshot of battery metrics.

Errors:

- `IO`: Communication failure with the fuel gauge hardware (e.g. I2C transfer failure).
- `INTERNAL`: Internal driver error.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_GetStatus_Result` |

### Watch

Change notification for battery state using a hanging-get pattern.

The first call returns the full current hardware state immediately. Subsequent calls block
until a state change matches the masks in [ConfigureWatch](https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#ConfigureWatch) or the interval in
`max_interval` has elapsed. Each return contains a complete telemetry snapshot of all
current battery fields, not a sparse delta.

At most one `Watch` call may be outstanding per connection; concurrent calls fail with
`ALREADY_WATCHING`.

Parameters:

- `lease`: An optional power lease token that keeps the system awake while the server processes the call. If the call is answered immediately, as the first call always is, the server hands it back as `wake_lease` unless it returns a wake lease of its own. If the call is parked, the server drops it.

Returns:

- `status`: Complete current telemetry snapshot of the battery.
- `wake_lease`: An optional lease token that the client should hold while it handles `status`: the client's `lease` handed back on an immediate reply, or a wake lease provided if the change triggered a `wake_on` condition or a `max_interval` sample woke the system for a client that set `wake_on_max_interval`. Omitted otherwise.

Errors:

- `ALREADY_WATCHING`: A `Watch` call is already pending on this connection.
- `IO`: Communication failure with the fuel gauge hardware (e.g. I2C transfer failure).
- `INTERNAL`: Internal driver error.

#### Request

| Name | Type |
|---|---|
| `lease` | `https://fuchsia.dev/reference/fuchsia.power.system//https://fuchsia.dev/reference/fuchsia.power.system#LeaseToken` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_Watch_Result` |

## **STRUCTS**

### Battery_ConfigureWatch_Response

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=264)*

| Field | Type | Description | Default |
|---|---|---|---|
| `effective_options` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#WatchOptions` |   | No default |

### Battery_GetSpec_Response

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=213)*

| Field | Type | Description | Default |
|---|---|---|---|
| `spec` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Spec` |   | No default |

### Battery_GetStatus_Response

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=225)*

| Field | Type | Description | Default |
|---|---|---|---|
| `status` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Status` |   | No default |

### Battery_Watch_Response [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=297)*

| Field | Type | Description | Default |
|---|---|---|---|
| `status` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Status` |   | No default |
| `wake_lease` | `https://fuchsia.dev/reference/fuchsia.power.system//https://fuchsia.dev/reference/fuchsia.power.system#LeaseToken` |   | No default |

## **ENUMS**

### Error [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=11)*

Errors returned by the battery protocol.

<br />

| Name | Value | Description |
|---|---|---|
| ### INTERNAL | `1` | An unexpected error occurred within the driver. |
| ### NOT_SUPPORTED | `2` | The requested operation, field, or mode is not supported by this hardware. |
| ### INVALID_ARGS | `3` | One or more arguments provided to the method were invalid, or a requested value lies outside the range the hardware can program. |
| ### IO | `4` | Communication with the battery hardware failed (e.g. a bus transfer error). |
| ### ALREADY_WATCHING | `5` | A `Watch` call is already pending on this connection. |

### HealthStatus [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=33)*

Battery health and safety status, including JEITA temperature regions and fault conditions.

Each value describes whether the pack may be charged and whether it can still supply power to
the system. Unless a value states otherwise, the battery can still supply power.

<br />

| Name | Value | Description |
|---|---|---|
| ### GOOD | `1` | Normal operating temperature and healthy battery condition. Both charging and discharging are permitted. |
| ### COLD | `2` | Battery temperature is below safe charging threshold (charging prohibited). The battery can still supply power, though available capacity and peak current are typically reduced. |
| ### COOL | `3` | Battery temperature is low (charging current or voltage may be restricted). The battery can still supply power. |
| ### WARM | `4` | Battery temperature is elevated (charging current or voltage may be restricted). The battery can still supply power. |
| ### HOT | `5` | Battery temperature exceeded safety threshold (charging prohibited). The battery can usually still supply power, but hardware protection may open the discharge path if the temperature continues to rise. |
| ### DEAD | `6` | Battery pack voltage is below operating threshold or cell is dead. The battery cannot supply usable power to the system. |
| ### OVER_VOLTAGE | `7` | Battery voltage exceeded hardware safety limit (charging prohibited). The battery can still supply power; discharging is the expected recovery path. |
| ### UNSPECIFIED_FAILURE | `8` | Unspecified hardware or fuel gauge safety fault. Whether the pack may be charged, or can supply power at all, is indeterminate. |

## **TABLES**

### Spec

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=112)*

Static hardware characteristics and driver capabilities.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `design_capacity_uah` | `uint32` | Optional. Design capacity in microamp-hours. Omitted if unsupported by hardware. |
| ### 2 | `design_voltage_uv` | `uint32` | Optional. Nominal design voltage in microvolts. Omitted if unsupported by hardware. |
| ### 3 | `chemistry` | `string:128` | Optional. Informational battery chemistry description (e.g. "Li-ion", "LiFePO4", "NiMH"). Omitted if unknown or unprogrammed in hardware. |
| ### 4 | `model` | `string:128` | Optional. Informational battery model string or manufacturer part number. Omitted if unknown or unprogrammed in hardware. |
| ### 5 | `supported_options` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#WatchOptions` | Required. The interest and wake options supported by this driver/hardware. Drivers must populate this table so clients know which fields support active change notifications. If omitted by the driver, clients should assume no active interrupt watching is supported. - `supported_options.interest`: Telemetry fields that can actively trigger hanging-get watch notifications on change. Fields omitted are passive measurements that do not generate hardware interrupts; their freshest values are returned during active state changes or via [Battery.GetStatus](https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery.GetStatus). - `supported_options.wake_on`: Telemetry fields capable of actively waking the system from suspend via hardware interrupt lines etc. - `supported_options.max_interval`: Present if the server supports periodic sampling; its value is the shortest interval the server will honor. - `supported_options.wake_on_max_interval`: True if the server can wake the system from suspend to take a `max_interval` sample. |

### Status

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=157)*

Primary telemetry snapshot from the battery fuel gauge.

All fields are optional. Each returned `Status` represents a complete snapshot, not a sparse
delta; fields omitted by the driver indicate that the metric is unsupported by the hardware fuel
gauge or currently unavailable/indeterminate.

NOTE: Some fields (e.g. instantaneous `voltage_uv` and `current_ua`) may be passive measurements
that do not generate hardware interrupts on change. Refer to [Spec.supported_options](https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Spec.supported_options) for the
options that can actively trigger change notifications.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `present` | `bool` | Whether the battery pack is physically present and connected. If false, the battery is detached/missing. Omitted if presence is indeterminate. |
| ### 2 | `voltage_uv` | `uint32` | Present terminal voltage in microvolts. Omitted if unsupported by hardware or unavailable. |
| ### 3 | `current_ua` | `int32` | Present current in microamps: positive (+) for charging, negative (-) for discharging. Omitted if unsupported by hardware or unavailable. |
| ### 4 | `level_percent` | `float32` | State of charge percentage in the range \[0.0, 100.0\]. Omitted if indeterminate or unsupported by hardware. |
| ### 5 | `temp_celsius` | `float32` | Internal battery temperature in Celsius. Omitted if temperature sensing is unsupported or unavailable. |
| ### 6 | `remaining_capacity_uah` | `uint32` | Estimated remaining usable capacity in microamp-hours. Omitted if indeterminate or unsupported by hardware. |
| ### 7 | `full_charge_capacity_uah` | `uint32` | Estimated full charge capacity in microamp-hours, reflecting pack aging. Omitted if indeterminate or unsupported by hardware. |
| ### 8 | `health` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#HealthStatus` | Health condition or safety trip status. Omitted if health diagnostics are unsupported by hardware. |
| ### 9 | `cycle_count` | `uint32` | Total charge-discharge cycle count. Omitted if cycle tracking is unsupported by hardware. |
| ### 10 | `time_remaining` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Duration` | Estimated duration remaining until fully empty (discharging) or fully charged (charging). Omitted if indeterminate, unsupported, or if the battery is idle. |

### WatchOptions

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=78)*

Configuration options for battery state watching.

`interest` and `wake_on` are optional masks: the actual field values within the `Status` table
are ignored; only field presence (set vs. unset) determines the mask.

An absent mask means "use this field's default"; a present but empty mask means "no fields".
The two defaults differ because the safe choice differs: `interest` defaults to everything the
driver supports watching, so a client that never configures anything still makes progress,
while `wake_on` defaults to nothing, since waking the system is a cost a client must opt into.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `interest` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Status` | Fields the client wants to receive change notifications for. Defaults to every field the driver supports watching, as reported by `Spec.supported_options`. Pass an explicitly empty table to be notified only for the fields named in `wake_on`. |
| ### 2 | `wake_on` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Status` | Fields that should actively wake the system from suspend. Any field present in `wake_on` is implicitly included in `interest`. Defaults to no fields: changes occurring during suspend are deferred until the next system wakeup and do not wake the device. |
| ### 3 | `max_interval` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Duration` | Maximum time between `Watch` responses. When set, the server completes a pending `Watch` with a freshly sampled `Status` once this much time has passed since the previous response, even if no field in `interest` changed. The time is measured on the boot timeline, so time spent suspended counts towards it. Defaults to absent: `Watch` only completes on changes. Servers that do not support periodic sampling omit this field from the effective options returned by `ConfigureWatch` and from `Spec.supported_options`. Servers may clamp the value, and report the interval they will honor in the effective options. Samples do not wake the system from suspend unless `wake_on_max_interval` is set: a sample that falls due while the system is suspended is taken once the system resumes. |
| ### 4 | `wake_on_max_interval` | `bool` | Whether a `max_interval` sample that falls due while the system is suspended wakes the system. Defaults to false; like `wake_on`, waking the system is a cost the client opts into. Ignored if `max_interval` is absent. Servers that cannot wake the system omit this field from the effective options returned by `ConfigureWatch` and from `Spec.supported_options`. |

## **UNIONS**

### Battery_ConfigureWatch_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=264)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_ConfigureWatch_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Battery_GetSpec_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=213)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_GetSpec_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Battery_GetStatus_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=225)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_GetStatus_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Battery_Watch_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible) [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=297)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Battery_Watch_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.power.battery#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

## **SERVICES**

### Service

*Defined in [fuchsia.hardware.power.battery/battery.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=303)*

| Name | Type | Transport |
|---|---|---|
| [battery](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.power.battery/battery.fidl;l=304) | `fuchsia.hardware.power.battery/Battery` | Channel |

<br />