xref: /haiku/src/kits/bluetooth/CommandManager.cpp (revision 31fd7ccc19fd7f18793a6309e4fd699a04e2520c)
132c01b55SOliver Ruiz Dorantes /*
232c01b55SOliver Ruiz Dorantes  * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
36e82afccSOliver Ruiz Dorantes  * Copyright 2008 Mika Lindqvist
432c01b55SOliver Ruiz Dorantes  * All rights reserved. Distributed under the terms of the MIT License.
532c01b55SOliver Ruiz Dorantes  */
632c01b55SOliver Ruiz Dorantes 
732c01b55SOliver Ruiz Dorantes 
819733b44SAlexander von Gluck IV #include "CommandManager.h"
940c666a5SOliver Ruiz Dorantes 
1040c666a5SOliver Ruiz Dorantes #include <bluetooth/bluetooth_error.h>
11fef016caSFredrik Modéen #include <bluetooth/debug.h>
1240c666a5SOliver Ruiz Dorantes 
1319733b44SAlexander von Gluck IV #include "CompanyIdentifiers.h"
1419733b44SAlexander von Gluck IV 
1519733b44SAlexander von Gluck IV 
1619733b44SAlexander von Gluck IV inline void*
buildCommand(uint8 ogf,uint8 ocf,void ** param,size_t psize,size_t * outsize)1719733b44SAlexander von Gluck IV buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize,
1840c666a5SOliver Ruiz Dorantes 	size_t* outsize)
1932c01b55SOliver Ruiz Dorantes {
20fef016caSFredrik Modéen 	CALLED();
2132c01b55SOliver Ruiz Dorantes 	struct hci_command_header* header;
2232c01b55SOliver Ruiz Dorantes 
2340c666a5SOliver Ruiz Dorantes 	header = (struct hci_command_header*) malloc(psize
2440c666a5SOliver Ruiz Dorantes 		+ sizeof(struct hci_command_header));
2532c01b55SOliver Ruiz Dorantes 	*outsize = psize + sizeof(struct hci_command_header);
2632c01b55SOliver Ruiz Dorantes 
2732c01b55SOliver Ruiz Dorantes 	if (header != NULL) {
2832c01b55SOliver Ruiz Dorantes 		header->opcode = B_HOST_TO_LENDIAN_INT16(PACK_OPCODE(ogf, ocf));
2932c01b55SOliver Ruiz Dorantes 		header->clen = psize;
3032c01b55SOliver Ruiz Dorantes 
3132c01b55SOliver Ruiz Dorantes 		if (param != NULL && psize != 0) {
3232c01b55SOliver Ruiz Dorantes 			*param = ((uint8*)header) + sizeof(struct hci_command_header);
3332c01b55SOliver Ruiz Dorantes 		}
3432c01b55SOliver Ruiz Dorantes 	}
3532c01b55SOliver Ruiz Dorantes 	return header;
3632c01b55SOliver Ruiz Dorantes }
3732c01b55SOliver Ruiz Dorantes 
3832c01b55SOliver Ruiz Dorantes 
3940c666a5SOliver Ruiz Dorantes // This is for request that only require a Command complete in reply.
4040c666a5SOliver Ruiz Dorantes 
4140c666a5SOliver Ruiz Dorantes // Propagate to ReadBufferSize => reply stored in server side
4240c666a5SOliver Ruiz Dorantes // ReadLocalVersion => reply stored in server side
4340c666a5SOliver Ruiz Dorantes // Reset => no reply
4440c666a5SOliver Ruiz Dorantes 
4540c666a5SOliver Ruiz Dorantes // Request that do not need any input parameter
4640c666a5SOliver Ruiz Dorantes // Output reply can be fit in 32 bits field without talking status into account
4740c666a5SOliver Ruiz Dorantes status_t
NonParameterCommandRequest(uint8 ofg,uint8 ocf,int32 * result,hci_id hId,BMessenger * messenger)4840c666a5SOliver Ruiz Dorantes NonParameterCommandRequest(uint8 ofg, uint8 ocf, int32* result, hci_id hId,
4940c666a5SOliver Ruiz Dorantes 	BMessenger* messenger)
5040c666a5SOliver Ruiz Dorantes {
51fef016caSFredrik Modéen 	CALLED();
5240c666a5SOliver Ruiz Dorantes 	int8 bt_status = BT_ERROR;
5340c666a5SOliver Ruiz Dorantes 
5440c666a5SOliver Ruiz Dorantes 	BluetoothCommand<> simpleCommand(ofg, ocf);
5540c666a5SOliver Ruiz Dorantes 
5640c666a5SOliver Ruiz Dorantes 	BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
5740c666a5SOliver Ruiz Dorantes 	BMessage reply;
5840c666a5SOliver Ruiz Dorantes 
5940c666a5SOliver Ruiz Dorantes 	request.AddInt32("hci_id", hId);
6040c666a5SOliver Ruiz Dorantes 	request.AddData("raw command", B_ANY_TYPE,
6140c666a5SOliver Ruiz Dorantes 		simpleCommand.Data(), simpleCommand.Size());
6240c666a5SOliver Ruiz Dorantes 	request.AddInt16("eventExpected",  HCI_EVENT_CMD_COMPLETE);
6340c666a5SOliver Ruiz Dorantes 	request.AddInt16("opcodeExpected", PACK_OPCODE(ofg, ocf));
6440c666a5SOliver Ruiz Dorantes 
6540c666a5SOliver Ruiz Dorantes 	if (messenger->SendMessage(&request, &reply) == B_OK) {
6640c666a5SOliver Ruiz Dorantes 		reply.FindInt8("status", &bt_status);
6740c666a5SOliver Ruiz Dorantes 		if (result != NULL)
6840c666a5SOliver Ruiz Dorantes 			reply.FindInt32("result", result);
6940c666a5SOliver Ruiz Dorantes 	}
7040c666a5SOliver Ruiz Dorantes 
7140c666a5SOliver Ruiz Dorantes 	return bt_status;
7240c666a5SOliver Ruiz Dorantes }
7340c666a5SOliver Ruiz Dorantes 
7440c666a5SOliver Ruiz Dorantes 
7532c01b55SOliver Ruiz Dorantes #if 0
7632c01b55SOliver Ruiz Dorantes #pragma mark - CONTROL BASEBAND -
7732c01b55SOliver Ruiz Dorantes #endif
7832c01b55SOliver Ruiz Dorantes 
7932c01b55SOliver Ruiz Dorantes 
8019733b44SAlexander von Gluck IV void*
buildReset(size_t * outsize)8119733b44SAlexander von Gluck IV buildReset(size_t* outsize)
8232c01b55SOliver Ruiz Dorantes {
83fef016caSFredrik Modéen 	CALLED();
8440c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET,
8540c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
8632c01b55SOliver Ruiz Dorantes }
8732c01b55SOliver Ruiz Dorantes 
8832c01b55SOliver Ruiz Dorantes 
8919733b44SAlexander von Gluck IV void*
buildReadLocalName(size_t * outsize)9019733b44SAlexander von Gluck IV buildReadLocalName(size_t* outsize)
9132c01b55SOliver Ruiz Dorantes {
92fef016caSFredrik Modéen 	CALLED();
9340c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME,
9440c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
9532c01b55SOliver Ruiz Dorantes }
9632c01b55SOliver Ruiz Dorantes 
9732c01b55SOliver Ruiz Dorantes 
9819733b44SAlexander von Gluck IV void*
buildReadClassOfDevice(size_t * outsize)9919733b44SAlexander von Gluck IV buildReadClassOfDevice(size_t* outsize)
100a2f8edf7SOliver Ruiz Dorantes {
101fef016caSFredrik Modéen 	CALLED();
10240c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV,
10340c666a5SOliver Ruiz Dorantes 	NULL, 0, outsize);
104a2f8edf7SOliver Ruiz Dorantes }
105a2f8edf7SOliver Ruiz Dorantes 
106a2f8edf7SOliver Ruiz Dorantes 
10719733b44SAlexander von Gluck IV void*
buildReadScan(size_t * outsize)10819733b44SAlexander von Gluck IV buildReadScan(size_t* outsize)
1097a74a5dfSFredrik Modéen {
110fef016caSFredrik Modéen 	CALLED();
1117a74a5dfSFredrik Modéen 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE,
1127a74a5dfSFredrik Modéen 	NULL, 0, outsize);
1137a74a5dfSFredrik Modéen }
1147a74a5dfSFredrik Modéen 
1157a74a5dfSFredrik Modéen 
11619733b44SAlexander von Gluck IV void*
buildWriteScan(uint8 scanmode,size_t * outsize)11719733b44SAlexander von Gluck IV buildWriteScan(uint8 scanmode, size_t* outsize)
118631aa548SOliver Ruiz Dorantes {
119fef016caSFredrik Modéen 	CALLED();
120631aa548SOliver Ruiz Dorantes 	struct hci_write_scan_enable* param;
12140c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE,
12240c666a5SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_write_scan_enable), outsize);
123631aa548SOliver Ruiz Dorantes 
124631aa548SOliver Ruiz Dorantes 
125631aa548SOliver Ruiz Dorantes 	if (command != NULL) {
126631aa548SOliver Ruiz Dorantes 		param->scan = scanmode;
127631aa548SOliver Ruiz Dorantes 	}
128631aa548SOliver Ruiz Dorantes 
129631aa548SOliver Ruiz Dorantes 	return command;
130631aa548SOliver Ruiz Dorantes }
131631aa548SOliver Ruiz Dorantes 
132631aa548SOliver Ruiz Dorantes 
13332c01b55SOliver Ruiz Dorantes #if 0
13432c01b55SOliver Ruiz Dorantes #pragma mark - LINK CONTROL -
13532c01b55SOliver Ruiz Dorantes #endif
13632c01b55SOliver Ruiz Dorantes 
1377434b760SOliver Ruiz Dorantes 
13819733b44SAlexander von Gluck IV void*
buildRemoteNameRequest(bdaddr_t bdaddr,uint8 pscan_rep_mode,uint16 clock_offset,size_t * outsize)13919733b44SAlexander von Gluck IV buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode,
14040c666a5SOliver Ruiz Dorantes 	uint16 clock_offset, size_t* outsize)
14132c01b55SOliver Ruiz Dorantes {
142fef016caSFredrik Modéen 	CALLED();
14332c01b55SOliver Ruiz Dorantes 	struct hci_remote_name_request* param;
14440c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST,
14540c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_remote_name_request), outsize);
14632c01b55SOliver Ruiz Dorantes 
14732c01b55SOliver Ruiz Dorantes 	if (command != NULL) {
14832c01b55SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
14932c01b55SOliver Ruiz Dorantes 		param->pscan_rep_mode = pscan_rep_mode;
15032c01b55SOliver Ruiz Dorantes 		param->clock_offset = clock_offset;
15132c01b55SOliver Ruiz Dorantes 	}
15232c01b55SOliver Ruiz Dorantes 
15332c01b55SOliver Ruiz Dorantes 	return command;
15432c01b55SOliver Ruiz Dorantes }
15532c01b55SOliver Ruiz Dorantes 
15632c01b55SOliver Ruiz Dorantes 
15719733b44SAlexander von Gluck IV void*
buildInquiry(uint32 lap,uint8 length,uint8 num_rsp,size_t * outsize)15819733b44SAlexander von Gluck IV buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
15932c01b55SOliver Ruiz Dorantes {
160fef016caSFredrik Modéen 	CALLED();
16132c01b55SOliver Ruiz Dorantes 	struct hci_cp_inquiry* param;
16240c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY,
16340c666a5SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_inquiry), outsize);
16432c01b55SOliver Ruiz Dorantes 
16532c01b55SOliver Ruiz Dorantes 	if (command != NULL) {
16632c01b55SOliver Ruiz Dorantes 
16732c01b55SOliver Ruiz Dorantes 		param->lap[2] = (lap >> 16) & 0xFF;
16832c01b55SOliver Ruiz Dorantes 		param->lap[1] = (lap >>  8) & 0xFF;
16932c01b55SOliver Ruiz Dorantes 		param->lap[0] = (lap >>  0) & 0xFF;
17032c01b55SOliver Ruiz Dorantes 		param->length = length;
17132c01b55SOliver Ruiz Dorantes 		param->num_rsp = num_rsp;
172350458a6SOliver Ruiz Dorantes 	}
173350458a6SOliver Ruiz Dorantes 
174350458a6SOliver Ruiz Dorantes 	return command;
175350458a6SOliver Ruiz Dorantes }
176350458a6SOliver Ruiz Dorantes 
1777434b760SOliver Ruiz Dorantes 
17819733b44SAlexander von Gluck IV void*
buildInquiryCancel(size_t * outsize)17919733b44SAlexander von Gluck IV buildInquiryCancel(size_t* outsize)
180350458a6SOliver Ruiz Dorantes {
181fef016caSFredrik Modéen 	CALLED();
182350458a6SOliver Ruiz Dorantes 	return buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL, NULL, 0, outsize);
183350458a6SOliver Ruiz Dorantes }
184350458a6SOliver Ruiz Dorantes 
185350458a6SOliver Ruiz Dorantes 
18619733b44SAlexander von Gluck IV void*
buildPinCodeRequestReply(bdaddr_t bdaddr,uint8 length,char pincode[16],size_t * outsize)18719733b44SAlexander von Gluck IV buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16],
18840c666a5SOliver Ruiz Dorantes 	size_t* outsize)
189350458a6SOliver Ruiz Dorantes {
190fef016caSFredrik Modéen 	CALLED();
191350458a6SOliver Ruiz Dorantes 	struct hci_cp_pin_code_reply* param;
192350458a6SOliver Ruiz Dorantes 
193350458a6SOliver Ruiz Dorantes 	if (length > HCI_PIN_SIZE)  // PinCode cannot be longer than 16
194350458a6SOliver Ruiz Dorantes 		return NULL;
195350458a6SOliver Ruiz Dorantes 
19640c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_REPLY,
19740c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_cp_pin_code_reply), outsize);
198350458a6SOliver Ruiz Dorantes 
199350458a6SOliver Ruiz Dorantes 	if (command != NULL) {
200350458a6SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
201350458a6SOliver Ruiz Dorantes 		param->pin_len = length;
202350458a6SOliver Ruiz Dorantes 		memcpy(&param->pin_code, pincode, length);
203350458a6SOliver Ruiz Dorantes 	}
204350458a6SOliver Ruiz Dorantes 
205350458a6SOliver Ruiz Dorantes 	return command;
206350458a6SOliver Ruiz Dorantes }
207350458a6SOliver Ruiz Dorantes 
208350458a6SOliver Ruiz Dorantes 
20919733b44SAlexander von Gluck IV void*
buildPinCodeRequestNegativeReply(bdaddr_t bdaddr,size_t * outsize)21019733b44SAlexander von Gluck IV buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize)
211350458a6SOliver Ruiz Dorantes {
212fef016caSFredrik Modéen 	CALLED();
213350458a6SOliver Ruiz Dorantes 	struct hci_cp_pin_code_neg_reply* param;
214350458a6SOliver Ruiz Dorantes 
215350458a6SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY,
216350458a6SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_pin_code_neg_reply), outsize);
217350458a6SOliver Ruiz Dorantes 
218350458a6SOliver Ruiz Dorantes 	if (command != NULL) {
219350458a6SOliver Ruiz Dorantes 
220350458a6SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
221350458a6SOliver Ruiz Dorantes 
22232c01b55SOliver Ruiz Dorantes 	}
22332c01b55SOliver Ruiz Dorantes 
22432c01b55SOliver Ruiz Dorantes 	return command;
22532c01b55SOliver Ruiz Dorantes }
22632c01b55SOliver Ruiz Dorantes 
22732c01b55SOliver Ruiz Dorantes 
22819733b44SAlexander von Gluck IV void*
buildAcceptConnectionRequest(bdaddr_t bdaddr,uint8 role,size_t * outsize)22919733b44SAlexander von Gluck IV buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize)
2307434b760SOliver Ruiz Dorantes {
231fef016caSFredrik Modéen 	CALLED();
2327434b760SOliver Ruiz Dorantes 	struct hci_cp_accept_conn_req* param;
2337434b760SOliver Ruiz Dorantes 
2347434b760SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ,
2357434b760SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_accept_conn_req), outsize);
2367434b760SOliver Ruiz Dorantes 
2377434b760SOliver Ruiz Dorantes 	if (command != NULL) {
2387434b760SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
2397434b760SOliver Ruiz Dorantes 		param->role = role;
2407434b760SOliver Ruiz Dorantes 	}
2417434b760SOliver Ruiz Dorantes 
2427434b760SOliver Ruiz Dorantes 	return command;
2437434b760SOliver Ruiz Dorantes }
2447434b760SOliver Ruiz Dorantes 
2457434b760SOliver Ruiz Dorantes 
24619733b44SAlexander von Gluck IV void*
buildRejectConnectionRequest(bdaddr_t bdaddr,size_t * outsize)24719733b44SAlexander von Gluck IV buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize)
2487434b760SOliver Ruiz Dorantes {
249fef016caSFredrik Modéen 	CALLED();
2507434b760SOliver Ruiz Dorantes 	struct hci_cp_reject_conn_req* param;
2517434b760SOliver Ruiz Dorantes 
2527434b760SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ,
25340c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_cp_reject_conn_req),
25440c666a5SOliver Ruiz Dorantes 		outsize);
2557434b760SOliver Ruiz Dorantes 
2567434b760SOliver Ruiz Dorantes 	if (command != NULL) {
2577434b760SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
2587434b760SOliver Ruiz Dorantes 	}
2597434b760SOliver Ruiz Dorantes 
2607434b760SOliver Ruiz Dorantes 	return command;
2617434b760SOliver Ruiz Dorantes }
2627434b760SOliver Ruiz Dorantes 
2637434b760SOliver Ruiz Dorantes 
26432c01b55SOliver Ruiz Dorantes #if 0
26532c01b55SOliver Ruiz Dorantes #pragma mark - INFORMATIONAL_PARAM -
26632c01b55SOliver Ruiz Dorantes #endif
26732c01b55SOliver Ruiz Dorantes 
26819733b44SAlexander von Gluck IV 
26919733b44SAlexander von Gluck IV void*
buildReadLocalVersionInformation(size_t * outsize)27019733b44SAlexander von Gluck IV buildReadLocalVersionInformation(size_t* outsize)
271b44ee583SOliver Ruiz Dorantes {
272fef016caSFredrik Modéen 	CALLED();
27340c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION,
27440c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
275b44ee583SOliver Ruiz Dorantes }
276b44ee583SOliver Ruiz Dorantes 
27732c01b55SOliver Ruiz Dorantes 
27819733b44SAlexander von Gluck IV void*
buildReadBufferSize(size_t * outsize)27919733b44SAlexander von Gluck IV buildReadBufferSize(size_t* outsize)
28032c01b55SOliver Ruiz Dorantes {
281fef016caSFredrik Modéen 	CALLED();
28240c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE,
28340c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
28432c01b55SOliver Ruiz Dorantes }
28532c01b55SOliver Ruiz Dorantes 
28632c01b55SOliver Ruiz Dorantes 
28719733b44SAlexander von Gluck IV void*
buildReadBdAddr(size_t * outsize)28819733b44SAlexander von Gluck IV buildReadBdAddr(size_t* outsize)
28932c01b55SOliver Ruiz Dorantes {
290fef016caSFredrik Modéen 	CALLED();
29140c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR,
29240c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
29332c01b55SOliver Ruiz Dorantes }
294631aa548SOliver Ruiz Dorantes 
295631aa548SOliver Ruiz Dorantes 
296a7c3c465SOliver Ruiz Dorantes const char* linkControlCommands[] = {
297a7c3c465SOliver Ruiz Dorantes 	"Inquiry",
29840c666a5SOliver Ruiz Dorantes 	"Inquiry Cancel",
29940c666a5SOliver Ruiz Dorantes 	"Periodic Inquiry Mode",
30040c666a5SOliver Ruiz Dorantes 	"Exit Periodic Inquiry Mode",
30140c666a5SOliver Ruiz Dorantes 	"Create Connection",
302a7c3c465SOliver Ruiz Dorantes 	"Disconnect",
30340c666a5SOliver Ruiz Dorantes 	"Add SCO Connection", // not on 2.1
30440c666a5SOliver Ruiz Dorantes 	"Cancel Create Connection",
30540c666a5SOliver Ruiz Dorantes 	"Accept Connection Request",
30640c666a5SOliver Ruiz Dorantes 	"Reject Connection Request",
30740c666a5SOliver Ruiz Dorantes 	"Link Key Request Reply",
30840c666a5SOliver Ruiz Dorantes 	"Link Key Request Negative Reply",
30940c666a5SOliver Ruiz Dorantes 	"PIN Code Request Reply",
31040c666a5SOliver Ruiz Dorantes 	"PIN Code Request Negative Reply",
31140c666a5SOliver Ruiz Dorantes 	"Change Connection Packet Type",
312b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
31340c666a5SOliver Ruiz Dorantes 	"Authentication Requested",
314b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
31540c666a5SOliver Ruiz Dorantes 	"Set Connection Encryption",
316b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
31740c666a5SOliver Ruiz Dorantes 	"Change Connection Link Key",
318b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
31940c666a5SOliver Ruiz Dorantes 	"Master Link Key",
320b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
32140c666a5SOliver Ruiz Dorantes 	"Remote Name Request",
32240c666a5SOliver Ruiz Dorantes 	"Cancel Remote Name Request",
32340c666a5SOliver Ruiz Dorantes 	"Read Remote Supported Features",
32440c666a5SOliver Ruiz Dorantes 	"Read Remote Extended Features",
32540c666a5SOliver Ruiz Dorantes 	"Read Remote Version Information",
326b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
32740c666a5SOliver Ruiz Dorantes 	"Read Clock Offset",
32840c666a5SOliver Ruiz Dorantes 	"Read LMP Handle",
329a7c3c465SOliver Ruiz Dorantes 	"Reserved",
330a7c3c465SOliver Ruiz Dorantes 	"Reserved",
331a7c3c465SOliver Ruiz Dorantes 	"Reserved",
332a7c3c465SOliver Ruiz Dorantes 	"Reserved",
333a7c3c465SOliver Ruiz Dorantes 	"Reserved",
334a7c3c465SOliver Ruiz Dorantes 	"Reserved",
335a7c3c465SOliver Ruiz Dorantes 	"Reserved",
33640c666a5SOliver Ruiz Dorantes 	"Setup Synchronous Connection",
33740c666a5SOliver Ruiz Dorantes 	"Accept Synchronous Connection",
33840c666a5SOliver Ruiz Dorantes 	"Reject Synchronous Connection",
33940c666a5SOliver Ruiz Dorantes 	"IO Capability Request Reply",
34040c666a5SOliver Ruiz Dorantes 	"User Confirmation Request Reply",
34140c666a5SOliver Ruiz Dorantes 	"User Confirmation Request Negative Reply",
34240c666a5SOliver Ruiz Dorantes 	"User Passkey Request Reply",
34340c666a5SOliver Ruiz Dorantes 	"User Passkey Request Negative Reply",
34440c666a5SOliver Ruiz Dorantes 	"Remote OOB Data Request Reply",
345a7c3c465SOliver Ruiz Dorantes 	"Reserved",
346a7c3c465SOliver Ruiz Dorantes 	"Reserved",
34740c666a5SOliver Ruiz Dorantes 	"Remote OOB Data Request Negative Reply",
34840c666a5SOliver Ruiz Dorantes 	"IO Capabilities Response Negative Reply"
349a7c3c465SOliver Ruiz Dorantes };
350a7c3c465SOliver Ruiz Dorantes 
351a7c3c465SOliver Ruiz Dorantes 
352a7c3c465SOliver Ruiz Dorantes const char* linkPolicyCommands[] = {
35340c666a5SOliver Ruiz Dorantes 	"Hold Mode",
354a7c3c465SOliver Ruiz Dorantes 	"Reserved",
35540c666a5SOliver Ruiz Dorantes 	"Sniff Mode",
35640c666a5SOliver Ruiz Dorantes 	"Exit Sniff Mode",
35740c666a5SOliver Ruiz Dorantes 	"Park State",
35840c666a5SOliver Ruiz Dorantes 	"Exit Park State",
35940c666a5SOliver Ruiz Dorantes 	"QoS Setup",
360a7c3c465SOliver Ruiz Dorantes 	"Reserved",
36140c666a5SOliver Ruiz Dorantes 	"Role Discovery",
362a7c3c465SOliver Ruiz Dorantes 	"Reserved",
36340c666a5SOliver Ruiz Dorantes 	"Switch Role",
36440c666a5SOliver Ruiz Dorantes 	"Read Link Policy Settings",
36540c666a5SOliver Ruiz Dorantes 	"Write Link Policy Settings",
36640c666a5SOliver Ruiz Dorantes 	"Read Default Link Policy Settings",
36740c666a5SOliver Ruiz Dorantes 	"Write Default Link Policy Settings",
36840c666a5SOliver Ruiz Dorantes 	"Flow Specification",
36940c666a5SOliver Ruiz Dorantes 	"Sniff Subrating"
370a7c3c465SOliver Ruiz Dorantes };
371a7c3c465SOliver Ruiz Dorantes 
372a7c3c465SOliver Ruiz Dorantes 
373a7c3c465SOliver Ruiz Dorantes const char* controllerBasebandCommands[] = {
37440c666a5SOliver Ruiz Dorantes 	"Set Event Mask",
375a7c3c465SOliver Ruiz Dorantes 	"Reserved",
376a7c3c465SOliver Ruiz Dorantes 	"Reset",
377a7c3c465SOliver Ruiz Dorantes 	"Reserved",
37840c666a5SOliver Ruiz Dorantes 	"Set Event Filter",
379a7c3c465SOliver Ruiz Dorantes 	"Reserved",
380a7c3c465SOliver Ruiz Dorantes 	"Reserved",
381a7c3c465SOliver Ruiz Dorantes 	"Flush",
38240c666a5SOliver Ruiz Dorantes 	"Read PIN Type",
38340c666a5SOliver Ruiz Dorantes 	"Write PIN Type",
38440c666a5SOliver Ruiz Dorantes 	"Create New Unit Key",
385a7c3c465SOliver Ruiz Dorantes 	"Reserved",
38640c666a5SOliver Ruiz Dorantes 	"Read Stored Link Key",
387a7c3c465SOliver Ruiz Dorantes 	"Reserved",
388a7c3c465SOliver Ruiz Dorantes 	"Reserved",
389a7c3c465SOliver Ruiz Dorantes 	"Reserved",
39040c666a5SOliver Ruiz Dorantes 	"Write Stored Link Key",
39140c666a5SOliver Ruiz Dorantes 	"Delete Stored Link Key",
39240c666a5SOliver Ruiz Dorantes 	"Write Local Name",
39340c666a5SOliver Ruiz Dorantes 	"Read Local Name",
39440c666a5SOliver Ruiz Dorantes 	"Read Connection Accept Timeout",
39540c666a5SOliver Ruiz Dorantes 	"Write Connection Accept Timeout",
39640c666a5SOliver Ruiz Dorantes 	"Read Page Timeout",
39740c666a5SOliver Ruiz Dorantes 	"Write Page Timeout",
39840c666a5SOliver Ruiz Dorantes 	"Read Scan Enable",
39940c666a5SOliver Ruiz Dorantes 	"Write Scan Enable",
40040c666a5SOliver Ruiz Dorantes 	"Read Page Scan Activity",
40140c666a5SOliver Ruiz Dorantes 	"Write Page Scan Activity",
40240c666a5SOliver Ruiz Dorantes 	"Read Inquiry Scan Activity",
40340c666a5SOliver Ruiz Dorantes 	"Write Inquiry Scan Activity",
40440c666a5SOliver Ruiz Dorantes 	"Read Authentication Enable",
40540c666a5SOliver Ruiz Dorantes 	"Write Authentication Enable",
40640c666a5SOliver Ruiz Dorantes 	"Read Encryption Mode", // not 2.1
40740c666a5SOliver Ruiz Dorantes 	"Write Encryption Mode",// not 2.1
40840c666a5SOliver Ruiz Dorantes 	"Read Class Of Device",
40940c666a5SOliver Ruiz Dorantes 	"Write Class Of Device",
41040c666a5SOliver Ruiz Dorantes 	"Read Voice Setting",
41140c666a5SOliver Ruiz Dorantes 	"Write Voice Setting",
41240c666a5SOliver Ruiz Dorantes 	"Read Automatic Flush Timeout",
41340c666a5SOliver Ruiz Dorantes 	"Write Automatic Flush Timeout",
41440c666a5SOliver Ruiz Dorantes 	"Read Num Broadcast Retransmissions",
41540c666a5SOliver Ruiz Dorantes 	"Write Num Broadcast Retransmissions",
41640c666a5SOliver Ruiz Dorantes 	"Read Hold Mode Activity",
41740c666a5SOliver Ruiz Dorantes 	"Write Hold Mode Activity",
41840c666a5SOliver Ruiz Dorantes 	"Read Transmit Power Level",
41940c666a5SOliver Ruiz Dorantes 	"Read Synchronous Flow Control Enable",
42040c666a5SOliver Ruiz Dorantes 	"Write Synchronous Flow Control Enable",
421a7c3c465SOliver Ruiz Dorantes 	"Reserved",
42240c666a5SOliver Ruiz Dorantes 	"Set Host Controller To Host Flow Control",
423a7c3c465SOliver Ruiz Dorantes 	"Reserved",
42440c666a5SOliver Ruiz Dorantes 	"Host Buffer Size",
425a7c3c465SOliver Ruiz Dorantes 	"Reserved",
42640c666a5SOliver Ruiz Dorantes 	"Host Number Of Completed Packets",
42740c666a5SOliver Ruiz Dorantes 	"Read Link Supervision Timeout",
42840c666a5SOliver Ruiz Dorantes 	"Write Link Supervision Timeout",
42940c666a5SOliver Ruiz Dorantes 	"Read Number of Supported IAC",
43040c666a5SOliver Ruiz Dorantes 	"Read Current IAC LAP",
43140c666a5SOliver Ruiz Dorantes 	"Write Current IAC LAP",
43240c666a5SOliver Ruiz Dorantes 	"Read Page Scan Period Mode", // not 2.1
43340c666a5SOliver Ruiz Dorantes 	"Write Page Scan Period Mode", // not 2.1
43440c666a5SOliver Ruiz Dorantes 	"Read Page Scan Mode",		// not 2.1
43540c666a5SOliver Ruiz Dorantes 	"Write Page Scan Mode",		// not 2.1
43640c666a5SOliver Ruiz Dorantes 	"Set AFH Channel Classification",
437a7c3c465SOliver Ruiz Dorantes 	"Reserved",
438a7c3c465SOliver Ruiz Dorantes 	"Reserved",
43940c666a5SOliver Ruiz Dorantes 	"Read Inquiry Scan Type",
44040c666a5SOliver Ruiz Dorantes 	"Write Inquiry Scan Type",
44140c666a5SOliver Ruiz Dorantes 	"Read Inquiry Mode",
44240c666a5SOliver Ruiz Dorantes 	"Write Inquiry Mode",
44340c666a5SOliver Ruiz Dorantes 	"Read Page Scan Type",
44440c666a5SOliver Ruiz Dorantes 	"Write Page Scan Type",
44540c666a5SOliver Ruiz Dorantes 	"Read AFH Channel Assessment Mode",
44640c666a5SOliver Ruiz Dorantes 	"Write AFH Channel Assessment Mode",
447a7c3c465SOliver Ruiz Dorantes 	"Reserved",
448a7c3c465SOliver Ruiz Dorantes 	"Reserved",
449a7c3c465SOliver Ruiz Dorantes 	"Reserved",
450a7c3c465SOliver Ruiz Dorantes 	"Reserved",
451a7c3c465SOliver Ruiz Dorantes 	"Reserved",
452a7c3c465SOliver Ruiz Dorantes 	"Reserved",
453a7c3c465SOliver Ruiz Dorantes 	"Reserved",
45440c666a5SOliver Ruiz Dorantes 	"Read Extended Inquiry Response",
45540c666a5SOliver Ruiz Dorantes 	"Write Extended Inquiry Response",
45640c666a5SOliver Ruiz Dorantes 	"Refresh Encryption Key",
457a7c3c465SOliver Ruiz Dorantes 	"Reserved",
45840c666a5SOliver Ruiz Dorantes 	"Read Simple Pairing Mode",
45940c666a5SOliver Ruiz Dorantes 	"Write Simple Pairing Mode",
46040c666a5SOliver Ruiz Dorantes 	"Read Local OOB Data",
46140c666a5SOliver Ruiz Dorantes 	"Read Inquiry Transmit Power Level",
46240c666a5SOliver Ruiz Dorantes 	"Write Inquiry Transmit Power Level",
46340c666a5SOliver Ruiz Dorantes 	"Read Default Erroneous Data Reporting",
46440c666a5SOliver Ruiz Dorantes 	"Write Default Erroneous Data Reporting",
465a7c3c465SOliver Ruiz Dorantes 	"Reserved",
466a7c3c465SOliver Ruiz Dorantes 	"Reserved",
467a7c3c465SOliver Ruiz Dorantes 	"Reserved",
46840c666a5SOliver Ruiz Dorantes 	"Enhanced Flush",
46940c666a5SOliver Ruiz Dorantes 	"Send Keypress Notification"
470a7c3c465SOliver Ruiz Dorantes };
471a7c3c465SOliver Ruiz Dorantes 
472a7c3c465SOliver Ruiz Dorantes 
473a7c3c465SOliver Ruiz Dorantes const char* informationalParametersCommands[] = {
47440c666a5SOliver Ruiz Dorantes 	"Read Local Version Information",
47540c666a5SOliver Ruiz Dorantes 	"Read Local Supported Commands",
47640c666a5SOliver Ruiz Dorantes 	"Read Local Supported Features",
47740c666a5SOliver Ruiz Dorantes 	"Read Local Extended Features",
47840c666a5SOliver Ruiz Dorantes 	"Read Buffer Size",
479a7c3c465SOliver Ruiz Dorantes 	"Reserved",
48040c666a5SOliver Ruiz Dorantes 	"Read Country Code", // not 2.1
481a7c3c465SOliver Ruiz Dorantes 	"Reserved",
482a7c3c465SOliver Ruiz Dorantes 	"Read BD ADDR"
483a7c3c465SOliver Ruiz Dorantes };
484a7c3c465SOliver Ruiz Dorantes 
485a7c3c465SOliver Ruiz Dorantes 
486a7c3c465SOliver Ruiz Dorantes const char* statusParametersCommands[] = {
48740c666a5SOliver Ruiz Dorantes 	"Read Failed Contact Counter",
48840c666a5SOliver Ruiz Dorantes 	"Reset Failed Contact Counter",
48940c666a5SOliver Ruiz Dorantes 	"Read Link Quality",
490a7c3c465SOliver Ruiz Dorantes 	"Reserved",
491a7c3c465SOliver Ruiz Dorantes 	"Read RSSI",
49240c666a5SOliver Ruiz Dorantes 	"Read AFH Channel Map",
49340c666a5SOliver Ruiz Dorantes 	"Read Clock",
494a7c3c465SOliver Ruiz Dorantes };
495a7c3c465SOliver Ruiz Dorantes 
496a7c3c465SOliver Ruiz Dorantes 
497a7c3c465SOliver Ruiz Dorantes const char* testingCommands[] = {
49840c666a5SOliver Ruiz Dorantes 	"Read Loopback Mode",
49940c666a5SOliver Ruiz Dorantes 	"Write Loopback Mode",
50040c666a5SOliver Ruiz Dorantes 	"Enable Device Under Test Mode",
50140c666a5SOliver Ruiz Dorantes 	"Write Simple Pairing Debug Mode",
502a7c3c465SOliver Ruiz Dorantes };
503a7c3c465SOliver Ruiz Dorantes 
504a7c3c465SOliver Ruiz Dorantes 
505d081e691SOliver Ruiz Dorantes const char* bluetoothEvents[] = {
50640c666a5SOliver Ruiz Dorantes 	"Inquiry Complete",
50740c666a5SOliver Ruiz Dorantes 	"Inquiry Result",
50840c666a5SOliver Ruiz Dorantes 	"Conn Complete",
50940c666a5SOliver Ruiz Dorantes 	"Conn Request",
51040c666a5SOliver Ruiz Dorantes 	"Disconnection Complete",
51140c666a5SOliver Ruiz Dorantes 	"Auth Complete",
51240c666a5SOliver Ruiz Dorantes 	"Remote Name Request Complete",
51340c666a5SOliver Ruiz Dorantes 	"Encrypt Change",
51440c666a5SOliver Ruiz Dorantes 	"Change Conn Link Key Complete",
51540c666a5SOliver Ruiz Dorantes 	"Master Link Key Compl",
51640c666a5SOliver Ruiz Dorantes 	"Rmt Features",
51740c666a5SOliver Ruiz Dorantes 	"Rmt Version",
51840c666a5SOliver Ruiz Dorantes 	"Qos Setup Complete",
51940c666a5SOliver Ruiz Dorantes 	"Command Complete",
52040c666a5SOliver Ruiz Dorantes 	"Command Status",
52140c666a5SOliver Ruiz Dorantes 	"Hardware Error",
52240c666a5SOliver Ruiz Dorantes 	"Flush Occur",
52340c666a5SOliver Ruiz Dorantes 	"Role Change",
52440c666a5SOliver Ruiz Dorantes 	"Num Comp Pkts",
52540c666a5SOliver Ruiz Dorantes 	"Mode Change",
52640c666a5SOliver Ruiz Dorantes 	"Return Link Keys",
52740c666a5SOliver Ruiz Dorantes 	"Pin Code Req",
52840c666a5SOliver Ruiz Dorantes 	"Link Key Req",
52940c666a5SOliver Ruiz Dorantes 	"Link Key Notify",
53040c666a5SOliver Ruiz Dorantes 	"Loopback Command",
53140c666a5SOliver Ruiz Dorantes 	"Data Buffer Overflow",
53240c666a5SOliver Ruiz Dorantes 	"Max Slot Change",
53340c666a5SOliver Ruiz Dorantes 	"Read Clock Offset Compl",
53440c666a5SOliver Ruiz Dorantes 	"Con Pkt Type Changed",
53540c666a5SOliver Ruiz Dorantes 	"Qos Violation",
536d081e691SOliver Ruiz Dorantes 	"Reserved",
53740c666a5SOliver Ruiz Dorantes 	"Page Scan Rep Mode Change",
53840c666a5SOliver Ruiz Dorantes 	"Flow Specification",
53940c666a5SOliver Ruiz Dorantes 	"Inquiry Result With Rssi",
54040c666a5SOliver Ruiz Dorantes 	"Remote Extended Features",
541d081e691SOliver Ruiz Dorantes 	"Reserved",
542d081e691SOliver Ruiz Dorantes 	"Reserved",
543d081e691SOliver Ruiz Dorantes 	"Reserved",
544d081e691SOliver Ruiz Dorantes 	"Reserved",
545d081e691SOliver Ruiz Dorantes 	"Reserved",
546d081e691SOliver Ruiz Dorantes 	"Reserved",
547d081e691SOliver Ruiz Dorantes 	"Reserved",
548d081e691SOliver Ruiz Dorantes 	"Reserved",
54940c666a5SOliver Ruiz Dorantes 	"Synchronous Connection Completed",
55040c666a5SOliver Ruiz Dorantes 	"Synchronous Connection Changed",
551d081e691SOliver Ruiz Dorantes 	"Reserved",
55240c666a5SOliver Ruiz Dorantes 	"Extended Inquiry Result",
55340c666a5SOliver Ruiz Dorantes 	"Encryption Key Refresh Complete",
55440c666a5SOliver Ruiz Dorantes 	"Io Capability Request",
55540c666a5SOliver Ruiz Dorantes 	"Io Capability Response",
55640c666a5SOliver Ruiz Dorantes 	"User Confirmation Request",
55740c666a5SOliver Ruiz Dorantes 	"User Passkey Request",
55840c666a5SOliver Ruiz Dorantes 	"Oob Data Request",
55940c666a5SOliver Ruiz Dorantes 	"Simple Pairing Complete",
560d081e691SOliver Ruiz Dorantes 	"Reserved",
56140c666a5SOliver Ruiz Dorantes 	"Link Supervision Timeout Changed",
56240c666a5SOliver Ruiz Dorantes 	"Enhanced Flush Complete",
563d081e691SOliver Ruiz Dorantes 	"Reserved",
564d081e691SOliver Ruiz Dorantes 	"Reserved",
56540c666a5SOliver Ruiz Dorantes 	"Keypress Notification",
56640c666a5SOliver Ruiz Dorantes 	"Remote Host Supported Features Notification"
567d081e691SOliver Ruiz Dorantes };
568d081e691SOliver Ruiz Dorantes 
569d081e691SOliver Ruiz Dorantes 
570880e5727SOliver Ruiz Dorantes const char* bluetoothErrors[] = {
57140c666a5SOliver Ruiz Dorantes 	"No Error",
57240c666a5SOliver Ruiz Dorantes 	"Unknown Command",
57340c666a5SOliver Ruiz Dorantes 	"No Connection",
57440c666a5SOliver Ruiz Dorantes 	"Hardware Failure",
57540c666a5SOliver Ruiz Dorantes 	"Page Timeout",
57640c666a5SOliver Ruiz Dorantes 	"Authentication Failure",
57740c666a5SOliver Ruiz Dorantes 	"Pin Or Key Missing",
57840c666a5SOliver Ruiz Dorantes 	"Memory Full",
57940c666a5SOliver Ruiz Dorantes 	"Connection Timeout",
58040c666a5SOliver Ruiz Dorantes 	"Max Number Of Connections",
58140c666a5SOliver Ruiz Dorantes 	"Max Number Of Sco Connections",
58240c666a5SOliver Ruiz Dorantes 	"Acl Connection Exists",
58340c666a5SOliver Ruiz Dorantes 	"Command Disallowed",
58440c666a5SOliver Ruiz Dorantes 	"Rejected Limited Resources",
58540c666a5SOliver Ruiz Dorantes 	"Rejected Security",
58640c666a5SOliver Ruiz Dorantes 	"Rejected Personal",
58740c666a5SOliver Ruiz Dorantes 	"Host Timeout",
58840c666a5SOliver Ruiz Dorantes 	"Unsupported Feature",
58940c666a5SOliver Ruiz Dorantes 	"Invalid Parameters",
59040c666a5SOliver Ruiz Dorantes 	"Remote User Ended Connection",
59140c666a5SOliver Ruiz Dorantes 	"Remote Low Resources",
59240c666a5SOliver Ruiz Dorantes 	"Remote Power Off",
59340c666a5SOliver Ruiz Dorantes 	"Connection Terminated",
59440c666a5SOliver Ruiz Dorantes 	"Repeated Attempts",
59540c666a5SOliver Ruiz Dorantes 	"Pairing Not Allowed",
59640c666a5SOliver Ruiz Dorantes 	"Unknown Lmp Pdu",
59740c666a5SOliver Ruiz Dorantes 	"Unsupported Remote Feature",
59840c666a5SOliver Ruiz Dorantes 	"Sco Offset Rejected",
59940c666a5SOliver Ruiz Dorantes 	"Sco Interval Rejected",
60040c666a5SOliver Ruiz Dorantes 	"Air Mode Rejected",
60140c666a5SOliver Ruiz Dorantes 	"Invalid Lmp Parameters",
60240c666a5SOliver Ruiz Dorantes 	"Unspecified Error",
60340c666a5SOliver Ruiz Dorantes 	"Unsupported Lmp Parameter Value",
60440c666a5SOliver Ruiz Dorantes 	"Role Change Not Allowed",
60540c666a5SOliver Ruiz Dorantes 	"Lmp Response Timeout",
60640c666a5SOliver Ruiz Dorantes 	"Lmp Error Transaction Collision",
60740c666a5SOliver Ruiz Dorantes 	"Lmp Pdu Not Allowed",
60840c666a5SOliver Ruiz Dorantes 	"Encryption Mode Not Accepted",
60940c666a5SOliver Ruiz Dorantes 	"Unit Link Key Used",
61040c666a5SOliver Ruiz Dorantes 	"Qos Not Supported",
61140c666a5SOliver Ruiz Dorantes 	"Instant Passed",
61240c666a5SOliver Ruiz Dorantes 	"Pairing With Unit Key Not Supported",
61340c666a5SOliver Ruiz Dorantes 	"Different Transaction Collision",
61440c666a5SOliver Ruiz Dorantes 	"Qos Unacceptable Parameter",
61540c666a5SOliver Ruiz Dorantes 	"Qos Rejected",
61640c666a5SOliver Ruiz Dorantes 	"Classification Not Supported",
61740c666a5SOliver Ruiz Dorantes 	"Insufficient Security",
61840c666a5SOliver Ruiz Dorantes 	"Parameter Out Of Range",
619880e5727SOliver Ruiz Dorantes 	"Reserved",
62040c666a5SOliver Ruiz Dorantes 	"Role Switch Pending",
621880e5727SOliver Ruiz Dorantes 	"Reserved",
62240c666a5SOliver Ruiz Dorantes 	"Slot Violation",
62340c666a5SOliver Ruiz Dorantes 	"Role Switch Failed",
62440c666a5SOliver Ruiz Dorantes 	"Extended Inquiry Response Too Large",
62540c666a5SOliver Ruiz Dorantes 	"Simple Pairing Not Supported By Host",
62640c666a5SOliver Ruiz Dorantes 	"Host Busy Pairing"
627880e5727SOliver Ruiz Dorantes };
628880e5727SOliver Ruiz Dorantes 
629880e5727SOliver Ruiz Dorantes 
630*31fd7cccSAlexander von Gluck IV const char* hciVersion[] = { "1.0B" , "1.1" , "1.2" , "2.0" , "2.1",
631*31fd7cccSAlexander von Gluck IV 	"3.0", "4.0", "4.1", "4.2", "5.0", "5.1", "5.2"};
632*31fd7cccSAlexander von Gluck IV const char* lmpVersion[] = { "1.0" , "1.1" , "1.2" , "2.0" , "2.1",
633*31fd7cccSAlexander von Gluck IV 	"3.0", "4.0", "4.1", "4.2", "5.0", "5.1", "5.2"};
634bd88ac97SOliver Ruiz Dorantes 
63540c666a5SOliver Ruiz Dorantes #if 0
63640c666a5SOliver Ruiz Dorantes #pragma mark -
63740c666a5SOliver Ruiz Dorantes #endif
63840c666a5SOliver Ruiz Dorantes 
63940c666a5SOliver Ruiz Dorantes 
640bd88ac97SOliver Ruiz Dorantes const char*
BluetoothHciVersion(uint16 ver)641ddac4074SOliver Ruiz Dorantes BluetoothHciVersion(uint16 ver)
642bd88ac97SOliver Ruiz Dorantes {
643fef016caSFredrik Modéen 	CALLED();
644bd88ac97SOliver Ruiz Dorantes 	return hciVersion[ver];
645bd88ac97SOliver Ruiz Dorantes }
646bd88ac97SOliver Ruiz Dorantes 
647bd88ac97SOliver Ruiz Dorantes 
648bd88ac97SOliver Ruiz Dorantes const char*
BluetoothLmpVersion(uint16 ver)649ddac4074SOliver Ruiz Dorantes BluetoothLmpVersion(uint16 ver)
650bd88ac97SOliver Ruiz Dorantes {
651fef016caSFredrik Modéen 	CALLED();
652bd88ac97SOliver Ruiz Dorantes 	return lmpVersion[ver];
653bd88ac97SOliver Ruiz Dorantes }
654bd88ac97SOliver Ruiz Dorantes 
655bd88ac97SOliver Ruiz Dorantes 
656a7c3c465SOliver Ruiz Dorantes const char*
BluetoothCommandOpcode(uint16 opcode)657ddac4074SOliver Ruiz Dorantes BluetoothCommandOpcode(uint16 opcode)
658a7c3c465SOliver Ruiz Dorantes {
659fef016caSFredrik Modéen 	CALLED();
660ddac4074SOliver Ruiz Dorantes 	// NOTE: BT implementations beyond 2.1
661a7c3c465SOliver Ruiz Dorantes 	// could specify new commands with OCF numbers
662a7c3c465SOliver Ruiz Dorantes 	// beyond the boundaries of the arrays and crash.
663a7c3c465SOliver Ruiz Dorantes 	// But only our stack could issue them so its under
664a7c3c465SOliver Ruiz Dorantes 	// our control.
665ddac4074SOliver Ruiz Dorantes 	switch (GET_OPCODE_OGF(opcode)) {
666a7c3c465SOliver Ruiz Dorantes 		case OGF_LINK_CONTROL:
667ddac4074SOliver Ruiz Dorantes 			return linkControlCommands[GET_OPCODE_OCF(opcode) - 1];
668a7c3c465SOliver Ruiz Dorantes 			break;
669a7c3c465SOliver Ruiz Dorantes 
670a7c3c465SOliver Ruiz Dorantes 		case OGF_LINK_POLICY:
671ddac4074SOliver Ruiz Dorantes 			return linkPolicyCommands[GET_OPCODE_OCF(opcode) - 1];
672a7c3c465SOliver Ruiz Dorantes 			break;
673a7c3c465SOliver Ruiz Dorantes 
674a7c3c465SOliver Ruiz Dorantes 		case OGF_CONTROL_BASEBAND:
675ddac4074SOliver Ruiz Dorantes 			return controllerBasebandCommands[GET_OPCODE_OCF(opcode) - 1];
676a7c3c465SOliver Ruiz Dorantes 			break;
677a7c3c465SOliver Ruiz Dorantes 
678a7c3c465SOliver Ruiz Dorantes 		case OGF_INFORMATIONAL_PARAM:
679ddac4074SOliver Ruiz Dorantes 			return informationalParametersCommands[GET_OPCODE_OCF(opcode) - 1];
680a7c3c465SOliver Ruiz Dorantes 			break;
681a7c3c465SOliver Ruiz Dorantes 
682a7c3c465SOliver Ruiz Dorantes 		case OGF_STATUS_PARAM:
683ddac4074SOliver Ruiz Dorantes 			return statusParametersCommands[GET_OPCODE_OCF(opcode) - 1];
684a7c3c465SOliver Ruiz Dorantes 			break;
685a7c3c465SOliver Ruiz Dorantes 
686a7c3c465SOliver Ruiz Dorantes 		case OGF_TESTING_CMD:
687ddac4074SOliver Ruiz Dorantes 			return testingCommands[GET_OPCODE_OCF(opcode) - 1];
688a7c3c465SOliver Ruiz Dorantes 			break;
6890b5931e0SOliver Ruiz Dorantes 		case OGF_VENDOR_CMD:
6900b5931e0SOliver Ruiz Dorantes 			return "Vendor specific command";
6910b5931e0SOliver Ruiz Dorantes 			break;
692a7c3c465SOliver Ruiz Dorantes 		default:
693a7c3c465SOliver Ruiz Dorantes 			return "Unknown command";
694a7c3c465SOliver Ruiz Dorantes 			break;
695a7c3c465SOliver Ruiz Dorantes 	}
696a7c3c465SOliver Ruiz Dorantes 
697a7c3c465SOliver Ruiz Dorantes }
698a7c3c465SOliver Ruiz Dorantes 
699a7c3c465SOliver Ruiz Dorantes 
700a7c3c465SOliver Ruiz Dorantes const char*
BluetoothEvent(uint8 event)70140c666a5SOliver Ruiz Dorantes BluetoothEvent(uint8 event)
70240c666a5SOliver Ruiz Dorantes {
703fef016caSFredrik Modéen 	CALLED();
70440c666a5SOliver Ruiz Dorantes 	if (event < sizeof(bluetoothEvents) / sizeof(const char*))
705d081e691SOliver Ruiz Dorantes 		return bluetoothEvents[event - 1];
70640c666a5SOliver Ruiz Dorantes 	else
70740c666a5SOliver Ruiz Dorantes 		return "Event out of Range!";
708d081e691SOliver Ruiz Dorantes }
709d081e691SOliver Ruiz Dorantes 
710d081e691SOliver Ruiz Dorantes 
711d081e691SOliver Ruiz Dorantes const char*
BluetoothManufacturer(uint16 manufacturer)71240c666a5SOliver Ruiz Dorantes BluetoothManufacturer(uint16 manufacturer)
71340c666a5SOliver Ruiz Dorantes {
714fef016caSFredrik Modéen 	CALLED();
71540c666a5SOliver Ruiz Dorantes 	if (manufacturer < sizeof(bluetoothManufacturers) / sizeof(const char*))
716a7c3c465SOliver Ruiz Dorantes 		return bluetoothManufacturers[manufacturer];
71740c666a5SOliver Ruiz Dorantes 	else if (manufacturer == 0xFFFF)
718a7c3c465SOliver Ruiz Dorantes 		return "internal use";
71940c666a5SOliver Ruiz Dorantes 	else
720a7c3c465SOliver Ruiz Dorantes 		return "not assigned";
721a7c3c465SOliver Ruiz Dorantes }
722880e5727SOliver Ruiz Dorantes 
723880e5727SOliver Ruiz Dorantes 
724880e5727SOliver Ruiz Dorantes const char*
BluetoothError(uint8 error)72540c666a5SOliver Ruiz Dorantes BluetoothError(uint8 error)
72640c666a5SOliver Ruiz Dorantes {
727fef016caSFredrik Modéen 	CALLED();
72840c666a5SOliver Ruiz Dorantes 	if (error < sizeof(bluetoothErrors) / sizeof(const char*))
729880e5727SOliver Ruiz Dorantes 		return bluetoothErrors[error];
73040c666a5SOliver Ruiz Dorantes 	else
731880e5727SOliver Ruiz Dorantes 		return "not specified";
732880e5727SOliver Ruiz Dorantes }
733