hci: fix compile warnings

This commit is contained in:
Matthias Ringwald 2020-07-25 22:56:43 +02:00
parent 697b823e5f
commit c3b46f5a8b

View File

@ -829,9 +829,7 @@ int hci_send_sco_packet_buffer(int size){
} }
#endif #endif
static void acl_handler(uint8_t *packet, int size){ static void acl_handler(uint8_t *packet, uint16_t size){
// log_info("acl_handler: size %u", size);
// get info // get info
hci_con_handle_t con_handle = READ_ACL_CONNECTION_HANDLE(packet); hci_con_handle_t con_handle = READ_ACL_CONNECTION_HANDLE(packet);
@ -841,13 +839,13 @@ static void acl_handler(uint8_t *packet, int size){
// ignore non-registered handle // ignore non-registered handle
if (!conn){ if (!conn){
log_error( "hci.c: acl_handler called with non-registered handle %u!" , con_handle); log_error("acl_handler called with non-registered handle %u!" , con_handle);
return; return;
} }
// assert packet is complete // assert packet is complete
if ((acl_length + 4u) != size){ if ((acl_length + 4u) != size){
log_error("hci.c: acl_handler called with ACL packet of wrong size %d, expected %u => dropping packet", size, acl_length + 4); log_error("acl_handler called with ACL packet of wrong size %d, expected %u => dropping packet", size, acl_length + 4);
return; return;
} }
@ -883,9 +881,6 @@ static void acl_handler(uint8_t *packet, int size){
&packet[4], acl_length); &packet[4], acl_length);
conn->acl_recombination_pos += acl_length; conn->acl_recombination_pos += acl_length;
// log_error( "ACL Cont Fragment: acl_len %u, combined_len %u, l2cap_len %u", acl_length,
// conn->acl_recombination_pos, conn->acl_recombination_length);
// forward complete L2CAP packet if complete. // forward complete L2CAP packet if complete.
if (conn->acl_recombination_pos >= (conn->acl_recombination_length + 4u + 4u)){ // pos already incl. ACL header if (conn->acl_recombination_pos >= (conn->acl_recombination_length + 4u + 4u)){ // pos already incl. ACL header
hci_emit_acl_packet(&conn->acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE], conn->acl_recombination_pos); hci_emit_acl_packet(&conn->acl_recombination_buffer[HCI_INCOMING_PRE_BUFFER_SIZE], conn->acl_recombination_pos);
@ -906,8 +901,6 @@ static void acl_handler(uint8_t *packet, int size){
// peek into L2CAP packet! // peek into L2CAP packet!
uint16_t l2cap_length = READ_L2CAP_LENGTH( packet ); uint16_t l2cap_length = READ_L2CAP_LENGTH( packet );
// log_info( "ACL First Fragment: acl_len %u, l2cap_len %u", acl_length, l2cap_length);
// compare fragment size to L2CAP packet size // compare fragment size to L2CAP packet size
if (acl_length >= (l2cap_length + 4u)){ if (acl_length >= (l2cap_length + 4u)){
// forward fragment as L2CAP packet // forward fragment as L2CAP packet
@ -931,7 +924,7 @@ static void acl_handler(uint8_t *packet, int size){
} }
default: default:
log_error( "hci.c: acl_handler called with invalid packet boundary flags %u", acl_flags & 0x03); log_error( "acl_handler called with invalid packet boundary flags %u", acl_flags & 0x03);
return; return;
} }
@ -2000,7 +1993,7 @@ static void handle_command_complete_event(uint8_t * packet, uint16_t size){
break; break;
case HCI_OPCODE_HCI_READ_BUFFER_SIZE: case HCI_OPCODE_HCI_READ_BUFFER_SIZE:
// "The HC_ACL_Data_Packet_Length return parameter will be used to determine the size of the L2CAP segments contained in ACL Data Packets" // "The HC_ACL_Data_Packet_Length return parameter will be used to determine the size of the L2CAP segments contained in ACL Data Packets"
if (hci_stack->state != HCI_STATE_INITIALIZING) break; if (hci_stack->state == HCI_STATE_INITIALIZING) {
uint16_t acl_len = little_endian_read_16(packet, 6); uint16_t acl_len = little_endian_read_16(packet, 6);
uint16_t sco_len = packet[8]; uint16_t sco_len = packet[8];
@ -2014,6 +2007,7 @@ static void handle_command_complete_event(uint8_t * packet, uint16_t size){
log_info("hci_read_buffer_size: ACL size module %u -> used %u, count %u / SCO size %u, count %u", log_info("hci_read_buffer_size: ACL size module %u -> used %u, count %u / SCO size %u, count %u",
acl_len, hci_stack->acl_data_packet_length, hci_stack->acl_packets_total_num, acl_len, hci_stack->acl_data_packet_length, hci_stack->acl_packets_total_num,
hci_stack->sco_data_packet_length, hci_stack->sco_packets_total_num); hci_stack->sco_data_packet_length, hci_stack->sco_packets_total_num);
}
break; break;
case HCI_OPCODE_HCI_READ_RSSI: case HCI_OPCODE_HCI_READ_RSSI:
if (packet[5] == ERROR_CODE_SUCCESS){ if (packet[5] == ERROR_CODE_SUCCESS){
@ -2115,7 +2109,7 @@ static void handle_command_complete_event(uint8_t * packet, uint16_t size){
status = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE]; status = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE];
handle = little_endian_read_16(packet, OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1); handle = little_endian_read_16(packet, OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1);
conn = hci_connection_for_handle(handle); conn = hci_connection_for_handle(handle);
if (!conn) return; if (conn != NULL) {
uint8_t key_size = 0; uint8_t key_size = 0;
if (status == 0){ if (status == 0){
key_size = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+3]; key_size = packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+3];
@ -2124,6 +2118,7 @@ static void handle_command_complete_event(uint8_t * packet, uint16_t size){
log_info("Read Encryption Key Size failed 0x%02x-> assuming insecure connection with key size of 1", status); log_info("Read Encryption Key Size failed 0x%02x-> assuming insecure connection with key size of 1", status);
} }
hci_handle_read_encryption_key_size_complete(conn, key_size); hci_handle_read_encryption_key_size_complete(conn, key_size);
}
break; break;
#endif #endif
default: default:
@ -2131,7 +2126,7 @@ static void handle_command_complete_event(uint8_t * packet, uint16_t size){
} }
} }
static void event_handler(uint8_t *packet, int size){ static void event_handler(uint8_t *packet, uint16_t size){
uint16_t event_length = packet[1]; uint16_t event_length = packet[1];