pub struct Host<A: Adapter> { /* private fields */ }Expand description
A running coordinator host. Clones share it.
Implementations§
Source§impl<A: Adapter> Host<A>
impl<A: Adapter> Host<A>
Sourcepub async fn ota_check(&self, ieee: Ieee) -> Result<OtaOffer, HostError>
pub async fn ota_check(&self, ieee: Ieee) -> Result<OtaOffer, HostError>
Ask a device which firmware it runs and whether the image directory has a newer one. The device is told to query (Image Notify) and answered “no image”; sleepy devices answer when they next wake.
Sourcepub async fn ota_update(&self, ieee: Ieee) -> Result<OtaOffer, HostError>
pub async fn ota_update(&self, ieee: Ieee) -> Result<OtaOffer, HostError>
Start upgrading a device from the image directory. Returns once the
device took the offer; HostEvent::OtaProgress and
HostEvent::OtaFinished follow.
Source§impl<A: Adapter> Host<A>
impl<A: Adapter> Host<A>
Sourcepub async fn start(
adapter: A,
adapter_events: UnboundedReceiver<AdapterEvent>,
mode: StartMode,
config: HostConfig,
) -> Result<(Host<A>, UnboundedReceiver<HostEvent>), HostError>
pub async fn start( adapter: A, adapter_events: UnboundedReceiver<AdapterEvent>, mode: StartMode, config: HostConfig, ) -> Result<(Host<A>, UnboundedReceiver<HostEvent>), HostError>
Start the network on adapter and run the host. Events arrive on the
returned receiver until the adapter fails.
Sourcepub fn network(&self) -> NetworkInfo
pub fn network(&self) -> NetworkInfo
The network.
Sourcepub fn adapter_info(&self) -> AdapterInfo
pub fn adapter_info(&self) -> AdapterInfo
The NCP.
Sourcepub fn device_by_nwk(&self, nwk: NodeId) -> Option<Device>
pub fn device_by_nwk(&self, nwk: NodeId) -> Option<Device>
The device with a network address.
Sourcepub fn set_name(
&self,
ieee: Ieee,
name: Option<String>,
) -> Result<(), HostError>
pub fn set_name( &self, ieee: Ieee, name: Option<String>, ) -> Result<(), HostError>
Give a device a name.
Sourcepub async fn zcl_raw(
&self,
ieee: Ieee,
request: RawZcl,
) -> Result<Option<Vec<u8>>, HostError>
pub async fn zcl_raw( &self, ieee: Ieee, request: RawZcl, ) -> Result<Option<Vec<u8>>, HostError>
Send a ZCL frame given as bytes, for a caller that builds frames
itself (a device library). The frame’s transaction sequence number
is overwritten with the host’s own. With response, waits for the
device’s reply with that sequence number and returns it exactly as
received; otherwise waits for APS delivery and returns None.
Sourcepub async fn zdo_raw(
&self,
ieee: Ieee,
cluster: u16,
payload: Vec<u8>,
response: bool,
timeout: Option<Duration>,
) -> Result<Option<Vec<u8>>, HostError>
pub async fn zdo_raw( &self, ieee: Ieee, cluster: u16, payload: Vec<u8>, response: bool, timeout: Option<Duration>, ) -> Result<Option<Vec<u8>>, HostError>
Send a ZDO request given as bytes (transaction sequence number
first, then the request). The sequence number is overwritten with
the host’s own. With response, returns the response payload
exactly as received (sequence number first); otherwise waits for
APS delivery and returns None.
Sourcepub async fn zdo_request(
&self,
nwk: NodeId,
body: Body,
) -> Result<Message, HostError>
pub async fn zdo_request( &self, nwk: NodeId, body: Body, ) -> Result<Message, HostError>
Send a ZDO request to nwk and wait for its response.
Sourcepub async fn zdo_request_retry(
&self,
nwk: NodeId,
body: Body,
) -> Result<Message, HostError>
pub async fn zdo_request_retry( &self, nwk: NodeId, body: Body, ) -> Result<Message, HostError>
Host::zdo_request with the configured retries.
Sourcepub async fn zcl_request(
&self,
ieee: Ieee,
endpoint: u8,
cluster: u16,
frame: Frame,
) -> Result<Frame, HostError>
pub async fn zcl_request( &self, ieee: Ieee, endpoint: u8, cluster: u16, frame: Frame, ) -> Result<Frame, HostError>
Send a ZCL frame to a device’s endpoint and wait for the reply with the same sequence number. The frame’s sequence number is assigned here.
Sourcepub async fn read_attributes(
&self,
ieee: Ieee,
endpoint: u8,
cluster: u16,
attributes: &[u16],
) -> Result<Vec<ReadRecord>, HostError>
pub async fn read_attributes( &self, ieee: Ieee, endpoint: u8, cluster: u16, attributes: &[u16], ) -> Result<Vec<ReadRecord>, HostError>
Read attributes. Returns one record per attribute the device answered.
Sourcepub async fn write_attributes(
&self,
ieee: Ieee,
endpoint: u8,
cluster: u16,
values: Vec<(u16, Value)>,
) -> Result<Vec<(u8, Option<u16>)>, HostError>
pub async fn write_attributes( &self, ieee: Ieee, endpoint: u8, cluster: u16, values: Vec<(u16, Value)>, ) -> Result<Vec<(u8, Option<u16>)>, HostError>
Write attributes. Returns (status, attribute) records; one success record means every write succeeded.
Sourcepub async fn configure_reporting(
&self,
ieee: Ieee,
endpoint: u8,
cluster: u16,
configs: Vec<ReportingConfig>,
) -> Result<Vec<ReportingStatus>, HostError>
pub async fn configure_reporting( &self, ieee: Ieee, endpoint: u8, cluster: u16, configs: Vec<ReportingConfig>, ) -> Result<Vec<ReportingStatus>, HostError>
Configure attribute reporting.
Sourcepub async fn command(
&self,
ieee: Ieee,
endpoint: u8,
cluster: u16,
name: &str,
values: &[Value],
) -> Result<Frame, HostError>
pub async fn command( &self, ieee: Ieee, endpoint: u8, cluster: u16, name: &str, values: &[Value], ) -> Result<Frame, HostError>
Send a cluster command by name, with field values in order (trailing optional fields may be left out). Returns the device’s reply: its default response or the command’s own response.
Sourcepub async fn bind_to_host(
&self,
ieee: Ieee,
endpoint: u8,
cluster: u16,
) -> Result<(), HostError>
pub async fn bind_to_host( &self, ieee: Ieee, endpoint: u8, cluster: u16, ) -> Result<(), HostError>
Bind a device’s cluster to the host’s endpoint, so its reports come here.
Sourcepub async fn permit_join(
&self,
seconds: u8,
via: Option<Ieee>,
) -> Result<(), HostError>
pub async fn permit_join( &self, seconds: u8, via: Option<Ieee>, ) -> Result<(), HostError>
Open the network for joining for seconds (at most 254; 0 closes
it), everywhere or only through one router. Opening through a router
leaves the coordinator’s own radio closed.
Sourcepub async fn add_install_code(
&self,
ieee: Ieee,
code_with_crc: &[u8],
) -> Result<(), HostError>
pub async fn add_install_code( &self, ieee: Ieee, code_with_crc: &[u8], ) -> Result<(), HostError>
Accept a device’s install code (with its CRC). The derived key is given to the NCP now and whenever joining opens, until the device joins. Install codes are kept in memory only.
Sourcepub async fn set_install_codes(
&self,
entries: &[(Ieee, Vec<u8>)],
) -> Result<usize, HostError>
pub async fn set_install_codes( &self, entries: &[(Ieee, Vec<u8>)], ) -> Result<usize, HostError>
Replace every install code the host holds with entries (IEEE
address, install code with its CRC). All are checked before any is
taken. Returns how many there are now.
Sourcepub async fn active_scan(&self) -> Result<Vec<Beacon>, HostError>
pub async fn active_scan(&self) -> Result<Vec<Beacon>, HostError>
Other networks heard on every channel (an active scan).
Sourcepub async fn leave(&self) -> Result<(), HostError>
pub async fn leave(&self) -> Result<(), HostError>
Leave the network and erase it from the coordinator, then forget every device. The host stops; start a new one to form again.
Sourcepub async fn remove(&self, ieee: Ieee, force: bool) -> Result<(), HostError>
pub async fn remove(&self, ieee: Ieee, force: bool) -> Result<(), HostError>
Ask a device to leave and forget it. With force, it is forgotten
even if it does not answer (a dead or sleepy device).
Sourcepub fn topology(&self) -> Vec<(Option<Ieee>, Option<Ieee>, Link)>
pub fn topology(&self) -> Vec<(Option<Ieee>, Option<Ieee>, Link)>
Current links, with addresses resolved to IEEE where known.
Sourcepub async fn scan_neighbors(
&self,
ieee: Ieee,
) -> Result<Vec<Neighbor>, HostError>
pub async fn scan_neighbors( &self, ieee: Ieee, ) -> Result<Vec<Neighbor>, HostError>
Read a router’s (or the coordinator’s) whole neighbor table. At most once a minute per device.
Sourcepub async fn change_channel(
&self,
channel: u8,
) -> Result<NetworkInfo, HostError>
pub async fn change_channel( &self, channel: u8, ) -> Result<NetworkInfo, HostError>
Move the network to channel (11 to 26): broadcast a network
update with the next update id and wait until the coordinator runs
on the new channel. Devices follow the broadcast; sleepy ones that
miss it find the network again when they next rejoin.
Sourcepub async fn energy_scan(&self) -> Result<Vec<(u8, i8)>, HostError>
pub async fn energy_scan(&self) -> Result<Vec<(u8, i8)>, HostError>
Measure every channel’s energy (channel, max RSSI in dBm).
Sourcepub async fn backup(&self) -> Result<Backup, HostError>
pub async fn backup(&self) -> Result<Backup, HostError>
Take a backup now, and write it if a backup path is configured.