xref: /haiku/src/kits/bluetooth/CommandManager.cpp (revision 7a74a5df454197933bc6e80a542102362ee98703)
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 #include "CommandManager.h"
832c01b55SOliver Ruiz Dorantes 
940c666a5SOliver Ruiz Dorantes 
1040c666a5SOliver Ruiz Dorantes #include <bluetooth/bluetooth_error.h>
1140c666a5SOliver Ruiz Dorantes 
1240c666a5SOliver Ruiz Dorantes inline void* buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize,
1340c666a5SOliver Ruiz Dorantes 	size_t* outsize)
1432c01b55SOliver Ruiz Dorantes {
1532c01b55SOliver Ruiz Dorantes 	struct hci_command_header* header;
1632c01b55SOliver Ruiz Dorantes 
1732c01b55SOliver Ruiz Dorantes #ifdef BT_IOCTLS_PASS_SIZE
1840c666a5SOliver Ruiz Dorantes 	header = (struct hci_command_header*) malloc(psize
1940c666a5SOliver Ruiz Dorantes 		+ sizeof(struct hci_command_header));
2032c01b55SOliver Ruiz Dorantes 	*outsize = psize + sizeof(struct hci_command_header);
2132c01b55SOliver Ruiz Dorantes #else
2240c666a5SOliver Ruiz Dorantes 	size_t* size = (size_t*)malloc(psize + sizeof(struct hci_command_header)
2340c666a5SOliver Ruiz Dorantes 		+ sizeof(size_t));
2432c01b55SOliver Ruiz Dorantes 	*outsize = psize + sizeof(struct hci_command_header) + sizeof(size_t);
2532c01b55SOliver Ruiz Dorantes 
2632c01b55SOliver Ruiz Dorantes 	*size = psize + sizeof(struct hci_command_header);
2732c01b55SOliver Ruiz Dorantes 	header = (struct hci_command_header*) (((uint8*)size)+4);
2832c01b55SOliver Ruiz Dorantes #endif
2932c01b55SOliver Ruiz Dorantes 
3032c01b55SOliver Ruiz Dorantes 
3132c01b55SOliver Ruiz Dorantes 	if (header != NULL) {
3232c01b55SOliver Ruiz Dorantes 
3332c01b55SOliver Ruiz Dorantes 		header->opcode = B_HOST_TO_LENDIAN_INT16(PACK_OPCODE(ogf, ocf));
3432c01b55SOliver Ruiz Dorantes 		header->clen = psize;
3532c01b55SOliver Ruiz Dorantes 
3632c01b55SOliver Ruiz Dorantes 		if (param != NULL && psize != 0) {
3732c01b55SOliver Ruiz Dorantes 			*param = ((uint8*)header) + sizeof(struct hci_command_header);
3832c01b55SOliver Ruiz Dorantes 		}
3932c01b55SOliver Ruiz Dorantes 	}
4032c01b55SOliver Ruiz Dorantes #ifdef BT_IOCTLS_PASS_SIZE
4132c01b55SOliver Ruiz Dorantes 	return header;
4232c01b55SOliver Ruiz Dorantes #else
4332c01b55SOliver Ruiz Dorantes 	return (void*)size;
4432c01b55SOliver Ruiz Dorantes #endif
4532c01b55SOliver Ruiz Dorantes }
4632c01b55SOliver Ruiz Dorantes 
4732c01b55SOliver Ruiz Dorantes 
4840c666a5SOliver Ruiz Dorantes // This is for request that only require a Command complete in reply.
4940c666a5SOliver Ruiz Dorantes 
5040c666a5SOliver Ruiz Dorantes // Propagate to ReadBufferSize => reply stored in server side
5140c666a5SOliver Ruiz Dorantes // ReadLocalVersion => reply stored in server side
5240c666a5SOliver Ruiz Dorantes // Reset => no reply
5340c666a5SOliver Ruiz Dorantes 
5440c666a5SOliver Ruiz Dorantes // Request that do not need any input parameter
5540c666a5SOliver Ruiz Dorantes // Output reply can be fit in 32 bits field without talking status into account
5640c666a5SOliver Ruiz Dorantes status_t
5740c666a5SOliver Ruiz Dorantes NonParameterCommandRequest(uint8 ofg, uint8 ocf, int32* result, hci_id hId,
5840c666a5SOliver Ruiz Dorantes 	BMessenger* messenger)
5940c666a5SOliver Ruiz Dorantes {
6040c666a5SOliver Ruiz Dorantes 	int8 bt_status = BT_ERROR;
6140c666a5SOliver Ruiz Dorantes 
6240c666a5SOliver Ruiz Dorantes 	BluetoothCommand<> simpleCommand(ofg, ocf);
6340c666a5SOliver Ruiz Dorantes 
6440c666a5SOliver Ruiz Dorantes 	BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
6540c666a5SOliver Ruiz Dorantes 	BMessage reply;
6640c666a5SOliver Ruiz Dorantes 
6740c666a5SOliver Ruiz Dorantes 	request.AddInt32("hci_id", hId);
6840c666a5SOliver Ruiz Dorantes 	request.AddData("raw command", B_ANY_TYPE,
6940c666a5SOliver Ruiz Dorantes 		simpleCommand.Data(), simpleCommand.Size());
7040c666a5SOliver Ruiz Dorantes 	request.AddInt16("eventExpected",  HCI_EVENT_CMD_COMPLETE);
7140c666a5SOliver Ruiz Dorantes 	request.AddInt16("opcodeExpected", PACK_OPCODE(ofg, ocf));
7240c666a5SOliver Ruiz Dorantes 
7340c666a5SOliver Ruiz Dorantes 	if (messenger->SendMessage(&request, &reply) == B_OK) {
7440c666a5SOliver Ruiz Dorantes 		reply.FindInt8("status", &bt_status);
7540c666a5SOliver Ruiz Dorantes 		if (result != NULL)
7640c666a5SOliver Ruiz Dorantes 			reply.FindInt32("result", result);
7740c666a5SOliver Ruiz Dorantes 	}
7840c666a5SOliver Ruiz Dorantes 
7940c666a5SOliver Ruiz Dorantes 	return bt_status;
8040c666a5SOliver Ruiz Dorantes }
8140c666a5SOliver Ruiz Dorantes 
8240c666a5SOliver Ruiz Dorantes 
8332c01b55SOliver Ruiz Dorantes #if 0
8432c01b55SOliver Ruiz Dorantes #pragma mark - CONTROL BASEBAND -
8532c01b55SOliver Ruiz Dorantes #endif
8632c01b55SOliver Ruiz Dorantes 
8732c01b55SOliver Ruiz Dorantes 
8832c01b55SOliver Ruiz Dorantes void* buildReset(size_t* outsize)
8932c01b55SOliver Ruiz Dorantes {
9040c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET,
9140c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
9232c01b55SOliver Ruiz Dorantes }
9332c01b55SOliver Ruiz Dorantes 
9432c01b55SOliver Ruiz Dorantes 
9532c01b55SOliver Ruiz Dorantes void* buildReadLocalName(size_t* outsize)
9632c01b55SOliver Ruiz Dorantes {
9740c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME,
9840c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
9932c01b55SOliver Ruiz Dorantes }
10032c01b55SOliver Ruiz Dorantes 
10132c01b55SOliver Ruiz Dorantes 
102a2f8edf7SOliver Ruiz Dorantes void* buildReadClassOfDevice(size_t* outsize)
103a2f8edf7SOliver Ruiz Dorantes {
10440c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV,
10540c666a5SOliver Ruiz Dorantes 	NULL, 0, outsize);
106a2f8edf7SOliver Ruiz Dorantes }
107a2f8edf7SOliver Ruiz Dorantes 
108a2f8edf7SOliver Ruiz Dorantes 
109*7a74a5dfSFredrik Modéen void* buildReadScan(size_t* outsize)
110*7a74a5dfSFredrik Modéen {
111*7a74a5dfSFredrik Modéen 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE,
112*7a74a5dfSFredrik Modéen 	NULL, 0, outsize);
113*7a74a5dfSFredrik Modéen }
114*7a74a5dfSFredrik Modéen 
115*7a74a5dfSFredrik Modéen 
116631aa548SOliver Ruiz Dorantes void* buildWriteScan(uint8 scanmode, size_t* outsize)
117631aa548SOliver Ruiz Dorantes {
118631aa548SOliver Ruiz Dorantes 	struct hci_write_scan_enable* param;
11940c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE,
12040c666a5SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_write_scan_enable), outsize);
121631aa548SOliver Ruiz Dorantes 
122631aa548SOliver Ruiz Dorantes 
123631aa548SOliver Ruiz Dorantes 	if (command != NULL) {
124631aa548SOliver Ruiz Dorantes 		param->scan = scanmode;
125631aa548SOliver Ruiz Dorantes 	}
126631aa548SOliver Ruiz Dorantes 
127631aa548SOliver Ruiz Dorantes 	return command;
128631aa548SOliver Ruiz Dorantes }
129631aa548SOliver Ruiz Dorantes 
130631aa548SOliver Ruiz Dorantes 
13132c01b55SOliver Ruiz Dorantes #if 0
13232c01b55SOliver Ruiz Dorantes #pragma mark - LINK CONTROL -
13332c01b55SOliver Ruiz Dorantes #endif
13432c01b55SOliver Ruiz Dorantes 
1357434b760SOliver Ruiz Dorantes 
13640c666a5SOliver Ruiz Dorantes void* buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode,
13740c666a5SOliver Ruiz Dorantes 	uint16 clock_offset, size_t* outsize)
13832c01b55SOliver Ruiz Dorantes {
13932c01b55SOliver Ruiz Dorantes 
14032c01b55SOliver Ruiz Dorantes 	struct hci_remote_name_request* param;
14140c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST,
14240c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_remote_name_request), outsize);
14332c01b55SOliver Ruiz Dorantes 
14432c01b55SOliver Ruiz Dorantes 	if (command != NULL) {
14532c01b55SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
14632c01b55SOliver Ruiz Dorantes 		param->pscan_rep_mode = pscan_rep_mode;
14732c01b55SOliver Ruiz Dorantes 		param->clock_offset = clock_offset;
14832c01b55SOliver Ruiz Dorantes 	}
14932c01b55SOliver Ruiz Dorantes 
15032c01b55SOliver Ruiz Dorantes 	return command;
15132c01b55SOliver Ruiz Dorantes }
15232c01b55SOliver Ruiz Dorantes 
15332c01b55SOliver Ruiz Dorantes 
15432c01b55SOliver Ruiz Dorantes void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
15532c01b55SOliver Ruiz Dorantes {
15632c01b55SOliver Ruiz Dorantes 
15732c01b55SOliver Ruiz Dorantes 	struct hci_cp_inquiry* param;
15840c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY,
15940c666a5SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_inquiry), outsize);
16032c01b55SOliver Ruiz Dorantes 
16132c01b55SOliver Ruiz Dorantes 	if (command != NULL) {
16232c01b55SOliver Ruiz Dorantes 
16332c01b55SOliver Ruiz Dorantes 		param->lap[2] = (lap >> 16) & 0xFF;
16432c01b55SOliver Ruiz Dorantes 		param->lap[1] = (lap >>  8) & 0xFF;
16532c01b55SOliver Ruiz Dorantes 		param->lap[0] = (lap >>  0) & 0xFF;
16632c01b55SOliver Ruiz Dorantes 		param->length = length;
16732c01b55SOliver Ruiz Dorantes 		param->num_rsp = num_rsp;
168350458a6SOliver Ruiz Dorantes 	}
169350458a6SOliver Ruiz Dorantes 
170350458a6SOliver Ruiz Dorantes 	return command;
171350458a6SOliver Ruiz Dorantes }
172350458a6SOliver Ruiz Dorantes 
1737434b760SOliver Ruiz Dorantes 
174350458a6SOliver Ruiz Dorantes void* buildInquiryCancel(size_t* outsize)
175350458a6SOliver Ruiz Dorantes {
176350458a6SOliver Ruiz Dorantes 
177350458a6SOliver Ruiz Dorantes 	return buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL, NULL, 0, outsize);
178350458a6SOliver Ruiz Dorantes 
179350458a6SOliver Ruiz Dorantes }
180350458a6SOliver Ruiz Dorantes 
181350458a6SOliver Ruiz Dorantes 
18240c666a5SOliver Ruiz Dorantes void* buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16],
18340c666a5SOliver Ruiz Dorantes 	size_t* outsize)
184350458a6SOliver Ruiz Dorantes {
185350458a6SOliver Ruiz Dorantes 	struct hci_cp_pin_code_reply* param;
186350458a6SOliver Ruiz Dorantes 
187350458a6SOliver Ruiz Dorantes 	if (length > HCI_PIN_SIZE)  // PinCode cannot be longer than 16
188350458a6SOliver Ruiz Dorantes 		return NULL;
189350458a6SOliver Ruiz Dorantes 
19040c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_REPLY,
19140c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_cp_pin_code_reply), outsize);
192350458a6SOliver Ruiz Dorantes 
193350458a6SOliver Ruiz Dorantes 	if (command != NULL) {
194350458a6SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
195350458a6SOliver Ruiz Dorantes 		param->pin_len = length;
196350458a6SOliver Ruiz Dorantes 		memcpy(&param->pin_code, pincode, length);
197350458a6SOliver Ruiz Dorantes 	}
198350458a6SOliver Ruiz Dorantes 
199350458a6SOliver Ruiz Dorantes 	return command;
200350458a6SOliver Ruiz Dorantes }
201350458a6SOliver Ruiz Dorantes 
202350458a6SOliver Ruiz Dorantes 
2030df89492SOliver Ruiz Dorantes void* buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize)
204350458a6SOliver Ruiz Dorantes {
205350458a6SOliver Ruiz Dorantes 
206350458a6SOliver Ruiz Dorantes 	struct hci_cp_pin_code_neg_reply* param;
207350458a6SOliver Ruiz Dorantes 
208350458a6SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY,
209350458a6SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_pin_code_neg_reply), outsize);
210350458a6SOliver Ruiz Dorantes 
211350458a6SOliver Ruiz Dorantes 	if (command != NULL) {
212350458a6SOliver Ruiz Dorantes 
213350458a6SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
214350458a6SOliver Ruiz Dorantes 
21532c01b55SOliver Ruiz Dorantes 	}
21632c01b55SOliver Ruiz Dorantes 
21732c01b55SOliver Ruiz Dorantes 	return command;
21832c01b55SOliver Ruiz Dorantes }
21932c01b55SOliver Ruiz Dorantes 
22032c01b55SOliver Ruiz Dorantes 
2217434b760SOliver Ruiz Dorantes void* buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize)
2227434b760SOliver Ruiz Dorantes {
2237434b760SOliver Ruiz Dorantes 	struct hci_cp_accept_conn_req* param;
2247434b760SOliver Ruiz Dorantes 
2257434b760SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_ACCEPT_CONN_REQ,
2267434b760SOliver Ruiz Dorantes 					(void**) &param, sizeof(struct hci_cp_accept_conn_req), outsize);
2277434b760SOliver Ruiz Dorantes 
2287434b760SOliver Ruiz Dorantes 	if (command != NULL) {
2297434b760SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
2307434b760SOliver Ruiz Dorantes 		param->role = role;
2317434b760SOliver Ruiz Dorantes 	}
2327434b760SOliver Ruiz Dorantes 
2337434b760SOliver Ruiz Dorantes 	return command;
2347434b760SOliver Ruiz Dorantes }
2357434b760SOliver Ruiz Dorantes 
2367434b760SOliver Ruiz Dorantes 
2377434b760SOliver Ruiz Dorantes void* buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize)
2387434b760SOliver Ruiz Dorantes {
2397434b760SOliver Ruiz Dorantes 	struct hci_cp_reject_conn_req* param;
2407434b760SOliver Ruiz Dorantes 
2417434b760SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ,
24240c666a5SOliver Ruiz Dorantes 					(void**)&param, sizeof(struct hci_cp_reject_conn_req),
24340c666a5SOliver Ruiz Dorantes 					outsize);
2447434b760SOliver Ruiz Dorantes 
2457434b760SOliver Ruiz Dorantes 	if (command != NULL) {
2467434b760SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
2477434b760SOliver Ruiz Dorantes 	}
2487434b760SOliver Ruiz Dorantes 
2497434b760SOliver Ruiz Dorantes 	return command;
2507434b760SOliver Ruiz Dorantes }
2517434b760SOliver Ruiz Dorantes 
2527434b760SOliver Ruiz Dorantes 
25332c01b55SOliver Ruiz Dorantes #if 0
25432c01b55SOliver Ruiz Dorantes #pragma mark - INFORMATIONAL_PARAM -
25532c01b55SOliver Ruiz Dorantes #endif
25632c01b55SOliver Ruiz Dorantes 
257b44ee583SOliver Ruiz Dorantes void* buildReadLocalVersionInformation(size_t* outsize)
258b44ee583SOliver Ruiz Dorantes {
25940c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION,
26040c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
261b44ee583SOliver Ruiz Dorantes }
262b44ee583SOliver Ruiz Dorantes 
26332c01b55SOliver Ruiz Dorantes 
26432c01b55SOliver Ruiz Dorantes void* buildReadBufferSize(size_t* outsize)
26532c01b55SOliver Ruiz Dorantes {
26640c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE,
26740c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
26832c01b55SOliver Ruiz Dorantes }
26932c01b55SOliver Ruiz Dorantes 
27032c01b55SOliver Ruiz Dorantes 
27132c01b55SOliver Ruiz Dorantes void* buildReadBdAddr(size_t* outsize)
27232c01b55SOliver Ruiz Dorantes {
27340c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR,
27440c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
27532c01b55SOliver Ruiz Dorantes }
276631aa548SOliver Ruiz Dorantes 
277631aa548SOliver Ruiz Dorantes 
278a7c3c465SOliver Ruiz Dorantes const char* bluetoothManufacturers[] = {
279a7c3c465SOliver Ruiz Dorantes 	"Ericsson Technology Licensing",
280a7c3c465SOliver Ruiz Dorantes 	"Nokia Mobile Phones",
281a7c3c465SOliver Ruiz Dorantes 	"Intel Corp.",
282a7c3c465SOliver Ruiz Dorantes 	"IBM Corp.",
283a7c3c465SOliver Ruiz Dorantes 	"Toshiba Corp.",
284a7c3c465SOliver Ruiz Dorantes 	"3Com",
285a7c3c465SOliver Ruiz Dorantes 	"Microsoft",
286a7c3c465SOliver Ruiz Dorantes 	"Lucent",
287a7c3c465SOliver Ruiz Dorantes 	"Motorola",
288a7c3c465SOliver Ruiz Dorantes 	"Infineon Technologies AG",
289a7c3c465SOliver Ruiz Dorantes 	"Cambridge Silicon Radio",
290a7c3c465SOliver Ruiz Dorantes 	"Silicon Wave",
291a7c3c465SOliver Ruiz Dorantes 	"Digianswer A/S",
292a7c3c465SOliver Ruiz Dorantes 	"Texas Instruments Inc.",
293a7c3c465SOliver Ruiz Dorantes 	"Parthus Technologies Inc.",
294a7c3c465SOliver Ruiz Dorantes 	"Broadcom Corporation",
295a7c3c465SOliver Ruiz Dorantes 	"Mitel Semiconductor",
296a7c3c465SOliver Ruiz Dorantes 	"Widcomm, Inc.",
297a7c3c465SOliver Ruiz Dorantes 	"Zeevo, Inc.",
298a7c3c465SOliver Ruiz Dorantes 	"Atmel Corporation",
299a7c3c465SOliver Ruiz Dorantes 	"Mitsubishi Electric Corporation",
300a7c3c465SOliver Ruiz Dorantes 	"RTX Telecom A/S",
301a7c3c465SOliver Ruiz Dorantes 	"KC Technology Inc.",
302a7c3c465SOliver Ruiz Dorantes 	"Newlogic",
303a7c3c465SOliver Ruiz Dorantes 	"Transilica, Inc.",
304a7c3c465SOliver Ruiz Dorantes 	"Rohde & Schwartz GmbH & Co. KG",
305a7c3c465SOliver Ruiz Dorantes 	"TTPCom Limited",
306a7c3c465SOliver Ruiz Dorantes 	"Signia Technologies, Inc.",
307a7c3c465SOliver Ruiz Dorantes 	"Conexant Systems Inc.",
308a7c3c465SOliver Ruiz Dorantes 	"Qualcomm",
309a7c3c465SOliver Ruiz Dorantes 	"Inventel",
310a7c3c465SOliver Ruiz Dorantes 	"AVM Berlin",
311a7c3c465SOliver Ruiz Dorantes 	"BandSpeed, Inc.",
312a7c3c465SOliver Ruiz Dorantes 	"Mansella Ltd",
313a7c3c465SOliver Ruiz Dorantes 	"NEC Corporation",
314a7c3c465SOliver Ruiz Dorantes 	"WavePlus Technology Co., Ltd.",
315a7c3c465SOliver Ruiz Dorantes 	"Alcatel",
316a7c3c465SOliver Ruiz Dorantes 	"Philips Semiconductors",
317a7c3c465SOliver Ruiz Dorantes 	"C Technologies",
318a7c3c465SOliver Ruiz Dorantes 	"Open Interface",
319a7c3c465SOliver Ruiz Dorantes 	"R F Micro Devices",
320a7c3c465SOliver Ruiz Dorantes 	"Hitachi Ltd",
321a7c3c465SOliver Ruiz Dorantes 	"Symbol Technologies, Inc.",
322a7c3c465SOliver Ruiz Dorantes 	"Tenovis",
323a7c3c465SOliver Ruiz Dorantes 	"Macronix International Co. Ltd.",
324a7c3c465SOliver Ruiz Dorantes 	"GCT Semiconductor",
325a7c3c465SOliver Ruiz Dorantes 	"Norwood Systems",
326a7c3c465SOliver Ruiz Dorantes 	"MewTel Technology Inc.",
327a7c3c465SOliver Ruiz Dorantes 	"ST Microelectronics",
328a7c3c465SOliver Ruiz Dorantes 	"Synopsys",
329a7c3c465SOliver Ruiz Dorantes 	"Red-M (Communications) Ltd",
330a7c3c465SOliver Ruiz Dorantes 	"Commil Ltd",
331a7c3c465SOliver Ruiz Dorantes 	"Computer Access Technology Corporation (CATC)",
332b3064a44SOliver Ruiz Dorantes 	"Eclipse (HQ España) S.L.",
333a7c3c465SOliver Ruiz Dorantes 	"Renesas Technology Corp.",
334a7c3c465SOliver Ruiz Dorantes 	"Mobilian Corporation",
335a7c3c465SOliver Ruiz Dorantes 	"Terax",
3363c2f52adSOliver Ruiz Dorantes 	"Integrated System Solution Corp.",
337a7c3c465SOliver Ruiz Dorantes 	"Matsushita Electric Industrial Co., Ltd.",
338a7c3c465SOliver Ruiz Dorantes 	"Gennum Corporation",
339a7c3c465SOliver Ruiz Dorantes 	"Research In Motion",
340a7c3c465SOliver Ruiz Dorantes 	"IPextreme, Inc.",
341a7c3c465SOliver Ruiz Dorantes 	"Systems and Chips, Inc",
342a7c3c465SOliver Ruiz Dorantes 	"Bluetooth SIG, Inc",
343a7c3c465SOliver Ruiz Dorantes 	"Seiko Epson Corporation",
344a7c3c465SOliver Ruiz Dorantes 	"Integrated Silicon Solution Taiwain, Inc.",
345a7c3c465SOliver Ruiz Dorantes 	"CONWISE Technology Corporation Ltd",
346b3064a44SOliver Ruiz Dorantes 	"PARROT SA",
347a7c3c465SOliver Ruiz Dorantes 	"Socket Communications",
348a7c3c465SOliver Ruiz Dorantes 	"Atheros Communications, Inc.",
349a7c3c465SOliver Ruiz Dorantes 	"MediaTek, Inc.",
350a7c3c465SOliver Ruiz Dorantes 	"Bluegiga",	/* (tentative) */
351a7c3c465SOliver Ruiz Dorantes 	"Marvell Technology Group Ltd.",
352a7c3c465SOliver Ruiz Dorantes 	"3DSP Corporation",
353a7c3c465SOliver Ruiz Dorantes 	"Accel Semiconductor Ltd.",
354a7c3c465SOliver Ruiz Dorantes 	"Continental Automotive Systems",
355a7c3c465SOliver Ruiz Dorantes 	"Apple, Inc.",
356a7c3c465SOliver Ruiz Dorantes 	"Staccato Communications, Inc."
357a7c3c465SOliver Ruiz Dorantes };
358631aa548SOliver Ruiz Dorantes 
359631aa548SOliver Ruiz Dorantes 
360a7c3c465SOliver Ruiz Dorantes const char* linkControlCommands[] = {
361a7c3c465SOliver Ruiz Dorantes 	"Inquiry",
36240c666a5SOliver Ruiz Dorantes 	"Inquiry Cancel",
36340c666a5SOliver Ruiz Dorantes 	"Periodic Inquiry Mode",
36440c666a5SOliver Ruiz Dorantes 	"Exit Periodic Inquiry Mode",
36540c666a5SOliver Ruiz Dorantes 	"Create Connection",
366a7c3c465SOliver Ruiz Dorantes 	"Disconnect",
36740c666a5SOliver Ruiz Dorantes 	"Add SCO Connection", // not on 2.1
36840c666a5SOliver Ruiz Dorantes 	"Cancel Create Connection",
36940c666a5SOliver Ruiz Dorantes 	"Accept Connection Request",
37040c666a5SOliver Ruiz Dorantes 	"Reject Connection Request",
37140c666a5SOliver Ruiz Dorantes 	"Link Key Request Reply",
37240c666a5SOliver Ruiz Dorantes 	"Link Key Request Negative Reply",
37340c666a5SOliver Ruiz Dorantes 	"PIN Code Request Reply",
37440c666a5SOliver Ruiz Dorantes 	"PIN Code Request Negative Reply",
37540c666a5SOliver Ruiz Dorantes 	"Change Connection Packet Type",
376b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
37740c666a5SOliver Ruiz Dorantes 	"Authentication Requested",
378b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
37940c666a5SOliver Ruiz Dorantes 	"Set Connection Encryption",
380b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
38140c666a5SOliver Ruiz Dorantes 	"Change Connection Link Key",
382b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
38340c666a5SOliver Ruiz Dorantes 	"Master Link Key",
384b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
38540c666a5SOliver Ruiz Dorantes 	"Remote Name Request",
38640c666a5SOliver Ruiz Dorantes 	"Cancel Remote Name Request",
38740c666a5SOliver Ruiz Dorantes 	"Read Remote Supported Features",
38840c666a5SOliver Ruiz Dorantes 	"Read Remote Extended Features",
38940c666a5SOliver Ruiz Dorantes 	"Read Remote Version Information",
390b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
39140c666a5SOliver Ruiz Dorantes 	"Read Clock Offset",
39240c666a5SOliver Ruiz Dorantes 	"Read LMP Handle",
393a7c3c465SOliver Ruiz Dorantes 	"Reserved",
394a7c3c465SOliver Ruiz Dorantes 	"Reserved",
395a7c3c465SOliver Ruiz Dorantes 	"Reserved",
396a7c3c465SOliver Ruiz Dorantes 	"Reserved",
397a7c3c465SOliver Ruiz Dorantes 	"Reserved",
398a7c3c465SOliver Ruiz Dorantes 	"Reserved",
399a7c3c465SOliver Ruiz Dorantes 	"Reserved",
40040c666a5SOliver Ruiz Dorantes 	"Setup Synchronous Connection",
40140c666a5SOliver Ruiz Dorantes 	"Accept Synchronous Connection",
40240c666a5SOliver Ruiz Dorantes 	"Reject Synchronous Connection",
40340c666a5SOliver Ruiz Dorantes 	"IO Capability Request Reply",
40440c666a5SOliver Ruiz Dorantes 	"User Confirmation Request Reply",
40540c666a5SOliver Ruiz Dorantes 	"User Confirmation Request Negative Reply",
40640c666a5SOliver Ruiz Dorantes 	"User Passkey Request Reply",
40740c666a5SOliver Ruiz Dorantes 	"User Passkey Request Negative Reply",
40840c666a5SOliver Ruiz Dorantes 	"Remote OOB Data Request Reply",
409a7c3c465SOliver Ruiz Dorantes 	"Reserved",
410a7c3c465SOliver Ruiz Dorantes 	"Reserved",
41140c666a5SOliver Ruiz Dorantes 	"Remote OOB Data Request Negative Reply",
41240c666a5SOliver Ruiz Dorantes 	"IO Capabilities Response Negative Reply"
413a7c3c465SOliver Ruiz Dorantes };
414a7c3c465SOliver Ruiz Dorantes 
415a7c3c465SOliver Ruiz Dorantes 
416a7c3c465SOliver Ruiz Dorantes const char* linkPolicyCommands[] = {
41740c666a5SOliver Ruiz Dorantes 	"Hold Mode",
418a7c3c465SOliver Ruiz Dorantes 	"Reserved",
41940c666a5SOliver Ruiz Dorantes 	"Sniff Mode",
42040c666a5SOliver Ruiz Dorantes 	"Exit Sniff Mode",
42140c666a5SOliver Ruiz Dorantes 	"Park State",
42240c666a5SOliver Ruiz Dorantes 	"Exit Park State",
42340c666a5SOliver Ruiz Dorantes 	"QoS Setup",
424a7c3c465SOliver Ruiz Dorantes 	"Reserved",
42540c666a5SOliver Ruiz Dorantes 	"Role Discovery",
426a7c3c465SOliver Ruiz Dorantes 	"Reserved",
42740c666a5SOliver Ruiz Dorantes 	"Switch Role",
42840c666a5SOliver Ruiz Dorantes 	"Read Link Policy Settings",
42940c666a5SOliver Ruiz Dorantes 	"Write Link Policy Settings",
43040c666a5SOliver Ruiz Dorantes 	"Read Default Link Policy Settings",
43140c666a5SOliver Ruiz Dorantes 	"Write Default Link Policy Settings",
43240c666a5SOliver Ruiz Dorantes 	"Flow Specification",
43340c666a5SOliver Ruiz Dorantes 	"Sniff Subrating"
434a7c3c465SOliver Ruiz Dorantes };
435a7c3c465SOliver Ruiz Dorantes 
436a7c3c465SOliver Ruiz Dorantes 
437a7c3c465SOliver Ruiz Dorantes const char* controllerBasebandCommands[] = {
43840c666a5SOliver Ruiz Dorantes 	"Set Event Mask",
439a7c3c465SOliver Ruiz Dorantes 	"Reserved",
440a7c3c465SOliver Ruiz Dorantes 	"Reset",
441a7c3c465SOliver Ruiz Dorantes 	"Reserved",
44240c666a5SOliver Ruiz Dorantes 	"Set Event Filter",
443a7c3c465SOliver Ruiz Dorantes 	"Reserved",
444a7c3c465SOliver Ruiz Dorantes 	"Reserved",
445a7c3c465SOliver Ruiz Dorantes 	"Flush",
44640c666a5SOliver Ruiz Dorantes 	"Read PIN Type",
44740c666a5SOliver Ruiz Dorantes 	"Write PIN Type",
44840c666a5SOliver Ruiz Dorantes 	"Create New Unit Key",
449a7c3c465SOliver Ruiz Dorantes 	"Reserved",
45040c666a5SOliver Ruiz Dorantes 	"Read Stored Link Key",
451a7c3c465SOliver Ruiz Dorantes 	"Reserved",
452a7c3c465SOliver Ruiz Dorantes 	"Reserved",
453a7c3c465SOliver Ruiz Dorantes 	"Reserved",
45440c666a5SOliver Ruiz Dorantes 	"Write Stored Link Key",
45540c666a5SOliver Ruiz Dorantes 	"Delete Stored Link Key",
45640c666a5SOliver Ruiz Dorantes 	"Write Local Name",
45740c666a5SOliver Ruiz Dorantes 	"Read Local Name",
45840c666a5SOliver Ruiz Dorantes 	"Read Connection Accept Timeout",
45940c666a5SOliver Ruiz Dorantes 	"Write Connection Accept Timeout",
46040c666a5SOliver Ruiz Dorantes 	"Read Page Timeout",
46140c666a5SOliver Ruiz Dorantes 	"Write Page Timeout",
46240c666a5SOliver Ruiz Dorantes 	"Read Scan Enable",
46340c666a5SOliver Ruiz Dorantes 	"Write Scan Enable",
46440c666a5SOliver Ruiz Dorantes 	"Read Page Scan Activity",
46540c666a5SOliver Ruiz Dorantes 	"Write Page Scan Activity",
46640c666a5SOliver Ruiz Dorantes 	"Read Inquiry Scan Activity",
46740c666a5SOliver Ruiz Dorantes 	"Write Inquiry Scan Activity",
46840c666a5SOliver Ruiz Dorantes 	"Read Authentication Enable",
46940c666a5SOliver Ruiz Dorantes 	"Write Authentication Enable",
47040c666a5SOliver Ruiz Dorantes 	"Read Encryption Mode", // not 2.1
47140c666a5SOliver Ruiz Dorantes 	"Write Encryption Mode",// not 2.1
47240c666a5SOliver Ruiz Dorantes 	"Read Class Of Device",
47340c666a5SOliver Ruiz Dorantes 	"Write Class Of Device",
47440c666a5SOliver Ruiz Dorantes 	"Read Voice Setting",
47540c666a5SOliver Ruiz Dorantes 	"Write Voice Setting",
47640c666a5SOliver Ruiz Dorantes 	"Read Automatic Flush Timeout",
47740c666a5SOliver Ruiz Dorantes 	"Write Automatic Flush Timeout",
47840c666a5SOliver Ruiz Dorantes 	"Read Num Broadcast Retransmissions",
47940c666a5SOliver Ruiz Dorantes 	"Write Num Broadcast Retransmissions",
48040c666a5SOliver Ruiz Dorantes 	"Read Hold Mode Activity",
48140c666a5SOliver Ruiz Dorantes 	"Write Hold Mode Activity",
48240c666a5SOliver Ruiz Dorantes 	"Read Transmit Power Level",
48340c666a5SOliver Ruiz Dorantes 	"Read Synchronous Flow Control Enable",
48440c666a5SOliver Ruiz Dorantes 	"Write Synchronous Flow Control Enable",
485a7c3c465SOliver Ruiz Dorantes 	"Reserved",
48640c666a5SOliver Ruiz Dorantes 	"Set Host Controller To Host Flow Control",
487a7c3c465SOliver Ruiz Dorantes 	"Reserved",
48840c666a5SOliver Ruiz Dorantes 	"Host Buffer Size",
489a7c3c465SOliver Ruiz Dorantes 	"Reserved",
49040c666a5SOliver Ruiz Dorantes 	"Host Number Of Completed Packets",
49140c666a5SOliver Ruiz Dorantes 	"Read Link Supervision Timeout",
49240c666a5SOliver Ruiz Dorantes 	"Write Link Supervision Timeout",
49340c666a5SOliver Ruiz Dorantes 	"Read Number of Supported IAC",
49440c666a5SOliver Ruiz Dorantes 	"Read Current IAC LAP",
49540c666a5SOliver Ruiz Dorantes 	"Write Current IAC LAP",
49640c666a5SOliver Ruiz Dorantes 	"Read Page Scan Period Mode", // not 2.1
49740c666a5SOliver Ruiz Dorantes 	"Write Page Scan Period Mode", // not 2.1
49840c666a5SOliver Ruiz Dorantes 	"Read Page Scan Mode",		// not 2.1
49940c666a5SOliver Ruiz Dorantes 	"Write Page Scan Mode",		// not 2.1
50040c666a5SOliver Ruiz Dorantes 	"Set AFH Channel Classification",
501a7c3c465SOliver Ruiz Dorantes 	"Reserved",
502a7c3c465SOliver Ruiz Dorantes 	"Reserved",
50340c666a5SOliver Ruiz Dorantes 	"Read Inquiry Scan Type",
50440c666a5SOliver Ruiz Dorantes 	"Write Inquiry Scan Type",
50540c666a5SOliver Ruiz Dorantes 	"Read Inquiry Mode",
50640c666a5SOliver Ruiz Dorantes 	"Write Inquiry Mode",
50740c666a5SOliver Ruiz Dorantes 	"Read Page Scan Type",
50840c666a5SOliver Ruiz Dorantes 	"Write Page Scan Type",
50940c666a5SOliver Ruiz Dorantes 	"Read AFH Channel Assessment Mode",
51040c666a5SOliver Ruiz Dorantes 	"Write AFH Channel Assessment Mode",
511a7c3c465SOliver Ruiz Dorantes 	"Reserved",
512a7c3c465SOliver Ruiz Dorantes 	"Reserved",
513a7c3c465SOliver Ruiz Dorantes 	"Reserved",
514a7c3c465SOliver Ruiz Dorantes 	"Reserved",
515a7c3c465SOliver Ruiz Dorantes 	"Reserved",
516a7c3c465SOliver Ruiz Dorantes 	"Reserved",
517a7c3c465SOliver Ruiz Dorantes 	"Reserved",
51840c666a5SOliver Ruiz Dorantes 	"Read Extended Inquiry Response",
51940c666a5SOliver Ruiz Dorantes 	"Write Extended Inquiry Response",
52040c666a5SOliver Ruiz Dorantes 	"Refresh Encryption Key",
521a7c3c465SOliver Ruiz Dorantes 	"Reserved",
52240c666a5SOliver Ruiz Dorantes 	"Read Simple Pairing Mode",
52340c666a5SOliver Ruiz Dorantes 	"Write Simple Pairing Mode",
52440c666a5SOliver Ruiz Dorantes 	"Read Local OOB Data",
52540c666a5SOliver Ruiz Dorantes 	"Read Inquiry Transmit Power Level",
52640c666a5SOliver Ruiz Dorantes 	"Write Inquiry Transmit Power Level",
52740c666a5SOliver Ruiz Dorantes 	"Read Default Erroneous Data Reporting",
52840c666a5SOliver Ruiz Dorantes 	"Write Default Erroneous Data Reporting",
529a7c3c465SOliver Ruiz Dorantes 	"Reserved",
530a7c3c465SOliver Ruiz Dorantes 	"Reserved",
531a7c3c465SOliver Ruiz Dorantes 	"Reserved",
53240c666a5SOliver Ruiz Dorantes 	"Enhanced Flush",
53340c666a5SOliver Ruiz Dorantes 	"Send Keypress Notification"
534a7c3c465SOliver Ruiz Dorantes };
535a7c3c465SOliver Ruiz Dorantes 
536a7c3c465SOliver Ruiz Dorantes 
537a7c3c465SOliver Ruiz Dorantes const char* informationalParametersCommands[] = {
53840c666a5SOliver Ruiz Dorantes 	"Read Local Version Information",
53940c666a5SOliver Ruiz Dorantes 	"Read Local Supported Commands",
54040c666a5SOliver Ruiz Dorantes 	"Read Local Supported Features",
54140c666a5SOliver Ruiz Dorantes 	"Read Local Extended Features",
54240c666a5SOliver Ruiz Dorantes 	"Read Buffer Size",
543a7c3c465SOliver Ruiz Dorantes 	"Reserved",
54440c666a5SOliver Ruiz Dorantes 	"Read Country Code", // not 2.1
545a7c3c465SOliver Ruiz Dorantes 	"Reserved",
546a7c3c465SOliver Ruiz Dorantes 	"Read BD ADDR"
547a7c3c465SOliver Ruiz Dorantes };
548a7c3c465SOliver Ruiz Dorantes 
549a7c3c465SOliver Ruiz Dorantes 
550a7c3c465SOliver Ruiz Dorantes const char* statusParametersCommands[] = {
55140c666a5SOliver Ruiz Dorantes 	"Read Failed Contact Counter",
55240c666a5SOliver Ruiz Dorantes 	"Reset Failed Contact Counter",
55340c666a5SOliver Ruiz Dorantes 	"Read Link Quality",
554a7c3c465SOliver Ruiz Dorantes 	"Reserved",
555a7c3c465SOliver Ruiz Dorantes 	"Read RSSI",
55640c666a5SOliver Ruiz Dorantes 	"Read AFH Channel Map",
55740c666a5SOliver Ruiz Dorantes 	"Read Clock",
558a7c3c465SOliver Ruiz Dorantes };
559a7c3c465SOliver Ruiz Dorantes 
560a7c3c465SOliver Ruiz Dorantes 
561a7c3c465SOliver Ruiz Dorantes const char* testingCommands[] = {
56240c666a5SOliver Ruiz Dorantes 	"Read Loopback Mode",
56340c666a5SOliver Ruiz Dorantes 	"Write Loopback Mode",
56440c666a5SOliver Ruiz Dorantes 	"Enable Device Under Test Mode",
56540c666a5SOliver Ruiz Dorantes 	"Write Simple Pairing Debug Mode",
566a7c3c465SOliver Ruiz Dorantes };
567a7c3c465SOliver Ruiz Dorantes 
568a7c3c465SOliver Ruiz Dorantes 
569d081e691SOliver Ruiz Dorantes const char* bluetoothEvents[] = {
57040c666a5SOliver Ruiz Dorantes 	"Inquiry Complete",
57140c666a5SOliver Ruiz Dorantes 	"Inquiry Result",
57240c666a5SOliver Ruiz Dorantes 	"Conn Complete",
57340c666a5SOliver Ruiz Dorantes 	"Conn Request",
57440c666a5SOliver Ruiz Dorantes 	"Disconnection Complete",
57540c666a5SOliver Ruiz Dorantes 	"Auth Complete",
57640c666a5SOliver Ruiz Dorantes 	"Remote Name Request Complete",
57740c666a5SOliver Ruiz Dorantes 	"Encrypt Change",
57840c666a5SOliver Ruiz Dorantes 	"Change Conn Link Key Complete",
57940c666a5SOliver Ruiz Dorantes 	"Master Link Key Compl",
58040c666a5SOliver Ruiz Dorantes 	"Rmt Features",
58140c666a5SOliver Ruiz Dorantes 	"Rmt Version",
58240c666a5SOliver Ruiz Dorantes 	"Qos Setup Complete",
58340c666a5SOliver Ruiz Dorantes 	"Command Complete",
58440c666a5SOliver Ruiz Dorantes 	"Command Status",
58540c666a5SOliver Ruiz Dorantes 	"Hardware Error",
58640c666a5SOliver Ruiz Dorantes 	"Flush Occur",
58740c666a5SOliver Ruiz Dorantes 	"Role Change",
58840c666a5SOliver Ruiz Dorantes 	"Num Comp Pkts",
58940c666a5SOliver Ruiz Dorantes 	"Mode Change",
59040c666a5SOliver Ruiz Dorantes 	"Return Link Keys",
59140c666a5SOliver Ruiz Dorantes 	"Pin Code Req",
59240c666a5SOliver Ruiz Dorantes 	"Link Key Req",
59340c666a5SOliver Ruiz Dorantes 	"Link Key Notify",
59440c666a5SOliver Ruiz Dorantes 	"Loopback Command",
59540c666a5SOliver Ruiz Dorantes 	"Data Buffer Overflow",
59640c666a5SOliver Ruiz Dorantes 	"Max Slot Change",
59740c666a5SOliver Ruiz Dorantes 	"Read Clock Offset Compl",
59840c666a5SOliver Ruiz Dorantes 	"Con Pkt Type Changed",
59940c666a5SOliver Ruiz Dorantes 	"Qos Violation",
600d081e691SOliver Ruiz Dorantes 	"Reserved",
60140c666a5SOliver Ruiz Dorantes 	"Page Scan Rep Mode Change",
60240c666a5SOliver Ruiz Dorantes 	"Flow Specification",
60340c666a5SOliver Ruiz Dorantes 	"Inquiry Result With Rssi",
60440c666a5SOliver Ruiz Dorantes 	"Remote Extended Features",
605d081e691SOliver Ruiz Dorantes 	"Reserved",
606d081e691SOliver Ruiz Dorantes 	"Reserved",
607d081e691SOliver Ruiz Dorantes 	"Reserved",
608d081e691SOliver Ruiz Dorantes 	"Reserved",
609d081e691SOliver Ruiz Dorantes 	"Reserved",
610d081e691SOliver Ruiz Dorantes 	"Reserved",
611d081e691SOliver Ruiz Dorantes 	"Reserved",
612d081e691SOliver Ruiz Dorantes 	"Reserved",
61340c666a5SOliver Ruiz Dorantes 	"Synchronous Connection Completed",
61440c666a5SOliver Ruiz Dorantes 	"Synchronous Connection Changed",
615d081e691SOliver Ruiz Dorantes 	"Reserved",
61640c666a5SOliver Ruiz Dorantes 	"Extended Inquiry Result",
61740c666a5SOliver Ruiz Dorantes 	"Encryption Key Refresh Complete",
61840c666a5SOliver Ruiz Dorantes 	"Io Capability Request",
61940c666a5SOliver Ruiz Dorantes 	"Io Capability Response",
62040c666a5SOliver Ruiz Dorantes 	"User Confirmation Request",
62140c666a5SOliver Ruiz Dorantes 	"User Passkey Request",
62240c666a5SOliver Ruiz Dorantes 	"Oob Data Request",
62340c666a5SOliver Ruiz Dorantes 	"Simple Pairing Complete",
624d081e691SOliver Ruiz Dorantes 	"Reserved",
62540c666a5SOliver Ruiz Dorantes 	"Link Supervision Timeout Changed",
62640c666a5SOliver Ruiz Dorantes 	"Enhanced Flush Complete",
627d081e691SOliver Ruiz Dorantes 	"Reserved",
628d081e691SOliver Ruiz Dorantes 	"Reserved",
62940c666a5SOliver Ruiz Dorantes 	"Keypress Notification",
63040c666a5SOliver Ruiz Dorantes 	"Remote Host Supported Features Notification"
631d081e691SOliver Ruiz Dorantes };
632d081e691SOliver Ruiz Dorantes 
633d081e691SOliver Ruiz Dorantes 
634880e5727SOliver Ruiz Dorantes const char* bluetoothErrors[] = {
63540c666a5SOliver Ruiz Dorantes 	"No Error",
63640c666a5SOliver Ruiz Dorantes 	"Unknown Command",
63740c666a5SOliver Ruiz Dorantes 	"No Connection",
63840c666a5SOliver Ruiz Dorantes 	"Hardware Failure",
63940c666a5SOliver Ruiz Dorantes 	"Page Timeout",
64040c666a5SOliver Ruiz Dorantes 	"Authentication Failure",
64140c666a5SOliver Ruiz Dorantes 	"Pin Or Key Missing",
64240c666a5SOliver Ruiz Dorantes 	"Memory Full",
64340c666a5SOliver Ruiz Dorantes 	"Connection Timeout",
64440c666a5SOliver Ruiz Dorantes 	"Max Number Of Connections",
64540c666a5SOliver Ruiz Dorantes 	"Max Number Of Sco Connections",
64640c666a5SOliver Ruiz Dorantes 	"Acl Connection Exists",
64740c666a5SOliver Ruiz Dorantes 	"Command Disallowed",
64840c666a5SOliver Ruiz Dorantes 	"Rejected Limited Resources",
64940c666a5SOliver Ruiz Dorantes 	"Rejected Security",
65040c666a5SOliver Ruiz Dorantes 	"Rejected Personal",
65140c666a5SOliver Ruiz Dorantes 	"Host Timeout",
65240c666a5SOliver Ruiz Dorantes 	"Unsupported Feature",
65340c666a5SOliver Ruiz Dorantes 	"Invalid Parameters",
65440c666a5SOliver Ruiz Dorantes 	"Remote User Ended Connection",
65540c666a5SOliver Ruiz Dorantes 	"Remote Low Resources",
65640c666a5SOliver Ruiz Dorantes 	"Remote Power Off",
65740c666a5SOliver Ruiz Dorantes 	"Connection Terminated",
65840c666a5SOliver Ruiz Dorantes 	"Repeated Attempts",
65940c666a5SOliver Ruiz Dorantes 	"Pairing Not Allowed",
66040c666a5SOliver Ruiz Dorantes 	"Unknown Lmp Pdu",
66140c666a5SOliver Ruiz Dorantes 	"Unsupported Remote Feature",
66240c666a5SOliver Ruiz Dorantes 	"Sco Offset Rejected",
66340c666a5SOliver Ruiz Dorantes 	"Sco Interval Rejected",
66440c666a5SOliver Ruiz Dorantes 	"Air Mode Rejected",
66540c666a5SOliver Ruiz Dorantes 	"Invalid Lmp Parameters",
66640c666a5SOliver Ruiz Dorantes 	"Unspecified Error",
66740c666a5SOliver Ruiz Dorantes 	"Unsupported Lmp Parameter Value",
66840c666a5SOliver Ruiz Dorantes 	"Role Change Not Allowed",
66940c666a5SOliver Ruiz Dorantes 	"Lmp Response Timeout",
67040c666a5SOliver Ruiz Dorantes 	"Lmp Error Transaction Collision",
67140c666a5SOliver Ruiz Dorantes 	"Lmp Pdu Not Allowed",
67240c666a5SOliver Ruiz Dorantes 	"Encryption Mode Not Accepted",
67340c666a5SOliver Ruiz Dorantes 	"Unit Link Key Used",
67440c666a5SOliver Ruiz Dorantes 	"Qos Not Supported",
67540c666a5SOliver Ruiz Dorantes 	"Instant Passed",
67640c666a5SOliver Ruiz Dorantes 	"Pairing With Unit Key Not Supported",
67740c666a5SOliver Ruiz Dorantes 	"Different Transaction Collision",
67840c666a5SOliver Ruiz Dorantes 	"Qos Unacceptable Parameter",
67940c666a5SOliver Ruiz Dorantes 	"Qos Rejected",
68040c666a5SOliver Ruiz Dorantes 	"Classification Not Supported",
68140c666a5SOliver Ruiz Dorantes 	"Insufficient Security",
68240c666a5SOliver Ruiz Dorantes 	"Parameter Out Of Range",
683880e5727SOliver Ruiz Dorantes 	"Reserved",
68440c666a5SOliver Ruiz Dorantes 	"Role Switch Pending",
685880e5727SOliver Ruiz Dorantes 	"Reserved",
68640c666a5SOliver Ruiz Dorantes 	"Slot Violation",
68740c666a5SOliver Ruiz Dorantes 	"Role Switch Failed",
68840c666a5SOliver Ruiz Dorantes 	"Extended Inquiry Response Too Large",
68940c666a5SOliver Ruiz Dorantes 	"Simple Pairing Not Supported By Host",
69040c666a5SOliver Ruiz Dorantes 	"Host Busy Pairing"
691880e5727SOliver Ruiz Dorantes };
692880e5727SOliver Ruiz Dorantes 
693880e5727SOliver Ruiz Dorantes 
6948dc33083SOliver Ruiz Dorantes const char* hciVersion[] = { "1.0B" , "1.1 " , "1.2 " , "2.0 " , "2.1 "};
6958dc33083SOliver Ruiz Dorantes const char* lmpVersion[] = { "1.0 " , "1.1 " , "1.2 " , "2.0 " , "2.1 "};
696bd88ac97SOliver Ruiz Dorantes 
697bd88ac97SOliver Ruiz Dorantes 
69840c666a5SOliver Ruiz Dorantes #if 0
69940c666a5SOliver Ruiz Dorantes #pragma mark -
70040c666a5SOliver Ruiz Dorantes #endif
70140c666a5SOliver Ruiz Dorantes 
70240c666a5SOliver Ruiz Dorantes 
703bd88ac97SOliver Ruiz Dorantes const char*
704ddac4074SOliver Ruiz Dorantes BluetoothHciVersion(uint16 ver)
705bd88ac97SOliver Ruiz Dorantes {
706bd88ac97SOliver Ruiz Dorantes 	return hciVersion[ver];
707bd88ac97SOliver Ruiz Dorantes }
708bd88ac97SOliver Ruiz Dorantes 
709bd88ac97SOliver Ruiz Dorantes 
710bd88ac97SOliver Ruiz Dorantes const char*
711ddac4074SOliver Ruiz Dorantes BluetoothLmpVersion(uint16 ver)
712bd88ac97SOliver Ruiz Dorantes {
713bd88ac97SOliver Ruiz Dorantes 	return lmpVersion[ver];
714bd88ac97SOliver Ruiz Dorantes }
715bd88ac97SOliver Ruiz Dorantes 
716bd88ac97SOliver Ruiz Dorantes 
717a7c3c465SOliver Ruiz Dorantes const char*
718ddac4074SOliver Ruiz Dorantes BluetoothCommandOpcode(uint16 opcode)
719a7c3c465SOliver Ruiz Dorantes {
72032261764SOliver Ruiz Dorantes 
721ddac4074SOliver Ruiz Dorantes 	// NOTE: BT implementations beyond 2.1
722a7c3c465SOliver Ruiz Dorantes 	// could specify new commands with OCF numbers
723a7c3c465SOliver Ruiz Dorantes 	// beyond the boundaries of the arrays and crash.
724a7c3c465SOliver Ruiz Dorantes 	// But only our stack could issue them so its under
725a7c3c465SOliver Ruiz Dorantes 	// our control.
726ddac4074SOliver Ruiz Dorantes 	switch (GET_OPCODE_OGF(opcode)) {
727a7c3c465SOliver Ruiz Dorantes 		case OGF_LINK_CONTROL:
728ddac4074SOliver Ruiz Dorantes 			return linkControlCommands[GET_OPCODE_OCF(opcode) - 1];
729a7c3c465SOliver Ruiz Dorantes 			break;
730a7c3c465SOliver Ruiz Dorantes 
731a7c3c465SOliver Ruiz Dorantes 		case OGF_LINK_POLICY:
732ddac4074SOliver Ruiz Dorantes 			return linkPolicyCommands[GET_OPCODE_OCF(opcode) - 1];
733a7c3c465SOliver Ruiz Dorantes 			break;
734a7c3c465SOliver Ruiz Dorantes 
735a7c3c465SOliver Ruiz Dorantes 		case OGF_CONTROL_BASEBAND:
736ddac4074SOliver Ruiz Dorantes 			return controllerBasebandCommands[GET_OPCODE_OCF(opcode) - 1];
737a7c3c465SOliver Ruiz Dorantes 			break;
738a7c3c465SOliver Ruiz Dorantes 
739a7c3c465SOliver Ruiz Dorantes 		case OGF_INFORMATIONAL_PARAM:
740ddac4074SOliver Ruiz Dorantes 			return informationalParametersCommands[GET_OPCODE_OCF(opcode) - 1];
741a7c3c465SOliver Ruiz Dorantes 			break;
742a7c3c465SOliver Ruiz Dorantes 
743a7c3c465SOliver Ruiz Dorantes 		case OGF_STATUS_PARAM:
744ddac4074SOliver Ruiz Dorantes 			return statusParametersCommands[GET_OPCODE_OCF(opcode) - 1];
745a7c3c465SOliver Ruiz Dorantes 			break;
746a7c3c465SOliver Ruiz Dorantes 
747a7c3c465SOliver Ruiz Dorantes 		case OGF_TESTING_CMD:
748ddac4074SOliver Ruiz Dorantes 			return testingCommands[GET_OPCODE_OCF(opcode) - 1];
749a7c3c465SOliver Ruiz Dorantes 			break;
7500b5931e0SOliver Ruiz Dorantes 		case OGF_VENDOR_CMD:
7510b5931e0SOliver Ruiz Dorantes 			return "Vendor specific command";
7520b5931e0SOliver Ruiz Dorantes 			break;
753a7c3c465SOliver Ruiz Dorantes 		default:
754a7c3c465SOliver Ruiz Dorantes 			return "Unknown command";
755a7c3c465SOliver Ruiz Dorantes 			break;
756a7c3c465SOliver Ruiz Dorantes 	}
757a7c3c465SOliver Ruiz Dorantes 
758a7c3c465SOliver Ruiz Dorantes }
759a7c3c465SOliver Ruiz Dorantes 
760a7c3c465SOliver Ruiz Dorantes 
761a7c3c465SOliver Ruiz Dorantes const char*
76240c666a5SOliver Ruiz Dorantes BluetoothEvent(uint8 event)
76340c666a5SOliver Ruiz Dorantes {
76440c666a5SOliver Ruiz Dorantes 	if (event < sizeof(bluetoothEvents) / sizeof(const char*))
765d081e691SOliver Ruiz Dorantes 		return bluetoothEvents[event - 1];
76640c666a5SOliver Ruiz Dorantes 	else
76740c666a5SOliver Ruiz Dorantes 		return "Event out of Range!";
768d081e691SOliver Ruiz Dorantes }
769d081e691SOliver Ruiz Dorantes 
770d081e691SOliver Ruiz Dorantes 
771d081e691SOliver Ruiz Dorantes const char*
77240c666a5SOliver Ruiz Dorantes BluetoothManufacturer(uint16 manufacturer)
77340c666a5SOliver Ruiz Dorantes {
77440c666a5SOliver Ruiz Dorantes 	if (manufacturer < sizeof(bluetoothManufacturers) / sizeof(const char*))
775a7c3c465SOliver Ruiz Dorantes 		return bluetoothManufacturers[manufacturer];
77640c666a5SOliver Ruiz Dorantes 	else if (manufacturer == 0xFFFF)
777a7c3c465SOliver Ruiz Dorantes 		return "internal use";
77840c666a5SOliver Ruiz Dorantes 	else
779a7c3c465SOliver Ruiz Dorantes 		return "not assigned";
780a7c3c465SOliver Ruiz Dorantes }
781880e5727SOliver Ruiz Dorantes 
782880e5727SOliver Ruiz Dorantes 
783880e5727SOliver Ruiz Dorantes const char*
78440c666a5SOliver Ruiz Dorantes BluetoothError(uint8 error)
78540c666a5SOliver Ruiz Dorantes {
78640c666a5SOliver Ruiz Dorantes 	if (error < sizeof(bluetoothErrors) / sizeof(const char*))
787880e5727SOliver Ruiz Dorantes 		return bluetoothErrors[error];
78840c666a5SOliver Ruiz Dorantes 	else
789880e5727SOliver Ruiz Dorantes 		return "not specified";
790880e5727SOliver Ruiz Dorantes }
791