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

Commit 67a4fd55 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix Long Read during MTU change

When MTU is changed during GATT Read Long procedure, we can receive full
packet using old MTU value, but compare it's length to new MTU. This
would cause us to not issue another read request, and stay with
partially read value.
If the read indeed ended with the length equal to old MTU, we can safely
attempt to read - remote should reply with invalid offset. This means
this fix is harmless, and shouldn't break any existing devices.

Test: none
Bug: 140617318
Change-Id: I29757bef957c94b1abb56d016cded08108047b09
parent cc366ee7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -708,6 +708,7 @@ tGATT_STATUS GATTC_Read(uint16_t conn_id, tGATT_READ_TYPE type,
  p_clcb->op_subtype = type;
  p_clcb->auth_req = p_read->by_handle.auth_req;
  p_clcb->counter = 0;
  p_clcb->read_req_current_mtu = p_tcb->payload_size;

  switch (type) {
    case GATT_READ_BY_TYPE:
+11 −4
Original line number Diff line number Diff line
@@ -913,11 +913,18 @@ void gatt_process_read_rsp(tGATT_TCB& tcb, tGATT_CLCB* p_clcb,

        memcpy(p_clcb->p_attr_buf + offset, p, len);

        /* send next request if needed  */
        /* full packet for read or read blob rsp */
        bool packet_is_full;
        if (tcb.payload_size == p_clcb->read_req_current_mtu) {
          packet_is_full = (len == (tcb.payload_size - 1));
        } else {
          packet_is_full = (len == (p_clcb->read_req_current_mtu - 1) ||
                            len == (tcb.payload_size - 1));
          p_clcb->read_req_current_mtu = tcb.payload_size;
        }

        if (len == (tcb.payload_size -
                    1) && /* full packet for read or read blob rsp */
            len + offset < GATT_MAX_ATTR_LEN) {
        /* send next request if needed  */
        if (packet_is_full && (len + offset < GATT_MAX_ATTR_LEN)) {
          VLOG(1) << StringPrintf(
              "full pkt issue read blob for remianing bytes old offset=%d "
              "len=%d new offset=%d",
+2 −0
Original line number Diff line number Diff line
@@ -323,6 +323,8 @@ struct tGATT_CLCB {
  bool in_use;
  alarm_t* gatt_rsp_timer_ent; /* peer response timer */
  uint8_t retry_count;
  uint16_t read_req_current_mtu; /* This is the MTU value that the read was
                                    initiated with */
};

typedef struct {