mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-12 15:47:14 +00:00
read buffer size on hci init
This commit is contained in:
parent
3ba22b71f3
commit
e2edc0c398
@ -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;
|
||||
|
27
src/hci.c
27
src/hci.c
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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 ->
|
||||
|
Loading…
Reference in New Issue
Block a user