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

Commit 24ec1c59 authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge changes I453ace5a,I6184560e

* changes:
  RootCanal: Support LeReadRemoteFeatures
  RootCanal: Send LeReadRemoteFeaturesStatus
parents 7cc8f12c 49d9fb08
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2170,7 +2170,7 @@ void DualModeController::LeReadRemoteFeatures(CommandView command) {
  auto status = link_layer_controller_.SendCommandToRemoteByHandle(
      OpCode::LE_READ_REMOTE_FEATURES, command_view.GetPayload(), handle);

  auto packet = bluetooth::hci::LeConnectionUpdateStatusBuilder::Create(
  auto packet = bluetooth::hci::LeReadRemoteFeaturesStatusBuilder::Create(
      status, kNumCommandPackets);
  send_event_(std::move(packet));
}
+45 −0
Original line number Diff line number Diff line
@@ -68,6 +68,10 @@ ErrorCode LinkLayerController::SendCommandToRemoteByAddress(
  Address local_address = properties_.GetAddress();

  switch (opcode) {
    case (OpCode::LE_READ_REMOTE_FEATURES):
      SendLinkLayerPacket(model::packets::LeReadRemoteFeaturesBuilder::Create(
          local_address, remote));
      break;
    case (OpCode::REMOTE_NAME_REQUEST):
      // LMP features get requested with remote name requests.
      SendLinkLayerPacket(model::packets::ReadRemoteLmpFeaturesBuilder::Create(
@@ -258,6 +262,12 @@ void LinkLayerController::IncomingPacket(
    case model::packets::PacketType::LE_ENCRYPT_CONNECTION_RESPONSE:
      IncomingLeEncryptConnectionResponse(incoming);
      break;
    case (model::packets::PacketType::LE_READ_REMOTE_FEATURES):
      IncomingLeReadRemoteFeatures(incoming);
      break;
    case (model::packets::PacketType::LE_READ_REMOTE_FEATURES_RESPONSE):
      IncomingLeReadRemoteFeaturesResponse(incoming);
      break;
    case model::packets::PacketType::LE_SCAN:
      // TODO: Check Advertising flags and see if we are scannable.
      IncomingLeScanPacket(incoming);
@@ -1262,6 +1272,41 @@ void LinkLayerController::IncomingLeEncryptConnectionResponse(
  }
}

void LinkLayerController::IncomingLeReadRemoteFeatures(
    model::packets::LinkLayerPacketView incoming) {
  uint16_t handle =
      connections_.GetHandleOnlyAddress(incoming.GetSourceAddress());
  ErrorCode status = ErrorCode::SUCCESS;
  if (handle == kReservedHandle) {
    LOG_INFO("@%s: Unknown connection @%s",
             incoming.GetDestinationAddress().ToString().c_str(),
             incoming.GetSourceAddress().ToString().c_str());
  }
  SendLinkLayerPacket(
      model::packets::LeReadRemoteFeaturesResponseBuilder::Create(
          incoming.GetDestinationAddress(), incoming.GetSourceAddress(),
          properties_.GetLeSupportedFeatures(), static_cast<uint8_t>(status)));
}

void LinkLayerController::IncomingLeReadRemoteFeaturesResponse(
    model::packets::LinkLayerPacketView incoming) {
  uint16_t handle =
      connections_.GetHandleOnlyAddress(incoming.GetSourceAddress());
  ErrorCode status = ErrorCode::SUCCESS;
  auto response =
      model::packets::LeReadRemoteFeaturesResponseView::Create(incoming);
  if (handle == kReservedHandle) {
    LOG_INFO("@%s: Unknown connection @%s",
             incoming.GetDestinationAddress().ToString().c_str(),
             incoming.GetSourceAddress().ToString().c_str());
    status = ErrorCode::UNKNOWN_CONNECTION;
  } else {
    status = static_cast<ErrorCode>(response.GetStatus());
  }
  send_event_(bluetooth::hci::LeReadRemoteFeaturesCompleteBuilder::Create(
      status, handle, response.GetFeatures()));
}

void LinkLayerController::IncomingLeScanPacket(
    model::packets::LinkLayerPacketView incoming) {
  for (auto& advertiser : advertisers_) {
+3 −0
Original line number Diff line number Diff line
@@ -364,6 +364,9 @@ class LinkLayerController {
  void IncomingLeEncryptConnection(model::packets::LinkLayerPacketView packet);
  void IncomingLeEncryptConnectionResponse(
      model::packets::LinkLayerPacketView packet);
  void IncomingLeReadRemoteFeatures(model::packets::LinkLayerPacketView packet);
  void IncomingLeReadRemoteFeaturesResponse(
      model::packets::LinkLayerPacketView packet);
  void IncomingLeScanPacket(model::packets::LinkLayerPacketView packet);
  void IncomingLeScanResponsePacket(model::packets::LinkLayerPacketView packet);
  void IncomingPagePacket(model::packets::LinkLayerPacketView packet);
+10 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ enum PacketType : 8 {
    KEYPRESS_NOTIFICATION = 0x29,
    PIN_REQUEST = 0x2A,
    PIN_RESPONSE = 0x2B,
    LE_READ_REMOTE_FEATURES = 0x2C,
    LE_READ_REMOTE_FEATURES_RESPONSE = 0x2D,
}

packet LinkLayerPacket {
@@ -350,3 +352,11 @@ packet PinResponse : LinkLayerPacket (type = PIN_RESPONSE) {
  _reserved_ : 3,
  pin_code : 8[], // string parameter, first octet first
}

packet LeReadRemoteFeatures : LinkLayerPacket (type = LE_READ_REMOTE_FEATURES) {
}

packet LeReadRemoteFeaturesResponse : LinkLayerPacket (type = LE_READ_REMOTE_FEATURES_RESPONSE) {
  features : 64,
  status : 8,
}