bluetooth_AdapterLEAdvertising: BLE advertising intervals autotest

Verify that the bluetooth adapter of a DUT could behave as a bluetooth
low-energy device and advertise with correct data and parameters.

Specifically, the following subtests are executed in this autotest.
  - test_register_advertisement
  - test_set_advertising_intervals
  - test_reset_advertising

Note that testing about multi-advertisements is not included. The two
control files provide two distinct advertisement data cannot be run
in parallel for now. We may support multi-advertisements testing later.

CQ-DEPEND=CL:390191
BUG=chromium:602461
TEST=Conduct the autotest as follows:
(cr) $ test_that --board=$BOARD  $DUT_IP bluetooth_AdapterLEAdvertising
 or
(cr) $ test_that --board=$BOARD  $DUT_IP bluetooth_AdapterLEAdvertising.case2

Change-Id: I7713e3c322ef74ec59ae401f9b6d67c3718c2568
Reviewed-on: https://chromium-review.googlesource.com/394578
Commit-Ready: Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
diff --git a/server/cros/bluetooth/bluetooth_device.py b/server/cros/bluetooth/bluetooth_device.py
index 8f45e47..45013ae 100644
--- a/server/cros/bluetooth/bluetooth_device.py
+++ b/server/cros/bluetooth/bluetooth_device.py
@@ -536,6 +536,78 @@
         return self._proxy.disconnect_device(address)
 
 
+    def btmon_start(self):
+        """Start btmon monitoring."""
+        self._proxy.btmon_start()
+
+
+    def btmon_stop(self):
+        """Stop btmon monitoring."""
+        self._proxy.btmon_stop()
+
+
+    def btmon_get(self):
+        """Get btmon output contents.
+
+        @returns: the recorded btmon output.
+
+        """
+        return self._proxy.btmon_get()
+
+
+    def btmon_find(self, pattern_str):
+        """Find if a pattern string exists in btmon output.
+
+        @param pattern_str: the pattern string to find.
+
+        @returns: True on success. False otherwise.
+
+        """
+        return self._proxy.btmon_find(pattern_str)
+
+
+    def register_advertisement(self, advertisement_data):
+        """Register an advertisement.
+
+        Note that rpc supports only conformable types. Hence, a
+        dict about the advertisement is passed as a parameter such
+        that the advertisement object could be contructed on the host.
+
+        @param advertisement_data: a dict of the advertisement for
+                                   the adapter to register.
+
+        @returns: True on success. False otherwise.
+
+        """
+        return self._proxy.register_advertisement(advertisement_data)
+
+
+    def set_advertising_intervals(self, min_adv_interval_ms,
+                                  max_adv_interval_ms):
+        """Set advertising intervals.
+
+        @param min_adv_interval_ms: the min advertising interval in ms.
+        @param max_adv_interval_ms: the max advertising interval in ms.
+
+        @returns: True on success. False otherwise.
+
+        """
+        return self._proxy.set_advertising_intervals(min_adv_interval_ms,
+                                                     max_adv_interval_ms)
+
+
+    def reset_advertising(self):
+        """Reset advertising.
+
+        This includes unregister all advertisements, reset advertising
+        intervals, and disable advertising.
+
+        @returns: True on success. False otherwise.
+
+        """
+        return self._proxy.reset_advertising()
+
+
     def copy_logs(self, destination):
         """Copy the logs generated by this device to a given location.