hci.c (9d78a7ec35d10cc59b12101cebe9cf2be33d6ece) | hci.c (71fd255d6139194e0c2e26430392f229aeaeb463) |
---|---|
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 --- 160 unchanged lines hidden (view full) --- 169 SUPPORTED_HCI_COMMANDS 170 SUPPORTED_HCI_COMMANDS_COUNT 171}; 172#undef X 173 174// prototypes 175#ifdef ENABLE_CLASSIC 176static void hci_update_scan_enable(void); | 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 --- 160 unchanged lines hidden (view full) --- 169 SUPPORTED_HCI_COMMANDS 170 SUPPORTED_HCI_COMMANDS_COUNT 171}; 172#undef X 173 174// prototypes 175#ifdef ENABLE_CLASSIC 176static void hci_update_scan_enable(void); |
177static void hci_emit_discoverable_enabled(uint8_t enabled); | 177static void hci_emit_scan_mode_changed(uint8_t discoverable, uint8_t connectable); |
178static int hci_local_ssp_activated(void); 179static bool hci_remote_ssp_supported(hci_con_handle_t con_handle); 180static bool hci_ssp_supported(hci_connection_t * connection); 181static void hci_notify_if_sco_can_send_now(void); 182static void hci_emit_connection_complete(bd_addr_t address, hci_con_handle_t con_handle, uint8_t status); 183static gap_security_level_t gap_security_level_for_connection(hci_connection_t * connection); 184static void hci_emit_security_level(hci_con_handle_t con_handle, gap_security_level_t level); 185static void hci_connection_timeout_handler(btstack_timer_source_t *timer); --- 2426 unchanged lines hidden (view full) --- 2612#ifdef ENABLE_CLASSIC 2613 if (hci_stack->link_key_db){ 2614 hci_stack->link_key_db->set_local_bd_addr(hci_stack->local_bd_addr); 2615 } 2616#endif 2617 break; 2618#ifdef ENABLE_CLASSIC 2619 case HCI_OPCODE_HCI_WRITE_SCAN_ENABLE: | 178static int hci_local_ssp_activated(void); 179static bool hci_remote_ssp_supported(hci_con_handle_t con_handle); 180static bool hci_ssp_supported(hci_connection_t * connection); 181static void hci_notify_if_sco_can_send_now(void); 182static void hci_emit_connection_complete(bd_addr_t address, hci_con_handle_t con_handle, uint8_t status); 183static gap_security_level_t gap_security_level_for_connection(hci_connection_t * connection); 184static void hci_emit_security_level(hci_con_handle_t con_handle, gap_security_level_t level); 185static void hci_connection_timeout_handler(btstack_timer_source_t *timer); --- 2426 unchanged lines hidden (view full) --- 2612#ifdef ENABLE_CLASSIC 2613 if (hci_stack->link_key_db){ 2614 hci_stack->link_key_db->set_local_bd_addr(hci_stack->local_bd_addr); 2615 } 2616#endif 2617 break; 2618#ifdef ENABLE_CLASSIC 2619 case HCI_OPCODE_HCI_WRITE_SCAN_ENABLE: |
2620 hci_emit_discoverable_enabled(hci_stack->discoverable); | 2620 hci_emit_scan_mode_changed(hci_stack->discoverable, hci_stack->connectable); |
2621 break; 2622 case HCI_OPCODE_HCI_PERIODIC_INQUIRY_MODE: 2623 status = hci_event_command_complete_get_return_parameters(packet)[0]; 2624 if (status == ERROR_CODE_SUCCESS) { 2625 hci_stack->inquiry_state = GAP_INQUIRY_STATE_PERIODIC; 2626 } else { 2627 hci_stack->inquiry_state = GAP_INQUIRY_STATE_IDLE; 2628 } --- 2138 unchanged lines hidden (view full) --- 4767 hci_stack->gap_tasks_classic |= GAP_TASK_WRITE_SCAN_ENABLE; 4768 hci_run(); 4769} 4770 4771void gap_discoverable_control(uint8_t enable){ 4772 if (enable) enable = 1; // normalize argument 4773 4774 if (hci_stack->discoverable == enable){ | 2621 break; 2622 case HCI_OPCODE_HCI_PERIODIC_INQUIRY_MODE: 2623 status = hci_event_command_complete_get_return_parameters(packet)[0]; 2624 if (status == ERROR_CODE_SUCCESS) { 2625 hci_stack->inquiry_state = GAP_INQUIRY_STATE_PERIODIC; 2626 } else { 2627 hci_stack->inquiry_state = GAP_INQUIRY_STATE_IDLE; 2628 } --- 2138 unchanged lines hidden (view full) --- 4767 hci_stack->gap_tasks_classic |= GAP_TASK_WRITE_SCAN_ENABLE; 4768 hci_run(); 4769} 4770 4771void gap_discoverable_control(uint8_t enable){ 4772 if (enable) enable = 1; // normalize argument 4773 4774 if (hci_stack->discoverable == enable){ |
4775 hci_emit_discoverable_enabled(hci_stack->discoverable); | 4775 hci_emit_scan_mode_changed(hci_stack->discoverable, hci_stack->connectable); |
4776 return; 4777 } 4778 4779 hci_stack->discoverable = enable; 4780 hci_update_scan_enable(); 4781} 4782 4783void gap_connectable_control(uint8_t enable){ --- 1999 unchanged lines hidden (view full) --- 6783 gap_security_level_t security_level = gap_security_level_for_link_key_type(connection->link_key_type); 6784 // LEVEL 4 always requires 128 bit encrytion key size 6785 if ((security_level == LEVEL_4) && (connection->encryption_key_size < 16)){ 6786 security_level = LEVEL_3; 6787 } 6788 return security_level; 6789} 6790 | 4776 return; 4777 } 4778 4779 hci_stack->discoverable = enable; 4780 hci_update_scan_enable(); 4781} 4782 4783void gap_connectable_control(uint8_t enable){ --- 1999 unchanged lines hidden (view full) --- 6783 gap_security_level_t security_level = gap_security_level_for_link_key_type(connection->link_key_type); 6784 // LEVEL 4 always requires 128 bit encrytion key size 6785 if ((security_level == LEVEL_4) && (connection->encryption_key_size < 16)){ 6786 security_level = LEVEL_3; 6787 } 6788 return security_level; 6789} 6790 |
6791static void hci_emit_discoverable_enabled(uint8_t enabled){ 6792 log_info("BTSTACK_EVENT_DISCOVERABLE_ENABLED %u", enabled); 6793 uint8_t event[3]; 6794 event[0] = BTSTACK_EVENT_DISCOVERABLE_ENABLED; | 6791static void hci_emit_scan_mode_changed(uint8_t discoverable, uint8_t connectable){ 6792 uint8_t event[4]; 6793 event[0] = BTSTACK_EVENT_SCAN_MODE_CHANGED; |
6795 event[1] = sizeof(event) - 2; | 6794 event[1] = sizeof(event) - 2; |
6796 event[2] = enabled; | 6795 event[2] = discoverable; 6796 event[3] = connectable; |
6797 hci_emit_event(event, sizeof(event), 1); 6798} 6799 6800// query if remote side supports eSCO 6801bool hci_remote_esco_supported(hci_con_handle_t con_handle){ 6802 hci_connection_t * connection = hci_connection_for_handle(con_handle); 6803 if (!connection) return false; 6804 return (connection->remote_supported_features[0] & 1) != 0; --- 1889 unchanged lines hidden --- | 6797 hci_emit_event(event, sizeof(event), 1); 6798} 6799 6800// query if remote side supports eSCO 6801bool hci_remote_esco_supported(hci_con_handle_t con_handle){ 6802 hci_connection_t * connection = hci_connection_for_handle(con_handle); 6803 if (!connection) return false; 6804 return (connection->remote_supported_features[0] & 1) != 0; --- 1889 unchanged lines hidden --- |