From 4bac7e4a78427ed2281d2e34f76eb5fd39e9bd91 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Fri, 25 Sep 2020 13:24:55 -0700 Subject: [PATCH] L2C_CSM: Send ConfigCfm to user after ConfigInd This way, users know that a ConfigCfm event with status OK means channel is established. No need to further keep track of state. Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: I90295349c53d57aa859c5bb65e6f28a299714b3d --- stack/l2cap/l2c_csm.cc | 10 +++++++++- stack/l2cap/l2c_int.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stack/l2cap/l2c_csm.cc b/stack/l2cap/l2c_csm.cc index 5a1b2b3fc..fd5547204 100644 --- a/stack/l2cap/l2c_csm.cc +++ b/stack/l2cap/l2c_csm.cc @@ -766,6 +766,10 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { p_ccb->local_cid, (p_cfg->flags & L2CAP_CFG_FLAGS_MASK_CONT)); (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg); l2c_csm_send_config_rsp_ok(p_ccb); + if (p_ccb->config_done & OB_CFG_DONE) { + (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)( + p_ccb->local_cid, p_ccb->remote_config_rsp_result); + } } else if (cfg_result == L2CAP_PEER_CFG_DISCONNECT) { /* Disconnect if channels are incompatible */ L2CAP_TRACE_EVENT("L2CAP - incompatible configurations disconnect"); @@ -832,7 +836,11 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { L2CAP_TRACE_API("L2CAP - Calling Config_Rsp_Cb(), CID: 0x%04x", p_ccb->local_cid); - (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, p_cfg->result); + p_ccb->remote_config_rsp_result = p_cfg->result; + if (p_ccb->config_done & IB_CFG_DONE) { + (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, + p_cfg->result); + } break; case L2CEVT_L2CAP_CONFIG_RSP_NEG: /* Peer config error rsp */ diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h index adec13d80..746b109b4 100644 --- a/stack/l2cap/l2c_int.h +++ b/stack/l2cap/l2c_int.h @@ -250,9 +250,9 @@ typedef struct t_l2c_ccb { #define IB_CFG_DONE 0x01 #define OB_CFG_DONE 0x02 #define RECONFIG_FLAG 0x04 /* True after initial configuration */ -#define CFG_DONE_MASK (IB_CFG_DONE | OB_CFG_DONE) uint8_t config_done; /* Configuration flag word */ + uint16_t remote_config_rsp_result; /* The config rsp result from remote */ uint8_t local_id; /* Transaction ID for local trans */ uint8_t remote_id; /* Transaction ID for local */ -- 2.11.0