1 // Copyright 2022 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "hci/hci_debug.h"
16
17 #include <cstdint>
18 #include <map>
19 #include <string>
20 #include <vector>
21
22 #include "util/string_utils.h"
23
24 namespace netsim {
25 namespace hci {
26 namespace {
27
28 /**
29 * HCI LE Meta events
30 *
31 * References can be found here:
32 * https://www.bluetooth.org/en-us/specification/adopted-specifications - Core
33 * specification 4.1 [vol 2] Part E (Section 7.7.65) - Le Meta Event
34 */
35 const std::map<int, const char *> HciMetaEventCode = {
36 {0x01, "LE_Meta_Event::Connection_Complete"},
37 {0x02, "LE_Meta_Event::Adv_Report"},
38 {0x03, "LE_Meta_Event::Conn_Update_Complete"},
39 {0x04, "LE_Meta_Event::Read_Remote_Features_Complete"},
40 {0x05, "LE_Meta_Event::LTK_Requested"},
41 // V4.1
42 {0x06, "LE_Meta_Event::Remote_Connection_Parameter_Request"},
43 // V4.2
44 {0x07, "LE_Meta_Event::Data_Length_Change"},
45 {0x08, "LE_Meta_Event::Read_Local_P256_Public_Key"},
46 {0x09, "LE_Meta_Event::Generate_DHKEY_Complete"},
47 {0x0A, "LE_Meta_Event::Enhanced_Connection_Complete"},
48 {0x0B, "LE_Meta_Event::Direct_Advertising_Report"},
49 // V5.0
50 {0x0C, "LE_Meta_Event::Phy_Update_Complete"},
51 //
52 {0x0D, "LE_Meta_Event::Extended_Adv_Report"},
53 {0x0E, "LE_Meta_Event::Periodic_Adv_Sync_Established"},
54 {0x0F, "LE_Meta_Event::Periodic_Adv_Report"},
55 {0x10, "LE_Meta_Event::Periodic_Adv_Sync_Lost"},
56 {0x11, "LE_Meta_Event::Scan_Timeout"},
57 {0x12, "LE_Meta_Event::Adv_Set_Terminated"},
58 {0x13, "LE_Meta_Event::Scan_Request_Received"},
59 {0x14, "LE_Meta_Event::Channel_Selection_Algorithm"},
60 {0x15, "LE_Meta_Event::Connectionless_IQ_Report"},
61 {0x16, "LE_Meta_Event::Connection_IQ_Report"},
62 {0x17, "LE_Meta_Event::CTE_Request_Failed"},
63 {0x18, "LE_Meta_Event::Peridic_Adv_Sync_Transfer_Received"},
64 {0x19, "LE_Meta_Event::CIS_Established"},
65 {0x1A, "LE_Meta_Event::CIS_Request"},
66 {0x1B, "LE_Meta_Event::Create_Big_Template"},
67 {0x1C, "LE_Meta_Event::Terminate_Big_Template"},
68 {0x1D, "LE_Meta_Event::Big_Sync_Established"},
69 {0x1E, "LE_Meta_Event::Big_Sync_Lost"},
70 {0x1F, "LE_Meta_Event::Request_Peer_SCA_Complete"},
71 {0x20, "LE_Meta_Event::Path_Loss_Threshold"},
72 {0x21, "LE_Meta_Event::Transmit_Power_Reporting"},
73 {0x22, "LE_Meta_Event::Big_Info_Adv_report"}};
74
75 /**
76 * HCI Event codes
77 *
78 * References can be found here:
79 * https://www.bluetooth.org/en-us/specification/adopted-specifications - Core
80 * specification 4.1 [vol 2] Part E (Section 7.7) - Events
81 */
82 constexpr uint8_t HciLeMetaEvent = 0x3e;
83
84 const std::map<int, const char *> HciEventCode = {
85 {0x01, "Inquiry_Complete_Event"},
86 {0x02, "Inquiry_Result_Event"},
87 {0x03, "Connection_Complete_Event"},
88 {0x04, "Connection_Request_Event"},
89 {0x05, "Disconnection_Complete_Event"},
90 {0x06, "Authentication_Complete_Event"},
91 {0x07, "Remote_Name_Request_Complete_Event"},
92 {0x08, "Encryption_Change_Event"},
93 {0x09, "Change_Connection_Link_Key_Complete_Event"},
94 {0x0A, "Master_Link_Key_Complete_Event"},
95 {0x0B, "Read_Remote_Supported_Features_Complete_Event"},
96 {0x0C, "Read_Remote_Version_Complete_Event"},
97 {0x0D, "Q0S_Setup_Complete_Event"},
98 {0x0E, "Command_Complete_Event"},
99 {0x0F, "Command_Status_Event"},
100 {0x10, "Hardware_Error_Event"},
101 {0x11, "Flush_Occurred_Event"},
102 {0x12, "Role_Change_Event"},
103 {0x13, "Number_Of_Completed_Packets_Event"},
104 {0x14, "Mode_Change_Event"},
105 {0x15, "Return_Link_Keys_Event"},
106 {0x16, "PIN_Code_Request_Event"},
107 {0x17, "Link_Key_Request_Event"},
108 {0x18, "Link_Key_Notification_Event"},
109 {0x19, "Loopback_Command_Event"},
110 {0x1A, "Data_Buffer_Overflow_Event"},
111 {0x1B, "Max_Slots_Change_Event"},
112 {0x1C, "Read_Clock_Offset_Complete_Event"},
113 {0x1D, "Connection_Packet_Type_Changed_Event"},
114 {0x1E, "QoS_Violation_Event"},
115 {0x1F, "Page_Scan_Mode_Change_Event"},
116 {0x20, "Page_Scan_Repetition_Mode_Change_Event"},
117 {0x21, "Flow_Specification_Complete"},
118 {0x22, "Inquiry_Result_With_Rssi"},
119 {0x23, "Read_Remote_Extended_Features_Complete"},
120 {0x2c, "Synchronous_Connection_Complete"},
121 {0x2d, "Synchronous_Connection_Changed"},
122 {0x2e, "Sniff_Subrating"},
123 {0x2f, "Extended_Inquiry_Result"},
124 {0x30, "Encryption_Key_Refresh_Complete"},
125 {0x31, "Io_Capability_Request"},
126 {0x32, "Io_Capability_Response"},
127 {0x33, "User_Confirmation_Request"},
128 {0x34, "User_Passkey_Request"},
129 {0x35, "Remote_Oob_Data_Request"},
130 {0x36, "Simple_Pairing_Complete"},
131 {0x38, "Link_Supervision_Timeout_Changed"},
132 {0x39, "Enhanced_Flush_Complete"},
133 {0x3b, "User_Passkey_Notification"},
134 {0x3c, "Keypress_Notification"},
135 {0x3d, "Remote_Host_Supported_Features_Notification"},
136 {HciLeMetaEvent, "Le_Meta_Event"},
137 {0x48, "Number_Of_Completed_Data_Blocks"},
138 {0xff, "Vendor_Specific"}};
139
140 const std::map<int, const char *> HciCommandOpCode = {
141 {0x0000, "None"},
142 {0x0401, "Inquiry"},
143 {0x0402, "Inquiry_Cancel"},
144 {0x0403, "Periodic_Inquiry_Mode"},
145 {0x0404, "Exit_Periodic_Inquiry_Mode"},
146 {0x0405, "Create_Connection"},
147 {0x0406, "Disconnect"},
148 {0x0407, "Add_Sco_Connection"},
149 {0x0408, "Create_Connection_Cancel"},
150 {0x0409, "Accept_Connection_Request"},
151 {0x040a, "Reject_Connection_Request"},
152 {0x040b, "Link_Key_Request_Reply"},
153 {0x040c, "Link_Key_Request_Negative_Reply"},
154 {0x040d, "Pin_Code_Request_Reply"},
155 {0x040e, "Pin_Code_Request_Negative_Reply"},
156 {0x040f, "Change_Connection_Packet_Type"},
157 {0x0411, "Authentication_Requested"},
158 {0x0413, "Set_Connection_Encryption"},
159 {0x0415, "Change_Connection_Link_Key"},
160 {0x0417, "Central_Link_Key"},
161 {0x0419, "Remote_Name_Request"},
162 {0x041a, "Remote_Name_Request_Cancel"},
163 {0x041b, "Read_Remote_Supported_Features"},
164 {0x041c, "Read_Remote_Extended_Features"},
165 {0x041d, "Read_Remote_Version_Information"},
166 {0x041f, "Read_Clock_Offset"},
167 {0x0420, "Read_Lmp_Handle"},
168 {0x0428, "Setup_Synchronous_Connection"},
169 {0x0429, "Accept_Synchronous_Connection"},
170 {0x042a, "Reject_Synchronous_Connection"},
171 {0x042b, "Io_Capability_Request_Reply"},
172 {0x042c, "User_Confirmation_Request_Reply"},
173 {0x042d, "User_Confirmation_Request_Negative_Reply"},
174 {0x042e, "User_Passkey_Request_Reply"},
175 {0x042f, "User_Passkey_Request_Negative_Reply"},
176 {0x0430, "Remote_Oob_Data_Request_Reply"},
177 {0x0433, "Remote_Oob_Data_Request_Negative_Reply"},
178 {0x0434, "Io_Capability_Request_Negative_Reply"},
179 {0x043d, "Enhanced_Setup_Synchronous_Connection"},
180 {0x043e, "Enhanced_Accept_Synchronous_Connection"},
181 {0x0445, "Remote_Oob_Extended_Data_Request_Reply"},
182 {0x0801, "Hold_Mode"},
183 {0x0803, "Sniff_Mode"},
184 {0x0804, "Exit_Sniff_Mode"},
185 {0x0807, "Qos_Setup"},
186 {0x0809, "Role_Discovery"},
187 {0x080b, "Switch_Role"},
188 {0x080c, "Read_Link_Policy_Settings"},
189 {0x080d, "Write_Link_Policy_Settings"},
190 {0x080e, "Read_Default_Link_Policy_Settings"},
191 {0x080f, "Write_Default_Link_Policy_Settings"},
192 {0x0810, "Flow_Specification"},
193 {0x0811, "Sniff_Subrating"},
194 {0x0c01, "Set_Event_Mask"},
195 {0x0c03, "Reset"},
196 {0x0c05, "Set_Event_Filter"},
197 {0x0c08, "Flush"},
198 {0x0c09, "Read_Pin_Type"},
199 {0x0c0a, "Write_Pin_Type"},
200 {0x0c0d, "Read_Stored_Link_Key"},
201 {0x0c11, "Write_Stored_Link_Key"},
202 {0x0c12, "Delete_Stored_Link_Key"},
203 {0x0c13, "Write_Local_Name"},
204 {0x0c14, "Read_Local_Name"},
205 {0x0c15, "Read_Connection_Accept_Timeout"},
206 {0x0c16, "Write_Connection_Accept_Timeout"},
207 {0x0c17, "Read_Page_Timeout"},
208 {0x0c18, "Write_Page_Timeout"},
209 {0x0c19, "Read_Scan_Enable"},
210 {0x0c1a, "Write_Scan_Enable"},
211 {0x0c1b, "Read_Page_Scan_Activity"},
212 {0x0c1c, "Write_Page_Scan_Activity"},
213 {0x0c1d, "Read_Inquiry_Scan_Activity"},
214 {0x0c1e, "Write_Inquiry_Scan_Activity"},
215 {0x0c1f, "Read_Authentication_Enable"},
216 {0x0c20, "Write_Authentication_Enable"},
217 {0x0c23, "Read_Class_Of_Device"},
218 {0x0c24, "Write_Class_Of_Device"},
219 {0x0c25, "Read_Voice_Setting"},
220 {0x0c26, "Write_Voice_Setting"},
221 {0x0c27, "Read_Automatic_Flush_Timeout"},
222 {0x0c28, "Write_Automatic_Flush_Timeout"},
223 {0x0c29, "Read_Num_Broadcast_Retransmits"},
224 {0x0c2a, "Write_Num_Broadcast_Retransmits"},
225 {0x0c2b, "Read_Hold_Mode_Activity"},
226 {0x0c2c, "Write_Hold_Mode_Activity"},
227 {0x0c2d, "Read_Transmit_Power_Level"},
228 {0x0c2e, "Read_Synchronous_Flow_Control_Enable"},
229 {0x0c2f, "Write_Synchronous_Flow_Control_Enable"},
230 {0x0c31, "Set_Controller_To_Host_Flow_Control"},
231 {0x0c33, "Host_Buffer_Size"},
232 {0x0c35, "Host_Num_Completed_Packets"},
233 {0x0c36, "Read_Link_Supervision_Timeout"},
234 {0x0c37, "Write_Link_Supervision_Timeout"},
235 {0x0c38, "Read_Number_Of_Supported_Iac"},
236 {0x0c39, "Read_Current_Iac_Lap"},
237 {0x0c3a, "Write_Current_Iac_Lap"},
238 {0x0c3f, "Set_Afh_Host_Channel_Classification"},
239 {0x0c42, "Read_Inquiry_Scan_Type"},
240 {0x0c43, "Write_Inquiry_Scan_Type"},
241 {0x0c44, "Read_Inquiry_Mode"},
242 {0x0c45, "Write_Inquiry_Mode"},
243 {0x0c46, "Read_Page_Scan_Type"},
244 {0x0c47, "Write_Page_Scan_Type"},
245 {0x0c48, "Read_Afh_Channel_Assessment_Mode"},
246 {0x0c49, "Write_Afh_Channel_Assessment_Mode"},
247 {0x0c51, "Read_Extended_Inquiry_Response"},
248 {0x0c52, "Write_Extended_Inquiry_Response"},
249 {0x0c53, "Refresh_Encryption_Key"},
250 {0x0c55, "Read_Simple_Pairing_Mode"},
251 {0x0c56, "Write_Simple_Pairing_Mode"},
252 {0x0c57, "Read_Local_Oob_Data"},
253 {0x0c58, "Read_Inquiry_Response_Transmit_Power_Level"},
254 {0x0c59, "Write_Inquiry_Transmit_Power_Level"},
255 {0x0c5f, "Enhanced_Flush"},
256 {0x0c60, "Send_Keypress_Notification"},
257 {0x0c63, "Set_Event_Mask_Page_2"},
258 {0x0c6c, "Read_Le_Host_Support"},
259 {0x0c6d, "Write_Le_Host_Support"},
260 {0x0c79, "Read_Secure_Connections_Host_Support"},
261 {0x0c7a, "Write_Secure_Connections_Host_Support"},
262 {0x0c7d, "Read_Local_Oob_Extended_Data"},
263 {0x0c82, "Set_Ecosystem_Base_Interval"},
264 {0x0c83, "Configure_Data_Path"},
265 {0x1001, "Read_Local_Version_Information"},
266 {0x1002, "Read_Local_Supported_Commands"},
267 {0x1003, "Read_Local_Supported_Features"},
268 {0x1004, "Read_Local_Extended_Features"},
269 {0x1005, "Read_Buffer_Size"},
270 {0x1009, "Read_Bd_Addr"},
271 {0x100a, "Read_Data_Block_Size"},
272 {0x100b, "Read_Local_Supported_Codecs_V1"},
273 {0x100d, "Read_Local_Supported_Codecs_V2"},
274 {0x100e, "Read_Local_Supported_Codec_Capabilities"},
275 {0x100f, "Read_Local_Supported_Controller_Delay"},
276 {0x1401, "Read_Failed_Contact_Counter"},
277 {0x1402, "Reset_Failed_Contact_Counter"},
278 {0x1403, "Read_Link_Quality"},
279 {0x1405, "Read_Rssi"},
280 {0x1406, "Read_Afh_Channel_Map"},
281 {0x1407, "Read_Clock"},
282 {0x1408, "Read_Encryption_Key_Size"},
283 {0x1801, "Read_Loopback_Mode"},
284 {0x1802, "Write_Loopback_Mode"},
285 {0x1803, "Enable_Device_Under_Test_Mode"},
286 {0x1804, "Write_Simple_Pairing_Debug_Mode"},
287 {0x180a, "Write_Secure_Connections_Test_Mode"},
288 {0x2001, "Le_Set_Event_Mask"},
289 {0x2002, "Le_Read_Buffer_Size_V1"},
290 {0x2003, "Le_Read_Local_Supported_Features"},
291 {0x2005, "Le_Set_Random_Address"},
292 {0x2006, "Le_Set_Advertising_Parameters"},
293 {0x2007, "Le_Read_Advertising_Physical_Channel_Tx_Power"},
294 {0x2008, "Le_Set_Advertising_Data"},
295 {0x2009, "Le_Set_Scan_Response_Data"},
296 {0x200a, "Le_Set_Advertising_Enable"},
297 {0x200b, "Le_Set_Scan_Parameters"},
298 {0x200c, "Le_Set_Scan_Enable"},
299 {0x200d, "Le_Create_Connection"},
300 {0x200e, "Le_Create_Connection_Cancel"},
301 {0x200f, "Le_Read_Filter_Accept_List_Size"},
302 {0x2010, "Le_Clear_Filter_Accept_List"},
303 {0x2011, "Le_Add_Device_To_Filter_Accept_List"},
304 {0x2012, "Le_Remove_Device_From_Filter_Accept_List"},
305 {0x2013, "Le_Connection_Update"},
306 {0x2014, "Le_Set_Host_Channel_Classification"},
307 {0x2015, "Le_Read_Channel_Map"},
308 {0x2016, "Le_Read_Remote_Features"},
309 {0x2017, "Le_Encrypt"},
310 {0x2018, "Le_Rand"},
311 {0x2019, "Le_Start_Encryption"},
312 {0x201a, "Le_Long_Term_Key_Request_Reply"},
313 {0x201b, "Le_Long_Term_Key_Request_Negative_Reply"},
314 {0x201c, "Le_Read_Supported_States"},
315 {0x201d, "Le_Receiver_Test"},
316 {0x201e, "Le_Transmitter_Test"},
317 {0x201f, "Le_Test_End"},
318 {0x2020, "Le_Remote_Connection_Parameter_Request_Reply"},
319 {0x2021, "Le_Remote_Connection_Parameter_Request_Negative_Reply"},
320 {0x2022, "Le_Set_Data_Length"},
321 {0x2023, "Le_Read_Suggested_Default_Data_Length"},
322 {0x2024, "Le_Write_Suggested_Default_Data_Length"},
323 {0x2025, "Le_Read_Local_P_256_Public_Key_Command"},
324 {0x2026, "Le_Generate_Dhkey_Command_V1"},
325 {0x2027, "Le_Add_Device_To_Resolving_List"},
326 {0x2028, "Le_Remove_Device_From_Resolving_List"},
327 {0x2029, "Le_Clear_Resolving_List"},
328 {0x202a, "Le_Read_Resolving_List_Size"},
329 {0x202b, "Le_Read_Peer_Resolvable_Address"},
330 {0x202c, "Le_Read_Local_Resolvable_Address"},
331 {0x202d, "Le_Set_Address_Resolution_Enable"},
332 {0x202e, "Le_Set_Resolvable_Private_Address_Timeout"},
333 {0x202f, "Le_Read_Maximum_Data_Length"},
334 {0x2030, "Le_Read_Phy"},
335 {0x2031, "Le_Set_Default_Phy"},
336 {0x2032, "Le_Set_Phy"},
337 {0x2033, "Le_Enhanced_Receiver_Test"},
338 {0x2034, "Le_Enhanced_Transmitter_Test"},
339 {0x2035, "Le_Set_Extended_Advertising_Random_Address"},
340 {0x2036, "Le_Set_Extended_Advertising_Parameters"},
341 {0x2037, "Le_Set_Extended_Advertising_Data"},
342 {0x2038, "Le_Set_Extended_Advertising_Scan_Response"},
343 {0x2039, "Le_Set_Extended_Advertising_Enable"},
344 {0x203a, "Le_Read_Maximum_Advertising_Data_Length"},
345 {0x203b, "Le_Read_Number_Of_Supported_Advertising_Sets"},
346 {0x203c, "Le_Remove_Advertising_Set"},
347 {0x203d, "Le_Clear_Advertising_Sets"},
348 {0x203e, "Le_Set_Periodic_Advertising_Param"},
349 {0x203f, "Le_Set_Periodic_Advertising_Data"},
350 {0x2040, "Le_Set_Periodic_Advertising_Enable"},
351 {0x2041, "Le_Set_Extended_Scan_Parameters"},
352 {0x2042, "Le_Set_Extended_Scan_Enable"},
353 {0x2043, "Le_Extended_Create_Connection"},
354 {0x2044, "Le_Periodic_Advertising_Create_Sync"},
355 {0x2045, "Le_Periodic_Advertising_Create_Sync_Cancel"},
356 {0x2046, "Le_Periodic_Advertising_Terminate_Sync"},
357 {0x2047, "Le_Add_Device_To_Periodic_Advertising_List"},
358 {0x2048, "Le_Remove_Device_From_Periodic_Advertising_List"},
359 {0x2049, "Le_Clear_Periodic_Advertising_List"},
360 {0x204a, "Le_Read_Periodic_Advertising_List_Size"},
361 {0x204b, "Le_Read_Transmit_Power"},
362 {0x204c, "Le_Read_Rf_Path_Compensation_Power"},
363 {0x204d, "Le_Write_Rf_Path_Compensation_Power"},
364 {0x204e, "Le_Set_Privacy_Mode"},
365 {0x2059, "Le_Set_Periodic_Advertising_Receive_Enable"},
366 {0x205a, "Le_Periodic_Advertising_Sync_Transfer"},
367 {0x205b, "Le_Periodic_Advertising_Set_Info_Transfer"},
368 {0x205c, "Le_Set_Periodic_Advertising_Sync_Transfer_Parameters"},
369 {0x205d, "Le_Set_Default_Periodic_Advertising_Sync_Transfer_Parameters"},
370 {0x205e, "Le_Generate_Dhkey_Command"},
371 {0x205f, "Le_Modify_Sleep_Clock_Accuracy"},
372 {0x2060, "Le_Read_Buffer_Size_V2"},
373 {0x2061, "Le_Read_Iso_Tx_Sync"},
374 {0x2062, "Le_Set_Cig_Parameters"},
375 {0x2063, "Le_Set_Cig_Parameters_Test"},
376 {0x2064, "Le_Create_Cis"},
377 {0x2065, "Le_Remove_Cig"},
378 {0x2066, "Le_Accept_Cis_Request"},
379 {0x2067, "Le_Reject_Cis_Request"},
380 {0x2068, "Le_Create_Big"},
381 {0x206a, "Le_Terminate_Big"},
382 {0x206b, "Le_Big_Create_Sync"},
383 {0x206c, "Le_Big_Terminate_Sync"},
384 {0x206d, "Le_Request_Peer_Sca"},
385 {0x206e, "Le_Setup_Iso_Data_Path"},
386 {0x206f, "Le_Remove_Iso_Data_Path"},
387 {0x2074, "Le_Set_Host_Feature"},
388 {0x2075, "Le_Read_Iso_Link_Quality"},
389 {0x2076, "Le_Enhanced_Read_Transmit_Power_Level"},
390 {0x2077, "Le_Read_Remote_Transmit_Power_Level"},
391 {0x2078, "Le_Set_Path_Loss_Reporting_Parameters"},
392 {0x2079, "Le_Set_Path_Loss_Reporting_Enable"},
393 {0x207a, "Le_Set_Transmit_Power_Reporting_Enable"},
394 {0xfd53, "Le_Get_Vendor_Capabilities"},
395 {0xfd54, "Le_Multi_Advt"},
396 {0xfd56, "Le_Batch_Scan"},
397 {0xfd57, "Le_Adv_Filter"},
398 {0xfd59, "Le_Energy_Info"},
399 {0xfd5a, "Le_Extended_Scan_Params"},
400 {0xfd5b, "Controller_Debug_Info"},
401 {0xfd5d, "Controller_A2dp_Opcode"},
402 {0xfd5e, "Controller_Bqr"}};
403
404 } // namespace
405
HciEventToString(const std::vector<uint8_t> & data)406 std::string HciEventToString(const std::vector<uint8_t> &data) {
407 if (data.size() < 2) {
408 return "Malformed HciEvent";
409 }
410 auto event_code = data.at(0);
411 if (event_code == HciLeMetaEvent) {
412 if (data.size() < 3) {
413 return "Malformed HciLeMetaEvent";
414 }
415 auto meta_code = data.at(2);
416 if (HciMetaEventCode.count(meta_code)) {
417 return HciMetaEventCode.at(meta_code);
418 } else {
419 return "LE_Meta_Event::" + stringutils::ToHexString(meta_code);
420 }
421 } else if (HciEventCode.count(event_code)) {
422 return HciEventCode.at(event_code);
423 }
424 return stringutils::ToHexString(event_code);
425 }
426
HciCommandToString(uint8_t x,uint8_t y)427 std::string HciCommandToString(uint8_t x, uint8_t y) {
428 auto opcode = y << 8 | x;
429 if (HciCommandOpCode.count(opcode)) {
430 return HciCommandOpCode.at(opcode);
431 }
432 return stringutils::ToHexString(x, y);
433 }
434
435 } // namespace hci
436 } // namespace netsim
437