hci.c (63c0b2fd6d47826d696ed89a933941c3cab4e3ad) | hci.c (308eeaffaa1b7bc3f35655c74d782ef314fd65cd) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2813 unchanged lines hidden (view full) --- 2822 break; 2823 } 2824 if (!done) break; 2825 } 2826 hci_handle_remote_features_received(conn); 2827 break; 2828 2829 case HCI_EVENT_LINK_KEY_REQUEST: | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2813 unchanged lines hidden (view full) --- 2822 break; 2823 } 2824 if (!done) break; 2825 } 2826 hci_handle_remote_features_received(conn); 2827 break; 2828 2829 case HCI_EVENT_LINK_KEY_REQUEST: |
2830#ifndef ENABLE_EXPLICIT_LINK_KEY_REPLY |
|
2830 hci_event_link_key_request_get_bd_addr(packet, addr); 2831 conn = hci_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL); 2832 if (!conn) break; 2833 2834 // lookup link key in db if not cached 2835 if ((conn->link_key_type == INVALID_LINK_KEY) && (hci_stack->link_key_db != NULL)){ 2836 hci_stack->link_key_db->get_link_key(conn->address, conn->link_key, &conn->link_key_type); 2837 } --- 3690 unchanged lines hidden (view full) --- 6528 * @param pin 6529 * @return 0 if ok 6530 */ 6531int gap_ssp_confirmation_negative(const bd_addr_t addr){ 6532 if (hci_stack->gap_pairing_state != GAP_PAIRING_STATE_IDLE) return ERROR_CODE_COMMAND_DISALLOWED; 6533 return gap_pairing_set_state_and_run(addr, GAP_PAIRING_STATE_SEND_CONFIRMATION_NEGATIVE); 6534} 6535 | 2831 hci_event_link_key_request_get_bd_addr(packet, addr); 2832 conn = hci_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL); 2833 if (!conn) break; 2834 2835 // lookup link key in db if not cached 2836 if ((conn->link_key_type == INVALID_LINK_KEY) && (hci_stack->link_key_db != NULL)){ 2837 hci_stack->link_key_db->get_link_key(conn->address, conn->link_key, &conn->link_key_type); 2838 } --- 3690 unchanged lines hidden (view full) --- 6529 * @param pin 6530 * @return 0 if ok 6531 */ 6532int gap_ssp_confirmation_negative(const bd_addr_t addr){ 6533 if (hci_stack->gap_pairing_state != GAP_PAIRING_STATE_IDLE) return ERROR_CODE_COMMAND_DISALLOWED; 6534 return gap_pairing_set_state_and_run(addr, GAP_PAIRING_STATE_SEND_CONFIRMATION_NEGATIVE); 6535} 6536 |
6536#ifdef ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY 6537 | 6537#if defined(ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY) || defined(ENABLE_EXPLICIT_LINK_KEY_REPLY) |
6538static uint8_t gap_set_auth_flag_and_run(const bd_addr_t addr, hci_authentication_flags_t flag){ 6539 hci_connection_t * conn = hci_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL); 6540 if (!conn) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6541 connectionSetAuthenticationFlags(conn, flag); 6542 hci_run(); 6543 return ERROR_CODE_SUCCESS; 6544} | 6538static uint8_t gap_set_auth_flag_and_run(const bd_addr_t addr, hci_authentication_flags_t flag){ 6539 hci_connection_t * conn = hci_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL); 6540 if (!conn) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6541 connectionSetAuthenticationFlags(conn, flag); 6542 hci_run(); 6543 return ERROR_CODE_SUCCESS; 6544} |
6545#endif |
|
6545 | 6546 |
6547#ifdef ENABLE_EXPLICIT_IO_CAPABILITIES_REPLY |
|
6546uint8_t gap_ssp_io_capabilities_response(const bd_addr_t addr){ 6547 return gap_set_auth_flag_and_run(addr, AUTH_FLAG_SEND_IO_CAPABILITIES_REPLY); 6548} 6549 6550uint8_t gap_ssp_io_capabilities_negative(const bd_addr_t addr){ 6551 return gap_set_auth_flag_and_run(addr, AUTH_FLAG_SEND_IO_CAPABILITIES_NEGATIVE_REPLY); 6552} 6553#endif --- 29 unchanged lines hidden (view full) --- 6583 */ 6584void gap_ssp_generate_oob_data(void){ 6585 hci_stack->classic_read_local_oob_data = true; 6586 hci_run(); 6587} 6588 6589#endif 6590 | 6548uint8_t gap_ssp_io_capabilities_response(const bd_addr_t addr){ 6549 return gap_set_auth_flag_and_run(addr, AUTH_FLAG_SEND_IO_CAPABILITIES_REPLY); 6550} 6551 6552uint8_t gap_ssp_io_capabilities_negative(const bd_addr_t addr){ 6553 return gap_set_auth_flag_and_run(addr, AUTH_FLAG_SEND_IO_CAPABILITIES_NEGATIVE_REPLY); 6554} 6555#endif --- 29 unchanged lines hidden (view full) --- 6585 */ 6586void gap_ssp_generate_oob_data(void){ 6587 hci_stack->classic_read_local_oob_data = true; 6588 hci_run(); 6589} 6590 6591#endif 6592 |
6593#ifdef ENABLE_EXPLICIT_LINK_KEY_REPLY 6594uint8_t gap_send_link_key_response(const bd_addr_t addr, link_key_t link_key, link_key_type_t type){ 6595 hci_connection_t * connection = hci_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL); 6596 if (connection == NULL) { 6597 return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6598 } 6599 6600 memcpy(connection->link_key, link_key, sizeof(link_key_t)); 6601 connection->link_key_type = type; 6602 6603 return gap_set_auth_flag_and_run(addr, AUTH_FLAG_HANDLE_LINK_KEY_REQUEST); 6604} 6605 6606#endif // ENABLE_EXPLICIT_LINK_KEY_REPLY |
|
6591/** 6592 * @brief Set inquiry mode: standard, with RSSI, with RSSI + Extended Inquiry Results. Has to be called before power on. 6593 * @param inquiry_mode see bluetooth_defines.h 6594 */ 6595void hci_set_inquiry_mode(inquiry_mode_t inquiry_mode){ 6596 hci_stack->inquiry_mode = inquiry_mode; 6597} 6598 --- 380 unchanged lines hidden --- | 6607/** 6608 * @brief Set inquiry mode: standard, with RSSI, with RSSI + Extended Inquiry Results. Has to be called before power on. 6609 * @param inquiry_mode see bluetooth_defines.h 6610 */ 6611void hci_set_inquiry_mode(inquiry_mode_t inquiry_mode){ 6612 hci_stack->inquiry_mode = inquiry_mode; 6613} 6614 --- 380 unchanged lines hidden --- |