[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] Snippets for reading country code



Hi,

I tried playing around with adding HCI commands to the Axis stack, and
think i managed to get Read_Country_Code working. However, I don't have
any French (or Spanish?) equipment so I can't be sure. Anyway, below are
some lines of code together with comments explaining where they belong,
and kernel log messages. If anything is incorrect let me know.

Kind regards,

Per

/* Code snippets for adding HCI command Read_Country_Code to Axis stack
** Based on HCI command Read_Scan_Enable, which was already implemented
** and very similar :)
*/

// File: btcommon.h, bt_if.h if using experimental stack
#define HCIREADCOUNTRYCODE _IOR(BT_IOC_MAGIC, 0X43, S32)


// File: hci.h
s32 hci_read_country_code(void);


// File: bluetooth.c (in /* Informational Parameters */ section)
case HCIREADCOUNTRYCODE:
	BT_DRIVER(FNC"HCIREADCOUNTRYCODE\n");
	tmp = hci_read_country_code();
	put_user(tmp, (s32*) arg);
	break;


// File: hci.c (in switch ogf, case HCI_IP section)
case READ_COUNTRY_CODE:
	D_CMD(__FUNCTION__": READ_COUNTRY_CODE\n");
	if (r_val[0]) {
		D_ERR(__FUNCTION__": READ_COUNTRY_CODE: %s\n",
			get_err_msg(r_val[0]));
		result_param =-r_val[0];
	} else {
		result_param = r_val[1];
	}
	printk("READ_COUNTRY_CODE %d\n", result_param);
	break;


// ioctl call in sample program
int c_code = 12; // To make sure it is actually changed :)
ioctl(bt_cfd, HCIREADCOUNTRYCODE, &c_code);
printf("-- Country code: %d\n", c_code); // output is "--Country code: 0"


// Kernel log output, with some debug turned on
Jul 29 13:20:47 pixel09 kernel: BT (driver) bt_open on line 7
Jul 29 13:20:47 pixel09 kernel: BT (driver) Registering tty on line 7 (bts)
Jul 29 13:20:47 pixel09 kernel: BT (driver) Now 2 open fd:s for ttyBTC [bts]
Jul 29 13:20:47 pixel09 kernel: BT (driver) bt_flush_buffer, ignored
Jul 29 13:20:47 pixel09 kernel: BT (driver) bt_ioctl: HCIREADCOUNTRYCODE
Jul 29 13:20:47 pixel09 kernel: HCI: hci_read_country_code
Jul 29 13:20:47 pixel09 kernel: HCI: start_cmd_timer
Jul 29 13:20:47 pixel09 kernel: HCI: insert_cmd
Jul 29 13:20:47 pixel09 kernel: HCI: send_cmd_queue: start: Num_HCI_Command_Packets=1
Jul 29 13:20:47 pixel09 kernel:
Jul 29 13:20:47 pixel09 kernel: send_cmd_queue:  (4):
Jul 29 13:20:47 pixel09 kernel: 0x01 0x07 0x10 0x00
Jul 29 13:20:47 pixel09 kernel: HCI: send_cmd_queue: end : 0 cmds left in queue
Jul 29 13:20:47 pixel09 kernel:
Jul 29 13:20:47 pixel09 kernel: hci_receive_data:  (8):
Jul 29 13:20:47 pixel09 kernel: 0x04 0x0e 0x05 0x01 0x07 0x10 0x00 0x00
Jul 29 13:20:47 pixel09 kernel: hci_receive_data: hci-8
Jul 29 13:20:47 pixel09 kernel: HCI: hci_receive_data: WAIT_FOR_PACKET_TYPE
Jul 29 13:20:47 pixel09 kernel: HCI: hci_receive_data: WAIT_FOR_EVENT_TYPE
Jul 29 13:20:47 pixel09 kernel: HCI: hci_receive_data: WAIT_FOR_EVENT_LENGTH
Jul 29 13:20:47 pixel09 kernel:
Jul 29 13:20:47 pixel09 kernel: process_event (5):
Jul 29 13:20:47 pixel09 kernel: 0x01 0x07 0x10 0x00 0x00
Jul 29 13:20:47 pixel09 kernel: HCI: process_event: COMMAND_COMPLETE
Jul 29 13:20:47 pixel09 kernel: HCI: <CC>
Jul 29 13:20:47 pixel09 kernel: HCI: release_cmd_timer
Jul 29 13:20:47 pixel09 kernel: HCI: process_return_param: READ_COUNTRY_CODE
Jul 29 13:20:47 pixel09 kernel: READ_COUNTRY_CODE 0
Jul 29 13:20:47 pixel09 kernel: HCI: update_nhcp: Num_HCI_Command_Packets=1
Jul 29 13:20:47 pixel09 kernel: HCI: send_cmd_queue: start: Num_HCI_Command_Packets=1
Jul 29 13:20:47 pixel09 kernel: HCI: send_cmd_queue: end : 0 cmds left in queue
Jul 29 13:20:51 pixel09 kernel: BT (driver) bt_close on line 7
Jul 29 13:20:51 pixel09 kernel: BT (driver) Unregistering tty on line 7




-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com