Loading system/bta/gatt/bta_gattc_act.cc +6 −0 Original line number Diff line number Diff line Loading @@ -911,6 +911,8 @@ void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_OP_CMPL* p_data) { /** configure MTU operation complete */ void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_OP_CMPL* p_data) { GATT_CONFIGURE_MTU_OP_CB cb = p_clcb->p_q_cmd->api_mtu.mtu_cb; void* my_cb_data = p_clcb->p_q_cmd->api_mtu.mtu_cb_data; tBTA_GATTC cb_data; osi_free_and_reset((void**)&p_clcb->p_q_cmd); Loading @@ -924,6 +926,10 @@ void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB* p_clcb, cb_data.cfg_mtu.status = p_data->status; cb_data.cfg_mtu.mtu = p_clcb->p_srcb->mtu; if (cb) { cb(p_clcb->bta_conn_id, p_data->status, my_cb_data); } (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CFG_MTU_EVT, &cb_data); } Loading system/bta/gatt/bta_gattc_api.cc +13 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,19 @@ void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu) { bta_sys_sendmsg(p_buf); } void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu, GATT_CONFIGURE_MTU_OP_CB callback, void* cb_data) { tBTA_GATTC_API_CFG_MTU* p_buf = (tBTA_GATTC_API_CFG_MTU*)osi_malloc(sizeof(tBTA_GATTC_API_CFG_MTU)); p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT; p_buf->hdr.layer_specific = conn_id; p_buf->mtu = mtu; p_buf->mtu_cb = callback; p_buf->mtu_cb_data = cb_data; bta_sys_sendmsg(p_buf); } /******************************************************************************* * Loading system/bta/gatt/bta_gattc_int.h +2 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,8 @@ typedef struct { typedef struct { BT_HDR hdr; uint16_t mtu; GATT_CONFIGURE_MTU_OP_CB mtu_cb; void* mtu_cb_data; } tBTA_GATTC_API_CFG_MTU; typedef struct { Loading system/bta/gatt/bta_gattc_queue.cc +41 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ constexpr uint8_t GATT_READ_CHAR = 1; constexpr uint8_t GATT_READ_DESC = 2; constexpr uint8_t GATT_WRITE_CHAR = 3; constexpr uint8_t GATT_WRITE_DESC = 4; constexpr uint8_t GATT_CONFIG_MTU = 5; struct gatt_read_op_data { GATT_READ_OP_CB cb; Loading Loading @@ -80,6 +81,29 @@ void BtaGattQueue::gatt_write_op_finished(uint16_t conn_id, tGATT_STATUS status, } } struct gatt_configure_mtu_op_data { GATT_CONFIGURE_MTU_OP_CB cb; void* cb_data; }; void BtaGattQueue::gatt_configure_mtu_op_finished(uint16_t conn_id, tGATT_STATUS status, void* data) { gatt_configure_mtu_op_data* tmp = (gatt_configure_mtu_op_data*)data; GATT_CONFIGURE_MTU_OP_CB tmp_cb = tmp->cb; void* tmp_cb_data = tmp->cb_data; osi_free(data); mark_as_not_executing(conn_id); gatt_execute_next_op(conn_id); if (tmp_cb) { tmp_cb(conn_id, status, tmp_cb_data); return; } } void BtaGattQueue::gatt_execute_next_op(uint16_t conn_id) { APPL_TRACE_DEBUG("%s: conn_id=0x%x", __func__, conn_id); if (gatt_op_queue.empty()) { Loading Loading @@ -137,6 +161,14 @@ void BtaGattQueue::gatt_execute_next_op(uint16_t conn_id) { data->cb_data = op.write_cb_data; BTA_GATTC_WriteCharDescr(conn_id, op.handle, std::move(op.value), GATT_AUTH_REQ_NONE, gatt_write_op_finished, data); } else if (op.type == GATT_CONFIG_MTU) { gatt_configure_mtu_op_data* data = (gatt_configure_mtu_op_data*)osi_malloc(sizeof(gatt_configure_mtu_op_data)); data->cb = op.mtu_cb; data->cb_data = op.mtu_cb_data; BTA_GATTC_ConfigureMTU(conn_id, static_cast<uint16_t>(op.value[0] | (op.value[1] << 8)), gatt_configure_mtu_op_finished, data); } gatt_ops.pop_front(); Loading Loading @@ -190,3 +222,12 @@ void BtaGattQueue::WriteDescriptor(uint16_t conn_id, uint16_t handle, .value = std::move(value)}); gatt_execute_next_op(conn_id); } void BtaGattQueue::ConfigureMtu(uint16_t conn_id, uint16_t mtu) { LOG(INFO) << __func__ << ", mtu: " << static_cast<int>(mtu); std::vector<uint8_t> value = {static_cast<uint8_t>(mtu & 0xff), static_cast<uint8_t>(mtu >> 8)}; gatt_op_queue[conn_id].push_back({.type = GATT_CONFIG_MTU, .value = std::move(value)}); gatt_execute_next_op(conn_id); } system/bta/include/bta_gatt_api.h +5 −0 Original line number Diff line number Diff line Loading @@ -601,6 +601,8 @@ typedef void (*GATT_READ_OP_CB)(uint16_t conn_id, tGATT_STATUS status, void* data); typedef void (*GATT_WRITE_OP_CB)(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, void* data); typedef void (*GATT_CONFIGURE_MTU_OP_CB)(uint16_t conn_id, tGATT_STATUS status, void* data); /******************************************************************************* * Loading Loading @@ -808,6 +810,9 @@ extern void BTA_GATTC_Refresh(const RawAddress& remote_bda); * ******************************************************************************/ extern void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu); extern void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu, GATT_CONFIGURE_MTU_OP_CB callback, void* cb_data); /******************************************************************************* * BTA GATT Server API Loading Loading
system/bta/gatt/bta_gattc_act.cc +6 −0 Original line number Diff line number Diff line Loading @@ -911,6 +911,8 @@ void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_OP_CMPL* p_data) { /** configure MTU operation complete */ void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_OP_CMPL* p_data) { GATT_CONFIGURE_MTU_OP_CB cb = p_clcb->p_q_cmd->api_mtu.mtu_cb; void* my_cb_data = p_clcb->p_q_cmd->api_mtu.mtu_cb_data; tBTA_GATTC cb_data; osi_free_and_reset((void**)&p_clcb->p_q_cmd); Loading @@ -924,6 +926,10 @@ void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB* p_clcb, cb_data.cfg_mtu.status = p_data->status; cb_data.cfg_mtu.mtu = p_clcb->p_srcb->mtu; if (cb) { cb(p_clcb->bta_conn_id, p_data->status, my_cb_data); } (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CFG_MTU_EVT, &cb_data); } Loading
system/bta/gatt/bta_gattc_api.cc +13 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,19 @@ void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu) { bta_sys_sendmsg(p_buf); } void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu, GATT_CONFIGURE_MTU_OP_CB callback, void* cb_data) { tBTA_GATTC_API_CFG_MTU* p_buf = (tBTA_GATTC_API_CFG_MTU*)osi_malloc(sizeof(tBTA_GATTC_API_CFG_MTU)); p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT; p_buf->hdr.layer_specific = conn_id; p_buf->mtu = mtu; p_buf->mtu_cb = callback; p_buf->mtu_cb_data = cb_data; bta_sys_sendmsg(p_buf); } /******************************************************************************* * Loading
system/bta/gatt/bta_gattc_int.h +2 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,8 @@ typedef struct { typedef struct { BT_HDR hdr; uint16_t mtu; GATT_CONFIGURE_MTU_OP_CB mtu_cb; void* mtu_cb_data; } tBTA_GATTC_API_CFG_MTU; typedef struct { Loading
system/bta/gatt/bta_gattc_queue.cc +41 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ constexpr uint8_t GATT_READ_CHAR = 1; constexpr uint8_t GATT_READ_DESC = 2; constexpr uint8_t GATT_WRITE_CHAR = 3; constexpr uint8_t GATT_WRITE_DESC = 4; constexpr uint8_t GATT_CONFIG_MTU = 5; struct gatt_read_op_data { GATT_READ_OP_CB cb; Loading Loading @@ -80,6 +81,29 @@ void BtaGattQueue::gatt_write_op_finished(uint16_t conn_id, tGATT_STATUS status, } } struct gatt_configure_mtu_op_data { GATT_CONFIGURE_MTU_OP_CB cb; void* cb_data; }; void BtaGattQueue::gatt_configure_mtu_op_finished(uint16_t conn_id, tGATT_STATUS status, void* data) { gatt_configure_mtu_op_data* tmp = (gatt_configure_mtu_op_data*)data; GATT_CONFIGURE_MTU_OP_CB tmp_cb = tmp->cb; void* tmp_cb_data = tmp->cb_data; osi_free(data); mark_as_not_executing(conn_id); gatt_execute_next_op(conn_id); if (tmp_cb) { tmp_cb(conn_id, status, tmp_cb_data); return; } } void BtaGattQueue::gatt_execute_next_op(uint16_t conn_id) { APPL_TRACE_DEBUG("%s: conn_id=0x%x", __func__, conn_id); if (gatt_op_queue.empty()) { Loading Loading @@ -137,6 +161,14 @@ void BtaGattQueue::gatt_execute_next_op(uint16_t conn_id) { data->cb_data = op.write_cb_data; BTA_GATTC_WriteCharDescr(conn_id, op.handle, std::move(op.value), GATT_AUTH_REQ_NONE, gatt_write_op_finished, data); } else if (op.type == GATT_CONFIG_MTU) { gatt_configure_mtu_op_data* data = (gatt_configure_mtu_op_data*)osi_malloc(sizeof(gatt_configure_mtu_op_data)); data->cb = op.mtu_cb; data->cb_data = op.mtu_cb_data; BTA_GATTC_ConfigureMTU(conn_id, static_cast<uint16_t>(op.value[0] | (op.value[1] << 8)), gatt_configure_mtu_op_finished, data); } gatt_ops.pop_front(); Loading Loading @@ -190,3 +222,12 @@ void BtaGattQueue::WriteDescriptor(uint16_t conn_id, uint16_t handle, .value = std::move(value)}); gatt_execute_next_op(conn_id); } void BtaGattQueue::ConfigureMtu(uint16_t conn_id, uint16_t mtu) { LOG(INFO) << __func__ << ", mtu: " << static_cast<int>(mtu); std::vector<uint8_t> value = {static_cast<uint8_t>(mtu & 0xff), static_cast<uint8_t>(mtu >> 8)}; gatt_op_queue[conn_id].push_back({.type = GATT_CONFIG_MTU, .value = std::move(value)}); gatt_execute_next_op(conn_id); }
system/bta/include/bta_gatt_api.h +5 −0 Original line number Diff line number Diff line Loading @@ -601,6 +601,8 @@ typedef void (*GATT_READ_OP_CB)(uint16_t conn_id, tGATT_STATUS status, void* data); typedef void (*GATT_WRITE_OP_CB)(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, void* data); typedef void (*GATT_CONFIGURE_MTU_OP_CB)(uint16_t conn_id, tGATT_STATUS status, void* data); /******************************************************************************* * Loading Loading @@ -808,6 +810,9 @@ extern void BTA_GATTC_Refresh(const RawAddress& remote_bda); * ******************************************************************************/ extern void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu); extern void BTA_GATTC_ConfigureMTU(uint16_t conn_id, uint16_t mtu, GATT_CONFIGURE_MTU_OP_CB callback, void* cb_data); /******************************************************************************* * BTA GATT Server API Loading