[Bluetooth] BLEAdapter isScanning and BLEDevice new functions.
[platform/core/api/webapi-plugins.git] / src / bluetooth / bluetooth_le_adapter.cc
index caad799..27fd38f 100644 (file)
@@ -465,6 +465,22 @@ void BluetoothLEAdapter::StopScan(const picojson::value& data, picojson::object&
   }
 }
 
+void BluetoothLEAdapter::IsScanning(picojson::object& out) {
+  ScopeLogger();
+
+  bool is_scanning;
+  int ret = bt_adapter_le_is_discovering(&is_scanning);
+
+  if (BT_ERROR_NONE != ret) {
+    LogAndReportError(
+        PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to check for scanning in progress"), &out,
+        ("Failed to check for scanning in progress: %d (%s)", ret, get_error_message(ret)));
+  } else {
+    scanning_ = is_scanning;
+    ReportSuccess(picojson::value(is_scanning), out);
+  }
+}
+
 void BluetoothLEAdapter::StartAdvertise(const picojson::value& data, picojson::object& out) {
   ScopeLogger();
   CHECK_BACKWARD_COMPABILITY_PRIVILEGE_ACCESS(Privilege::kBluetooth, Privilege::kBluetoothAdmin,