Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2021 Project CHIP Authors
4 : * All rights reserved.
5 : *
6 : * Licensed under the Apache License, Version 2.0 (the "License");
7 : * you may not use this file except in compliance with the License.
8 : * You may obtain a copy of the License at
9 : *
10 : * http://www.apache.org/licenses/LICENSE-2.0
11 : *
12 : * Unless required by applicable law or agreed to in writing, software
13 : * distributed under the License is distributed on an "AS IS" BASIS,
14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : * See the License for the specific language governing permissions and
16 : * limitations under the License.
17 : */
18 :
19 : #include <controller/CommissioningDelegate.h>
20 :
21 : namespace chip {
22 : namespace Controller {
23 :
24 0 : const char * StageToString(CommissioningStage stage)
25 : {
26 0 : switch (stage)
27 : {
28 0 : case kError:
29 0 : return "Error";
30 :
31 0 : case kSecurePairing:
32 0 : return "SecurePairing";
33 :
34 0 : case kReadCommissioningInfo:
35 0 : return "ReadCommissioningInfo";
36 :
37 0 : case kArmFailsafe:
38 0 : return "ArmFailSafe";
39 :
40 0 : case kScanNetworks:
41 0 : return "ScanNetworks";
42 :
43 0 : case kConfigRegulatory:
44 0 : return "ConfigRegulatory";
45 :
46 0 : case kConfigureTCAcknowledgments:
47 0 : return "ConfigureTCAcknowledgments";
48 :
49 0 : case kConfigureUTCTime:
50 0 : return "ConfigureUTCTime";
51 :
52 0 : case kConfigureTimeZone:
53 0 : return "ConfigureTimeZone";
54 :
55 0 : case kConfigureDSTOffset:
56 0 : return "ConfigureDSTOffset";
57 :
58 0 : case kConfigureDefaultNTP:
59 0 : return "ConfigureDefaultNTP";
60 :
61 0 : case kSendPAICertificateRequest:
62 0 : return "SendPAICertificateRequest";
63 :
64 0 : case kSendDACCertificateRequest:
65 0 : return "SendDACCertificateRequest";
66 :
67 0 : case kSendAttestationRequest:
68 0 : return "SendAttestationRequest";
69 :
70 0 : case kAttestationVerification:
71 0 : return "AttestationVerification";
72 :
73 0 : case kAttestationRevocationCheck:
74 0 : return "AttestationRevocationCheck";
75 :
76 0 : case kSendOpCertSigningRequest:
77 0 : return "SendOpCertSigningRequest";
78 :
79 0 : case kValidateCSR:
80 0 : return "ValidateCSR";
81 :
82 0 : case kGenerateNOCChain:
83 0 : return "GenerateNOCChain";
84 :
85 0 : case kSendTrustedRootCert:
86 0 : return "SendTrustedRootCert";
87 :
88 0 : case kSendNOC:
89 0 : return "SendNOC";
90 :
91 0 : case kConfigureTrustedTimeSource:
92 0 : return "ConfigureTrustedTimeSource";
93 :
94 0 : case kICDGetRegistrationInfo:
95 0 : return "ICDGetRegistrationInfo";
96 :
97 0 : case kICDRegistration:
98 0 : return "ICDRegistration";
99 :
100 0 : case kWiFiNetworkSetup:
101 0 : return "WiFiNetworkSetup";
102 :
103 0 : case kThreadNetworkSetup:
104 0 : return "ThreadNetworkSetup";
105 :
106 0 : case kFailsafeBeforeWiFiEnable:
107 0 : return "FailsafeBeforeWiFiEnable";
108 :
109 0 : case kFailsafeBeforeThreadEnable:
110 0 : return "FailsafeBeforeThreadEnable";
111 :
112 0 : case kWiFiNetworkEnable:
113 0 : return "WiFiNetworkEnable";
114 :
115 0 : case kThreadNetworkEnable:
116 0 : return "ThreadNetworkEnable";
117 :
118 0 : case kEvictPreviousCaseSessions:
119 0 : return "kEvictPreviousCaseSessions";
120 :
121 0 : case kFindOperationalForStayActive:
122 0 : return "kFindOperationalForStayActive";
123 :
124 0 : case kFindOperationalForCommissioningComplete:
125 0 : return "kFindOperationalForCommissioningComplete";
126 :
127 0 : case kICDSendStayActive:
128 0 : return "ICDSendStayActive";
129 :
130 0 : case kSendComplete:
131 0 : return "SendComplete";
132 :
133 0 : case kCleanup:
134 0 : return "Cleanup";
135 :
136 0 : case kNeedsNetworkCreds:
137 0 : return "NeedsNetworkCreds";
138 :
139 0 : case kPrimaryOperationalNetworkFailed:
140 0 : return "PrimaryOperationalNetworkFailed";
141 :
142 0 : case kRemoveWiFiNetworkConfig:
143 0 : return "RemoveWiFiNetworkConfig";
144 :
145 0 : case kRemoveThreadNetworkConfig:
146 0 : return "RemoveThreadNetworkConfig";
147 :
148 0 : default:
149 0 : return "???";
150 : }
151 : }
152 :
153 : #if MATTER_TRACING_ENABLED
154 : const char * MetricKeyForCommissioningStage(CommissioningStage stage)
155 : {
156 : switch (stage)
157 : {
158 : case kError:
159 : return "core_commissioning_stage_error";
160 :
161 : case kSecurePairing:
162 : return "core_commissioning_stage_secure_pairing";
163 :
164 : case kReadCommissioningInfo:
165 : return "core_commissioning_stage_read_commissioning_info";
166 :
167 : case kArmFailsafe:
168 : return "core_commissioning_stage_arm_failsafe";
169 :
170 : case kScanNetworks:
171 : return "core_commissioning_stage_scan_networks";
172 :
173 : case kConfigRegulatory:
174 : return "core_commissioning_stage_config_regulatory";
175 :
176 : case kConfigureUTCTime:
177 : return "core_commissioning_stage_configure_utc_time";
178 :
179 : case kConfigureTimeZone:
180 : return "core_commissioning_stage_configure_timezone";
181 :
182 : case kConfigureDSTOffset:
183 : return "core_commissioning_stage_configure_dst_offset";
184 :
185 : case kConfigureDefaultNTP:
186 : return "core_commissioning_stage_configure_default_ntp";
187 :
188 : case kSendPAICertificateRequest:
189 : return "core_commissioning_stage_send_pai_certificate_request";
190 :
191 : case kSendDACCertificateRequest:
192 : return "core_commissioning_stage_send_dac_certificate_request";
193 :
194 : case kSendAttestationRequest:
195 : return "core_commissioning_stage_send_attestation_request";
196 :
197 : case kAttestationVerification:
198 : return "core_commissioning_stage_attestation_verification";
199 :
200 : case kSendOpCertSigningRequest:
201 : return "core_commissioning_stage_opcert_signing_request";
202 :
203 : case kValidateCSR:
204 : return "core_commissioning_stage_validate_csr";
205 :
206 : case kGenerateNOCChain:
207 : return "core_commissioning_stage_generate_noc_chain";
208 :
209 : case kSendTrustedRootCert:
210 : return "core_commissioning_stage_send_trusted_root_cert";
211 :
212 : case kSendNOC:
213 : return "core_commissioning_stage_send_noc";
214 :
215 : case kConfigureTrustedTimeSource:
216 : return "core_commissioning_stage_configure_trusted_time_source";
217 :
218 : case kICDGetRegistrationInfo:
219 : return "core_commissioning_stage_icd_get_registration_info";
220 :
221 : case kICDRegistration:
222 : return "core_commissioning_stage_icd_registration";
223 :
224 : case kWiFiNetworkSetup:
225 : return "core_commissioning_stage_wifi_network_setup";
226 :
227 : case kThreadNetworkSetup:
228 : return "core_commissioning_stage_thread_network_setup";
229 :
230 : case kFailsafeBeforeWiFiEnable:
231 : return "core_commissioning_stage_failsafe_before_wifi_enable";
232 :
233 : case kFailsafeBeforeThreadEnable:
234 : return "core_commissioning_stage_failsafe_before_thread_enable";
235 :
236 : case kWiFiNetworkEnable:
237 : return "core_commissioning_stage_wifi_network_enable";
238 :
239 : case kThreadNetworkEnable:
240 : return "core_commissioning_stage_thread_network_enable";
241 :
242 : case kEvictPreviousCaseSessions:
243 : return "core_commissioning_stage_evict_previous_case_sessions";
244 :
245 : case kFindOperationalForStayActive:
246 : return "core_commissioning_stage_find_operational_for_stay_active";
247 :
248 : case kFindOperationalForCommissioningComplete:
249 : return "core_commissioning_stage_find_operational_for_commissioning_complete";
250 :
251 : case kICDSendStayActive:
252 : return "core_commissioning_stage_icd_send_stay_active";
253 :
254 : case kSendComplete:
255 : return "core_commissioning_stage_send_complete";
256 :
257 : case kCleanup:
258 : return "core_commissioning_stage_cleanup";
259 :
260 : case kNeedsNetworkCreds:
261 : return "core_commissioning_stage_need_network_creds";
262 :
263 : default:
264 : return "core_commissioning_stage_unknown";
265 : }
266 : }
267 : #endif
268 :
269 : } // namespace Controller
270 : } // namespace chip
|