From 51579c08032c338ef6d9a25204973e5bd051fc80 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Tue, 28 Jan 2014 19:50:30 +0000 Subject: [PATCH] don't require outgoing credits or a sent MSC Response as required to treat channel as open -> should fix RFC_BV_13 --- src/rfcomm.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/rfcomm.c b/src/rfcomm.c index d493711cd..479595548 100644 --- a/src/rfcomm.c +++ b/src/rfcomm.c @@ -1549,11 +1549,14 @@ void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe } static int rfcomm_channel_ready_for_open(rfcomm_channel_t *channel){ + // note: exchanging MSC isn't neccessary to consider channel open + // note: having outgoing credits is also not necessary to consider channel open // log_info("rfcomm_channel_ready_for_open state %u, flags needed %04x, current %04x, rf credits %u, l2cap credits %u \n", channel->state, RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_RSP|RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP|RFCOMM_CHANNEL_STATE_VAR_SENT_CREDITS, channel->state_var, channel->credits_outgoing, channel->multiplexer->l2cap_credits); + // if ((channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP) == 0) return 0; + // if (channel->credits_outgoing == 0) return 0; + log_info("rfcomm_channel_ready_for_open state %u, flags needed %04x, current %04x, rf credits %u, l2cap credits %u \n", channel->state, RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_RSP, channel->state_var, channel->credits_outgoing, channel->multiplexer->l2cap_credits); if ((channel->state_var & RFCOMM_CHANNEL_STATE_VAR_RCVD_MSC_RSP) == 0) return 0; - if ((channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP) == 0) return 0; if ((channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SENT_CREDITS) == 0) return 0; - if (channel->credits_outgoing == 0) return 0; return 1; } @@ -1625,6 +1628,13 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann rfcomm_send_uih_rpn_rsp(multiplexer, channel->dlci, &channel->rpn_data); return; } + if (channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP){ + log_info("Sending MSC RSP for #%u\n", channel->dlci); + rfcomm_channel_state_remove(channel, RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP); + rfcomm_channel_state_add(channel, RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP); + rfcomm_send_uih_msc_rsp(multiplexer, channel->dlci, 0x8d); // ea=1,fc=0,rtc=1,rtr=1,ic=0,dv=1 + return; + } } // emit MSC status to app @@ -1782,13 +1792,6 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann rfcomm_send_uih_msc_cmd(multiplexer, channel->dlci , 0x8d); // ea=1,fc=0,rtc=1,rtr=1,ic=0,dv=1 break; } - if (channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP){ - log_info("Sending MSC RSP for #%u\n", channel->dlci); - rfcomm_channel_state_remove(channel, RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP); - rfcomm_channel_state_add(channel, RFCOMM_CHANNEL_STATE_VAR_SENT_MSC_RSP); - rfcomm_send_uih_msc_rsp(multiplexer, channel->dlci, 0x8d); // ea=1,fc=0,rtc=1,rtr=1,ic=0,dv=1 - break; - } if (channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SEND_CREDITS){ log_info("Providing credits for #%u\n", channel->dlci); rfcomm_channel_state_remove(channel, RFCOMM_CHANNEL_STATE_VAR_SEND_CREDITS); @@ -1819,12 +1822,6 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann rfcomm_channel_state_add(channel, RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP); break; case CH_EVT_READY_TO_SEND: - if (channel->state_var & RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP){ - log_info("Sending MSC RSP for #%u\n", channel->dlci); - rfcomm_channel_state_remove(channel, RFCOMM_CHANNEL_STATE_VAR_SEND_MSC_RSP); - rfcomm_send_uih_msc_rsp(multiplexer, channel->dlci, 0x8d); // ea=1,fc=0,rtc=1,rtr=1,ic=0,dv=1 - break; - } if (channel->new_credits_incoming) { uint8_t new_credits = channel->new_credits_incoming; channel->new_credits_incoming = 0;