OSDN Git Service

Add "LE Remove Advertising Set Command"
authorJakub Pawlowski <jpawlowski@google.com>
Sun, 12 Mar 2017 00:40:52 +0000 (16:40 -0800)
committerJakub Pawlowski <jpawlowski@google.com>
Tue, 14 Mar 2017 21:27:43 +0000 (14:27 -0700)
Bug: 30622771
Test: manual
Change-Id: Ie0df73475359c69af8df672454fe0c0374523c88

stack/btm/ble_advertiser_hci_interface.cc
stack/btm/ble_advertiser_hci_interface.h
stack/test/ble_advertiser_test.cc

index 9f52640..c527278 100644 (file)
@@ -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__;
index 1408606..5a9fd4f 100644 (file)
@@ -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; }
index fe992a6..bbcd630 100644 (file)
@@ -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,