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

Commit e76c34ea authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Restart legacy advertising after successfull connection"

parents 86d524fa 4dc74657
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -318,7 +318,9 @@ class BleAdvertiserLegacyHciInterfaceImpl : public BleAdvertiserHciInterface {
  }

  void SetAdvertisingEventObserver(
      AdvertisingEventObserver* observer) override {}
      AdvertisingEventObserver* observer) override {
    this->advertising_event_observer = observer;
  }

  void SetParameters(uint8_t handle, uint16_t properties, uint32_t adv_int_min,
                     uint32_t adv_int_max, uint8_t channel_map,
@@ -457,6 +459,19 @@ class BleAdvertiserLegacyHciInterfaceImpl : public BleAdvertiserHciInterface {
    // Legacy Advertising don't have remove method.
    command_complete.Run(0);
  }

 public:
  void OnAdvertisingSetTerminated(uint8_t status, uint16_t connection_handle) {
    VLOG(1) << __func__;

    AdvertisingEventObserver* observer = this->advertising_event_observer;
    if (observer)
      observer->OnAdvertisingSetTerminated(status, 0 /*advertising_handle*/,
                                           connection_handle, 0);
  }

 private:
  AdvertisingEventObserver* advertising_event_observer = nullptr;
};

class BleAdvertiserHciExtendedImpl : public BleAdvertiserHciInterface {
@@ -697,6 +712,15 @@ void btm_le_on_advertising_set_terminated(uint8_t* p, uint16_t length) {
  }
}

bool legacy_advertising_in_use = false;
void btm_ble_advertiser_notify_terminated_legacy(uint8_t status,
                                                 uint16_t connection_handle) {
  if (BleAdvertiserHciInterface::Get() && legacy_advertising_in_use) {
    ((BleAdvertiserLegacyHciInterfaceImpl*)BleAdvertiserHciInterface::Get())
        ->OnAdvertisingSetTerminated(status, connection_handle);
  }
}

void BleAdvertiserHciInterface::Initialize() {
  VLOG(1) << __func__;
  LOG_ASSERT(instance == nullptr) << "Was already initialized.";
@@ -712,6 +736,7 @@ void BleAdvertiserHciInterface::Initialize() {
  } else {
    LOG(INFO) << "Legacy advertising will be in use";
    instance = new BleAdvertiserLegacyHciInterfaceImpl();
    legacy_advertising_in_use = true;
  }
}

+4 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ extern bool aes_cipher_msg_auth_code(BT_OCTET16 key, uint8_t* input,
                                     uint8_t* p_signature);
extern void gatt_notify_phy_updated(uint8_t status, uint16_t handle,
                                    uint8_t tx_phy, uint8_t rx_phy);
extern void btm_ble_advertiser_notify_terminated_legacy(
    uint8_t status, uint16_t connection_handle);

/******************************************************************************/
/* External Function to be called by other modules                            */
@@ -1996,6 +1998,8 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,
  }

  btm_ble_update_mode_operation(role, &bda, status);

  btm_ble_advertiser_notify_terminated_legacy(status, handle);
}

/*****************************************************************************