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

Commit 54185959 authored by Peng Qi's avatar Peng Qi Committed by android-build-merger
Browse files

BT HAL H4 write flow am: 92afd74a

am: 2b1413fd

Change-Id: I10da550c30c9b480ac1f3f3b14d463b9441b9368
parents c33b9bce 2b1413fd
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -18,8 +18,10 @@


#define LOG_TAG "android.hardware.bluetooth-hci-h4"
#define LOG_TAG "android.hardware.bluetooth-hci-h4"
#include <android-base/logging.h>
#include <android-base/logging.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <log/log.h>
#include <sys/uio.h>


namespace android {
namespace android {
namespace hardware {
namespace hardware {
@@ -27,11 +29,20 @@ namespace bluetooth {
namespace hci {
namespace hci {


size_t H4Protocol::Send(uint8_t type, const uint8_t* data, size_t length) {
size_t H4Protocol::Send(uint8_t type, const uint8_t* data, size_t length) {
  int rv = WriteSafely(uart_fd_, &type, sizeof(type));
  struct iovec iov[] = {{&type, sizeof(type)},
  if (rv == sizeof(type)) {
                        {const_cast<uint8_t*>(data), length}};
    rv = WriteSafely(uart_fd_, data, length);
  ssize_t ret = 0;
  do {
    ret = TEMP_FAILURE_RETRY(writev(uart_fd_, iov, sizeof(iov) / sizeof(iov[0])));
  } while (-1 == ret && EAGAIN == errno);

  if (ret == -1) {
    ALOGE("%s error writing to UART (%s)", __func__, strerror(errno));
  } else if (ret == 0) {
    // Nothing written :(
    ALOGE("%s zero bytes written - something went wrong...", __func__);
  }
  }
  return rv;
  return ret;
}
}


void H4Protocol::OnPacketReady() {
void H4Protocol::OnPacketReady() {