mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-04 15:39:59 +00:00
remembered to close all RFCOMM channels and unregister RFCOMM services - close channels not implemented yet
This commit is contained in:
parent
7934ed2f08
commit
7392f586da
@ -333,6 +333,7 @@ static int daemon_client_handler(connection_t *connection, uint16_t packet_type,
|
||||
break;
|
||||
case DAEMON_EVENT_CONNECTION_CLOSED:
|
||||
sdp_unregister_services_for_connection(connection);
|
||||
rfcomm_close_connection(connection);
|
||||
l2cap_close_connection(connection);
|
||||
client = client_for_connection(connection);
|
||||
if (!client) break;
|
||||
|
29
src/rfcomm.c
29
src/rfcomm.c
@ -562,9 +562,6 @@ static void rfcomm_hand_out_credits(){
|
||||
}
|
||||
}
|
||||
|
||||
// data: event(8), len(8), registration id(16), rfcomm channel id
|
||||
#define RFCOMM_EVENT_SERVICE_REGISTERED 0x85
|
||||
|
||||
// sends UIH PN CMD to first channel with RFCOMM_CHANNEL_W4_MULTIPLEXER
|
||||
// this can then called after connection open/fail to handle all outgoing requests
|
||||
static void rfcomm_multiplexer_start_connecting(rfcomm_multiplexer_t * multiplexer) {
|
||||
@ -1211,6 +1208,32 @@ void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void rfcomm_close_connection(void *connection){
|
||||
linked_item_t *it;
|
||||
|
||||
// close open channels
|
||||
rfcomm_channel_t * channel;
|
||||
for (it = (linked_item_t *) rfcomm_channels; it ; it = it->next){
|
||||
channel = (rfcomm_channel_t *) it;
|
||||
if (channel->connection == connection) {
|
||||
// TODO: shut down channels immediately - if items are freed, while loop is necessary
|
||||
}
|
||||
}
|
||||
|
||||
// unregister services
|
||||
it = (linked_item_t *) &rfcomm_services;
|
||||
while (it->next) {
|
||||
rfcomm_service_t * service = (rfcomm_service_t *) it->next;
|
||||
if (service->connection == connection){
|
||||
it->next = it->next->next;
|
||||
free(service);
|
||||
} else {
|
||||
it = it->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark RFCOMM BTstack API
|
||||
|
||||
void rfcomm_init(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user