(btstack_hid) Cleanups

This commit is contained in:
twinaphex 2015-04-04 01:41:20 +02:00
parent 677723ba3c
commit 55a162a77b

View File

@ -496,9 +496,11 @@ void btpad_packet_handler(uint8_t packet_type,
{
struct pad_connection *connection = &g_connections[i];
if (connection && connection->state == BTPAD_CONNECTED
&& (connection->channels[0] == channel ||
connection->channels[1] == channel))
if (!connection || connection->state != BTPAD_CONNECTED)
continue;
if ( connection->channels[0] == channel
|| connection->channels[1] == channel)
pad_connection_packet(&slots[connection->slot], connection->slot, packet, size);
}
break;
@ -512,9 +514,10 @@ void btpad_packet_handler(uint8_t packet_type,
{
case HCI_STATE_WORKING:
btpad_queue_reset();
btpad_queue_hci_read_bd_addr(cmd);
/* TODO: Where did I get 672 for MTU? */
bt_send_cmd_ptr(l2cap_register_service_ptr,
PSM_HID_CONTROL, 672);
bt_send_cmd_ptr(l2cap_register_service_ptr,
@ -552,9 +555,11 @@ void btpad_packet_handler(uint8_t packet_type,
case HCI_EVENT_INQUIRY_RESULT:
if (packet[2])
{
struct pad_connection* connection = NULL;
bt_flip_addr_ptr(event_addr, &packet[3]);
struct pad_connection* connection = btpad_find_empty_connection();
connection = btpad_find_empty_connection();
if (!connection)
return;