zigbee_znp/ids.rs
1//! Subsystems, command ids, NV item ids and status codes.
2
3/// MT subsystems.
4pub mod subsystem {
5 /// Reserved; the NCP's "unknown command" error comes from here.
6 pub const RPC_ERROR: u8 = 0x00;
7 /// System: reset, version, NV memory.
8 pub const SYS: u8 = 0x01;
9 /// Application framework: endpoints and data.
10 pub const AF: u8 = 0x04;
11 /// Zigbee device objects.
12 pub const ZDO: u8 = 0x05;
13 /// Utilities.
14 pub const UTIL: u8 = 0x07;
15 /// Base device behavior configuration.
16 pub const APP_CNF: u8 = 0x0F;
17}
18
19/// SYS commands.
20pub mod sys {
21 /// Reset (AREQ).
22 pub const RESET_REQ: u8 = 0x00;
23 /// Ping.
24 pub const PING: u8 = 0x01;
25 /// Version.
26 pub const VERSION: u8 = 0x02;
27 /// Create an OSAL NV item.
28 pub const OSAL_NV_ITEM_INIT: u8 = 0x07;
29 /// Read an OSAL NV item.
30 pub const OSAL_NV_READ: u8 = 0x08;
31 /// Write an OSAL NV item.
32 pub const OSAL_NV_WRITE: u8 = 0x09;
33 /// Delete an OSAL NV item.
34 pub const OSAL_NV_DELETE: u8 = 0x12;
35 /// An OSAL NV item's length.
36 pub const OSAL_NV_LENGTH: u8 = 0x13;
37 /// Transmit power.
38 pub const SET_TX_POWER: u8 = 0x14;
39 /// Create an extended NV item (Z-Stack 3.x.0).
40 pub const NV_CREATE: u8 = 0x30;
41 /// Delete an extended NV item.
42 pub const NV_DELETE: u8 = 0x31;
43 /// An extended NV item's length.
44 pub const NV_LENGTH: u8 = 0x32;
45 /// Read an extended NV item.
46 pub const NV_READ: u8 = 0x33;
47 /// Write an extended NV item.
48 pub const NV_WRITE: u8 = 0x34;
49 /// Reset indication (AREQ).
50 pub const RESET_IND: u8 = 0x80;
51}
52
53/// AF commands.
54pub mod af {
55 /// Register an endpoint.
56 pub const REGISTER: u8 = 0x00;
57 /// Send data, short addressing.
58 pub const DATA_REQUEST: u8 = 0x01;
59 /// Send data, any addressing and long payloads.
60 pub const DATA_REQUEST_EXT: u8 = 0x02;
61 /// Data confirm (AREQ).
62 pub const DATA_CONFIRM: u8 = 0x80;
63 /// Incoming message (AREQ).
64 pub const INCOMING_MSG: u8 = 0x81;
65 /// Incoming message, extended (AREQ).
66 pub const INCOMING_MSG_EXT: u8 = 0x82;
67}
68
69/// ZDO commands.
70pub mod zdo {
71 /// Install a link key for a device.
72 pub const SET_LINK_KEY: u8 = 0x23;
73 /// Discover networks (an active scan).
74 pub const NWK_DISCOVERY_REQ: u8 = 0x26;
75 /// Send a raw ZDO frame.
76 pub const SEND_DATA: u8 = 0x28;
77 /// Permit joining.
78 pub const MGMT_PERMIT_JOIN_REQ: u8 = 0x36;
79 /// Network update (channel change, energy scan).
80 pub const MGMT_NWK_UPDATE_REQ: u8 = 0x37;
81 /// Forward ZDO frames of a cluster to the host.
82 pub const MSG_CB_REGISTER: u8 = 0x3E;
83 /// Start the stack.
84 pub const STARTUP_FROM_APP: u8 = 0x40;
85 /// Network information.
86 pub const EXT_NWK_INFO: u8 = 0x50;
87 /// Device state changed (AREQ).
88 pub const STATE_CHANGE_IND: u8 = 0xC0;
89 /// Device announce (AREQ).
90 pub const END_DEVICE_ANNCE_IND: u8 = 0xC1;
91 /// Source route (AREQ).
92 pub const SRC_RTG_IND: u8 = 0xC4;
93 /// Beacons heard by a network discovery (AREQ).
94 pub const BEACON_NOTIFY_IND: u8 = 0xC5;
95 /// Network discovery finished (AREQ).
96 pub const NWK_DISCOVERY_CNF: u8 = 0xC7;
97 /// A device left (AREQ).
98 pub const LEAVE_IND: u8 = 0xC9;
99 /// The trust center admitted a device (AREQ).
100 pub const TC_DEV_IND: u8 = 0xCA;
101 /// Permit join state (AREQ).
102 pub const PERMIT_JOIN_IND: u8 = 0xCB;
103 /// A forwarded ZDO frame (AREQ).
104 pub const MSG_CB_INCOMING: u8 = 0xFF;
105}
106
107/// UTIL commands.
108pub mod util {
109 /// Device information.
110 pub const GET_DEVICE_INFO: u8 = 0x00;
111}
112
113/// APP_CNF commands.
114pub mod app_cnf {
115 /// Trust center policy on rejoins.
116 pub const SET_ALLOWREJOIN_TC_POLICY: u8 = 0x03;
117 /// Add an install code.
118 pub const BDB_ADD_INSTALLCODE: u8 = 0x04;
119 /// Only devices with an install code may join.
120 pub const BDB_SET_JOINUSESINSTALLCODEKEY: u8 = 0x06;
121 /// Start commissioning.
122 pub const BDB_START_COMMISSIONING: u8 = 0x05;
123 /// Commissioning channels.
124 pub const BDB_SET_CHANNEL: u8 = 0x08;
125 /// Require a trust center link key exchange from joiners.
126 pub const BDB_SET_TC_REQUIRE_KEY_EXCHANGE: u8 = 0x09;
127 /// Commissioning progress (AREQ).
128 pub const BDB_COMMISSIONING_NOTIFICATION: u8 = 0x80;
129}
130
131/// Commissioning modes for `BDB_START_COMMISSIONING`.
132pub mod commissioning {
133 /// Network steering (open for joining).
134 pub const STEERING: u8 = 0x02;
135 /// Network formation.
136 pub const FORMATION: u8 = 0x04;
137}
138
139/// Device states (`ZDO_STATE_CHANGE_IND`).
140pub mod state {
141 /// Initialized, not started.
142 pub const HOLD: u8 = 0x00;
143 /// Starting as coordinator.
144 pub const COORD_STARTING: u8 = 0x08;
145 /// Running as coordinator.
146 pub const ZB_COORD: u8 = 0x09;
147}
148
149/// Z-Stack product ids from `SYS_VERSION`.
150pub mod product {
151 /// Z-Stack Home 1.2 (not Zigbee 3.0).
152 pub const ZSTACK_12: u8 = 0;
153 /// Z-Stack 3.x.0 (CC13x2, CC26x2, CC2652).
154 pub const ZSTACK_3X0: u8 = 1;
155 /// Z-Stack 3.0.x (CC2530, CC2531).
156 pub const ZSTACK_30X: u8 = 2;
157}
158
159/// Status codes.
160pub mod status {
161 /// Success.
162 pub const SUCCESS: u8 = 0x00;
163 /// Failure.
164 pub const FAILURE: u8 = 0x01;
165 /// An NV item was created.
166 pub const NV_ITEM_UNINIT: u8 = 0x09;
167 /// NV operation failed.
168 pub const NV_OPER_FAILED: u8 = 0x0A;
169 /// No such NV item.
170 pub const NV_BAD_ITEM_LEN: u8 = 0x0C;
171 /// MAC: no acknowledgement.
172 pub const MAC_NO_ACK: u8 = 0xE9;
173 /// APS: no acknowledgement.
174 pub const APS_NO_ACK: u8 = 0xA7;
175 /// NWK: no route.
176 pub const NWK_NO_ROUTE: u8 = 0xCD;
177}
178
179/// AF transmit options.
180pub mod af_option {
181 /// Ask for an APS acknowledgement.
182 pub const ACK_REQUEST: u8 = 0x10;
183 /// Discover a route if needed.
184 pub const DISCOVER_ROUTE: u8 = 0x20;
185}
186
187/// Address modes in `AF_DATA_REQUEST_EXT` and `ZDO_MGMT_*`.
188pub mod addr_mode {
189 /// Group.
190 pub const GROUP: u8 = 0x01;
191 /// 16-bit network address.
192 pub const SHORT: u8 = 0x02;
193 /// 64-bit IEEE address.
194 pub const IEEE: u8 = 0x03;
195 /// Broadcast.
196 pub const BROADCAST: u8 = 0x0F;
197}
198
199/// Legacy OSAL NV item ids (every Z-Stack 3 build).
200pub mod nv {
201 /// The coordinator's IEEE address; read at start-up.
202 pub const EXTADDR: u16 = 0x0001;
203 /// Start-up options: clear state and configuration on the next reset.
204 pub const STARTUP_OPTION: u16 = 0x0003;
205 /// Network information base.
206 pub const NIB: u16 = 0x0021;
207 /// Extended PAN id.
208 pub const EXTENDED_PAN_ID: u16 = 0x002D;
209 /// Active network key and its sequence number.
210 pub const NWK_ACTIVE_KEY_INFO: u16 = 0x003A;
211 /// Use the configured extended PAN id.
212 pub const APS_USE_EXT_PANID: u16 = 0x0047;
213 /// The network key to form with.
214 pub const PRECFGKEY: u16 = 0x0062;
215 /// Distribute the network key in the clear (1) or under link keys (0).
216 pub const PRECFGKEYS_ENABLE: u16 = 0x0063;
217 /// The network security material table (Z-Stack 3.0.x), first entry.
218 pub const LEGACY_NWK_SEC_MATERIAL_TABLE_START: u16 = 0x0075;
219 /// PAN id.
220 pub const PANID: u16 = 0x0083;
221 /// Channel mask.
222 pub const CHANLIST: u16 = 0x0084;
223 /// Logical type: 0 coordinator.
224 pub const LOGICAL_TYPE: u16 = 0x0087;
225 /// Deliver ZDO responses to the host.
226 pub const ZDO_DIRECT_CB: u16 = 0x008F;
227 /// The trust center's link key seed (unique keys are derived from it).
228 pub const TCLK_SEED: u16 = 0x0101;
229}
230
231/// Extended NV tables (Z-Stack 3.x.0), system id 1.
232pub mod nv_ex {
233 /// The Z-Stack system id.
234 pub const SYSID_ZSTACK: u8 = 1;
235 /// The network security material table.
236 pub const NWK_SEC_MATERIAL_TABLE: u16 = 0x0007;
237}
238
239/// Start-up option bits.
240pub mod startup_option {
241 /// Clear the network configuration.
242 pub const CLEAR_CONFIG: u8 = 0x01;
243 /// Clear the network state.
244 pub const CLEAR_STATE: u8 = 0x02;
245}