diff --git a/example/l2cap-server.c b/example/l2cap-server.c index 8b2373fa7..81f607250 100644 --- a/example/l2cap-server.c +++ b/example/l2cap-server.c @@ -118,7 +118,9 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint if ( COMMAND_COMPLETE_EVENT(packet, hci_write_local_name) ) { bt_send_cmd(&hci_write_authentication_enable, 0); } - + if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) { + bt_send_cmd(&hci_write_class_of_device, 0x2580); + } default: // other event break; diff --git a/src/hci.c b/src/hci.c index 70c92d043..0e8563977 100644 --- a/src/hci.c +++ b/src/hci.c @@ -188,15 +188,21 @@ static void event_handler(uint8_t *packet, int size){ break; case HCI_EVENT_CONNECTION_REQUEST: - bt_flip_addr(addr, &packet[5]); - printf("Connection_incoming: "); print_bd_addr(addr); printf("\n"); - conn = connection_for_address(addr); - if (!conn) { - conn = create_connection_for_addr(addr); + bt_flip_addr(addr, &packet[2]); + // TODO: eval COD 8-10 + uint8_t link_type = packet[11]; + printf("Connection_incoming: "); print_bd_addr(addr); printf(", type %u\n", link_type); + if (link_type == 1) { // ACL + conn = connection_for_address(addr); + if (!conn) { + conn = create_connection_for_addr(addr); + } + // TODO: check for malloc failure + conn->state = ACCEPTED_CONNECTION_REQUEST; + hci_send_cmd(&hci_accept_connection_request, addr, 1); + } else { + // TODO: decline request } - // TODO: check for malloc failure - conn->state = ACCEPTED_CONNECTION_REQUEST; - hci_send_cmd(&hci_accept_connection_request, 1); break; case HCI_EVENT_CONNECTION_COMPLETE: