hci.c (f48a558634ae46d89c8e106c8db59c770787ebe7) | hci.c (91036612ebdd445b9241967a8fbd95a40b972a0e) |
---|---|
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 --- 2767 unchanged lines hidden (view full) --- 2776 hci_connection_t * conn; 2777#endif 2778#if defined(ENABLE_CLASSIC) || (defined(ENABLE_BLE) && defined(ENABLE_LE_ISOCHRONOUS_STREAMS)) 2779 hci_con_handle_t handle; 2780#endif 2781#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS 2782 le_audio_cig_t * cig; 2783#endif | 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 --- 2767 unchanged lines hidden (view full) --- 2776 hci_connection_t * conn; 2777#endif 2778#if defined(ENABLE_CLASSIC) || (defined(ENABLE_BLE) && defined(ENABLE_LE_ISOCHRONOUS_STREAMS)) 2779 hci_con_handle_t handle; 2780#endif 2781#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS 2782 le_audio_cig_t * cig; 2783#endif |
2784#if defined(ENABLE_BLE) && defined (ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS WORKAROUND) | 2784#if defined(ENABLE_BLE) && defined(ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS_WORKAROUND) |
2785 hci_stack->hci_command_con_handle = HCI_CON_HANDLE_INVALID; 2786#endif 2787 2788 // get num cmd packets - limit to 1 to reduce complexity 2789 hci_stack->num_cmd_packets = packet[2] ? 1 : 0; 2790 2791 uint16_t opcode = hci_event_command_complete_get_command_opcode(packet); 2792 switch (opcode){ --- 401 unchanged lines hidden (view full) --- 3194 uint8_t status = hci_event_command_status_get_status(packet); 3195#endif 3196 3197#if defined(ENABLE_CLASSIC) || defined(ENABLE_LE_CENTRAL) 3198 bd_addr_type_t addr_type; 3199 bd_addr_t addr; 3200#endif 3201 | 2785 hci_stack->hci_command_con_handle = HCI_CON_HANDLE_INVALID; 2786#endif 2787 2788 // get num cmd packets - limit to 1 to reduce complexity 2789 hci_stack->num_cmd_packets = packet[2] ? 1 : 0; 2790 2791 uint16_t opcode = hci_event_command_complete_get_command_opcode(packet); 2792 switch (opcode){ --- 401 unchanged lines hidden (view full) --- 3194 uint8_t status = hci_event_command_status_get_status(packet); 3195#endif 3196 3197#if defined(ENABLE_CLASSIC) || defined(ENABLE_LE_CENTRAL) 3198 bd_addr_type_t addr_type; 3199 bd_addr_t addr; 3200#endif 3201 |
3202#if defined(ENABLE_BLE) && defined (ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS) | 3202#if defined(ENABLE_BLE) && defined (ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS_WORKAROUND) |
3203 hci_stack->hci_command_con_handle = HCI_CON_HANDLE_INVALID; 3204#endif 3205 3206 switch (opcode){ 3207#ifdef ENABLE_CLASSIC 3208 case HCI_OPCODE_HCI_CREATE_CONNECTION: 3209 case HCI_OPCODE_HCI_SETUP_SYNCHRONOUS_CONNECTION: 3210 case HCI_OPCODE_HCI_ACCEPT_SYNCHRONOUS_CONNECTION: --- 947 unchanged lines hidden (view full) --- 4158 while (btstack_linked_list_iterator_has_next(&it)){ 4159 hci_iso_stream_t * iso_stream = (hci_iso_stream_t *) btstack_linked_list_iterator_next(&it); 4160 if (iso_stream->acl_handle == handle ) { 4161 hci_iso_stream_finalize(iso_stream); 4162 } 4163 } 4164#endif 4165 | 3203 hci_stack->hci_command_con_handle = HCI_CON_HANDLE_INVALID; 3204#endif 3205 3206 switch (opcode){ 3207#ifdef ENABLE_CLASSIC 3208 case HCI_OPCODE_HCI_CREATE_CONNECTION: 3209 case HCI_OPCODE_HCI_SETUP_SYNCHRONOUS_CONNECTION: 3210 case HCI_OPCODE_HCI_ACCEPT_SYNCHRONOUS_CONNECTION: --- 947 unchanged lines hidden (view full) --- 4158 while (btstack_linked_list_iterator_has_next(&it)){ 4159 hci_iso_stream_t * iso_stream = (hci_iso_stream_t *) btstack_linked_list_iterator_next(&it); 4160 if (iso_stream->acl_handle == handle ) { 4161 hci_iso_stream_finalize(iso_stream); 4162 } 4163 } 4164#endif 4165 |
4166#if defined(ENABLE_BLE) && defined (ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS WORKAROUND) | 4166#if defined(ENABLE_BLE) && defined (ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS_WORKAROUND) |
4167 if ((handle != HCI_CON_HANDLE_INVALID) && (handle == hci_stack->hci_command_con_handle)){ 4168 // we did not receive a HCI Command Complete or HCI Command Status event for the disconnected connection 4169 // if needed, we could also track the hci command opcode and simulate a hci command complete with status 4170 // but the connection has failed anyway, so for now, we only set the num hci commands back to 1 4171 hci_stack->num_cmd_packets = 1; 4172 } 4173#endif 4174 --- 586 unchanged lines hidden (view full) --- 4761#endif 4762#ifdef ENABLE_LE_PRIVACY_ADDRESS_RESOLUTION 4763 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_SEND_ENABLE_ADDRESS_RESOLUTION; 4764#endif 4765#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS 4766 hci_stack->iso_active_operation_type = HCI_ISO_TYPE_INVALID; 4767 hci_stack->iso_active_operation_group_id = HCI_ISO_GROUP_ID_INVALID; 4768#endif | 4167 if ((handle != HCI_CON_HANDLE_INVALID) && (handle == hci_stack->hci_command_con_handle)){ 4168 // we did not receive a HCI Command Complete or HCI Command Status event for the disconnected connection 4169 // if needed, we could also track the hci command opcode and simulate a hci command complete with status 4170 // but the connection has failed anyway, so for now, we only set the num hci commands back to 1 4171 hci_stack->num_cmd_packets = 1; 4172 } 4173#endif 4174 --- 586 unchanged lines hidden (view full) --- 4761#endif 4762#ifdef ENABLE_LE_PRIVACY_ADDRESS_RESOLUTION 4763 hci_stack->le_resolving_list_state = LE_RESOLVING_LIST_SEND_ENABLE_ADDRESS_RESOLUTION; 4764#endif 4765#ifdef ENABLE_LE_ISOCHRONOUS_STREAMS 4766 hci_stack->iso_active_operation_type = HCI_ISO_TYPE_INVALID; 4767 hci_stack->iso_active_operation_group_id = HCI_ISO_GROUP_ID_INVALID; 4768#endif |
4769#ifdef ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS WORKAROUND | 4769#ifdef ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS_WORKAROUND |
4770 hci_stack->hci_command_con_handle = HCI_CON_HANDLE_INVALID; 4771#endif 4772} 4773 4774#ifdef ENABLE_CLASSIC 4775/** 4776 * @brief Configure Bluetooth hardware control. Has to be called before power on. 4777 */ --- 2874 unchanged lines hidden (view full) --- 7652 hci_stack->outgoing_addr_type = (bd_addr_type_t) packet[5]; // peer address type 7653 reverse_bd_addr( &packet[6], hci_stack->outgoing_addr); // peer address 7654 break; 7655#endif 7656 case HCI_OPCODE_HCI_LE_CREATE_CONNECTION_CANCEL: 7657 hci_stack->le_connecting_state = LE_CONNECTING_CANCEL; 7658 break; 7659#endif | 4770 hci_stack->hci_command_con_handle = HCI_CON_HANDLE_INVALID; 4771#endif 4772} 4773 4774#ifdef ENABLE_CLASSIC 4775/** 4776 * @brief Configure Bluetooth hardware control. Has to be called before power on. 4777 */ --- 2874 unchanged lines hidden (view full) --- 7652 hci_stack->outgoing_addr_type = (bd_addr_type_t) packet[5]; // peer address type 7653 reverse_bd_addr( &packet[6], hci_stack->outgoing_addr); // peer address 7654 break; 7655#endif 7656 case HCI_OPCODE_HCI_LE_CREATE_CONNECTION_CANCEL: 7657 hci_stack->le_connecting_state = LE_CONNECTING_CANCEL; 7658 break; 7659#endif |
7660#ifdef ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS WORKAROUND | 7660#ifdef ENABLE_HCI_COMMAND_STATUS_DISCARDED_FOR_FAILED_CONNECTIONS_WORKAROUND |
7661 case HCI_OPCODE_HCI_LE_CONNECTION_UPDATE: 7662 case HCI_OPCODE_HCI_LE_READ_REMOTE_USED_FEATURES: 7663 case HCI_OPCODE_HCI_LE_START_ENCRYPTION: 7664 case HCI_OPCODE_HCI_LE_LONG_TERM_KEY_REQUEST_REPLY: 7665 case HCI_OPCODE_HCI_LE_LONG_TERM_KEY_NEGATIVE_REPLY: 7666 case HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY: 7667 case HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY: 7668 case HCI_OPCODE_HCI_LE_SET_DATA_LENGTH: --- 2890 unchanged lines hidden --- | 7661 case HCI_OPCODE_HCI_LE_CONNECTION_UPDATE: 7662 case HCI_OPCODE_HCI_LE_READ_REMOTE_USED_FEATURES: 7663 case HCI_OPCODE_HCI_LE_START_ENCRYPTION: 7664 case HCI_OPCODE_HCI_LE_LONG_TERM_KEY_REQUEST_REPLY: 7665 case HCI_OPCODE_HCI_LE_LONG_TERM_KEY_NEGATIVE_REPLY: 7666 case HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY: 7667 case HCI_OPCODE_HCI_LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY: 7668 case HCI_OPCODE_HCI_LE_SET_DATA_LENGTH: --- 2890 unchanged lines hidden --- |