1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Host errors.
use zigbee_primitives::{Ieee, NodeId};
/// A host operation failed.
#[derive(Debug, Clone, thiserror::Error)]
pub enum HostError {
/// The NCP failed or rejected a command.
#[error("NCP: {0}")]
Ncp(String),
/// The NCP runs a different network than configured. Nothing was
/// changed; restore a backup or allow replacing it.
#[error("the coordinator runs another network ({found}); refusing to replace it")]
NetworkMismatch {
/// What the NCP has.
found: String,
},
/// A restore needs the coordinator's IEEE address and this chip cannot
/// take it.
#[error("cannot restore: {0}")]
RestoreRefused(String),
/// The coordinator's IEEE address was written; the NCP must be power
/// cycled (or the host restarted) before the restore can finish.
#[error("coordinator IEEE address written; restart to finish the restore")]
RestartRequired,
/// No such device.
#[error("unknown device {0}")]
UnknownDevice(Ieee),
/// The device did not answer in time.
#[error("no response from {0:#06x}")]
Timeout(NodeId),
/// The NCP could not deliver the frame.
#[error("delivery to {0:#06x} failed")]
DeliveryFailed(NodeId),
/// The device answered with a failure status.
#[error("{what} failed with status {status:#04x}")]
Status {
/// The request.
what: String,
/// The status.
status: u8,
},
/// A frame did not decode.
#[error("bad frame: {0}")]
BadFrame(String),
/// A request was not valid.
#[error("{0}")]
Invalid(String),
/// Store or backup file I/O.
#[error("{0}")]
Io(String),
/// The host has stopped.
#[error("host stopped")]
Stopped,
}
impl From<zigbee_ezsp::EzspError> for HostError {
fn from(e: zigbee_ezsp::EzspError) -> Self {
HostError::Ncp(e.to_string())
}
}