Commit 6c4fcc1e authored by khorimoto's avatar khorimoto Committed by Commit bot

[CrOS Tether] Create ble_constants.h/cc, which include common constants to be...

[CrOS Tether] Create ble_constants.h/cc, which include common constants to be shared among multiple BLE-related classes.

BUG=672263

Review-Url: https://codereview.chromium.org/2590553003
Cr-Commit-Position: refs/heads/master@{#439738}
parent 8e885367
......@@ -8,6 +8,8 @@ static_library("tether") {
sources = [
"ble_advertisement_device_queue.cc",
"ble_advertisement_device_queue.h",
"ble_constants.cc",
"ble_constants.h",
"host_scan_scheduler.cc",
"host_scan_scheduler.h",
"host_scanner.cc",
......
......@@ -8,14 +8,13 @@
#include <string>
#include "base/logging.h"
#include "chromeos/components/tether/ble_constants.h"
#include "components/proximity_auth/logging/logging.h"
namespace chromeos {
namespace tether {
const int BleAdvertisementDeviceQueue::kMaxConcurrentAdvertisements = 2;
BleAdvertisementDeviceQueue::BleAdvertisementDeviceQueue() {}
BleAdvertisementDeviceQueue::~BleAdvertisementDeviceQueue() {}
......
......@@ -20,14 +20,6 @@ namespace tether {
// fair share of time spent contacting it.
class BleAdvertisementDeviceQueue {
public:
// The maximum number of devices to which to advertise concurrently. If more
// than this number of devices are registered, some advertisement must be
// stopped before new ones can be added.
//
// Note that this upper limit on concurrent advertisements is imposed due to a
// hardware limit of advertisements.
static const int kMaxConcurrentAdvertisements;
BleAdvertisementDeviceQueue();
virtual ~BleAdvertisementDeviceQueue();
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "chromeos/components/tether/ble_constants.h"
#include "components/cryptauth/remote_device_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -94,9 +95,9 @@ TEST_F(BleAdvertisementDeviceQueueTest, TestTwoDevices_MoveToEnd) {
}
TEST_F(BleAdvertisementDeviceQueueTest, TestThreeDevices) {
// Note: These tests need to be rewritten if MAX_CONCURRENT_ADVERTISEMENTS is
// Note: These tests need to be rewritten if |kMaxConcurrentAdvertisements| is
// ever changed.
ASSERT_GT(3, BleAdvertisementDeviceQueue::kMaxConcurrentAdvertisements);
ASSERT_GT(3, kMaxConcurrentAdvertisements);
std::vector<cryptauth::RemoteDevice> devices =
cryptauth::GenerateTestRemoteDevices(3);
......@@ -121,9 +122,9 @@ TEST_F(BleAdvertisementDeviceQueueTest, TestThreeDevices) {
}
TEST_F(BleAdvertisementDeviceQueueTest, TestAddingDevices) {
// Note: These tests need to be rewritten if MAX_CONCURRENT_ADVERTISEMENTS is
// Note: These tests need to be rewritten if |kMaxConcurrentAdvertisements| is
// ever changed.
ASSERT_GT(3, BleAdvertisementDeviceQueue::kMaxConcurrentAdvertisements);
ASSERT_GT(3, kMaxConcurrentAdvertisements);
std::vector<cryptauth::RemoteDevice> all_devices =
cryptauth::GenerateTestRemoteDevices(5);
......
// Copyright 2016 The Chromium 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 "chromeos/components/tether/ble_constants.h"
namespace chromeos {
namespace tether {
const int kMaxConcurrentAdvertisements = 2;
const char kAdvertisingServiceUuid[] = "0000fe50-0000-1000-8000-00805f9b34fb";
} // namespace tether
} // namespace chromeos
// Copyright 2016 The Chromium 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 CHROMEOS_COMPONENTS_TETHER_BLE_CONSTANTS_H_
#define CHROMEOS_COMPONENTS_TETHER_BLE_CONSTANTS_H_
#include <string>
namespace chromeos {
namespace tether {
// The maximum number of devices to which to advertise concurrently. If more
// than this number of devices are registered, other advertisements must be
// stopped before new ones can be added.
//
// Note that this upper limit on concurrent advertisements is imposed due to a
// hardware limit of advertisements (many devices have <10 total advertisement
// slots).
extern const int kMaxConcurrentAdvertisements;
// The service UUID used for BLE advertisements.
extern const char kAdvertisingServiceUuid[];
} // namespace tether
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_TETHER_BLE_CONSTANTS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment