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

Commit 797f9796 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Add main/shim/helpers::debug::DumpBtHdr am: 5353a053

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1460809

Change-Id: I2e59386a1048a6467e202aa510e2527cf04cfe0a
parents b5c0f04e 5353a053
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -184,4 +184,24 @@ inline uint8_t ToLegacyHciErrorCode(hci::ErrorCode reason) {
  }
}

namespace debug {

inline void DumpBtHdr(const BT_HDR* p_buf, const char* token) {
  uint16_t len = p_buf->len;
  char buf[255];
  const uint8_t* data = p_buf->data + p_buf->offset;
  int cnt = 0;
  while (len > 0) {
    memset(buf, 0, sizeof(buf));
    char* pbuf = buf;
    pbuf += sprintf(pbuf, "len:%5u %5d: ", p_buf->len, cnt);
    for (int j = 0; j < 16; j++, --len, data++, cnt++) {
      if (len == 0) break;
      pbuf += sprintf(pbuf, "0x%02x ", *data);
    }
    LOG_DEBUG("%s %s", token, buf);
  }
}

}  // namespace debug
}  // namespace bluetooth