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 kConfigureUTCTime:
47 0 : return "ConfigureUTCTime";
48 :
49 0 : case kConfigureTimeZone:
50 0 : return "ConfigureTimeZone";
51 :
52 0 : case kConfigureDSTOffset:
53 0 : return "ConfigureDSTOffset";
54 :
55 0 : case kConfigureDefaultNTP:
56 0 : return "ConfigureDefaultNTP";
57 :
58 0 : case kSendPAICertificateRequest:
59 0 : return "SendPAICertificateRequest";
60 :
61 0 : case kSendDACCertificateRequest:
62 0 : return "SendDACCertificateRequest";
63 :
64 0 : case kSendAttestationRequest:
65 0 : return "SendAttestationRequest";
66 :
67 0 : case kAttestationVerification:
68 0 : return "AttestationVerification";
69 :
70 0 : case kAttestationRevocationCheck:
71 0 : return "AttestationRevocationCheck";
72 :
73 0 : case kSendOpCertSigningRequest:
74 0 : return "SendOpCertSigningRequest";
75 :
76 0 : case kValidateCSR:
77 0 : return "ValidateCSR";
78 :
79 0 : case kGenerateNOCChain:
80 0 : return "GenerateNOCChain";
81 :
82 0 : case kSendTrustedRootCert:
83 0 : return "SendTrustedRootCert";
84 :
85 0 : case kSendNOC:
86 0 : return "SendNOC";
87 :
88 0 : case kConfigureTrustedTimeSource:
89 0 : return "ConfigureTrustedTimeSource";
90 :
91 0 : case kICDGetRegistrationInfo:
92 0 : return "ICDGetRegistrationInfo";
93 :
94 0 : case kICDRegistration:
95 0 : return "ICDRegistration";
96 :
97 0 : case kWiFiNetworkSetup:
98 0 : return "WiFiNetworkSetup";
99 :
100 0 : case kThreadNetworkSetup:
101 0 : return "ThreadNetworkSetup";
102 :
103 0 : case kFailsafeBeforeWiFiEnable:
104 0 : return "FailsafeBeforeWiFiEnable";
105 :
106 0 : case kFailsafeBeforeThreadEnable:
107 0 : return "FailsafeBeforeThreadEnable";
108 :
109 0 : case kWiFiNetworkEnable:
110 0 : return "WiFiNetworkEnable";
111 :
112 0 : case kThreadNetworkEnable:
113 0 : return "ThreadNetworkEnable";
114 :
115 0 : case kEvictPreviousCaseSessions:
116 0 : return "kEvictPreviousCaseSessions";
117 :
118 0 : case kFindOperationalForStayActive:
119 0 : return "kFindOperationalForStayActive";
120 :
121 0 : case kFindOperationalForCommissioningComplete:
122 0 : return "kFindOperationalForCommissioningComplete";
123 :
124 0 : case kICDSendStayActive:
125 0 : return "ICDSendStayActive";
126 :
127 0 : case kSendComplete:
128 0 : return "SendComplete";
129 :
130 0 : case kCleanup:
131 0 : return "Cleanup";
132 :
133 0 : case kNeedsNetworkCreds:
134 0 : return "NeedsNetworkCreds";
135 :
136 0 : case kPrimaryOperationalNetworkFailed:
137 0 : return "PrimaryOperationalNetworkFailed";
138 :
139 0 : case kRemoveWiFiNetworkConfig:
140 0 : return "RemoveWiFiNetworkConfig";
141 :
142 0 : case kRemoveThreadNetworkConfig:
143 0 : return "RemoveThreadNetworkConfig";
144 :
145 0 : default:
146 0 : return "???";
147 : }
148 : }
149 :
150 : #if MATTER_TRACING_ENABLED
151 : const char * MetricKeyForCommissioningStage(CommissioningStage stage)
152 : {
153 : switch (stage)
154 : {
155 : case kError:
156 : return "core_commissioning_stage_error";
157 :
158 : case kSecurePairing:
159 : return "core_commissioning_stage_secure_pairing";
160 :
161 : case kReadCommissioningInfo:
162 : return "core_commissioning_stage_read_commissioning_info";
163 :
164 : case kArmFailsafe:
165 : return "core_commissioning_stage_arm_failsafe";
166 :
167 : case kScanNetworks:
168 : return "core_commissioning_stage_scan_networks";
169 :
170 : case kConfigRegulatory:
171 : return "core_commissioning_stage_config_regulatory";
172 :
173 : case kConfigureUTCTime:
174 : return "core_commissioning_stage_configure_utc_time";
175 :
176 : case kConfigureTimeZone:
177 : return "core_commissioning_stage_configure_timezone";
178 :
179 : case kConfigureDSTOffset:
180 : return "core_commissioning_stage_configure_dst_offset";
181 :
182 : case kConfigureDefaultNTP:
183 : return "core_commissioning_stage_configure_default_ntp";
184 :
185 : case kSendPAICertificateRequest:
186 : return "core_commissioning_stage_send_pai_certificate_request";
187 :
188 : case kSendDACCertificateRequest:
189 : return "core_commissioning_stage_send_dac_certificate_request";
190 :
191 : case kSendAttestationRequest:
192 : return "core_commissioning_stage_send_attestation_request";
193 :
194 : case kAttestationVerification:
195 : return "core_commissioning_stage_attestation_verification";
196 :
197 : case kSendOpCertSigningRequest:
198 : return "core_commissioning_stage_opcert_signing_request";
199 :
200 : case kValidateCSR:
201 : return "core_commissioning_stage_validate_csr";
202 :
203 : case kGenerateNOCChain:
204 : return "core_commissioning_stage_generate_noc_chain";
205 :
206 : case kSendTrustedRootCert:
207 : return "core_commissioning_stage_send_trusted_root_cert";
208 :
209 : case kSendNOC:
210 : return "core_commissioning_stage_send_noc";
211 :
212 : case kConfigureTrustedTimeSource:
213 : return "core_commissioning_stage_configure_trusted_time_source";
214 :
215 : case kICDGetRegistrationInfo:
216 : return "core_commissioning_stage_icd_get_registration_info";
217 :
218 : case kICDRegistration:
219 : return "core_commissioning_stage_icd_registration";
220 :
221 : case kWiFiNetworkSetup:
222 : return "core_commissioning_stage_wifi_network_setup";
223 :
224 : case kThreadNetworkSetup:
225 : return "core_commissioning_stage_thread_network_setup";
226 :
227 : case kFailsafeBeforeWiFiEnable:
228 : return "core_commissioning_stage_failsafe_before_wifi_enable";
229 :
230 : case kFailsafeBeforeThreadEnable:
231 : return "core_commissioning_stage_failsafe_before_thread_enable";
232 :
233 : case kWiFiNetworkEnable:
234 : return "core_commissioning_stage_wifi_network_enable";
235 :
236 : case kThreadNetworkEnable:
237 : return "core_commissioning_stage_thread_network_enable";
238 :
239 : case kEvictPreviousCaseSessions:
240 : return "core_commissioning_stage_evict_previous_case_sessions";
241 :
242 : case kFindOperationalForStayActive:
243 : return "core_commissioning_stage_find_operational_for_stay_active";
244 :
245 : case kFindOperationalForCommissioningComplete:
246 : return "core_commissioning_stage_find_operational_for_commissioning_complete";
247 :
248 : case kICDSendStayActive:
249 : return "core_commissioning_stage_icd_send_stay_active";
250 :
251 : case kSendComplete:
252 : return "core_commissioning_stage_send_complete";
253 :
254 : case kCleanup:
255 : return "core_commissioning_stage_cleanup";
256 :
257 : case kNeedsNetworkCreds:
258 : return "core_commissioning_stage_need_network_creds";
259 :
260 : default:
261 : return "core_commissioning_stage_unknown";
262 : }
263 : }
264 : #endif
265 :
266 : } // namespace Controller
267 : } // namespace chip
|