Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adde3329 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

Send ATT_EXECUTE_WRITE_RSP when no pending writes

According to the Bluetooth Core Specification
Vol 3, Part F, 3.4.6.3 ATT_EXECUTE_WRITE_REQ,

If there are no pending prepared write values,
then no values are written,
and an ATT_EXECUTE_WRITE_RSP PDU shall be sent.

This change ensures that behavior.

Bug: 385118069
Bug: 382008796
Test: atest net_test_stack_gatt_native
Change-Id: I98142197f6276646ece034e3a288c58cf56c2c9c
parent 7de67de7
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -430,9 +430,20 @@ static void gatt_process_exec_write_req(tGATT_TCB& tcb, uint16_t cid, uint8_t op
      }
    }
  } else { /* nothing needs to be executed , send response now */
    log::error("gatt_process_exec_write_req: no prepare write pending");
    log::warn("gatt_process_exec_write_req: no prepare write pending");
    if (com::android::bluetooth::flags::fix_execute_write_no_pending()) {
      uint16_t payload_size = gatt_tcb_get_payload_size(tcb, cid);
      BT_HDR* p_buf =
              attp_build_sr_msg(tcb, GATT_RSP_EXEC_WRITE, (tGATT_SR_MSG*)NULL, payload_size);
      if (p_buf != NULL) {
        attp_send_sr_msg(tcb, cid, p_buf);
      } else {
        gatt_send_error_rsp(tcb, cid, GATT_ERROR, GATT_REQ_EXEC_WRITE, 0, false);
      }
    } else {
      gatt_send_error_rsp(tcb, cid, GATT_ERROR, GATT_REQ_EXEC_WRITE, 0, false);
    }
  }
}

/*******************************************************************************