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

Commit 8a6d8dda authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Implement additional HCI commands"

parents 8ea171aa 3503403f
Loading
Loading
Loading
Loading
+32 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ namespace rootcanal {
constexpr uint16_t kNumCommandPackets = 0x01;
constexpr uint16_t kLeMaximumDataLength = 64;
constexpr uint16_t kLeMaximumDataTime = 0x148;
constexpr uint8_t kTransmitPowerLevel = -20;

static int next_instance_id() {
  static int instance_counter = 0;
@@ -1368,6 +1369,33 @@ void DualModeController::WriteScanEnable(CommandView command) {
      kNumCommandPackets, ErrorCode::SUCCESS));
}

void DualModeController::ReadTransmitPowerLevel(CommandView command) {
  auto command_view = bluetooth::hci::ReadTransmitPowerLevelView::Create(command);
  ASSERT(command_view.IsValid());

  uint16_t connection_handle = command_view.GetConnectionHandle();
  ErrorCode status = link_layer_controller_.HasAclConnection(connection_handle)
                         ? ErrorCode::SUCCESS
                         : ErrorCode::UNKNOWN_CONNECTION;

  send_event_(bluetooth::hci::ReadTransmitPowerLevelCompleteBuilder::Create(
      kNumCommandPackets, status, connection_handle, kTransmitPowerLevel));
}

void DualModeController::ReadEnhancedTransmitPowerLevel(CommandView command) {
  auto command_view = bluetooth::hci::ReadEnhancedTransmitPowerLevelView::Create(command);
  ASSERT(command_view.IsValid());

  uint16_t connection_handle = command_view.GetConnectionHandle();
  ErrorCode status = link_layer_controller_.HasAclConnection(connection_handle)
                         ? ErrorCode::SUCCESS
                         : ErrorCode::UNKNOWN_CONNECTION;

  send_event_(bluetooth::hci::ReadEnhancedTransmitPowerLevelCompleteBuilder::Create(
      kNumCommandPackets, status, connection_handle, kTransmitPowerLevel,
      kTransmitPowerLevel, kTransmitPowerLevel));
}

void DualModeController::ReadSynchronousFlowControlEnable(CommandView command) {
  auto command_view =
      bluetooth::hci::ReadSynchronousFlowControlEnableView::Create(command);
@@ -3290,8 +3318,8 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //&DualModeController::ReadHoldModeActivity},
        //{OpCode::WRITE_HOLD_MODE_ACTIVITY,
        //&DualModeController::WriteHoldModeActivity},
        //{OpCode::READ_TRANSMIT_POWER_LEVEL,
        //&DualModeController::ReadTransmitPowerLevel},
        {OpCode::READ_TRANSMIT_POWER_LEVEL,
         &DualModeController::ReadTransmitPowerLevel},
        {OpCode::READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE,
         &DualModeController::ReadSynchronousFlowControlEnable},
        {OpCode::WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE,
@@ -3350,8 +3378,8 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //&DualModeController::ReadFlowControlMode},
        //{OpCode::WRITE_FLOW_CONTROL_MODE,
        //&DualModeController::WriteFlowControlMode},
        //{OpCode::READ_ENHANCED_TRANSMIT_POWER_LEVEL,
        //&DualModeController::ReadEnhancedTransmitPowerLevel},
        {OpCode::READ_ENHANCED_TRANSMIT_POWER_LEVEL,
         &DualModeController::ReadEnhancedTransmitPowerLevel},
        //{OpCode::READ_LE_HOST_SUPPORT,
        //&DualModeController::ReadLeHostSupport},
        {OpCode::WRITE_LE_HOST_SUPPORT,
+6 −0
Original line number Diff line number Diff line
@@ -256,6 +256,9 @@ class DualModeController : public Device {
  // 7.3.28
  void WriteVoiceSetting(CommandView command);

  // 7.3.35
  void ReadTransmitPowerLevel(CommandView command);

  // 7.3.36
  void ReadSynchronousFlowControlEnable(CommandView command);

@@ -316,6 +319,9 @@ class DualModeController : public Device {
  // 7.3.69
  void SetEventMaskPage2(CommandView command);

  // 7.3.74
  void ReadEnhancedTransmitPowerLevel(CommandView command);

  // 7.3.79
  void WriteLeHostSupport(CommandView command);

+15 −1
Original line number Diff line number Diff line
@@ -2123,7 +2123,6 @@ packet ReadTransmitPowerLevel : Command (op_code = READ_TRANSMIT_POWER_LEVEL) {
  connection_handle : 12,
  _reserved_ : 4,
  transmit_power_level_type : TransmitPowerLevelType,

}

packet ReadTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_TRANSMIT_POWER_LEVEL) {
@@ -2461,6 +2460,21 @@ packet SetEventMaskPage2Complete : CommandComplete (command_op_code = SET_EVENT_
  status: ErrorCode,
}

packet ReadEnhancedTransmitPowerLevel : Command (op_code = READ_ENHANCED_TRANSMIT_POWER_LEVEL) {
  connection_handle : 12,
  _reserved_ : 4,
  transmit_power_level_type : TransmitPowerLevelType,
}

packet ReadEnhancedTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_ENHANCED_TRANSMIT_POWER_LEVEL) {
  status : ErrorCode,
  connection_handle : 12,
  _reserved_ : 4,
  tx_power_level_gfsk : 8,
  tx_power_level_dqpsk : 8,
  tx_power_level_8dpsk : 8,
}

packet ReadLeHostSupport : Command (op_code = READ_LE_HOST_SUPPORT) {
}