xref: /haiku/src/kits/bluetooth/CommandManager.cpp (revision fef016caf6d8ecd012f9685144368c4fbdbf7217)
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>
11*fef016caSFredrik Modéen #include <bluetooth/debug.h>
1240c666a5SOliver Ruiz Dorantes 
1340c666a5SOliver Ruiz Dorantes inline void* buildCommand(uint8 ogf, uint8 ocf, void** param, size_t psize,
1440c666a5SOliver Ruiz Dorantes 	size_t* outsize)
1532c01b55SOliver Ruiz Dorantes {
16*fef016caSFredrik Modéen 	CALLED();
1732c01b55SOliver Ruiz Dorantes 	struct hci_command_header* header;
1832c01b55SOliver Ruiz Dorantes 
1932c01b55SOliver Ruiz Dorantes #ifdef BT_IOCTLS_PASS_SIZE
2040c666a5SOliver Ruiz Dorantes 	header = (struct hci_command_header*) malloc(psize
2140c666a5SOliver Ruiz Dorantes 		+ sizeof(struct hci_command_header));
2232c01b55SOliver Ruiz Dorantes 	*outsize = psize + sizeof(struct hci_command_header);
2332c01b55SOliver Ruiz Dorantes #else
2440c666a5SOliver Ruiz Dorantes 	size_t* size = (size_t*)malloc(psize + sizeof(struct hci_command_header)
2540c666a5SOliver Ruiz Dorantes 		+ sizeof(size_t));
2632c01b55SOliver Ruiz Dorantes 	*outsize = psize + sizeof(struct hci_command_header) + sizeof(size_t);
2732c01b55SOliver Ruiz Dorantes 
2832c01b55SOliver Ruiz Dorantes 	*size = psize + sizeof(struct hci_command_header);
2932c01b55SOliver Ruiz Dorantes 	header = (struct hci_command_header*) (((uint8*)size)+4);
3032c01b55SOliver Ruiz Dorantes #endif
3132c01b55SOliver Ruiz Dorantes 
3232c01b55SOliver Ruiz Dorantes 
3332c01b55SOliver Ruiz Dorantes 	if (header != NULL) {
3432c01b55SOliver Ruiz Dorantes 
3532c01b55SOliver Ruiz Dorantes 		header->opcode = B_HOST_TO_LENDIAN_INT16(PACK_OPCODE(ogf, ocf));
3632c01b55SOliver Ruiz Dorantes 		header->clen = psize;
3732c01b55SOliver Ruiz Dorantes 
3832c01b55SOliver Ruiz Dorantes 		if (param != NULL && psize != 0) {
3932c01b55SOliver Ruiz Dorantes 			*param = ((uint8*)header) + sizeof(struct hci_command_header);
4032c01b55SOliver Ruiz Dorantes 		}
4132c01b55SOliver Ruiz Dorantes 	}
4232c01b55SOliver Ruiz Dorantes #ifdef BT_IOCTLS_PASS_SIZE
4332c01b55SOliver Ruiz Dorantes 	return header;
4432c01b55SOliver Ruiz Dorantes #else
4532c01b55SOliver Ruiz Dorantes 	return (void*)size;
4632c01b55SOliver Ruiz Dorantes #endif
4732c01b55SOliver Ruiz Dorantes }
4832c01b55SOliver Ruiz Dorantes 
4932c01b55SOliver Ruiz Dorantes 
5040c666a5SOliver Ruiz Dorantes // This is for request that only require a Command complete in reply.
5140c666a5SOliver Ruiz Dorantes 
5240c666a5SOliver Ruiz Dorantes // Propagate to ReadBufferSize => reply stored in server side
5340c666a5SOliver Ruiz Dorantes // ReadLocalVersion => reply stored in server side
5440c666a5SOliver Ruiz Dorantes // Reset => no reply
5540c666a5SOliver Ruiz Dorantes 
5640c666a5SOliver Ruiz Dorantes // Request that do not need any input parameter
5740c666a5SOliver Ruiz Dorantes // Output reply can be fit in 32 bits field without talking status into account
5840c666a5SOliver Ruiz Dorantes status_t
5940c666a5SOliver Ruiz Dorantes NonParameterCommandRequest(uint8 ofg, uint8 ocf, int32* result, hci_id hId,
6040c666a5SOliver Ruiz Dorantes 	BMessenger* messenger)
6140c666a5SOliver Ruiz Dorantes {
62*fef016caSFredrik Modéen 	CALLED();
6340c666a5SOliver Ruiz Dorantes 	int8 bt_status = BT_ERROR;
6440c666a5SOliver Ruiz Dorantes 
6540c666a5SOliver Ruiz Dorantes 	BluetoothCommand<> simpleCommand(ofg, ocf);
6640c666a5SOliver Ruiz Dorantes 
6740c666a5SOliver Ruiz Dorantes 	BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST);
6840c666a5SOliver Ruiz Dorantes 	BMessage reply;
6940c666a5SOliver Ruiz Dorantes 
7040c666a5SOliver Ruiz Dorantes 	request.AddInt32("hci_id", hId);
7140c666a5SOliver Ruiz Dorantes 	request.AddData("raw command", B_ANY_TYPE,
7240c666a5SOliver Ruiz Dorantes 		simpleCommand.Data(), simpleCommand.Size());
7340c666a5SOliver Ruiz Dorantes 	request.AddInt16("eventExpected",  HCI_EVENT_CMD_COMPLETE);
7440c666a5SOliver Ruiz Dorantes 	request.AddInt16("opcodeExpected", PACK_OPCODE(ofg, ocf));
7540c666a5SOliver Ruiz Dorantes 
7640c666a5SOliver Ruiz Dorantes 	if (messenger->SendMessage(&request, &reply) == B_OK) {
7740c666a5SOliver Ruiz Dorantes 		reply.FindInt8("status", &bt_status);
7840c666a5SOliver Ruiz Dorantes 		if (result != NULL)
7940c666a5SOliver Ruiz Dorantes 			reply.FindInt32("result", result);
8040c666a5SOliver Ruiz Dorantes 	}
8140c666a5SOliver Ruiz Dorantes 
8240c666a5SOliver Ruiz Dorantes 	return bt_status;
8340c666a5SOliver Ruiz Dorantes }
8440c666a5SOliver Ruiz Dorantes 
8540c666a5SOliver Ruiz Dorantes 
8632c01b55SOliver Ruiz Dorantes #if 0
8732c01b55SOliver Ruiz Dorantes #pragma mark - CONTROL BASEBAND -
8832c01b55SOliver Ruiz Dorantes #endif
8932c01b55SOliver Ruiz Dorantes 
9032c01b55SOliver Ruiz Dorantes 
9132c01b55SOliver Ruiz Dorantes void* buildReset(size_t* outsize)
9232c01b55SOliver Ruiz Dorantes {
93*fef016caSFredrik Modéen 	CALLED();
9440c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_RESET,
9540c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
9632c01b55SOliver Ruiz Dorantes }
9732c01b55SOliver Ruiz Dorantes 
9832c01b55SOliver Ruiz Dorantes 
9932c01b55SOliver Ruiz Dorantes void* buildReadLocalName(size_t* outsize)
10032c01b55SOliver Ruiz Dorantes {
101*fef016caSFredrik Modéen 	CALLED();
10240c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_LOCAL_NAME,
10340c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
10432c01b55SOliver Ruiz Dorantes }
10532c01b55SOliver Ruiz Dorantes 
10632c01b55SOliver Ruiz Dorantes 
107a2f8edf7SOliver Ruiz Dorantes void* buildReadClassOfDevice(size_t* outsize)
108a2f8edf7SOliver Ruiz Dorantes {
109*fef016caSFredrik Modéen 	CALLED();
11040c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_CLASS_OF_DEV,
11140c666a5SOliver Ruiz Dorantes 	NULL, 0, outsize);
112a2f8edf7SOliver Ruiz Dorantes }
113a2f8edf7SOliver Ruiz Dorantes 
114a2f8edf7SOliver Ruiz Dorantes 
1157a74a5dfSFredrik Modéen void* buildReadScan(size_t* outsize)
1167a74a5dfSFredrik Modéen {
117*fef016caSFredrik Modéen 	CALLED();
1187a74a5dfSFredrik Modéen 	return buildCommand(OGF_CONTROL_BASEBAND, OCF_READ_SCAN_ENABLE,
1197a74a5dfSFredrik Modéen 	NULL, 0, outsize);
1207a74a5dfSFredrik Modéen }
1217a74a5dfSFredrik Modéen 
1227a74a5dfSFredrik Modéen 
123631aa548SOliver Ruiz Dorantes void* buildWriteScan(uint8 scanmode, size_t* outsize)
124631aa548SOliver Ruiz Dorantes {
125*fef016caSFredrik Modéen 	CALLED();
126631aa548SOliver Ruiz Dorantes 	struct hci_write_scan_enable* param;
12740c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE,
12840c666a5SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_write_scan_enable), outsize);
129631aa548SOliver Ruiz Dorantes 
130631aa548SOliver Ruiz Dorantes 
131631aa548SOliver Ruiz Dorantes 	if (command != NULL) {
132631aa548SOliver Ruiz Dorantes 		param->scan = scanmode;
133631aa548SOliver Ruiz Dorantes 	}
134631aa548SOliver Ruiz Dorantes 
135631aa548SOliver Ruiz Dorantes 	return command;
136631aa548SOliver Ruiz Dorantes }
137631aa548SOliver Ruiz Dorantes 
138631aa548SOliver Ruiz Dorantes 
13932c01b55SOliver Ruiz Dorantes #if 0
14032c01b55SOliver Ruiz Dorantes #pragma mark - LINK CONTROL -
14132c01b55SOliver Ruiz Dorantes #endif
14232c01b55SOliver Ruiz Dorantes 
1437434b760SOliver Ruiz Dorantes 
14440c666a5SOliver Ruiz Dorantes void* buildRemoteNameRequest(bdaddr_t bdaddr, uint8 pscan_rep_mode,
14540c666a5SOliver Ruiz Dorantes 	uint16 clock_offset, size_t* outsize)
14632c01b55SOliver Ruiz Dorantes {
147*fef016caSFredrik Modéen 	CALLED();
14832c01b55SOliver Ruiz Dorantes 	struct hci_remote_name_request* param;
14940c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST,
15040c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_remote_name_request), outsize);
15132c01b55SOliver Ruiz Dorantes 
15232c01b55SOliver Ruiz Dorantes 	if (command != NULL) {
15332c01b55SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
15432c01b55SOliver Ruiz Dorantes 		param->pscan_rep_mode = pscan_rep_mode;
15532c01b55SOliver Ruiz Dorantes 		param->clock_offset = clock_offset;
15632c01b55SOliver Ruiz Dorantes 	}
15732c01b55SOliver Ruiz Dorantes 
15832c01b55SOliver Ruiz Dorantes 	return command;
15932c01b55SOliver Ruiz Dorantes }
16032c01b55SOliver Ruiz Dorantes 
16132c01b55SOliver Ruiz Dorantes 
16232c01b55SOliver Ruiz Dorantes void* buildInquiry(uint32 lap, uint8 length, uint8 num_rsp, size_t* outsize)
16332c01b55SOliver Ruiz Dorantes {
164*fef016caSFredrik Modéen 	CALLED();
16532c01b55SOliver Ruiz Dorantes 	struct hci_cp_inquiry* param;
16640c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY,
16740c666a5SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_inquiry), outsize);
16832c01b55SOliver Ruiz Dorantes 
16932c01b55SOliver Ruiz Dorantes 	if (command != NULL) {
17032c01b55SOliver Ruiz Dorantes 
17132c01b55SOliver Ruiz Dorantes 		param->lap[2] = (lap >> 16) & 0xFF;
17232c01b55SOliver Ruiz Dorantes 		param->lap[1] = (lap >>  8) & 0xFF;
17332c01b55SOliver Ruiz Dorantes 		param->lap[0] = (lap >>  0) & 0xFF;
17432c01b55SOliver Ruiz Dorantes 		param->length = length;
17532c01b55SOliver Ruiz Dorantes 		param->num_rsp = num_rsp;
176350458a6SOliver Ruiz Dorantes 	}
177350458a6SOliver Ruiz Dorantes 
178350458a6SOliver Ruiz Dorantes 	return command;
179350458a6SOliver Ruiz Dorantes }
180350458a6SOliver Ruiz Dorantes 
1817434b760SOliver Ruiz Dorantes 
182350458a6SOliver Ruiz Dorantes void* buildInquiryCancel(size_t* outsize)
183350458a6SOliver Ruiz Dorantes {
184*fef016caSFredrik Modéen 	CALLED();
185350458a6SOliver Ruiz Dorantes 	return buildCommand(OGF_LINK_CONTROL, OCF_INQUIRY_CANCEL, NULL, 0, outsize);
186350458a6SOliver Ruiz Dorantes }
187350458a6SOliver Ruiz Dorantes 
188350458a6SOliver Ruiz Dorantes 
18940c666a5SOliver Ruiz Dorantes void* buildPinCodeRequestReply(bdaddr_t bdaddr, uint8 length, char pincode[16],
19040c666a5SOliver Ruiz Dorantes 	size_t* outsize)
191350458a6SOliver Ruiz Dorantes {
192*fef016caSFredrik Modéen 	CALLED();
193350458a6SOliver Ruiz Dorantes 	struct hci_cp_pin_code_reply* param;
194350458a6SOliver Ruiz Dorantes 
195350458a6SOliver Ruiz Dorantes 	if (length > HCI_PIN_SIZE)  // PinCode cannot be longer than 16
196350458a6SOliver Ruiz Dorantes 		return NULL;
197350458a6SOliver Ruiz Dorantes 
19840c666a5SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_REPLY,
19940c666a5SOliver Ruiz Dorantes 		(void**)&param, sizeof(struct hci_cp_pin_code_reply), outsize);
200350458a6SOliver Ruiz Dorantes 
201350458a6SOliver Ruiz Dorantes 	if (command != NULL) {
202350458a6SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
203350458a6SOliver Ruiz Dorantes 		param->pin_len = length;
204350458a6SOliver Ruiz Dorantes 		memcpy(&param->pin_code, pincode, length);
205350458a6SOliver Ruiz Dorantes 	}
206350458a6SOliver Ruiz Dorantes 
207350458a6SOliver Ruiz Dorantes 	return command;
208350458a6SOliver Ruiz Dorantes }
209350458a6SOliver Ruiz Dorantes 
210350458a6SOliver Ruiz Dorantes 
2110df89492SOliver Ruiz Dorantes void* buildPinCodeRequestNegativeReply(bdaddr_t bdaddr, size_t* outsize)
212350458a6SOliver Ruiz Dorantes {
213*fef016caSFredrik Modéen 	CALLED();
214350458a6SOliver Ruiz Dorantes 	struct hci_cp_pin_code_neg_reply* param;
215350458a6SOliver Ruiz Dorantes 
216350458a6SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_PIN_CODE_NEG_REPLY,
217350458a6SOliver Ruiz Dorantes 		(void**) &param, sizeof(struct hci_cp_pin_code_neg_reply), outsize);
218350458a6SOliver Ruiz Dorantes 
219350458a6SOliver Ruiz Dorantes 	if (command != NULL) {
220350458a6SOliver Ruiz Dorantes 
221350458a6SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
222350458a6SOliver Ruiz Dorantes 
22332c01b55SOliver Ruiz Dorantes 	}
22432c01b55SOliver Ruiz Dorantes 
22532c01b55SOliver Ruiz Dorantes 	return command;
22632c01b55SOliver Ruiz Dorantes }
22732c01b55SOliver Ruiz Dorantes 
22832c01b55SOliver Ruiz Dorantes 
2297434b760SOliver Ruiz Dorantes void* buildAcceptConnectionRequest(bdaddr_t bdaddr, uint8 role, size_t* outsize)
2307434b760SOliver Ruiz Dorantes {
231*fef016caSFredrik 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 
2467434b760SOliver Ruiz Dorantes void* buildRejectConnectionRequest(bdaddr_t bdaddr, size_t* outsize)
2477434b760SOliver Ruiz Dorantes {
248*fef016caSFredrik Modéen 	CALLED();
2497434b760SOliver Ruiz Dorantes 	struct hci_cp_reject_conn_req* param;
2507434b760SOliver Ruiz Dorantes 
2517434b760SOliver Ruiz Dorantes 	void* command = buildCommand(OGF_LINK_CONTROL, OCF_REJECT_CONN_REQ,
25240c666a5SOliver Ruiz Dorantes 					(void**)&param, sizeof(struct hci_cp_reject_conn_req),
25340c666a5SOliver Ruiz Dorantes 					outsize);
2547434b760SOliver Ruiz Dorantes 
2557434b760SOliver Ruiz Dorantes 	if (command != NULL) {
2567434b760SOliver Ruiz Dorantes 		param->bdaddr = bdaddr;
2577434b760SOliver Ruiz Dorantes 	}
2587434b760SOliver Ruiz Dorantes 
2597434b760SOliver Ruiz Dorantes 	return command;
2607434b760SOliver Ruiz Dorantes }
2617434b760SOliver Ruiz Dorantes 
2627434b760SOliver Ruiz Dorantes 
26332c01b55SOliver Ruiz Dorantes #if 0
26432c01b55SOliver Ruiz Dorantes #pragma mark - INFORMATIONAL_PARAM -
26532c01b55SOliver Ruiz Dorantes #endif
26632c01b55SOliver Ruiz Dorantes 
267b44ee583SOliver Ruiz Dorantes void* buildReadLocalVersionInformation(size_t* outsize)
268b44ee583SOliver Ruiz Dorantes {
269*fef016caSFredrik Modéen 	CALLED();
27040c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_LOCAL_VERSION,
27140c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
272b44ee583SOliver Ruiz Dorantes }
273b44ee583SOliver Ruiz Dorantes 
27432c01b55SOliver Ruiz Dorantes 
27532c01b55SOliver Ruiz Dorantes void* buildReadBufferSize(size_t* outsize)
27632c01b55SOliver Ruiz Dorantes {
277*fef016caSFredrik Modéen 	CALLED();
27840c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BUFFER_SIZE,
27940c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
28032c01b55SOliver Ruiz Dorantes }
28132c01b55SOliver Ruiz Dorantes 
28232c01b55SOliver Ruiz Dorantes 
28332c01b55SOliver Ruiz Dorantes void* buildReadBdAddr(size_t* outsize)
28432c01b55SOliver Ruiz Dorantes {
285*fef016caSFredrik Modéen 	CALLED();
28640c666a5SOliver Ruiz Dorantes 	return buildCommand(OGF_INFORMATIONAL_PARAM, OCF_READ_BD_ADDR,
28740c666a5SOliver Ruiz Dorantes 		NULL, 0, outsize);
28832c01b55SOliver Ruiz Dorantes }
289631aa548SOliver Ruiz Dorantes 
290631aa548SOliver Ruiz Dorantes 
291a7c3c465SOliver Ruiz Dorantes const char* bluetoothManufacturers[] = {
292a7c3c465SOliver Ruiz Dorantes 	"Ericsson Technology Licensing",
293a7c3c465SOliver Ruiz Dorantes 	"Nokia Mobile Phones",
294a7c3c465SOliver Ruiz Dorantes 	"Intel Corp.",
295a7c3c465SOliver Ruiz Dorantes 	"IBM Corp.",
296a7c3c465SOliver Ruiz Dorantes 	"Toshiba Corp.",
297a7c3c465SOliver Ruiz Dorantes 	"3Com",
298a7c3c465SOliver Ruiz Dorantes 	"Microsoft",
299a7c3c465SOliver Ruiz Dorantes 	"Lucent",
300a7c3c465SOliver Ruiz Dorantes 	"Motorola",
301a7c3c465SOliver Ruiz Dorantes 	"Infineon Technologies AG",
302a7c3c465SOliver Ruiz Dorantes 	"Cambridge Silicon Radio",
303a7c3c465SOliver Ruiz Dorantes 	"Silicon Wave",
304a7c3c465SOliver Ruiz Dorantes 	"Digianswer A/S",
305a7c3c465SOliver Ruiz Dorantes 	"Texas Instruments Inc.",
306a7c3c465SOliver Ruiz Dorantes 	"Parthus Technologies Inc.",
307a7c3c465SOliver Ruiz Dorantes 	"Broadcom Corporation",
308a7c3c465SOliver Ruiz Dorantes 	"Mitel Semiconductor",
309a7c3c465SOliver Ruiz Dorantes 	"Widcomm, Inc.",
310a7c3c465SOliver Ruiz Dorantes 	"Zeevo, Inc.",
311a7c3c465SOliver Ruiz Dorantes 	"Atmel Corporation",
312a7c3c465SOliver Ruiz Dorantes 	"Mitsubishi Electric Corporation",
313a7c3c465SOliver Ruiz Dorantes 	"RTX Telecom A/S",
314a7c3c465SOliver Ruiz Dorantes 	"KC Technology Inc.",
315a7c3c465SOliver Ruiz Dorantes 	"Newlogic",
316a7c3c465SOliver Ruiz Dorantes 	"Transilica, Inc.",
317a7c3c465SOliver Ruiz Dorantes 	"Rohde & Schwartz GmbH & Co. KG",
318a7c3c465SOliver Ruiz Dorantes 	"TTPCom Limited",
319a7c3c465SOliver Ruiz Dorantes 	"Signia Technologies, Inc.",
320a7c3c465SOliver Ruiz Dorantes 	"Conexant Systems Inc.",
321a7c3c465SOliver Ruiz Dorantes 	"Qualcomm",
322a7c3c465SOliver Ruiz Dorantes 	"Inventel",
323a7c3c465SOliver Ruiz Dorantes 	"AVM Berlin",
324a7c3c465SOliver Ruiz Dorantes 	"BandSpeed, Inc.",
325a7c3c465SOliver Ruiz Dorantes 	"Mansella Ltd",
326a7c3c465SOliver Ruiz Dorantes 	"NEC Corporation",
327a7c3c465SOliver Ruiz Dorantes 	"WavePlus Technology Co., Ltd.",
328a7c3c465SOliver Ruiz Dorantes 	"Alcatel",
329a7c3c465SOliver Ruiz Dorantes 	"Philips Semiconductors",
330a7c3c465SOliver Ruiz Dorantes 	"C Technologies",
331a7c3c465SOliver Ruiz Dorantes 	"Open Interface",
332a7c3c465SOliver Ruiz Dorantes 	"R F Micro Devices",
333a7c3c465SOliver Ruiz Dorantes 	"Hitachi Ltd",
334a7c3c465SOliver Ruiz Dorantes 	"Symbol Technologies, Inc.",
335a7c3c465SOliver Ruiz Dorantes 	"Tenovis",
336a7c3c465SOliver Ruiz Dorantes 	"Macronix International Co. Ltd.",
337a7c3c465SOliver Ruiz Dorantes 	"GCT Semiconductor",
338a7c3c465SOliver Ruiz Dorantes 	"Norwood Systems",
339a7c3c465SOliver Ruiz Dorantes 	"MewTel Technology Inc.",
340a7c3c465SOliver Ruiz Dorantes 	"ST Microelectronics",
341a7c3c465SOliver Ruiz Dorantes 	"Synopsys",
342a7c3c465SOliver Ruiz Dorantes 	"Red-M (Communications) Ltd",
343a7c3c465SOliver Ruiz Dorantes 	"Commil Ltd",
344a7c3c465SOliver Ruiz Dorantes 	"Computer Access Technology Corporation (CATC)",
345b3064a44SOliver Ruiz Dorantes 	"Eclipse (HQ España) S.L.",
346a7c3c465SOliver Ruiz Dorantes 	"Renesas Technology Corp.",
347a7c3c465SOliver Ruiz Dorantes 	"Mobilian Corporation",
348a7c3c465SOliver Ruiz Dorantes 	"Terax",
3493c2f52adSOliver Ruiz Dorantes 	"Integrated System Solution Corp.",
350a7c3c465SOliver Ruiz Dorantes 	"Matsushita Electric Industrial Co., Ltd.",
351a7c3c465SOliver Ruiz Dorantes 	"Gennum Corporation",
352a7c3c465SOliver Ruiz Dorantes 	"Research In Motion",
353a7c3c465SOliver Ruiz Dorantes 	"IPextreme, Inc.",
354a7c3c465SOliver Ruiz Dorantes 	"Systems and Chips, Inc",
355a7c3c465SOliver Ruiz Dorantes 	"Bluetooth SIG, Inc",
356a7c3c465SOliver Ruiz Dorantes 	"Seiko Epson Corporation",
357a7c3c465SOliver Ruiz Dorantes 	"Integrated Silicon Solution Taiwain, Inc.",
358a7c3c465SOliver Ruiz Dorantes 	"CONWISE Technology Corporation Ltd",
359b3064a44SOliver Ruiz Dorantes 	"PARROT SA",
360a7c3c465SOliver Ruiz Dorantes 	"Socket Communications",
361a7c3c465SOliver Ruiz Dorantes 	"Atheros Communications, Inc.",
362a7c3c465SOliver Ruiz Dorantes 	"MediaTek, Inc.",
363a7c3c465SOliver Ruiz Dorantes 	"Bluegiga",	/* (tentative) */
364a7c3c465SOliver Ruiz Dorantes 	"Marvell Technology Group Ltd.",
365a7c3c465SOliver Ruiz Dorantes 	"3DSP Corporation",
366a7c3c465SOliver Ruiz Dorantes 	"Accel Semiconductor Ltd.",
367a7c3c465SOliver Ruiz Dorantes 	"Continental Automotive Systems",
368a7c3c465SOliver Ruiz Dorantes 	"Apple, Inc.",
369a7c3c465SOliver Ruiz Dorantes 	"Staccato Communications, Inc."
370a7c3c465SOliver Ruiz Dorantes };
371631aa548SOliver Ruiz Dorantes 
372631aa548SOliver Ruiz Dorantes 
373a7c3c465SOliver Ruiz Dorantes const char* linkControlCommands[] = {
374a7c3c465SOliver Ruiz Dorantes 	"Inquiry",
37540c666a5SOliver Ruiz Dorantes 	"Inquiry Cancel",
37640c666a5SOliver Ruiz Dorantes 	"Periodic Inquiry Mode",
37740c666a5SOliver Ruiz Dorantes 	"Exit Periodic Inquiry Mode",
37840c666a5SOliver Ruiz Dorantes 	"Create Connection",
379a7c3c465SOliver Ruiz Dorantes 	"Disconnect",
38040c666a5SOliver Ruiz Dorantes 	"Add SCO Connection", // not on 2.1
38140c666a5SOliver Ruiz Dorantes 	"Cancel Create Connection",
38240c666a5SOliver Ruiz Dorantes 	"Accept Connection Request",
38340c666a5SOliver Ruiz Dorantes 	"Reject Connection Request",
38440c666a5SOliver Ruiz Dorantes 	"Link Key Request Reply",
38540c666a5SOliver Ruiz Dorantes 	"Link Key Request Negative Reply",
38640c666a5SOliver Ruiz Dorantes 	"PIN Code Request Reply",
38740c666a5SOliver Ruiz Dorantes 	"PIN Code Request Negative Reply",
38840c666a5SOliver Ruiz Dorantes 	"Change Connection Packet Type",
389b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
39040c666a5SOliver Ruiz Dorantes 	"Authentication Requested",
391b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
39240c666a5SOliver Ruiz Dorantes 	"Set Connection Encryption",
393b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
39440c666a5SOliver Ruiz Dorantes 	"Change Connection Link Key",
395b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
39640c666a5SOliver Ruiz Dorantes 	"Master Link Key",
397b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
39840c666a5SOliver Ruiz Dorantes 	"Remote Name Request",
39940c666a5SOliver Ruiz Dorantes 	"Cancel Remote Name Request",
40040c666a5SOliver Ruiz Dorantes 	"Read Remote Supported Features",
40140c666a5SOliver Ruiz Dorantes 	"Read Remote Extended Features",
40240c666a5SOliver Ruiz Dorantes 	"Read Remote Version Information",
403b3064a44SOliver Ruiz Dorantes 	"Reserved", // not on 2.1",
40440c666a5SOliver Ruiz Dorantes 	"Read Clock Offset",
40540c666a5SOliver Ruiz Dorantes 	"Read LMP Handle",
406a7c3c465SOliver Ruiz Dorantes 	"Reserved",
407a7c3c465SOliver Ruiz Dorantes 	"Reserved",
408a7c3c465SOliver Ruiz Dorantes 	"Reserved",
409a7c3c465SOliver Ruiz Dorantes 	"Reserved",
410a7c3c465SOliver Ruiz Dorantes 	"Reserved",
411a7c3c465SOliver Ruiz Dorantes 	"Reserved",
412a7c3c465SOliver Ruiz Dorantes 	"Reserved",
41340c666a5SOliver Ruiz Dorantes 	"Setup Synchronous Connection",
41440c666a5SOliver Ruiz Dorantes 	"Accept Synchronous Connection",
41540c666a5SOliver Ruiz Dorantes 	"Reject Synchronous Connection",
41640c666a5SOliver Ruiz Dorantes 	"IO Capability Request Reply",
41740c666a5SOliver Ruiz Dorantes 	"User Confirmation Request Reply",
41840c666a5SOliver Ruiz Dorantes 	"User Confirmation Request Negative Reply",
41940c666a5SOliver Ruiz Dorantes 	"User Passkey Request Reply",
42040c666a5SOliver Ruiz Dorantes 	"User Passkey Request Negative Reply",
42140c666a5SOliver Ruiz Dorantes 	"Remote OOB Data Request Reply",
422a7c3c465SOliver Ruiz Dorantes 	"Reserved",
423a7c3c465SOliver Ruiz Dorantes 	"Reserved",
42440c666a5SOliver Ruiz Dorantes 	"Remote OOB Data Request Negative Reply",
42540c666a5SOliver Ruiz Dorantes 	"IO Capabilities Response Negative Reply"
426a7c3c465SOliver Ruiz Dorantes };
427a7c3c465SOliver Ruiz Dorantes 
428a7c3c465SOliver Ruiz Dorantes 
429a7c3c465SOliver Ruiz Dorantes const char* linkPolicyCommands[] = {
43040c666a5SOliver Ruiz Dorantes 	"Hold Mode",
431a7c3c465SOliver Ruiz Dorantes 	"Reserved",
43240c666a5SOliver Ruiz Dorantes 	"Sniff Mode",
43340c666a5SOliver Ruiz Dorantes 	"Exit Sniff Mode",
43440c666a5SOliver Ruiz Dorantes 	"Park State",
43540c666a5SOliver Ruiz Dorantes 	"Exit Park State",
43640c666a5SOliver Ruiz Dorantes 	"QoS Setup",
437a7c3c465SOliver Ruiz Dorantes 	"Reserved",
43840c666a5SOliver Ruiz Dorantes 	"Role Discovery",
439a7c3c465SOliver Ruiz Dorantes 	"Reserved",
44040c666a5SOliver Ruiz Dorantes 	"Switch Role",
44140c666a5SOliver Ruiz Dorantes 	"Read Link Policy Settings",
44240c666a5SOliver Ruiz Dorantes 	"Write Link Policy Settings",
44340c666a5SOliver Ruiz Dorantes 	"Read Default Link Policy Settings",
44440c666a5SOliver Ruiz Dorantes 	"Write Default Link Policy Settings",
44540c666a5SOliver Ruiz Dorantes 	"Flow Specification",
44640c666a5SOliver Ruiz Dorantes 	"Sniff Subrating"
447a7c3c465SOliver Ruiz Dorantes };
448a7c3c465SOliver Ruiz Dorantes 
449a7c3c465SOliver Ruiz Dorantes 
450a7c3c465SOliver Ruiz Dorantes const char* controllerBasebandCommands[] = {
45140c666a5SOliver Ruiz Dorantes 	"Set Event Mask",
452a7c3c465SOliver Ruiz Dorantes 	"Reserved",
453a7c3c465SOliver Ruiz Dorantes 	"Reset",
454a7c3c465SOliver Ruiz Dorantes 	"Reserved",
45540c666a5SOliver Ruiz Dorantes 	"Set Event Filter",
456a7c3c465SOliver Ruiz Dorantes 	"Reserved",
457a7c3c465SOliver Ruiz Dorantes 	"Reserved",
458a7c3c465SOliver Ruiz Dorantes 	"Flush",
45940c666a5SOliver Ruiz Dorantes 	"Read PIN Type",
46040c666a5SOliver Ruiz Dorantes 	"Write PIN Type",
46140c666a5SOliver Ruiz Dorantes 	"Create New Unit Key",
462a7c3c465SOliver Ruiz Dorantes 	"Reserved",
46340c666a5SOliver Ruiz Dorantes 	"Read Stored Link Key",
464a7c3c465SOliver Ruiz Dorantes 	"Reserved",
465a7c3c465SOliver Ruiz Dorantes 	"Reserved",
466a7c3c465SOliver Ruiz Dorantes 	"Reserved",
46740c666a5SOliver Ruiz Dorantes 	"Write Stored Link Key",
46840c666a5SOliver Ruiz Dorantes 	"Delete Stored Link Key",
46940c666a5SOliver Ruiz Dorantes 	"Write Local Name",
47040c666a5SOliver Ruiz Dorantes 	"Read Local Name",
47140c666a5SOliver Ruiz Dorantes 	"Read Connection Accept Timeout",
47240c666a5SOliver Ruiz Dorantes 	"Write Connection Accept Timeout",
47340c666a5SOliver Ruiz Dorantes 	"Read Page Timeout",
47440c666a5SOliver Ruiz Dorantes 	"Write Page Timeout",
47540c666a5SOliver Ruiz Dorantes 	"Read Scan Enable",
47640c666a5SOliver Ruiz Dorantes 	"Write Scan Enable",
47740c666a5SOliver Ruiz Dorantes 	"Read Page Scan Activity",
47840c666a5SOliver Ruiz Dorantes 	"Write Page Scan Activity",
47940c666a5SOliver Ruiz Dorantes 	"Read Inquiry Scan Activity",
48040c666a5SOliver Ruiz Dorantes 	"Write Inquiry Scan Activity",
48140c666a5SOliver Ruiz Dorantes 	"Read Authentication Enable",
48240c666a5SOliver Ruiz Dorantes 	"Write Authentication Enable",
48340c666a5SOliver Ruiz Dorantes 	"Read Encryption Mode", // not 2.1
48440c666a5SOliver Ruiz Dorantes 	"Write Encryption Mode",// not 2.1
48540c666a5SOliver Ruiz Dorantes 	"Read Class Of Device",
48640c666a5SOliver Ruiz Dorantes 	"Write Class Of Device",
48740c666a5SOliver Ruiz Dorantes 	"Read Voice Setting",
48840c666a5SOliver Ruiz Dorantes 	"Write Voice Setting",
48940c666a5SOliver Ruiz Dorantes 	"Read Automatic Flush Timeout",
49040c666a5SOliver Ruiz Dorantes 	"Write Automatic Flush Timeout",
49140c666a5SOliver Ruiz Dorantes 	"Read Num Broadcast Retransmissions",
49240c666a5SOliver Ruiz Dorantes 	"Write Num Broadcast Retransmissions",
49340c666a5SOliver Ruiz Dorantes 	"Read Hold Mode Activity",
49440c666a5SOliver Ruiz Dorantes 	"Write Hold Mode Activity",
49540c666a5SOliver Ruiz Dorantes 	"Read Transmit Power Level",
49640c666a5SOliver Ruiz Dorantes 	"Read Synchronous Flow Control Enable",
49740c666a5SOliver Ruiz Dorantes 	"Write Synchronous Flow Control Enable",
498a7c3c465SOliver Ruiz Dorantes 	"Reserved",
49940c666a5SOliver Ruiz Dorantes 	"Set Host Controller To Host Flow Control",
500a7c3c465SOliver Ruiz Dorantes 	"Reserved",
50140c666a5SOliver Ruiz Dorantes 	"Host Buffer Size",
502a7c3c465SOliver Ruiz Dorantes 	"Reserved",
50340c666a5SOliver Ruiz Dorantes 	"Host Number Of Completed Packets",
50440c666a5SOliver Ruiz Dorantes 	"Read Link Supervision Timeout",
50540c666a5SOliver Ruiz Dorantes 	"Write Link Supervision Timeout",
50640c666a5SOliver Ruiz Dorantes 	"Read Number of Supported IAC",
50740c666a5SOliver Ruiz Dorantes 	"Read Current IAC LAP",
50840c666a5SOliver Ruiz Dorantes 	"Write Current IAC LAP",
50940c666a5SOliver Ruiz Dorantes 	"Read Page Scan Period Mode", // not 2.1
51040c666a5SOliver Ruiz Dorantes 	"Write Page Scan Period Mode", // not 2.1
51140c666a5SOliver Ruiz Dorantes 	"Read Page Scan Mode",		// not 2.1
51240c666a5SOliver Ruiz Dorantes 	"Write Page Scan Mode",		// not 2.1
51340c666a5SOliver Ruiz Dorantes 	"Set AFH Channel Classification",
514a7c3c465SOliver Ruiz Dorantes 	"Reserved",
515a7c3c465SOliver Ruiz Dorantes 	"Reserved",
51640c666a5SOliver Ruiz Dorantes 	"Read Inquiry Scan Type",
51740c666a5SOliver Ruiz Dorantes 	"Write Inquiry Scan Type",
51840c666a5SOliver Ruiz Dorantes 	"Read Inquiry Mode",
51940c666a5SOliver Ruiz Dorantes 	"Write Inquiry Mode",
52040c666a5SOliver Ruiz Dorantes 	"Read Page Scan Type",
52140c666a5SOliver Ruiz Dorantes 	"Write Page Scan Type",
52240c666a5SOliver Ruiz Dorantes 	"Read AFH Channel Assessment Mode",
52340c666a5SOliver Ruiz Dorantes 	"Write AFH Channel Assessment Mode",
524a7c3c465SOliver Ruiz Dorantes 	"Reserved",
525a7c3c465SOliver Ruiz Dorantes 	"Reserved",
526a7c3c465SOliver Ruiz Dorantes 	"Reserved",
527a7c3c465SOliver Ruiz Dorantes 	"Reserved",
528a7c3c465SOliver Ruiz Dorantes 	"Reserved",
529a7c3c465SOliver Ruiz Dorantes 	"Reserved",
530a7c3c465SOliver Ruiz Dorantes 	"Reserved",
53140c666a5SOliver Ruiz Dorantes 	"Read Extended Inquiry Response",
53240c666a5SOliver Ruiz Dorantes 	"Write Extended Inquiry Response",
53340c666a5SOliver Ruiz Dorantes 	"Refresh Encryption Key",
534a7c3c465SOliver Ruiz Dorantes 	"Reserved",
53540c666a5SOliver Ruiz Dorantes 	"Read Simple Pairing Mode",
53640c666a5SOliver Ruiz Dorantes 	"Write Simple Pairing Mode",
53740c666a5SOliver Ruiz Dorantes 	"Read Local OOB Data",
53840c666a5SOliver Ruiz Dorantes 	"Read Inquiry Transmit Power Level",
53940c666a5SOliver Ruiz Dorantes 	"Write Inquiry Transmit Power Level",
54040c666a5SOliver Ruiz Dorantes 	"Read Default Erroneous Data Reporting",
54140c666a5SOliver Ruiz Dorantes 	"Write Default Erroneous Data Reporting",
542a7c3c465SOliver Ruiz Dorantes 	"Reserved",
543a7c3c465SOliver Ruiz Dorantes 	"Reserved",
544a7c3c465SOliver Ruiz Dorantes 	"Reserved",
54540c666a5SOliver Ruiz Dorantes 	"Enhanced Flush",
54640c666a5SOliver Ruiz Dorantes 	"Send Keypress Notification"
547a7c3c465SOliver Ruiz Dorantes };
548a7c3c465SOliver Ruiz Dorantes 
549a7c3c465SOliver Ruiz Dorantes 
550a7c3c465SOliver Ruiz Dorantes const char* informationalParametersCommands[] = {
55140c666a5SOliver Ruiz Dorantes 	"Read Local Version Information",
55240c666a5SOliver Ruiz Dorantes 	"Read Local Supported Commands",
55340c666a5SOliver Ruiz Dorantes 	"Read Local Supported Features",
55440c666a5SOliver Ruiz Dorantes 	"Read Local Extended Features",
55540c666a5SOliver Ruiz Dorantes 	"Read Buffer Size",
556a7c3c465SOliver Ruiz Dorantes 	"Reserved",
55740c666a5SOliver Ruiz Dorantes 	"Read Country Code", // not 2.1
558a7c3c465SOliver Ruiz Dorantes 	"Reserved",
559a7c3c465SOliver Ruiz Dorantes 	"Read BD ADDR"
560a7c3c465SOliver Ruiz Dorantes };
561a7c3c465SOliver Ruiz Dorantes 
562a7c3c465SOliver Ruiz Dorantes 
563a7c3c465SOliver Ruiz Dorantes const char* statusParametersCommands[] = {
56440c666a5SOliver Ruiz Dorantes 	"Read Failed Contact Counter",
56540c666a5SOliver Ruiz Dorantes 	"Reset Failed Contact Counter",
56640c666a5SOliver Ruiz Dorantes 	"Read Link Quality",
567a7c3c465SOliver Ruiz Dorantes 	"Reserved",
568a7c3c465SOliver Ruiz Dorantes 	"Read RSSI",
56940c666a5SOliver Ruiz Dorantes 	"Read AFH Channel Map",
57040c666a5SOliver Ruiz Dorantes 	"Read Clock",
571a7c3c465SOliver Ruiz Dorantes };
572a7c3c465SOliver Ruiz Dorantes 
573a7c3c465SOliver Ruiz Dorantes 
574a7c3c465SOliver Ruiz Dorantes const char* testingCommands[] = {
57540c666a5SOliver Ruiz Dorantes 	"Read Loopback Mode",
57640c666a5SOliver Ruiz Dorantes 	"Write Loopback Mode",
57740c666a5SOliver Ruiz Dorantes 	"Enable Device Under Test Mode",
57840c666a5SOliver Ruiz Dorantes 	"Write Simple Pairing Debug Mode",
579a7c3c465SOliver Ruiz Dorantes };
580a7c3c465SOliver Ruiz Dorantes 
581a7c3c465SOliver Ruiz Dorantes 
582d081e691SOliver Ruiz Dorantes const char* bluetoothEvents[] = {
58340c666a5SOliver Ruiz Dorantes 	"Inquiry Complete",
58440c666a5SOliver Ruiz Dorantes 	"Inquiry Result",
58540c666a5SOliver Ruiz Dorantes 	"Conn Complete",
58640c666a5SOliver Ruiz Dorantes 	"Conn Request",
58740c666a5SOliver Ruiz Dorantes 	"Disconnection Complete",
58840c666a5SOliver Ruiz Dorantes 	"Auth Complete",
58940c666a5SOliver Ruiz Dorantes 	"Remote Name Request Complete",
59040c666a5SOliver Ruiz Dorantes 	"Encrypt Change",
59140c666a5SOliver Ruiz Dorantes 	"Change Conn Link Key Complete",
59240c666a5SOliver Ruiz Dorantes 	"Master Link Key Compl",
59340c666a5SOliver Ruiz Dorantes 	"Rmt Features",
59440c666a5SOliver Ruiz Dorantes 	"Rmt Version",
59540c666a5SOliver Ruiz Dorantes 	"Qos Setup Complete",
59640c666a5SOliver Ruiz Dorantes 	"Command Complete",
59740c666a5SOliver Ruiz Dorantes 	"Command Status",
59840c666a5SOliver Ruiz Dorantes 	"Hardware Error",
59940c666a5SOliver Ruiz Dorantes 	"Flush Occur",
60040c666a5SOliver Ruiz Dorantes 	"Role Change",
60140c666a5SOliver Ruiz Dorantes 	"Num Comp Pkts",
60240c666a5SOliver Ruiz Dorantes 	"Mode Change",
60340c666a5SOliver Ruiz Dorantes 	"Return Link Keys",
60440c666a5SOliver Ruiz Dorantes 	"Pin Code Req",
60540c666a5SOliver Ruiz Dorantes 	"Link Key Req",
60640c666a5SOliver Ruiz Dorantes 	"Link Key Notify",
60740c666a5SOliver Ruiz Dorantes 	"Loopback Command",
60840c666a5SOliver Ruiz Dorantes 	"Data Buffer Overflow",
60940c666a5SOliver Ruiz Dorantes 	"Max Slot Change",
61040c666a5SOliver Ruiz Dorantes 	"Read Clock Offset Compl",
61140c666a5SOliver Ruiz Dorantes 	"Con Pkt Type Changed",
61240c666a5SOliver Ruiz Dorantes 	"Qos Violation",
613d081e691SOliver Ruiz Dorantes 	"Reserved",
61440c666a5SOliver Ruiz Dorantes 	"Page Scan Rep Mode Change",
61540c666a5SOliver Ruiz Dorantes 	"Flow Specification",
61640c666a5SOliver Ruiz Dorantes 	"Inquiry Result With Rssi",
61740c666a5SOliver Ruiz Dorantes 	"Remote Extended Features",
618d081e691SOliver Ruiz Dorantes 	"Reserved",
619d081e691SOliver Ruiz Dorantes 	"Reserved",
620d081e691SOliver Ruiz Dorantes 	"Reserved",
621d081e691SOliver Ruiz Dorantes 	"Reserved",
622d081e691SOliver Ruiz Dorantes 	"Reserved",
623d081e691SOliver Ruiz Dorantes 	"Reserved",
624d081e691SOliver Ruiz Dorantes 	"Reserved",
625d081e691SOliver Ruiz Dorantes 	"Reserved",
62640c666a5SOliver Ruiz Dorantes 	"Synchronous Connection Completed",
62740c666a5SOliver Ruiz Dorantes 	"Synchronous Connection Changed",
628d081e691SOliver Ruiz Dorantes 	"Reserved",
62940c666a5SOliver Ruiz Dorantes 	"Extended Inquiry Result",
63040c666a5SOliver Ruiz Dorantes 	"Encryption Key Refresh Complete",
63140c666a5SOliver Ruiz Dorantes 	"Io Capability Request",
63240c666a5SOliver Ruiz Dorantes 	"Io Capability Response",
63340c666a5SOliver Ruiz Dorantes 	"User Confirmation Request",
63440c666a5SOliver Ruiz Dorantes 	"User Passkey Request",
63540c666a5SOliver Ruiz Dorantes 	"Oob Data Request",
63640c666a5SOliver Ruiz Dorantes 	"Simple Pairing Complete",
637d081e691SOliver Ruiz Dorantes 	"Reserved",
63840c666a5SOliver Ruiz Dorantes 	"Link Supervision Timeout Changed",
63940c666a5SOliver Ruiz Dorantes 	"Enhanced Flush Complete",
640d081e691SOliver Ruiz Dorantes 	"Reserved",
641d081e691SOliver Ruiz Dorantes 	"Reserved",
64240c666a5SOliver Ruiz Dorantes 	"Keypress Notification",
64340c666a5SOliver Ruiz Dorantes 	"Remote Host Supported Features Notification"
644d081e691SOliver Ruiz Dorantes };
645d081e691SOliver Ruiz Dorantes 
646d081e691SOliver Ruiz Dorantes 
647880e5727SOliver Ruiz Dorantes const char* bluetoothErrors[] = {
64840c666a5SOliver Ruiz Dorantes 	"No Error",
64940c666a5SOliver Ruiz Dorantes 	"Unknown Command",
65040c666a5SOliver Ruiz Dorantes 	"No Connection",
65140c666a5SOliver Ruiz Dorantes 	"Hardware Failure",
65240c666a5SOliver Ruiz Dorantes 	"Page Timeout",
65340c666a5SOliver Ruiz Dorantes 	"Authentication Failure",
65440c666a5SOliver Ruiz Dorantes 	"Pin Or Key Missing",
65540c666a5SOliver Ruiz Dorantes 	"Memory Full",
65640c666a5SOliver Ruiz Dorantes 	"Connection Timeout",
65740c666a5SOliver Ruiz Dorantes 	"Max Number Of Connections",
65840c666a5SOliver Ruiz Dorantes 	"Max Number Of Sco Connections",
65940c666a5SOliver Ruiz Dorantes 	"Acl Connection Exists",
66040c666a5SOliver Ruiz Dorantes 	"Command Disallowed",
66140c666a5SOliver Ruiz Dorantes 	"Rejected Limited Resources",
66240c666a5SOliver Ruiz Dorantes 	"Rejected Security",
66340c666a5SOliver Ruiz Dorantes 	"Rejected Personal",
66440c666a5SOliver Ruiz Dorantes 	"Host Timeout",
66540c666a5SOliver Ruiz Dorantes 	"Unsupported Feature",
66640c666a5SOliver Ruiz Dorantes 	"Invalid Parameters",
66740c666a5SOliver Ruiz Dorantes 	"Remote User Ended Connection",
66840c666a5SOliver Ruiz Dorantes 	"Remote Low Resources",
66940c666a5SOliver Ruiz Dorantes 	"Remote Power Off",
67040c666a5SOliver Ruiz Dorantes 	"Connection Terminated",
67140c666a5SOliver Ruiz Dorantes 	"Repeated Attempts",
67240c666a5SOliver Ruiz Dorantes 	"Pairing Not Allowed",
67340c666a5SOliver Ruiz Dorantes 	"Unknown Lmp Pdu",
67440c666a5SOliver Ruiz Dorantes 	"Unsupported Remote Feature",
67540c666a5SOliver Ruiz Dorantes 	"Sco Offset Rejected",
67640c666a5SOliver Ruiz Dorantes 	"Sco Interval Rejected",
67740c666a5SOliver Ruiz Dorantes 	"Air Mode Rejected",
67840c666a5SOliver Ruiz Dorantes 	"Invalid Lmp Parameters",
67940c666a5SOliver Ruiz Dorantes 	"Unspecified Error",
68040c666a5SOliver Ruiz Dorantes 	"Unsupported Lmp Parameter Value",
68140c666a5SOliver Ruiz Dorantes 	"Role Change Not Allowed",
68240c666a5SOliver Ruiz Dorantes 	"Lmp Response Timeout",
68340c666a5SOliver Ruiz Dorantes 	"Lmp Error Transaction Collision",
68440c666a5SOliver Ruiz Dorantes 	"Lmp Pdu Not Allowed",
68540c666a5SOliver Ruiz Dorantes 	"Encryption Mode Not Accepted",
68640c666a5SOliver Ruiz Dorantes 	"Unit Link Key Used",
68740c666a5SOliver Ruiz Dorantes 	"Qos Not Supported",
68840c666a5SOliver Ruiz Dorantes 	"Instant Passed",
68940c666a5SOliver Ruiz Dorantes 	"Pairing With Unit Key Not Supported",
69040c666a5SOliver Ruiz Dorantes 	"Different Transaction Collision",
69140c666a5SOliver Ruiz Dorantes 	"Qos Unacceptable Parameter",
69240c666a5SOliver Ruiz Dorantes 	"Qos Rejected",
69340c666a5SOliver Ruiz Dorantes 	"Classification Not Supported",
69440c666a5SOliver Ruiz Dorantes 	"Insufficient Security",
69540c666a5SOliver Ruiz Dorantes 	"Parameter Out Of Range",
696880e5727SOliver Ruiz Dorantes 	"Reserved",
69740c666a5SOliver Ruiz Dorantes 	"Role Switch Pending",
698880e5727SOliver Ruiz Dorantes 	"Reserved",
69940c666a5SOliver Ruiz Dorantes 	"Slot Violation",
70040c666a5SOliver Ruiz Dorantes 	"Role Switch Failed",
70140c666a5SOliver Ruiz Dorantes 	"Extended Inquiry Response Too Large",
70240c666a5SOliver Ruiz Dorantes 	"Simple Pairing Not Supported By Host",
70340c666a5SOliver Ruiz Dorantes 	"Host Busy Pairing"
704880e5727SOliver Ruiz Dorantes };
705880e5727SOliver Ruiz Dorantes 
706880e5727SOliver Ruiz Dorantes 
7078dc33083SOliver Ruiz Dorantes const char* hciVersion[] = { "1.0B" , "1.1 " , "1.2 " , "2.0 " , "2.1 "};
7088dc33083SOliver Ruiz Dorantes const char* lmpVersion[] = { "1.0 " , "1.1 " , "1.2 " , "2.0 " , "2.1 "};
709bd88ac97SOliver Ruiz Dorantes 
710bd88ac97SOliver Ruiz Dorantes 
71140c666a5SOliver Ruiz Dorantes #if 0
71240c666a5SOliver Ruiz Dorantes #pragma mark -
71340c666a5SOliver Ruiz Dorantes #endif
71440c666a5SOliver Ruiz Dorantes 
71540c666a5SOliver Ruiz Dorantes 
716bd88ac97SOliver Ruiz Dorantes const char*
717ddac4074SOliver Ruiz Dorantes BluetoothHciVersion(uint16 ver)
718bd88ac97SOliver Ruiz Dorantes {
719*fef016caSFredrik Modéen 	CALLED();
720bd88ac97SOliver Ruiz Dorantes 	return hciVersion[ver];
721bd88ac97SOliver Ruiz Dorantes }
722bd88ac97SOliver Ruiz Dorantes 
723bd88ac97SOliver Ruiz Dorantes 
724bd88ac97SOliver Ruiz Dorantes const char*
725ddac4074SOliver Ruiz Dorantes BluetoothLmpVersion(uint16 ver)
726bd88ac97SOliver Ruiz Dorantes {
727*fef016caSFredrik Modéen 	CALLED();
728bd88ac97SOliver Ruiz Dorantes 	return lmpVersion[ver];
729bd88ac97SOliver Ruiz Dorantes }
730bd88ac97SOliver Ruiz Dorantes 
731bd88ac97SOliver Ruiz Dorantes 
732a7c3c465SOliver Ruiz Dorantes const char*
733ddac4074SOliver Ruiz Dorantes BluetoothCommandOpcode(uint16 opcode)
734a7c3c465SOliver Ruiz Dorantes {
735*fef016caSFredrik Modéen 	CALLED();
736ddac4074SOliver Ruiz Dorantes 	// NOTE: BT implementations beyond 2.1
737a7c3c465SOliver Ruiz Dorantes 	// could specify new commands with OCF numbers
738a7c3c465SOliver Ruiz Dorantes 	// beyond the boundaries of the arrays and crash.
739a7c3c465SOliver Ruiz Dorantes 	// But only our stack could issue them so its under
740a7c3c465SOliver Ruiz Dorantes 	// our control.
741ddac4074SOliver Ruiz Dorantes 	switch (GET_OPCODE_OGF(opcode)) {
742a7c3c465SOliver Ruiz Dorantes 		case OGF_LINK_CONTROL:
743ddac4074SOliver Ruiz Dorantes 			return linkControlCommands[GET_OPCODE_OCF(opcode) - 1];
744a7c3c465SOliver Ruiz Dorantes 			break;
745a7c3c465SOliver Ruiz Dorantes 
746a7c3c465SOliver Ruiz Dorantes 		case OGF_LINK_POLICY:
747ddac4074SOliver Ruiz Dorantes 			return linkPolicyCommands[GET_OPCODE_OCF(opcode) - 1];
748a7c3c465SOliver Ruiz Dorantes 			break;
749a7c3c465SOliver Ruiz Dorantes 
750a7c3c465SOliver Ruiz Dorantes 		case OGF_CONTROL_BASEBAND:
751ddac4074SOliver Ruiz Dorantes 			return controllerBasebandCommands[GET_OPCODE_OCF(opcode) - 1];
752a7c3c465SOliver Ruiz Dorantes 			break;
753a7c3c465SOliver Ruiz Dorantes 
754a7c3c465SOliver Ruiz Dorantes 		case OGF_INFORMATIONAL_PARAM:
755ddac4074SOliver Ruiz Dorantes 			return informationalParametersCommands[GET_OPCODE_OCF(opcode) - 1];
756a7c3c465SOliver Ruiz Dorantes 			break;
757a7c3c465SOliver Ruiz Dorantes 
758a7c3c465SOliver Ruiz Dorantes 		case OGF_STATUS_PARAM:
759ddac4074SOliver Ruiz Dorantes 			return statusParametersCommands[GET_OPCODE_OCF(opcode) - 1];
760a7c3c465SOliver Ruiz Dorantes 			break;
761a7c3c465SOliver Ruiz Dorantes 
762a7c3c465SOliver Ruiz Dorantes 		case OGF_TESTING_CMD:
763ddac4074SOliver Ruiz Dorantes 			return testingCommands[GET_OPCODE_OCF(opcode) - 1];
764a7c3c465SOliver Ruiz Dorantes 			break;
7650b5931e0SOliver Ruiz Dorantes 		case OGF_VENDOR_CMD:
7660b5931e0SOliver Ruiz Dorantes 			return "Vendor specific command";
7670b5931e0SOliver Ruiz Dorantes 			break;
768a7c3c465SOliver Ruiz Dorantes 		default:
769a7c3c465SOliver Ruiz Dorantes 			return "Unknown command";
770a7c3c465SOliver Ruiz Dorantes 			break;
771a7c3c465SOliver Ruiz Dorantes 	}
772a7c3c465SOliver Ruiz Dorantes 
773a7c3c465SOliver Ruiz Dorantes }
774a7c3c465SOliver Ruiz Dorantes 
775a7c3c465SOliver Ruiz Dorantes 
776a7c3c465SOliver Ruiz Dorantes const char*
77740c666a5SOliver Ruiz Dorantes BluetoothEvent(uint8 event)
77840c666a5SOliver Ruiz Dorantes {
779*fef016caSFredrik Modéen 	CALLED();
78040c666a5SOliver Ruiz Dorantes 	if (event < sizeof(bluetoothEvents) / sizeof(const char*))
781d081e691SOliver Ruiz Dorantes 		return bluetoothEvents[event - 1];
78240c666a5SOliver Ruiz Dorantes 	else
78340c666a5SOliver Ruiz Dorantes 		return "Event out of Range!";
784d081e691SOliver Ruiz Dorantes }
785d081e691SOliver Ruiz Dorantes 
786d081e691SOliver Ruiz Dorantes 
787d081e691SOliver Ruiz Dorantes const char*
78840c666a5SOliver Ruiz Dorantes BluetoothManufacturer(uint16 manufacturer)
78940c666a5SOliver Ruiz Dorantes {
790*fef016caSFredrik Modéen 	CALLED();
79140c666a5SOliver Ruiz Dorantes 	if (manufacturer < sizeof(bluetoothManufacturers) / sizeof(const char*))
792a7c3c465SOliver Ruiz Dorantes 		return bluetoothManufacturers[manufacturer];
79340c666a5SOliver Ruiz Dorantes 	else if (manufacturer == 0xFFFF)
794a7c3c465SOliver Ruiz Dorantes 		return "internal use";
79540c666a5SOliver Ruiz Dorantes 	else
796a7c3c465SOliver Ruiz Dorantes 		return "not assigned";
797a7c3c465SOliver Ruiz Dorantes }
798880e5727SOliver Ruiz Dorantes 
799880e5727SOliver Ruiz Dorantes 
800880e5727SOliver Ruiz Dorantes const char*
80140c666a5SOliver Ruiz Dorantes BluetoothError(uint8 error)
80240c666a5SOliver Ruiz Dorantes {
803*fef016caSFredrik Modéen 	CALLED();
80440c666a5SOliver Ruiz Dorantes 	if (error < sizeof(bluetoothErrors) / sizeof(const char*))
805880e5727SOliver Ruiz Dorantes 		return bluetoothErrors[error];
80640c666a5SOliver Ruiz Dorantes 	else
807880e5727SOliver Ruiz Dorantes 		return "not specified";
808880e5727SOliver Ruiz Dorantes }
809