read buffer size on hci init

This commit is contained in:
matthias.ringwald 2010-07-25 15:11:33 +00:00
parent 3ba22b71f3
commit e2edc0c398
4 changed files with 33 additions and 10 deletions

View File

@ -209,6 +209,7 @@ extern hci_cmd_t hci_pin_code_request_reply;
extern hci_cmd_t hci_pin_code_request_negative_reply;
extern hci_cmd_t hci_qos_setup;
extern hci_cmd_t hci_read_bd_addr;
extern hci_cmd_t hci_read_buffer_size;
extern hci_cmd_t hci_read_link_policy_settings;
extern hci_cmd_t hci_read_link_supervision_timeout;
extern hci_cmd_t hci_remote_name_request;

View File

@ -257,12 +257,24 @@ static void event_handler(uint8_t *packet, int size){
hci_con_handle_t handle;
hci_connection_t * conn;
// get num_cmd_packets
if (packet[0] == HCI_EVENT_COMMAND_COMPLETE || packet[0] == HCI_EVENT_COMMAND_STATUS){
// Get Num_HCI_Command_Packets
hci_stack.num_cmd_packets = packet[2];
}
switch (packet[0]) {
case HCI_EVENT_COMMAND_COMPLETE:
case HCI_EVENT_COMMAND_STATUS:
// Get Num_HCI_Command_Packets
hci_stack.num_cmd_packets = packet[2];
if (COMMAND_COMPLETE_EVENT(packet, hci_read_buffer_size)){
// from offset 5
// status
hci_stack.acl_data_packet_length = READ_BT_16(packet, 6);
// SCO data packet len (8)
hci_stack.total_num_acl_packets = packet[9];
// total num SCO packets
log_dbg("hci_read_buffer_size: size %u, count %u\n", hci_stack.acl_data_packet_length, hci_stack.total_num_acl_packets);
}
break;
case HCI_EVENT_CONNECTION_REQUEST:
@ -462,14 +474,17 @@ void hci_run(){
case 1:
hci_send_cmd(&hci_read_bd_addr);
break;
case 2:
case 2:
hci_send_cmd(&hci_read_buffer_size);
break;
case 3:
// ca. 15 sec
hci_send_cmd(&hci_write_page_timeout, 0x6000);
break;
case 3:
case 4:
hci_send_cmd(&hci_write_scan_enable, 3); // 3 inq scan + page scan
break;
case 4:
case 5:
// done.
hci_stack.state = HCI_STATE_WORKING;
hci_emit_state();

View File

@ -189,7 +189,9 @@ typedef struct {
/* host to controller flow control */
uint8_t num_cmd_packets;
uint8_t num_acl_packets;
// uint8_t total_num_cmd_packets;
uint8_t total_num_acl_packets;
uint16_t acl_data_packet_length;
/* callback to L2CAP layer */
void (*packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size);

View File

@ -238,7 +238,7 @@ OPCODE(OGF_LINK_POLICY, 0x0c), "H"
};
hci_cmd_t hci_write_link_policy_settings = {
OPCODE(OGF_LINK_POLICY, 0x0d), "H2"
// handlee, settings
// handle, settings
};
/**
@ -296,19 +296,24 @@ 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
};
/**
* Informational Parameters
*/
hci_cmd_t hci_read_buffer_size = {
OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x05), ""
// no params
};
hci_cmd_t hci_read_bd_addr = {
OPCODE(OGF_INFORMATIONAL_PARAMETERS, 0x09), ""
// no params
};
// BTstack commands
hci_cmd_t btstack_get_state = {
OPCODE(OGF_BTSTACK, BTSTACK_GET_STATE), ""
// no params ->