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

Commit c4eca1e4 authored by Sunny Kapdi's avatar Sunny Kapdi Committed by William Escande
Browse files

BT5.3 Features: ADI and Encrypt key size

Snapshot of:
cfb019d7b43a103dd1749f66c20de93554d5d1bf
b513db3e630666ff4b58fc3a5f568aad4d9214cd
8a51e278f0a4318411cbef7af80937905b6a39ec
c1eed243784f2d87dd3659d8304bd29afee6833f

Sponsor: wescande@
Bug: 248126637
Tag: #feature
Test: Manual end-to-end testing (need 5.3 support in controller)
Change-Id: Ibafca123d2f89529619a2133527078df638f4e20
parent 4a6631bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ typedef struct controller_t {
  bool (*supports_sniff_subrating)(void);
  bool (*supports_encryption_pause)(void);
  bool (*supports_configure_data_path)(void);
  bool (*supports_set_min_encryption_key_size)(void);

  bool (*supports_ble)(void);
  bool (*supports_ble_packet_extension)(void);
+16 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@
namespace bluetooth {
namespace hci {

constexpr uint8_t kMinEncryptionKeySize = 7;  // #define MIN_ENCRYPTION_KEY_SIZE 7

using os::Handler;

struct Controller::impl {
@@ -71,6 +73,12 @@ struct Controller::impl {
    hci_->EnqueueCommand(ReadBufferSizeBuilder::Create(),
                         handler->BindOnceOn(this, &Controller::impl::read_buffer_size_complete_handler));

    if (is_supported(OpCode::SET_MIN_ENCRYPTION_KEY_SIZE)) {
      hci_->EnqueueCommand(
          SetMinEncryptionKeySizeBuilder::Create(kMinEncryptionKeySize),
          handler->BindOnceOn(this, &Controller::impl::set_min_encryption_key_size_handler));
    }

    if (is_supported(OpCode::LE_READ_BUFFER_SIZE_V2)) {
      hci_->EnqueueCommand(
          LeReadBufferSizeV2Builder::Create(),
@@ -321,6 +329,13 @@ struct Controller::impl {
    }
  }

  void set_min_encryption_key_size_handler(CommandCompleteView view) {
    auto complete_view = SetMinEncryptionKeySizeCompleteView::Create(view);
    ASSERT(complete_view.IsValid());
    ErrorCode status = complete_view.GetStatus();
    ASSERT_LOG(status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str());
  }

  void le_read_buffer_size_v2_handler(CommandCompleteView view) {
    auto complete_view = LeReadBufferSizeV2CompleteView::Create(view);
    ASSERT(complete_view.IsValid());
@@ -1035,6 +1050,7 @@ LOCAL_LE_FEATURE_ACCESSOR(SupportsBleIsochronousChannelsHostSupport, 32)
LOCAL_LE_FEATURE_ACCESSOR(SupportsBlePowerControlRequest, 33)
LOCAL_LE_FEATURE_ACCESSOR(SupportsBlePowerChangeIndication, 34)
LOCAL_LE_FEATURE_ACCESSOR(SupportsBlePathLossMonitoring, 35)
LOCAL_LE_FEATURE_ACCESSOR(SupportsBlePeriodicAdvertisingAdi, 36)

uint64_t Controller::GetLocalFeatures(uint8_t page_number) const {
  if (page_number < impl_->extended_lmp_features_array_.size()) {
+1 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ class Controller : public Module {
  virtual bool SupportsBlePowerControlRequest() const;
  virtual bool SupportsBlePowerChangeIndication() const;
  virtual bool SupportsBlePathLossMonitoring() const;
  virtual bool SupportsBlePeriodicAdvertisingAdi() const;

  virtual uint16_t GetAclPacketLength() const;

+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ class MockController : public Controller {
  MOCK_METHOD(bool, SupportsBleConnectedIsochronousStreamPeripheral, (), (const));
  MOCK_METHOD(bool, SupportsBleIsochronousBroadcaster, (), (const));
  MOCK_METHOD(bool, SupportsBleSynchronizedReceiver, (), (const));
  MOCK_METHOD(bool, SupportsBlePeriodicAdvertisingAdi, (), (const));
  MOCK_METHOD(uint16_t, GetAclPacketLength, (), (const));
  MOCK_METHOD(uint16_t, GetNumAclPacketBuffers, (), (const));
  MOCK_METHOD(uint8_t, GetScoPacketLength, (), (const));
+3 −0
Original line number Diff line number Diff line
@@ -1054,6 +1054,9 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
  }

  void enable_periodic_advertising(AdvertiserId advertiser_id, bool enable, bool include_adi) {
    if (include_adi && !controller_->SupportsBlePeriodicAdvertisingAdi()) {
      include_adi = false;
    }
    le_advertising_interface_->EnqueueCommand(
        hci::LeSetPeriodicAdvertisingEnableBuilder::Create(enable, include_adi, advertiser_id),
        module_handler_->BindOnceOn(
Loading