
<!-- Generated from deploy/crds.yaml by crdref. Do not edit. -->

# `Peripheral`

A `Peripheral` is one bonded device. The controller or speaker has
link keys for this adapter, and the object reports what the radio
observes about it. The operator creates the object when pairing
succeeds and when it finds a bond that `bluetoothd` already stores.
The keys are in a `Secret` this object owns. Read
`status.conditions` for the link, `status.battery` for the charge
the device reports, and `status.bond` for the keys. Deleting a
`Peripheral` is the unpair: the operator disconnects the device,
waits for the claim that holds it to release, retires the device
from the `ResourceSlice`, and removes the bond from `bluetoothd`,
and the `Secret` is collected with the object. Edit `spec.alias` to
rename a device and `spec.trusted` to say whether it may reconnect
on its own.

One bonded Bluetooth device, named for its own address in the same form the ResourceSlice uses. The object owns the Secret that stores this bond's keys.

## spec

What the operator makes true about the device.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="spec--alias"></span>`alias` | string | no | The name for this device, written into BlueZ's Device1.Alias. bluetoothd stores the alias in the bond's own file, so the name is stored with the keys. Leave it empty to keep the name the device reports for itself. |
| <span id="spec--trusted"></span>`trusted` | boolean | no | Whether the device may connect with no agent, written into BlueZ's Device1.Trusted. With this off, BlueZ asks an agent to authorize each service on every connection, and no agent is registered outside a pairing window, so the device does not connect. A trusted controller connects when its own button is pressed. A trusted speaker is connected by the operator whenever it is powered on and in range. Default: `true`. |

## status

What the operator observes about the device.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="status--address"></span>`address` | string | no | The device's Bluetooth address, in the uppercase form the label on the hardware shows. |
| <span id="status--name"></span>`name` | string | no | The name the device reports for itself. It is not spec.alias, so a person who renames a device still reads the name the hardware states. |
| <span id="status--icon"></span>`icon` | string | no | The freedesktop icon name BlueZ derives for this device, such as input-gaming or audio-headset. It is empty when BlueZ states none. |
| <span id="status--adapter"></span>`adapter` | string | no | The address of the adapter this bond belongs to. |
| <span id="status--node"></span>`node` | string | no | The machine whose operator holds this bond now. The value changes when the adapter moves. |
| <span id="status--bond"></span>`bond` | [object](#statusbond) | no | What the operator observes about the bond. |
| <span id="status--battery"></span>`battery` | [object](#statusbattery) | no | The charge the device reports. The operator reads the kernel's power supply class first, and BlueZ's org.bluez.Battery1 interface for a device the kernel registers no power supply for. The block is absent when neither reports a level, which covers every device with no battery and every battery device that is not connected. |
| <span id="status--conditions"></span>`conditions` | [\[\]object](#statusconditions) | no | Connected reports whether the device has a link now, and its reason says why the link ended, from the reason BlueZ gave. The reason is LinkUp when the link is up. Asleep is a link that timed out on a device that sleeps between sessions, such as a Low Energy remote after an idle hour, and the device's next connect writes one KEY_UNKNOWN press into its virtual device. LinkLost is a link that timed out on a device that does not sleep, which went out of range or whose battery ran out. ClosedByDevice is a link the device ended, and ClosedByRadio is a link this radio ended, at an unpair or at the input recovery. AuthenticationFailed is a link that ended because the keys did not match, and the device needs to be paired again. NotConnected is a link that ended with no reason the operator received: it ended while the operator was not running, or BlueZ reported no reason. NotBonded means bluetoothd holds no object for the device, so the bond was removed by another route. The reason changes only when the link changes, and lastTransitionTime changes only when the status changes. |

### status.bond

What the operator observes about the bond.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="statusbond--held"></span>`held` | boolean | no | Whether bluetoothd still has this bond. It is false when the daemon no longer has the keys. The operator reports this state but does not act on it. |
| <span id="statusbond--paired"></span>`paired` | boolean | no | Whether BlueZ reports this device as paired, from Device1.Paired, read on every pass the operator makes over the devices. |
| <span id="statusbond--bonded"></span>`bonded` | boolean | no | Whether BlueZ reports a stored link key for this device, from Device1.Bonded. Paired alone does not state that the key is stored. |
| <span id="statusbond--trusted"></span>`trusted` | boolean | no | Whether BlueZ reports this device as trusted, from Device1.Trusted. This is the property spec.trusted reconciles into. |
| <span id="statusbond--connected"></span>`connected` | boolean | no | Whether BlueZ reports this device as connected, from Device1.Connected. It is the same reading the Connected condition reports. |
| <span id="statusbond--secret"></span>`secret` | string | no | The namespace and name of the Secret that stores this bond's keys. The Secret is owned by this object, so deleting the Peripheral collects it. |
| <span id="statusbond--pairedat"></span>`pairedAt` | string | no | When the operator first recorded this bond, which is the pairing for a bond it made and the adoption for one it discovered. |
| <span id="statusbond--request"></span>`request` | string | no | The namespace and name of the PairingRequest that produced this bond. It is empty for a bond the operator adopted. A finished request is collected after its TTL, and this field outlasts it. |

### status.battery

The charge the device reports. The operator reads the kernel's power supply class first, and BlueZ's org.bluez.Battery1 interface for a device the kernel registers no power supply for. The block is absent when neither reports a level, which covers every device with no battery and every battery device that is not connected.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="statusbattery--percentage"></span>`percentage` | integer | no | The charge left, from 0 to 100. |
| <span id="statusbattery--source"></span>`source` | string | no | Where the level came from. It is the power supply's own name for a reading from the kernel, such as ps-controller-battery-7c:66:ef:22:e7:80, and BlueZ's own word for a reading from BlueZ, such as HID or a GATT service. |
| <span id="statusbattery--charging"></span>`charging` | boolean | no | Whether the device is charging now. It is absent when the source is BlueZ, which reports a level and no direction, and when the kernel reports the status Unknown. |

### status.conditions[]

Connected reports whether the device has a link now, and its reason says why the link ended, from the reason BlueZ gave. The reason is LinkUp when the link is up. Asleep is a link that timed out on a device that sleeps between sessions, such as a Low Energy remote after an idle hour, and the device's next connect writes one KEY_UNKNOWN press into its virtual device. LinkLost is a link that timed out on a device that does not sleep, which went out of range or whose battery ran out. ClosedByDevice is a link the device ended, and ClosedByRadio is a link this radio ended, at an unpair or at the input recovery. AuthenticationFailed is a link that ended because the keys did not match, and the device needs to be paired again. NotConnected is a link that ended with no reason the operator received: it ended while the operator was not running, or BlueZ reported no reason. NotBonded means bluetoothd holds no object for the device, so the bond was removed by another route. The reason changes only when the link changes, and lastTransitionTime changes only when the status changes.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="statusconditions--type"></span>`type` | string | yes | The state this condition reports on. |
| <span id="statusconditions--status"></span>`status` | string | yes | Whether the reported state is true, false, or unknown. One of: `True`, `False`, `Unknown`. |
| <span id="statusconditions--reason"></span>`reason` | string | no | One word for why the condition has this status. |
| <span id="statusconditions--message"></span>`message` | string | no | One sentence on what the reason means, and what a person can do about it when there is something to do. The Event of each transition carries the same sentence. |
| <span id="statusconditions--lasttransitiontime"></span>`lastTransitionTime` | string | no | When the status last changed, which is not when the operator last wrote the object. A reason that changes under the same status does not move it. |

