add more HCI commands

This commit is contained in:
matthias.ringwald 2009-07-01 20:56:27 +00:00
parent 40c7e443c8
commit bd67ef2f9d
2 changed files with 55 additions and 10 deletions

View File

@ -11,12 +11,6 @@
#include <stdio.h>
#include "hci.h"
// calculate combined ogf/ocf value
#define OPCODE(ogf, ocf) (ocf | ogf << 10)
#define OGF_LINK_CONTROL 0x01
#define OGF_CONTROLLER_BASEBAND 0x03
#define OGF_INFORMATIONAL_PARAMETERS 0x04
/**
* Link Control Commands
*/
@ -56,6 +50,10 @@ hci_cmd_t hci_remote_name_request = {
/**
* Controller & Baseband Commands
*/
hci_cmd_t hci_set_event_mask = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x01), "44"
// event_mask lower 4 octets, higher 4 bytes
};
hci_cmd_t hci_reset = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x03), ""
// no params
@ -64,24 +62,46 @@ hci_cmd_t hci_delete_stored_link_key = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x12), "B1"
// BD_ADDR, Delete_All_Flag
};
hci_cmd_t hci_write_local_name = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x13), "N"
// Local name (UTF-8, Null Terminated, max 248 octets)
};
hci_cmd_t hci_write_page_timeout = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x18), "2"
// Page_Timeout * 0.625 ms
};
hci_cmd_t hci_write_scan_enable = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x1A), "1"
// Scan_enable: no, inq, page, inq+page
OPCODE(OGF_CONTROLLER_BASEBAND, 0x1A), "1"
// Scan_enable: no, inq, page, inq+page
};
hci_cmd_t hci_write_authentication_enable = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x20), "1"
// Authentication_Enable
};
hci_cmd_t hci_write_class_of_device = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x24), "3"
// Class of Device
};
hci_cmd_t hci_host_buffer_size = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x33), "2122"
// Host_ACL_Data_Packet_Length:, Host_Synchronous_Data_Packet_Length:, Host_Total_Num_ACL_Data_Packets:, Host_Total_Num_Synchronous_Data_Packets:
};
hci_cmd_t hci_write_inquiry_mode = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x45), "1"
// Inquiry mode: 0x00 = standard, 0x01 = with RSSI, 0x02 = extended
};
hci_cmd_t hci_write_extended_inquiry_response = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x52), "1E"
// FEC_Required, Exstended Inquiry Response
};
hci_cmd_t hci_write_simple_pairing_mode = {
OPCODE(OGF_CONTROLLER_BASEBAND, 0x56), "1"
// mode: 0 = off, 1 = on
};
hci_cmd_t hci_read_bd_addr = {
OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x09), ""
// no params
@ -294,7 +314,7 @@ uint32_t hci_run(){
hci_send_cmd(&hci_write_page_timeout, 0x6000);
break;
case 3:
hci_send_cmd(&hci_write_scan_enable, 3);
hci_send_cmd(&hci_write_scan_enable, 3); // 3 inq scan + page scan
break;
case 4:
// done.
@ -374,6 +394,16 @@ int hci_send_cmd(hci_cmd_t *cmd, ...){
memcpy(&hci_cmd_buffer[pos], ptr, 16);
pos += 16;
break;
case 'N': // UTF-8 string, null terminated
ptr = va_arg(argptr, uint8_t *);
memcpy(&hci_cmd_buffer[pos], ptr, 248);
pos += 248;
break;
case 'E': // Extended Inquiry Information 240 octets
ptr = va_arg(argptr, uint8_t *);
memcpy(&hci_cmd_buffer[pos], ptr, 240);
pos += 240;
break;
default:
break;
}

View File

@ -18,12 +18,21 @@
#define READ_BT_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16))
#define READ_BT_32( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16) | (((uint32_t) buffer[pos+3])) << 24)
// calculate combined ogf/ocf value
#define OPCODE(ogf, ocf) (ocf | ogf << 10)
// packet header lengh
#define HCI_CMD_DATA_PKT_HDR 0x03
#define HCI_ACL_DATA_PKT_HDR 0x04
#define HCI_SCO_DATA_PKT_HDR 0x03
#define HCI_EVENT_PKT_HDR 0x02
// OGFs
#define OGF_LINK_CONTROL 0x01
#define OGF_CONTROLLER_BASEBAND 0x03
#define OGF_INFORMATIONAL_PARAMETERS 0x04
#define OGF_VENDOR_COMMANDS 0x3f
// Events from host controller to host
#define HCI_EVENT_INQUIRY_COMPLETE 0x01
#define HCI_EVENT_INQUIRY_RESULT 0x02
@ -181,14 +190,20 @@ extern hci_cmd_t hci_inquiry;
extern hci_cmd_t hci_inquiry_cancel;
extern hci_cmd_t hci_link_key_request_negative_reply;
extern hci_cmd_t hci_pin_code_request_reply;
extern hci_cmd_t hci_set_event_mask;
extern hci_cmd_t hci_reset;
extern hci_cmd_t hci_create_connection;
extern hci_cmd_t hci_host_buffer_size;
extern hci_cmd_t hci_write_authentication_enable;
extern hci_cmd_t hci_write_local_name;
extern hci_cmd_t hci_write_page_timeout;
extern hci_cmd_t hci_write_class_of_device;
extern hci_cmd_t hci_remote_name_request;
extern hci_cmd_t hci_remote_name_request_cancel;
extern hci_cmd_t hci_read_bd_addr;
extern hci_cmd_t hci_delete_stored_link_key;
extern hci_cmd_t hci_write_scan_enable;
extern hci_cmd_t hci_accept_connection_request;
extern hci_cmd_t hci_write_inquiry_mode;
extern hci_cmd_t hci_write_extended_inquiry_response;
extern hci_cmd_t hci_write_simple_pairing_mode;