mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-31 10:20:58 +00:00
rfcomm: support connection requests during connection failure
This commit is contained in:
parent
69cb6daf5c
commit
4c3eeed1f8
@ -315,6 +315,8 @@ static rfcomm_multiplexer_t * rfcomm_multiplexer_for_addr(bd_addr_t addr){
|
|||||||
btstack_linked_item_t *it;
|
btstack_linked_item_t *it;
|
||||||
for (it = (btstack_linked_item_t *) rfcomm_multiplexers; it ; it = it->next){
|
for (it = (btstack_linked_item_t *) rfcomm_multiplexers; it ; it = it->next){
|
||||||
rfcomm_multiplexer_t * multiplexer = ((rfcomm_multiplexer_t *) it);
|
rfcomm_multiplexer_t * multiplexer = ((rfcomm_multiplexer_t *) it);
|
||||||
|
// ignore multiplexer in shutdown
|
||||||
|
if (multiplexer->state == RFCOMM_MULTIPLEXER_SHUTTING_DOWN) continue;
|
||||||
if (bd_addr_cmp(addr, multiplexer->remote_addr) == 0) {
|
if (bd_addr_cmp(addr, multiplexer->remote_addr) == 0) {
|
||||||
return multiplexer;
|
return multiplexer;
|
||||||
};
|
};
|
||||||
@ -982,16 +984,23 @@ static int rfcomm_hci_event_handler(uint8_t *packet, uint16_t size){
|
|||||||
// remove (potential) timer
|
// remove (potential) timer
|
||||||
rfcomm_multiplexer_stop_timer(multiplexer);
|
rfcomm_multiplexer_stop_timer(multiplexer);
|
||||||
|
|
||||||
|
// mark multiplexer as shutting down
|
||||||
|
multiplexer->state = RFCOMM_MULTIPLEXER_SHUTTING_DOWN;
|
||||||
|
|
||||||
// emit rfcomm_channel_opened with status and free channel
|
// emit rfcomm_channel_opened with status and free channel
|
||||||
btstack_linked_item_t * it = (btstack_linked_item_t *) &rfcomm_channels;
|
int done = 0;
|
||||||
while (it->next) {
|
while (!done){
|
||||||
rfcomm_channel_t * channel = (rfcomm_channel_t *) it->next;
|
btstack_linked_item_t * it = (btstack_linked_item_t *) &rfcomm_channels;
|
||||||
if (channel->multiplexer == multiplexer){
|
while (it->next) {
|
||||||
rfcomm_emit_channel_opened(channel, status);
|
rfcomm_channel_t * channel = (rfcomm_channel_t *) it->next;
|
||||||
it->next = it->next->next;
|
if (channel->multiplexer == multiplexer){
|
||||||
btstack_memory_rfcomm_channel_free(channel);
|
rfcomm_emit_channel_opened(channel, status);
|
||||||
} else {
|
btstack_linked_list_remove(&rfcomm_channels, (btstack_linked_item_t *) channel);
|
||||||
it = it->next;
|
btstack_memory_rfcomm_channel_free(channel);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
it = it->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,8 @@ typedef enum {
|
|||||||
RFCOMM_MULTIPLEXER_W4_SABM_0, // incoming
|
RFCOMM_MULTIPLEXER_W4_SABM_0, // incoming
|
||||||
RFCOMM_MULTIPLEXER_SEND_UA_0,
|
RFCOMM_MULTIPLEXER_SEND_UA_0,
|
||||||
RFCOMM_MULTIPLEXER_OPEN,
|
RFCOMM_MULTIPLEXER_OPEN,
|
||||||
RFCOMM_MULTIPLEXER_SEND_UA_0_AND_DISC
|
RFCOMM_MULTIPLEXER_SEND_UA_0_AND_DISC,
|
||||||
|
RFCOMM_MULTIPLEXER_SHUTTING_DOWN,
|
||||||
} RFCOMM_MULTIPLEXER_STATE;
|
} RFCOMM_MULTIPLEXER_STATE;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -89,6 +90,7 @@ typedef enum {
|
|||||||
RFCOMM_CHANNEL_SEND_DISC,
|
RFCOMM_CHANNEL_SEND_DISC,
|
||||||
RFCOMM_CHANNEL_W4_UA_AFTER_UA,
|
RFCOMM_CHANNEL_W4_UA_AFTER_UA,
|
||||||
RFCOMM_CHANNEL_SEND_DM,
|
RFCOMM_CHANNEL_SEND_DM,
|
||||||
|
RFCOMM_CHANNEL_EMIT_OPEN_FAILED_AND_DISCARD,
|
||||||
} RFCOMM_CHANNEL_STATE;
|
} RFCOMM_CHANNEL_STATE;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user