Initial add of weave::Bluetooth interface
Initial add of an empty bluetooth interface, soon to be followed
up with actual methods.
Bug: 24009281
Change-Id: I1004c232a3f1b636fe9ad5195e303903ae900c27
diff --git a/libweave/.gitignore b/libweave/.gitignore
index a4a2e7d..4011af4 100644
--- a/libweave/.gitignore
+++ b/libweave/.gitignore
@@ -1,3 +1,4 @@
+*~
/out/
/third_party/include
/third_party/lib
diff --git a/libweave/examples/ubuntu/bluez_client.cc b/libweave/examples/ubuntu/bluez_client.cc
new file mode 100644
index 0000000..d1f6558
--- /dev/null
+++ b/libweave/examples/ubuntu/bluez_client.cc
@@ -0,0 +1,14 @@
+// Copyright 2015 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "libweave/examples/ubuntu/bluez_client.h"
+
+namespace weave {
+namespace examples {
+
+BluetoothImpl::BluetoothImpl() {};
+BluetoothImpl::~BluetoothImpl() {};
+
+} // namespace examples
+} // namespace weave
diff --git a/libweave/examples/ubuntu/bluez_client.h b/libweave/examples/ubuntu/bluez_client.h
new file mode 100644
index 0000000..0915403
--- /dev/null
+++ b/libweave/examples/ubuntu/bluez_client.h
@@ -0,0 +1,24 @@
+// Copyright 2015 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBWEAVE_EXAMPLES_UBUNTU_BLUEZ_CLIENT_H_
+#define LIBWEAVE_EXAMPLES_UBUNTU_BLUEZ_CLIENT_H_
+
+#include <weave/bluetooth.h>
+
+namespace weave {
+namespace examples {
+
+// Example of weave::Bluetooth implemented with bluez.
+class BluetoothImpl : public Bluetooth {
+ public:
+ BluetoothImpl();
+
+ ~BluetoothImpl() override;
+};
+
+} // namespace examples
+} // namespace weave
+
+#endif // LIBWEAVE_EXAMPLES_UBUNTU_BLUEZ_CLIENT_H_
diff --git a/libweave/examples/ubuntu/main.cc b/libweave/examples/ubuntu/main.cc
index b42ab66..9901898 100644
--- a/libweave/examples/ubuntu/main.cc
+++ b/libweave/examples/ubuntu/main.cc
@@ -5,6 +5,7 @@
#include <weave/device.h>
#include "libweave/examples/ubuntu/avahi_client.h"
+#include "libweave/examples/ubuntu/bluez_client.h"
#include "libweave/examples/ubuntu/curl_http_client.h"
#include "libweave/examples/ubuntu/event_http_server.h"
#include "libweave/examples/ubuntu/event_task_runner.h"
@@ -18,6 +19,7 @@
weave::examples::NetworkImpl network{&task_runner};
weave::examples::MdnsImpl mdns;
weave::examples::HttpServerImpl http_server{task_runner.GetEventBase()};
+ weave::examples::BluetoothImpl bluetooth;
auto device = weave::Device::Create();
weave::Device::Options opts;
@@ -26,7 +28,7 @@
opts.disable_security = false;
opts.enable_ping = true;
device->Start(opts, &config_store, &task_runner, &http_client, &network,
- &mdns, &http_server);
+ &mdns, &http_server, &bluetooth);
task_runner.Run();
diff --git a/libweave/examples/ubuntu/weave.gyp b/libweave/examples/ubuntu/weave.gyp
index 0aa4e3a..e8abc5e 100644
--- a/libweave/examples/ubuntu/weave.gyp
+++ b/libweave/examples/ubuntu/weave.gyp
@@ -12,6 +12,7 @@
'network_manager.cc',
'avahi_client.cc',
'event_http_server.cc',
+ 'bluez_client.cc',
],
'dependencies': [
'../../libweave_standalone.gyp:libweave',
diff --git a/libweave/include/weave/bluetooth.h b/libweave/include/weave/bluetooth.h
new file mode 100644
index 0000000..69fdc5e
--- /dev/null
+++ b/libweave/include/weave/bluetooth.h
@@ -0,0 +1,20 @@
+// Copyright 2015 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef LIBWEAVE_INCLUDE_WEAVE_BLUETOOTH_H_
+#define LIBWEAVE_INCLUDE_WEAVE_BLUETOOTH_H_
+
+namespace weave {
+
+class Bluetooth {
+ public:
+ // TODO(rginda): Add bluetooth interface methods here.
+
+ protected:
+ virtual ~Bluetooth() = default;
+};
+
+} // namespace weave
+
+#endif // LIBWEAVE_INCLUDE_WEAVE_BLUETOOTH_H_
diff --git a/libweave/include/weave/device.h b/libweave/include/weave/device.h
index 0bd5ade..c7ed3ae 100644
--- a/libweave/include/weave/device.h
+++ b/libweave/include/weave/device.h
@@ -9,6 +9,7 @@
#include <set>
#include <string>
+#include <weave/bluetooth.h>
#include <weave/cloud.h>
#include <weave/commands.h>
#include <weave/config_store.h>
@@ -41,7 +42,8 @@
HttpClient* http_client,
Network* network,
Mdns* mdns,
- HttpServer* http_server) = 0;
+ HttpServer* http_server,
+ Bluetooth* bluetooth) = 0;
virtual Commands* GetCommands() = 0;
virtual State* GetState() = 0;
diff --git a/libweave/include/weave/test/mock_bluetooth.h b/libweave/include/weave/test/mock_bluetooth.h
new file mode 100644
index 0000000..d02e314
--- /dev/null
+++ b/libweave/include/weave/test/mock_bluetooth.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_BLUETOOTH_H_
+#define LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_BLUETOOTH_H_
+
+#include <weave/bluetooth.h>
+
+namespace weave {
+namespace test {
+
+class MockBluetooth : public Bluetooth {
+ public:
+};
+
+} // namespace test
+} // namespace weave
+
+#endif // LIBWEAVE_INCLUDE_WEAVE_TEST_MOCK_BLUETOOTH_H_
diff --git a/libweave/src/device_manager.cc b/libweave/src/device_manager.cc
index a54ac05..1435aeb 100644
--- a/libweave/src/device_manager.cc
+++ b/libweave/src/device_manager.cc
@@ -35,7 +35,8 @@
HttpClient* http_client,
Network* network,
Mdns* mdns,
- HttpServer* http_server) {
+ HttpServer* http_server,
+ Bluetooth* bluetooth) {
command_manager_ = std::make_shared<CommandManager>();
command_manager_->Startup(config_store);
state_change_queue_.reset(new StateChangeQueue(kMaxStateChangeQueueSize));
@@ -56,7 +57,7 @@
device_info_->Start();
if (!options.disable_privet) {
- StartPrivet(options, task_runner, network, mdns, http_server);
+ StartPrivet(options, task_runner, network, mdns, http_server, bluetooth);
} else {
CHECK(!http_server);
CHECK(!mdns);
@@ -87,7 +88,8 @@
TaskRunner* task_runner,
Network* network,
Mdns* mdns,
- HttpServer* http_server) {
+ HttpServer* http_server,
+ Bluetooth* bluetooth) {
privet_.reset(new privet::Manager{});
privet_->Start(options, task_runner, network, mdns, http_server,
device_info_.get(), command_manager_.get(),
diff --git a/libweave/src/device_manager.h b/libweave/src/device_manager.h
index 951cbf2..376f122 100644
--- a/libweave/src/device_manager.h
+++ b/libweave/src/device_manager.h
@@ -32,7 +32,8 @@
HttpClient* http_client,
Network* network,
Mdns* mdns,
- HttpServer* http_server) override;
+ HttpServer* http_server,
+ Bluetooth* bluetooth) override;
Commands* GetCommands() override;
State* GetState() override;
@@ -46,7 +47,8 @@
TaskRunner* task_runner,
Network* network,
Mdns* mdns,
- HttpServer* http_server);
+ HttpServer* http_server,
+ Bluetooth* bluetooth);
void OnWiFiBootstrapStateChanged(weave::WifiSetupState state);
diff --git a/libweave/src/weave_unittest.cc b/libweave/src/weave_unittest.cc
index 0f7e274..a957f1c 100644
--- a/libweave/src/weave_unittest.cc
+++ b/libweave/src/weave_unittest.cc
@@ -6,6 +6,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <weave/test/mock_bluetooth.h>
#include <weave/test/mock_config_store.h>
#include <weave/test/mock_http_client.h>
#include <weave/test/mock_http_server.h>
@@ -293,7 +294,7 @@
options.xmpp_enabled = false;
device_->Start(options, &config_store_, &task_runner_, &http_client_,
- &network_, &mdns_, &http_server_);
+ &network_, &mdns_, &http_server_, &bluetooth_);
cloud_ = device_->GetCloud();
ASSERT_TRUE(cloud_);
@@ -321,6 +322,7 @@
StrictMock<test::MockNetwork> network_;
StrictMock<test::MockMdns> mdns_;
StrictMock<test::MockHttpServer> http_server_;
+ StrictMock<test::MockBluetooth> bluetooth_;
std::vector<Network::OnConnectionChangedCallback> network_callbacks_;
@@ -341,7 +343,7 @@
InitConfigStore();
device_->Start(options, &config_store_, &task_runner_, &http_client_,
- &network_, nullptr, nullptr);
+ &network_, nullptr, nullptr, nullptr);
}
class WeaveBasicTest : public WeaveTest {