From 8158c4219752a2479a1cf5344bb5e9d6baa5a722 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Fri, 24 Jun 2011 18:37:10 +0000 Subject: [PATCH] added RFCOMM_CHANNEL_SEND_SABM_W4_UA --- src/l2cap.c | 4 ++-- src/rfcomm.c | 34 +++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/l2cap.c b/src/l2cap.c index 28be256f4..1d965e846 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -260,11 +260,11 @@ int l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len){ return err; } - + +// MARK: L2CAP_RUN // process outstanding signaling tasks void l2cap_run(void){ - // check pending signaling responses while (signaling_responses_pending){ diff --git a/src/rfcomm.c b/src/rfcomm.c index b44c3e378..c4c53e5f2 100644 --- a/src/rfcomm.c +++ b/src/rfcomm.c @@ -102,6 +102,7 @@ typedef enum { RFCOMM_CHANNEL_W4_PN_AFTER_OPEN, RFCOMM_CHANNEL_W4_PN_RSP, RFCOMM_CHANNEL_W4_SABM_OR_PN_CMD, + RFCOMM_CHANNEL_SEND_SABM_W4_UA, RFCOMM_CHANNEL_W4_UA, RFCOMM_CHANNEL_W4_MSC_CMD_OR_MSC_RSP, // outgoing, sent MSC_CMD RFCOMM_CHANNEL_W4_MSC_CMD, @@ -1119,9 +1120,7 @@ void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe log_dbg("UIH Parameter Negotiation Response max frame %u, credits %u\n", max_frame_size, rfChannel->credits_outgoing); - log_dbg("Sending SABM #%u\n", message_dlci); - rfcomm_send_sabm(multiplexer, message_dlci); - rfChannel->state = RFCOMM_CHANNEL_W4_UA; + rfChannel->state = RFCOMM_CHANNEL_SEND_SABM_W4_UA; } break; @@ -1288,15 +1287,28 @@ void rfcomm_run(void){ rfcomm_channel_t * channel = ((rfcomm_channel_t *) it); if (!l2cap_can_send_packet_now(channel->multiplexer->l2cap_cid)) continue; - - // 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 + + switch (channel->state){ + + case RFCOMM_CHANNEL_W4_MULTIPLEXER: + // 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 + if (channel->outgoing && channel->multiplexer->state == RFCOMM_MULTIPLEXER_OPEN) { + log_dbg("Sending UIH Parameter Negotiation Command for #%u\n", channel->dlci ); + rfcomm_send_uih_pn_command(channel->multiplexer, channel->dlci, channel->max_frame_size); + channel->state = RFCOMM_CHANNEL_W4_PN_RSP; + } + break; - if (channel->outgoing && channel->state == RFCOMM_CHANNEL_W4_MULTIPLEXER && channel->multiplexer->state == RFCOMM_MULTIPLEXER_OPEN) { - int err = rfcomm_send_uih_pn_command(channel->multiplexer, channel->dlci, channel->max_frame_size); - if (err) return; - log_dbg("-> Sending UIH Parameter Negotiation Command for #%u\n", channel->dlci ); - channel->state = RFCOMM_CHANNEL_W4_PN_RSP; + case RFCOMM_CHANNEL_SEND_SABM_W4_UA: + log_dbg("Sending SABM #%u\n", channel->dlci); + rfcomm_send_sabm(channel->multiplexer, channel->dlci); + channel->state = RFCOMM_CHANNEL_W4_UA; + continue; + break; + + default: + break; } } }