zigbee_core/zdp/client_services/discovery/mod.rs
1#![allow(dead_code)]
2
3use heapless::Vec;
4use zigbee_types::IeeeAddress;
5use zigbee_types::ShortAddress;
6
7use crate::apl::descriptors::node_descriptor::MacCapabilities;
8use crate::apl::descriptors::node_descriptor::ServerMask;
9use crate::apl::descriptors::user_descriptor::UserDescriptor;
10
11const CLUSTER_LIST_SIZE: usize = 2 * 0xffff;
12
13/// 2.4.3.1.1 NWK_addr_req
14pub struct NWKAddrReq {
15 /// The IEEE address to be matched by the Remote Device
16 ieee_address: IeeeAddress,
17 /// Request type for this command:
18 /// 0x00 – Single device response
19 /// 0x01 – Extended response
20 /// 0x02-0xFF – reserved
21 request_type: u8,
22 /// If the Request type for this command is Extended
23 /// response, the StartIndex provides the starting index
24 /// for the requested elements of the associated devices list.
25 start_index: u8,
26}
27
28/// 2.4.3.1.2 IEEE_addr_req
29pub struct IeeeAddrReq {
30 /// NWK address that is used for IEEE address mapping.
31 nwk_addr_of_interest: ShortAddress,
32 /// Request type for this command:
33 /// 0x00 – Single device response
34 /// 0x01 – Extended response
35 /// 0x02-0xFF – reserved
36 request_type: u8,
37 /// If the Request type for this command is Extended
38 /// response, the StartIndex provides the starting index
39 /// for the requested elements of the associated devices list.
40 start_index: u8,
41}
42
43/// 2.4.3.1.3 Node_Desc_req
44pub struct NodeDescReq {
45 /// NWK address for the request
46 nwk_addr_of_interest: ShortAddress,
47}
48
49/// 2.4.3.1.4 Power_Desc_req
50pub struct PowerDescReq {
51 /// NWK address for the request
52 nwk_addr_of_interest: ShortAddress,
53}
54
55/// 2.4.3.1.5 Simple_Desc_req
56pub struct SimpleDescReq {
57 /// NWK address for the request
58 nwk_addr_of_interest: ShortAddress,
59 /// The endpoint on the destination
60 endpoint: u8,
61}
62
63/// 2.4.3.1.6 Active_EP_req
64pub struct ActivePeReq {
65 /// NWK address for the request
66 nwk_addr_of_interest: ShortAddress,
67}
68
69/// 2.4.3.1.7 Match_Desc_req
70pub struct MatchDescReq {
71 /// NWK address for the request
72 nwk_addr_of_interest: ShortAddress,
73 /// Profile ID to be matched at the destination.
74 profile_id: u16,
75 /// The number of Input Clusters provided for matching within the
76 /// InClusterList.
77 num_in_clusters: u8,
78 /// List of Input ClusterIDs to be used for matching;
79 /// the InClusterList is the desired list to be matched
80 /// by the Remote Device (the elements of the InClusterList
81 /// are the supported output clusters of the Local Device).
82 in_cluster_list: Vec<u16, CLUSTER_LIST_SIZE>,
83 /// The number of Output Clusters provided for matching within
84 /// OutClusterList.
85 num_out_clusters: u8,
86 /// List of Output ClusterIDs to be used for matching;
87 /// the OutClusterList is the desired list to be
88 /// matched by the Remote Device (the elements of
89 /// the OutClusterList are the supported input clusters
90 /// of the Local Device).
91 out_cluster_list: Vec<u16, CLUSTER_LIST_SIZE>,
92}
93
94/// 2.4.3.1.8 Complex_Desc_req
95pub struct ComplexDescReq {
96 /// NWK address for the request
97 nwk_addr_of_interest: ShortAddress,
98}
99
100/// 2.4.3.1.9 User_Desc_req
101pub struct UserDescReq {
102 /// NWK address for the request
103 nwk_addr_of_interest: ShortAddress,
104}
105
106// 2.4.3.1.11 Device_annce — see crate::zdp::device_annce::DeviceAnnce
107
108/// 2.4.3.1.11 Parent_annce
109pub struct ChildInfo(IeeeAddress);
110
111pub struct ParentAnnce {
112 number_of_children: u8,
113 children: Vec<ChildInfo, { 255 * size_of::<ChildInfo>() }>,
114}
115
116/// 2.4.3.1.13 User_Desc_set
117pub struct UserDescSet<'a> {
118 /// NWK address for the request.
119 nwk_addr_of_interest: ShortAddress,
120 /// Length of the User Descriptor in bytes.
121 length: u8,
122 /// The user description to configure; if the ASCII character string to be
123 /// entered here is less than 16 characters in length, it shall be
124 /// padded with space characters (0x20) to make a total length of 16
125 /// characters. Characters with codes 0x00-0x1f are not permitted.
126 user_description: UserDescriptor<'a>,
127}
128
129/// 2.4.3.1.14 System_Server_Discovery_req
130pub struct SystemServerDiscoveryReq {
131 server_mask: ServerMask,
132}
133
134/// 2.4.3.1.15 Discovery_store_req
135pub struct DiscoveryStoreReq {
136 /// NWK Address for the Local Device.
137 nwk_addr: ShortAddress,
138 /// IEEE Address for the Local Device.
139 ieee_addr: IeeeAddress,
140 /// Size in bytes of the Node Descriptor for the Local Device.
141 node_desc_size: u8,
142 /// Size in bytes of the Power Descriptor for the Local Device.
143 power_desc_size: u8,
144 /// Size in bytes of the ActiveEPCount and ActiveEPList fields of the
145 /// Active_EP_rsp for the Local Device.
146 active_ep_size: u8,
147 /// Number of Simple Descriptors supported by the Local Device (should be
148 /// the same value as the ActiveEPSize).
149 simple_desc_count: u8,
150 /// List of bytes of simple_desc_count length, each of which represents the
151 /// size in bytes of the Simple Descriptor for each Active Endpoint on
152 /// the Local Device.
153 simple_desc_size_list: Vec<u8, 255>,
154}
155
156/// 2.4.3.1.16 Node_Desc_store_req
157pub struct NodeDescStoreReq {
158 /// NWK Address for the Local Device
159 nwk_addr: ShortAddress,
160 /// IEEE Address for the Local Device.
161 ieee_addr: IeeeAddress,
162 // TODO: node descriptor field
163}