pub struct Controller { /* private fields */ }Expand description
A handle to a running controller. Clones share it.
Implementations§
Source§impl Controller
impl Controller
Sourcepub async fn start<P: Port>(
port: P,
cfg: HostConfig,
) -> Result<(Controller, Events), Error>
pub async fn start<P: Port>( port: P, cfg: HostConfig, ) -> Result<(Controller, Events), Error>
Initializes the controller on port, loads the store, starts the
dispatcher and resumes interviews. Events arrive on the returned
channel; read it, or events are dropped when it fills.
Sourcepub fn info(&self) -> ControllerInfo
pub fn info(&self) -> ControllerInfo
The controller’s own information.
Sourcepub fn node(&self, node: NodeId) -> Option<NodeRecord>
pub fn node(&self, node: NodeId) -> Option<NodeRecord>
A node’s record.
Sourcepub fn nodes(&self) -> Vec<NodeRecord>
pub fn nodes(&self) -> Vec<NodeRecord>
Every node’s record.
Sourcepub fn status(&self, node: NodeId) -> NodeStatus
pub fn status(&self, node: NodeId) -> NodeStatus
A node’s runtime status.
Sourcepub fn set_name(
&self,
node: NodeId,
name: Option<String>,
location: Option<String>,
) -> Result<(), Error>
pub fn set_name( &self, node: NodeId, name: Option<String>, location: Option<String>, ) -> Result<(), Error>
Sets a node’s name and location (persisted).
Sourcepub fn store_error(&self) -> Option<String>
pub fn store_error(&self) -> Option<String>
The last store write error, if the last write failed.
Sourcepub fn close(&self) -> Result<(), Error>
pub fn close(&self) -> Result<(), Error>
Stops the controller: writes the store, closes the serial port and
ends the event stream. Every clone stops with it; start a new
Controller to use the stick again (after a restore or a region
change, or to hand the port to something else).
Sourcepub async fn send(
&self,
node: NodeId,
endpoint: u8,
cmd: &Command,
) -> Result<(), Error>
pub async fn send( &self, node: NodeId, endpoint: u8, cmd: &Command, ) -> Result<(), Error>
Sends a command to a node’s endpoint. For a sleeping node this waits until the node wakes up.
Sourcepub async fn send_supervised(
&self,
node: NodeId,
endpoint: u8,
cmd: &Command,
) -> Result<u8, Error>
pub async fn send_supervised( &self, node: NodeId, endpoint: u8, cmd: &Command, ) -> Result<u8, Error>
Sends a command with Supervision and returns the node’s status
(0xFF success, 0x01 working; failure and no support are errors).
Sourcepub async fn request(
&self,
node: NodeId,
endpoint: u8,
cmd: Command,
expect: impl Fn(&Command) -> bool + Send + Sync + 'static,
) -> Result<Command, Error>
pub async fn request( &self, node: NodeId, endpoint: u8, cmd: Command, expect: impl Fn(&Command) -> bool + Send + Sync + 'static, ) -> Result<Command, Error>
Sends a command and waits for the reply expect accepts.
Sourcepub async fn set_value(
&self,
id: &ValueId,
value: &ValueKind,
) -> Result<(), Error>
pub async fn set_value( &self, id: &ValueId, value: &ValueKind, ) -> Result<(), Error>
Sets a value (switches, levels) and refreshes it.
Sourcepub async fn configure(
&self,
node: NodeId,
config: &DeviceConfig,
settings: &[(String, i64)],
) -> Result<(), Error>
pub async fn configure( &self, node: NodeId, config: &DeviceConfig, settings: &[(String, i64)], ) -> Result<(), Error>
Applies configuration settings keyed as in the node’s device file
("3", "41[0xf00]"): partial parameters are read, merged and written
as one value; each written parameter is read back so its value is
reported.
Sourcepub async fn factory_reset(&self) -> Result<(), Error>
pub async fn factory_reset(&self) -> Result<(), Error>
Resets the controller to factory defaults: a new home id, no nodes.
This Controller must be dropped and a new one started afterwards.
Sourcepub async fn set_region(&self, region: RfRegion) -> Result<(), Error>
pub async fn set_region(&self, region: RfRegion) -> Result<(), Error>
Sets the controller’s RF region and restarts it (the region takes
effect after a restart). This Controller must be dropped and a new
one started afterwards.
Sourcepub async fn configure_raw(
&self,
node: NodeId,
settings: &[(String, i64)],
) -> Result<(), Error>
pub async fn configure_raw( &self, node: NodeId, settings: &[(String, i64)], ) -> Result<(), Error>
Applies configuration settings by key ("3", "41[0xf00]") without a
device file: each parameter is read first for its size and current
value, partial values are merged into it, and it is read back after.
Sourcepub async fn ping(&self, node: NodeId) -> bool
pub async fn ping(&self, node: NodeId) -> bool
Pings a node (No Operation); true if it acknowledged.
Sourcepub fn last_route(&self, node: NodeId) -> Option<(Vec<NodeId>, Option<i8>)>
pub fn last_route(&self, node: NodeId) -> Option<(Vec<NodeId>, Option<i8>)>
The repeaters (nearest the controller first) and ACK RSSI of the last frame that reached a node.
Source§impl Controller
impl Controller
Sourcepub async fn update_firmware(
&self,
node: NodeId,
image: &[u8],
target: u8,
) -> Result<FirmwareUpdateResult, Error>
pub async fn update_firmware( &self, node: NodeId, image: &[u8], target: u8, ) -> Result<FirmwareUpdateResult, Error>
Updates a node’s firmware target (0 is the main firmware) with image.
Emits Event::FirmwareUpdateProgress as fragments go out.
Source§impl Controller
impl Controller
Sourcepub async fn replace_failed_node(
&self,
node: NodeId,
opts: InclusionOptions,
) -> Result<InclusionResult, Error>
pub async fn replace_failed_node( &self, node: NodeId, opts: InclusionOptions, ) -> Result<InclusionResult, Error>
Replaces a failed node: the controller gives its node id to the next node that joins (press its button), which then gets security and an interview as a new node would. The node must be one the controller considers failed.
Sourcepub fn grant_security_classes(&self, classes: Vec<SecurityClass>) -> bool
pub fn grant_security_classes(&self, classes: Vec<SecurityClass>) -> bool
Answers Event::GrantSecurityClasses.
Sourcepub fn validate_dsk(&self, pin: Option<u16>) -> bool
pub fn validate_dsk(&self, pin: Option<u16>) -> bool
Answers Event::ValidateDsk with the PIN, or None to abort.
Sourcepub fn stop_inclusion(&self) -> bool
pub fn stop_inclusion(&self) -> bool
Stops a running inclusion or exclusion.
Sourcepub async fn include(
&self,
opts: InclusionOptions,
) -> Result<InclusionResult, Error>
pub async fn include( &self, opts: InclusionOptions, ) -> Result<InclusionResult, Error>
Includes a node: turns on inclusion mode, waits for a node, runs the key exchange, and starts its interview.
Sourcepub async fn exclude(
&self,
timeout: Option<Duration>,
) -> Result<Option<NodeId>, Error>
pub async fn exclude( &self, timeout: Option<Duration>, ) -> Result<Option<NodeId>, Error>
Excludes a node: turns on exclusion mode and waits for one. Returns the node id it had in this network, if any.
Sourcepub async fn remove_failed_node(&self, node: NodeId) -> Result<(), Error>
pub async fn remove_failed_node(&self, node: NodeId) -> Result<(), Error>
Removes a node the controller considers failed (it stopped answering).
Sourcepub async fn provision(&self, entry: Entry) -> Result<(), Error>
pub async fn provision(&self, entry: Entry) -> Result<(), Error>
Adds or replaces a provisioning list entry (from a scanned QR code).
Sourcepub async fn unprovision(&self, dsk: &Dsk) -> Option<Entry>
pub async fn unprovision(&self, dsk: &Dsk) -> Option<Entry>
Removes a provisioning list entry.
Sourcepub fn provisioning_list(&self) -> Vec<Entry>
pub fn provisioning_list(&self) -> Vec<Entry>
The provisioning list.
Source§impl Controller
impl Controller
Sourcepub fn spawn_interview(&self, node: NodeId)
pub fn spawn_interview(&self, node: NodeId)
Starts (or resumes) a node’s interview in the background, unless one is running.
Sourcepub fn reinterview(&self, node: NodeId) -> Result<(), Error>
pub fn reinterview(&self, node: NodeId) -> Result<(), Error>
Re-runs a node’s interview from the start.
Sourcepub fn security_classes(&self, node: NodeId) -> Vec<SecurityClass>
pub fn security_classes(&self, node: NodeId) -> Vec<SecurityClass>
The classes a node was granted, for callers that need them.
Source§impl Controller
impl Controller
Source§impl Controller
impl Controller
Sourcepub async fn restore_nvm(&self, image: &[u8]) -> Result<(), Error>
pub async fn restore_nvm(&self, image: &[u8]) -> Result<(), Error>
Writes a backup image back to the controller and restarts it.
A backup from another series (700 or 800) or SDK is converted first
(crate::nvm3::convert); one whose protocol format is newer than
the controller reads is refused. The controller restarts afterwards, so this
Controller must be dropped and a new one started.