Skip to main content

LevelControl

Struct LevelControl 

Source
pub struct LevelControl<'a, H: LevelControlHooks, O: OnOffState = NoOnOff> { /* private fields */ }
Expand description

Level Control, with the device’s hooks and whatever On/Off cluster shares the endpoint.

Implementations§

Source§

impl<'a, H: LevelControlHooks> LevelControl<'a, H, NoOnOff>

Source

pub fn new(hooks: &'a H, feature_map: u32) -> Self

A cluster on an endpoint with no On/Off — a volume control, say.

Source§

impl<'a, H: LevelControlHooks, O: OnOffState> LevelControl<'a, H, O>

Source

pub const WITH_ALL_OPTIONAL: Optional<'static>

Everything §1.6.6 leaves to the product.

Source

pub const WITH_RANGE: Optional<'static>

Just the two range attributes, which a lighting device type requires.

Source

pub fn with_on_off(hooks: &'a H, on_off: &'a O, feature_map: u32) -> Self

A cluster coupled to the On/Off cluster on_off on the same endpoint.

Source

pub fn with_range(self, min_level: u8, max_level: u8) -> Self

The same cluster over a narrower range (§1.6.6.4, §1.6.6.5).

Only for a device without the Lighting feature: with it, the specification fixes the range at 1..=254, and a lighting device that narrowed it would report a MinLevel its own device type forbids.

Source

pub const fn with_frequency(self, min: u16, max: u16) -> Self

The same cluster with the Frequency feature’s range (§1.6.6.7, §1.6.6.8).

Source

pub fn conforming( feature_map: u32, optional: &Optional<'_>, ) -> Result<Conforming<14, 9, 0, 0>>

The descriptor for an instance, derived from the specification’s tables.

Source

pub fn start(&self, previous: Option<u8>)

§1.6.6.15’s start-up behaviour.

StartUpCurrentLevelwhat CurrentLevel becomes
0the minimum the device permits
nullprevious — what it was before the power cut
anything elsethat value

previous is the device’s to remember; this cluster persists nothing. A device that stores nothing passes None, which is the null level — honest for a lamp that does not know how bright it was.

Source

pub fn level(&self) -> Option<u8>

CurrentLevel (§1.6.6.2).

Source

pub fn remaining_time(&self) -> u16

RemainingTime (§1.6.6.3), in tenths of a second.

Source

pub const fn min_level(&self) -> u8

MinLevel (§1.6.6.4).

Source

pub const fn max_level(&self) -> u8

MaxLevel (§1.6.6.5).

Source

pub fn options(&self) -> OptionsBitmap

Options (§1.6.6.9).

Source

pub fn on_level(&self) -> Option<u8>

OnLevel (§1.6.6.11) — the level an On command restores, or null for none.

Source

pub fn set_on_level(&self, level: Option<u8>)

Sets OnLevel without a write interaction, for a device with a fixed one.

Source

pub fn set_start_up_level(&self, level: Option<u8>)

Sets StartUpCurrentLevel (§1.6.6.15) without a write interaction.

Source

pub fn wake_at(&self) -> Option<Instant>

When LevelControl::poll next has something to do.

None while nothing is moving, which is the ordinary case — a lamp sitting at a level needs no clock, and an intermittently connected device can sleep.

Source

pub fn poll(&self, now: Instant)

Advances whatever is in motion.

Catches up on elapsed time rather than counting calls, so a device that polls late arrives at the level it promised rather than however many ticks behind.

Source§

impl<H: LevelControlHooks, O: OnOffState> LevelControl<'_, H, O>

Source

pub fn on_off_changed(&self, on: bool, stored: Option<u8>, now: Instant)

§1.6.4.1.1’s coupling, for a device that wants it.

Called by the product from its own OnOffHooks::set, because §1.6.4.1 makes the whole dependency optional: “dependencies MAY be introduced between them. Facilities are provided to introduce dependencies if required.”

On. Temporarily store CurrentLevel. Set CurrentLevel to the minimum level allowed for the device. Change CurrentLevel to OnLevel, or to the stored level if OnLevel is not defined, over the time period OnOffTransitionTime.

stored is the level to return to — what the device remembers from before it was switched off. The specification’s own note is the reason it is a parameter: “If another of these commands is received, before the transition is completed, the originally stored CurrentLevel SHALL be preserved and restored”, and only the device knows which value that is across a power cut.

Trait Implementations§

Source§

impl<H: LevelControlHooks, O: OnOffState> Cluster for LevelControl<'_, H, O>

So a tuple of clusters can dispatch to it by id.

Source§

const ID: ClusterId = ID

The cluster id this implementation serves.
Source§

impl<H: LevelControlHooks, O: OnOffState> ClusterHandler for LevelControl<'_, H, O>

Source§

fn read( &self, resolved: &Resolved<'_>, _ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Writes the value of resolved’s attribute under tag. Read more
Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], _op: WriteOp, _ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Writes data — the encoded TLV element, tag included — into the attribute. Read more
Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, _w: &mut TlvWriter<'_>, _tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Runs a command. Read more
Source§

fn data_version(&self, _resolved: &Resolved<'_>) -> Option<u32>

The cluster instance’s data version (§7.10.3), if it tracks one. Read more
Source§

fn on_lifecycle(&self, _event: Lifecycle)

Reacts to something that happened to the node (see Lifecycle). Read more
Source§

impl<'a, H: Debug + LevelControlHooks, O: Debug + OnOffState> Debug for LevelControl<'a, H, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, H, O = NoOnOff> !Freeze for LevelControl<'a, H, O>

§

impl<'a, H, O = NoOnOff> !RefUnwindSafe for LevelControl<'a, H, O>

§

impl<'a, H, O = NoOnOff> !Sync for LevelControl<'a, H, O>

§

impl<'a, H, O> Forget for LevelControl<'a, H, O>

§

impl<'a, H, O> Move for LevelControl<'a, H, O>

§

impl<'a, H, O> Send for LevelControl<'a, H, O>
where &'a H: Send, &'a O: Send,

§

impl<'a, H, O> Unpin for LevelControl<'a, H, O>

§

impl<'a, H, O> UnsafeUnpin for LevelControl<'a, H, O>

§

impl<'a, H, O> UnwindSafe for LevelControl<'a, H, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.