mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 17:42:51 +00:00
finished rfcomm_close_connection
This commit is contained in:
parent
ee709849fc
commit
9fad573414
37
src/rfcomm.c
37
src/rfcomm.c
@ -1213,11 +1213,27 @@ void rfcomm_close_connection(void *connection){
|
|||||||
linked_item_t *it;
|
linked_item_t *it;
|
||||||
|
|
||||||
// close open channels
|
// close open channels
|
||||||
rfcomm_channel_t * channel;
|
it = (linked_item_t *) &rfcomm_channels;
|
||||||
for (it = (linked_item_t *) rfcomm_channels; it ; it = it->next){
|
while (it->next){
|
||||||
channel = (rfcomm_channel_t *) it;
|
rfcomm_channel_t * channel = (rfcomm_channel_t *) it->next;
|
||||||
if (channel->connection == connection) {
|
if (channel->connection == connection){
|
||||||
// TODO: shut down channels immediately - if items are freed, while loop is necessary
|
|
||||||
|
// signal client
|
||||||
|
rfcomm_emit_channel_closed(channel);
|
||||||
|
|
||||||
|
// signal close
|
||||||
|
rfcomm_multiplexer_t * multiplexer = channel->multiplexer;
|
||||||
|
rfcomm_send_disc(multiplexer, channel->dlci);
|
||||||
|
|
||||||
|
// remove from list
|
||||||
|
it->next = it->next->next;
|
||||||
|
free(channel);
|
||||||
|
|
||||||
|
// update multiplexer timeout after channel was removed from list
|
||||||
|
rfcomm_multiplexer_prepare_idle_timer(multiplexer);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
it = it->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,14 +1344,17 @@ void rfcomm_disconnect_internal(uint16_t rfcomm_cid){
|
|||||||
// TODO: be less drastic
|
// TODO: be less drastic
|
||||||
rfcomm_channel_t * channel = rfcomm_channel_for_rfcomm_cid(rfcomm_cid);
|
rfcomm_channel_t * channel = rfcomm_channel_for_rfcomm_cid(rfcomm_cid);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
rfcomm_multiplexer_t * multiplexer = channel->multiplexer;
|
|
||||||
// signal close
|
|
||||||
rfcomm_send_disc(multiplexer, channel->dlci);
|
|
||||||
// signal client
|
// signal client
|
||||||
rfcomm_emit_channel_closed(channel);
|
rfcomm_emit_channel_closed(channel);
|
||||||
// discard channel
|
|
||||||
|
// signal close
|
||||||
|
rfcomm_multiplexer_t * multiplexer = channel->multiplexer;
|
||||||
|
rfcomm_send_disc(multiplexer, channel->dlci);
|
||||||
|
|
||||||
|
// remove from list
|
||||||
linked_list_remove( &rfcomm_channels, (linked_item_t *) channel);
|
linked_list_remove( &rfcomm_channels, (linked_item_t *) channel);
|
||||||
free(channel);
|
free(channel);
|
||||||
|
|
||||||
rfcomm_multiplexer_prepare_idle_timer(multiplexer);
|
rfcomm_multiplexer_prepare_idle_timer(multiplexer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user