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

Commit 9cc30ddb authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Add "LE Remove Advertising Set Command"

am: 366f7e63

Change-Id: I3157d266f0e454bcc46a10b4e7cea9f2018179c9
parents fda6ce8a 366f7e63
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -234,6 +234,12 @@ class BleAdvertiserVscHciInterfaceImpl : public BleAdvertiserHciInterface {
    return false;
  }

  void RemoveAdvertisingSet(uint8_t handle,
                            status_cb command_complete) override {
    // VSC Advertising don't have remove method.
    command_complete.Run(0);
  }

 public:
  static void VendorSpecificEventCback(uint8_t length, uint8_t* p) {
    VLOG(1) << __func__;
@@ -404,6 +410,12 @@ class BleAdvertiserLegacyHciInterfaceImpl : public BleAdvertiserHciInterface {
    LOG(INFO) << __func__ << "Legacy can't do periodic advertising";
    command_complete.Run(HCI_ERR_ILLEGAL_COMMAND);
  }

  void RemoveAdvertisingSet(uint8_t handle,
                            status_cb command_complete) override {
    // Legacy Advertising don't have remove method.
    command_complete.Run(0);
  }
};

class BleAdvertiserHciExtendedImpl : public BleAdvertiserHciInterface {
@@ -591,6 +603,21 @@ class BleAdvertiserHciExtendedImpl : public BleAdvertiserHciInterface {
               HCI_LE_ENABLE_PRIODIC_ADVERTISEMENT_LEN, command_complete);
  }

  void RemoveAdvertisingSet(uint8_t handle,
                            status_cb command_complete) override {
    VLOG(1) << __func__;

    const uint16_t cmd_length = 1;
    uint8_t param[cmd_length];
    memset(param, 0, cmd_length);

    uint8_t* pp = param;
    UINT8_TO_STREAM(pp, handle);

    SendAdvCmd(FROM_HERE, HCI_LE_REMOVE_ADVERTISING_SET, param, cmd_length,
               command_complete);
  }

 public:
  void OnAdvertisingSetTerminated(uint8_t length, uint8_t* p) {
    VLOG(1) << __func__;
+2 −0
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ class BleAdvertiserHciInterface {
                                          status_cb command_complete) = 0;
  virtual void SetPeriodicAdvertisingEnable(uint8_t enable, uint8_t handle,
                                            status_cb command_complete) = 0;
  virtual void RemoveAdvertisingSet(uint8_t handle,
                                    status_cb command_complete) = 0;

  // Some implementation don't behave well when handle value 0 is used.
  virtual bool QuirkAdvertiserZeroHandle() { return 0; }
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ class AdvertiserHciMock : public BleAdvertiserHciInterface {
  MOCK_METHOD5(SetPeriodicAdvertisingData,
               void(uint8_t, uint8_t, uint8_t, uint8_t*, status_cb));
  MOCK_METHOD3(SetPeriodicAdvertisingEnable, void(uint8_t, uint8_t, status_cb));
  MOCK_METHOD2(RemoveAdvertisingSet, void(uint8_t, status_cb));

  MOCK_METHOD9(SetParameters1,
               void(uint8_t, uint16_t, uint32_t, uint32_t, uint8_t, uint8_t,