mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-07 15:39:51 +00:00
l2cap: drop reason param in l2cap_disconnect
This commit is contained in:
parent
d374cc2839
commit
b93f89661e
@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- L2CAP: provide status instead of undocumented int error code and bool for API functions
|
||||
- L2CAP: remote features not required for SDP connections
|
||||
- L2CAP: replaced l2cap_register_packet_handler with l2cap_add_event_handler to register multiple handlers
|
||||
- L2CAP: drop reason parameter in l2cap_disconnect
|
||||
- L2CAP: use official terminology for L2CAP channel modes - ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE replaces ENABLE_LE_DATA_CHANNELS
|
||||
- RFCOMM: `RFCOMM_EVENT_PORT_CONFIGURATION` contains rfcomm_cid and remote flag, emitted for query config
|
||||
- RFCOMM: provide status instead of undocumented int error code and bool for API functions
|
||||
|
@ -549,7 +549,7 @@ static void daemon_l2cap_close_connection(client_state_t * daemon_client){
|
||||
btstack_linked_list_iterator_init(&it, l2cap_cids);
|
||||
while (btstack_linked_list_iterator_has_next(&it)){
|
||||
btstack_linked_list_uint32_t * item = (btstack_linked_list_uint32_t*) btstack_linked_list_iterator_next(&it);
|
||||
l2cap_disconnect(item->value, 0); // note: reason isn't used
|
||||
l2cap_disconnect(item->value);
|
||||
btstack_linked_list_remove(l2cap_cids, (btstack_linked_item_t *) item);
|
||||
free(item);
|
||||
}
|
||||
@ -985,8 +985,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
break;
|
||||
case L2CAP_DISCONNECT:
|
||||
cid = little_endian_read_16(packet, 3);
|
||||
reason = packet[5];
|
||||
l2cap_disconnect(cid, reason);
|
||||
l2cap_disconnect(cid);
|
||||
break;
|
||||
case L2CAP_REGISTER_SERVICE:
|
||||
psm = little_endian_read_16(packet, 3);
|
||||
|
@ -117,10 +117,9 @@ const hci_cmd_t l2cap_create_channel_mtu_cmd = {
|
||||
|
||||
/**
|
||||
* @param channel (16)
|
||||
* @param reason (16)
|
||||
*/
|
||||
const hci_cmd_t l2cap_disconnect_cmd = {
|
||||
DAEMON_OPCODE_L2CAP_DISCONNECT, "21"
|
||||
DAEMON_OPCODE_L2CAP_DISCONNECT, "2"
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1072,7 +1072,7 @@ uint8_t avdtp_disconnect(uint16_t avdtp_cid){
|
||||
case AVDTP_STREAM_ENDPOINT_OPENED:
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_W4_L2CAP_FOR_MEDIA_DISCONNECTED;
|
||||
l2cap_disconnect(stream_endpoint->l2cap_media_cid, 0);
|
||||
l2cap_disconnect(stream_endpoint->l2cap_media_cid);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1080,7 +1080,7 @@ uint8_t avdtp_disconnect(uint16_t avdtp_cid){
|
||||
}
|
||||
|
||||
connection->state = AVDTP_SIGNALING_CONNECTION_W4_L2CAP_DISCONNECTED;
|
||||
l2cap_disconnect(connection->l2cap_signaling_cid, 0);
|
||||
l2cap_disconnect(connection->l2cap_signaling_cid);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t *connection, uint8_t
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
stream_endpoint_for_event = stream_endpoint;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_CLOSING;
|
||||
l2cap_disconnect(stream_endpoint->l2cap_media_cid, 0);
|
||||
l2cap_disconnect(stream_endpoint->l2cap_media_cid);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -256,7 +256,7 @@ void avdtp_initiator_stream_config_subsm(avdtp_connection_t *connection, uint8_t
|
||||
case AVDTP_STREAM_ENDPOINT_STREAMING:
|
||||
stream_endpoint_for_event = stream_endpoint;
|
||||
stream_endpoint->state = AVDTP_STREAM_ENDPOINT_ABORTING;
|
||||
l2cap_disconnect(stream_endpoint->l2cap_media_cid, 0);
|
||||
l2cap_disconnect(stream_endpoint->l2cap_media_cid);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -919,9 +919,9 @@ uint8_t avrcp_disconnect(uint16_t avrcp_cid){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (connection_controller->browsing_connection){
|
||||
l2cap_disconnect(connection_controller->browsing_connection->l2cap_browsing_cid, 0);
|
||||
l2cap_disconnect(connection_controller->browsing_connection->l2cap_browsing_cid);
|
||||
}
|
||||
l2cap_disconnect(connection_controller->l2cap_signaling_cid, 0);
|
||||
l2cap_disconnect(connection_controller->l2cap_signaling_cid);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ uint8_t avrcp_browsing_disconnect(uint16_t avrcp_browsing_cid){
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
|
||||
l2cap_disconnect(connection_controller->browsing_connection->l2cap_browsing_cid, 0);
|
||||
l2cap_disconnect(connection_controller->browsing_connection->l2cap_browsing_cid);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,7 @@ static void bnep_channel_finalize(bnep_channel_t *channel)
|
||||
|
||||
/* Free ressources and then close the l2cap channel */
|
||||
bnep_channel_free(channel);
|
||||
l2cap_disconnect(l2cap_cid, 0x13);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
}
|
||||
|
||||
static int bnep_handle_connection_request(bnep_channel_t *channel, uint8_t *packet, uint16_t size)
|
||||
|
@ -963,7 +963,7 @@ void hid_device_disconnect_interrupt_channel(uint16_t hid_cid){
|
||||
}
|
||||
log_info("Disconnect from interrupt channel HID Host");
|
||||
if (hid_device->interrupt_cid){
|
||||
l2cap_disconnect(hid_device->interrupt_cid, 0); // reason isn't used
|
||||
l2cap_disconnect(hid_device->interrupt_cid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -975,7 +975,7 @@ void hid_device_disconnect_control_channel(uint16_t hid_cid){
|
||||
}
|
||||
log_info("Disconnect from control channel HID Host");
|
||||
if (hid_device->control_cid){
|
||||
l2cap_disconnect(hid_device->control_cid, 0); // reason isn't used
|
||||
l2cap_disconnect(hid_device->control_cid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,11 +987,11 @@ void hid_device_disconnect(uint16_t hid_cid){
|
||||
}
|
||||
log_info("Disconnect from HID Host");
|
||||
if (hid_device->interrupt_cid){
|
||||
l2cap_disconnect(hid_device->interrupt_cid, 0); // reason isn't used
|
||||
l2cap_disconnect(hid_device->interrupt_cid);
|
||||
}
|
||||
if (hid_device->control_cid){
|
||||
l2cap_disconnect(hid_device->control_cid, 0); // reason isn't used
|
||||
}
|
||||
l2cap_disconnect(hid_device->control_cid);
|
||||
}
|
||||
}
|
||||
|
||||
int hid_device_in_boot_protocol_mode(uint16_t hid_cid){
|
||||
|
@ -368,10 +368,10 @@ static void hid_host_finalize_connection(hid_host_connection_t * connection){
|
||||
connection->control_cid = 0;
|
||||
|
||||
if (interrupt_cid != 0){
|
||||
l2cap_disconnect(interrupt_cid, 0);
|
||||
l2cap_disconnect(interrupt_cid);
|
||||
}
|
||||
if (control_cid != 0){
|
||||
l2cap_disconnect(control_cid, 0);
|
||||
l2cap_disconnect(control_cid);
|
||||
}
|
||||
btstack_linked_list_remove(&hid_host_connections, (btstack_linked_item_t*) connection);
|
||||
btstack_memory_hid_host_connection_free(connection);
|
||||
@ -904,7 +904,7 @@ static void hid_host_packet_handler(uint8_t packet_type, uint16_t channel, uint8
|
||||
connection->interrupt_cid = 0;
|
||||
if (connection->state == HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED){
|
||||
connection->state = HID_HOST_W4_CONTROL_CONNECTION_DISCONNECTED;
|
||||
l2cap_disconnect(connection->control_cid, 0);
|
||||
l2cap_disconnect(connection->control_cid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1158,13 +1158,13 @@ void hid_host_disconnect(uint16_t hid_cid){
|
||||
|
||||
if (connection->interrupt_cid){
|
||||
connection->state = HID_HOST_W4_INTERRUPT_CONNECTION_DISCONNECTED;
|
||||
l2cap_disconnect(connection->interrupt_cid, 0); // reason isn't used
|
||||
l2cap_disconnect(connection->interrupt_cid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (connection->control_cid){
|
||||
connection->state = HID_HOST_W4_CONTROL_CONNECTION_DISCONNECTED;
|
||||
l2cap_disconnect(connection->control_cid, 0); // reason isn't used
|
||||
l2cap_disconnect(connection->control_cid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ static void rfcomm_multiplexer_timer_handler(btstack_timer_source_t *timer){
|
||||
log_info("handler timeout: shutting down multiplexer! (no channels)");
|
||||
uint16_t l2cap_cid = multiplexer->l2cap_cid;
|
||||
rfcomm_multiplexer_finalize(multiplexer);
|
||||
l2cap_disconnect(l2cap_cid, 0x13);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
}
|
||||
|
||||
static void rfcomm_multiplexer_prepare_idle_timer(rfcomm_multiplexer_t * multiplexer){
|
||||
@ -1242,7 +1242,7 @@ static int rfcomm_multiplexer_l2cap_packet_handler(uint16_t channel, uint8_t *pa
|
||||
log_info("Received DM #0");
|
||||
log_info("-> Closing down multiplexer");
|
||||
rfcomm_multiplexer_finalize(multiplexer);
|
||||
l2cap_disconnect(l2cap_cid, 0x13);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
return 1;
|
||||
|
||||
case BT_RFCOMM_UIH:
|
||||
@ -1253,7 +1253,7 @@ static int rfcomm_multiplexer_l2cap_packet_handler(uint16_t channel, uint8_t *pa
|
||||
log_info("Received Multiplexer close down command");
|
||||
log_info("-> Closing down multiplexer");
|
||||
rfcomm_multiplexer_finalize(multiplexer);
|
||||
l2cap_disconnect(l2cap_cid, 0x13);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
return 1;
|
||||
}
|
||||
switch (packet[payload_offset]){
|
||||
@ -1262,7 +1262,7 @@ static int rfcomm_multiplexer_l2cap_packet_handler(uint16_t channel, uint8_t *pa
|
||||
log_info("Received Multiplexer close down command");
|
||||
log_info("-> Closing down multiplexer");
|
||||
rfcomm_multiplexer_finalize(multiplexer);
|
||||
l2cap_disconnect(l2cap_cid, 0x13);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
return 1;
|
||||
|
||||
case BT_RFCOMM_FCON_CMD:
|
||||
@ -1373,7 +1373,7 @@ static void rfcomm_multiplexer_state_machine(rfcomm_multiplexer_t * multiplexer,
|
||||
rfcomm_send_ua(multiplexer, 0);
|
||||
|
||||
rfcomm_multiplexer_finalize(multiplexer);
|
||||
l2cap_disconnect(l2cap_cid, 0x13);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
break;
|
||||
case RFCOMM_MULTIPLEXER_OPEN:
|
||||
// respond to test command
|
||||
|
@ -464,7 +464,7 @@ void sdp_client_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
|
||||
switch (sdp_client_pdu_id){
|
||||
case SDP_ErrorResponse:
|
||||
log_error("Received error response with code %u, disconnecting", packet[2]);
|
||||
l2cap_disconnect(sdp_client_sdp_cid, 0);
|
||||
l2cap_disconnect(sdp_client_sdp_cid);
|
||||
return;
|
||||
#ifdef ENABLE_SDP_EXTRA_QUERIES
|
||||
case SDP_ServiceSearchResponse:
|
||||
@ -486,7 +486,7 @@ void sdp_client_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
|
||||
if (sdp_client_continuation_state_len == 0){
|
||||
log_debug("SDP Client Query DONE! ");
|
||||
sdp_client_state = QUERY_COMPLETE;
|
||||
l2cap_disconnect(sdp_client_sdp_cid, 0);
|
||||
l2cap_disconnect(sdp_client_sdp_cid);
|
||||
return;
|
||||
}
|
||||
// prepare next request and send
|
||||
|
12
src/l2cap.c
12
src/l2cap.c
@ -2459,16 +2459,14 @@ uint8_t l2cap_create_channel(btstack_packet_handler_t channel_packet_handler, bd
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void l2cap_disconnect(uint16_t local_cid, uint8_t reason){
|
||||
log_info("disconnect local_cid 0x%x reason 0x%x", local_cid, reason);
|
||||
UNUSED(reason);
|
||||
// find channel for local_cid
|
||||
uint8_t l2cap_disconnect(uint16_t local_cid){
|
||||
l2cap_channel_t * channel = l2cap_get_channel_for_local_cid(local_cid);
|
||||
if (channel) {
|
||||
channel->state = L2CAP_STATE_WILL_SEND_DISCONNECT_REQUEST;
|
||||
if (!channel) {
|
||||
return L2CAP_LOCAL_CID_DOES_NOT_EXIST;
|
||||
}
|
||||
// process
|
||||
channel->state = L2CAP_STATE_WILL_SEND_DISCONNECT_REQUEST;
|
||||
l2cap_run();
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void l2cap_handle_connection_failed_for_addr(bd_addr_t address, uint8_t status){
|
||||
|
@ -501,8 +501,10 @@ uint8_t l2cap_create_channel(btstack_packet_handler_t packet_handler, bd_addr_t
|
||||
|
||||
/**
|
||||
* @brief Disconnects L2CAP channel with given identifier.
|
||||
* @param local_cid
|
||||
* @return status ERROR_CODE_SUCCESS if successful or L2CAP_LOCAL_CID_DOES_NOT_EXIST
|
||||
*/
|
||||
void l2cap_disconnect(uint16_t local_cid, uint8_t reason);
|
||||
uint8_t l2cap_disconnect(uint16_t local_cid);
|
||||
|
||||
/**
|
||||
* @brief Queries the maximal transfer unit (MTU) for L2CAP channel with given identifier.
|
||||
|
@ -199,7 +199,7 @@ TEST(L2CAP_CHANNELS, some_functions){
|
||||
l2cap_cbm_unregister_service(TEST_PSM);
|
||||
l2cap_cbm_accept_connection(0X01, NULL, 0, 0);
|
||||
l2cap_cbm_decline_connection(0x01, L2CAP_CBM_CONNECTION_RESULT_NO_RESOURCES_AVAILABLE);
|
||||
l2cap_cbm_disconnect(0x01);
|
||||
l2cap_disconnect(0x01);
|
||||
}
|
||||
|
||||
TEST(L2CAP_CHANNELS, outgoing_no_connection){
|
||||
@ -235,7 +235,7 @@ TEST(L2CAP_CHANNELS, outgoing_1){
|
||||
// print_acl("le_data_channel_data_1", mock_hci_transport_outgoing_packet_buffer, mock_hci_transport_outgoing_packet_size);
|
||||
// simulate data
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, le_data_channel_data_1, sizeof(le_data_channel_data_1));
|
||||
l2cap_cbm_disconnect(l2cap_cid);
|
||||
l2cap_disconnect(l2cap_cid);
|
||||
}
|
||||
|
||||
TEST(L2CAP_CHANNELS, incoming_1){
|
||||
|
@ -496,8 +496,8 @@ TEST(L2CAP_CHANNELS, outgoing_le_disconnect_initiator){
|
||||
CHECK_EQUAL(ERROR_CODE_SUCCESS, status);
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, l2cap_enhanced_data_channel_le_conn_response_2_success, sizeof(l2cap_enhanced_data_channel_le_conn_response_2_success));
|
||||
CHECK_EQUAL(2, num_l2cap_channel_opened);
|
||||
l2cap_ecbm_disconnect(l2cap_cids[0]);
|
||||
l2cap_ecbm_disconnect(l2cap_cids[1]);
|
||||
l2cap_disconnect(l2cap_cids[0]);
|
||||
l2cap_disconnect(l2cap_cids[1]);
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, l2cap_enhanced_data_channel_le_disconnect_response_1, sizeof(l2cap_enhanced_data_channel_le_disconnect_response_1));
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, l2cap_enhanced_data_channel_le_disconnect_response_2, sizeof(l2cap_enhanced_data_channel_le_disconnect_response_2));
|
||||
CHECK_EQUAL(2, num_l2cap_channel_closed);
|
||||
@ -524,8 +524,8 @@ TEST(L2CAP_CHANNELS, outgoing_classic_disconnect_initiator){
|
||||
CHECK_EQUAL(ERROR_CODE_SUCCESS, status);
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, l2cap_enhanced_data_channel_classic_conn_response_2_success, sizeof(l2cap_enhanced_data_channel_classic_conn_response_2_success));
|
||||
CHECK_EQUAL(2, num_l2cap_channel_opened);
|
||||
l2cap_ecbm_disconnect(l2cap_cids[0]);
|
||||
l2cap_ecbm_disconnect(l2cap_cids[1]);
|
||||
l2cap_disconnect(l2cap_cids[0]);
|
||||
l2cap_disconnect(l2cap_cids[1]);
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, l2cap_enhanced_data_channel_classic_disconnect_response_1, sizeof(l2cap_enhanced_data_channel_classic_disconnect_response_1));
|
||||
mock_hci_transport_receive_packet(HCI_ACL_DATA_PACKET, l2cap_enhanced_data_channel_classic_disconnect_response_2, sizeof(l2cap_enhanced_data_channel_classic_disconnect_response_2));
|
||||
CHECK_EQUAL(2, num_l2cap_channel_closed);
|
||||
|
@ -631,7 +631,7 @@ static void stdin_process(char c){
|
||||
break;
|
||||
case 's':
|
||||
printf("L2CAP Channel Closed\n");
|
||||
l2cap_disconnect(local_cid, 0);
|
||||
l2cap_disconnect(local_cid);
|
||||
break;
|
||||
case 'x':
|
||||
printf("Outgoing L2CAP Channels to SDP will also require SSP\n");
|
||||
|
@ -514,10 +514,10 @@ static void stdin_process(char buffer){
|
||||
case 't':
|
||||
if (enhanced_data_channel){
|
||||
printf("Disconnect channel 0x%02x\n", cid_enhanced);
|
||||
l2cap_ecbm_disconnect(cid_enhanced);
|
||||
l2cap_disconnect(cid_enhanced);
|
||||
} else {
|
||||
printf("Disconnect channel 0x%02x\n", cid_le);
|
||||
l2cap_cbm_disconnect(cid_le);
|
||||
l2cap_disconnect(cid_le);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -196,7 +196,7 @@ static void stdin_process(char buffer){
|
||||
break;
|
||||
case 'd':
|
||||
printf("L2CAP Channel Closed\n");
|
||||
l2cap_disconnect(local_cid, 0);
|
||||
l2cap_disconnect(local_cid);
|
||||
break;
|
||||
case 'e':
|
||||
printf("L2CAP Enhanced Retransmission Mode (ERTM) optional\n");
|
||||
|
@ -21,7 +21,7 @@ extern "C" uint8_t l2cap_create_channel(btstack_packet_handler_t handler, bd_add
|
||||
packet_handler = handler;
|
||||
return 0x41;
|
||||
}
|
||||
extern "C" void l2cap_disconnect(uint16_t local_cid, uint8_t reason){
|
||||
extern "C" void l2cap_disconnect(uint16_t local_cid){
|
||||
}
|
||||
extern "C" uint8_t *l2cap_get_outgoing_buffer(void){
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user