diff --git a/fastpair/common/BUILD b/fastpair/common/BUILD new file mode 100644 index 00000000..f53566da --- /dev/null +++ b/fastpair/common/BUILD @@ -0,0 +1,18 @@ +licenses(["notice"]) + +cc_library( + name = "common", + srcs = [ + "protocol.cc", + ], + hdrs = [ + "constant.h", + "protocol.h", + ], + visibility = [ + "//fastpair:__subpackages__", + ], + deps = [ + "@com_google_absl//absl/container:flat_hash_map", + ], +) diff --git a/fastpair/common/constant.h b/fastpair/common/constant.h new file mode 100644 index 00000000..195bfceb --- /dev/null +++ b/fastpair/common/constant.h @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// 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 +// +// https://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 THIRD_PARTY_NEARBY_FASTPAIR_COMMON_CONSTANT_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_COMMON_CONSTANT_H_ + +namespace location { +namespace nearby { +namespace fastpair { + +constexpr char kServiceId[] = "Fast Pair"; +constexpr char kFastPairServiceUuid[] = "0000FE2C-0000-1000-8000-00805F9B34FB"; +const char kKeyBasedPairingCharacteristicUuidV1[] = "1234"; +const char kKeyBasedPairingCharacteristicUuidV2[] = + "FE2C1234-8366-4814-8EB0-01DE32100BEA"; +const char kPasskeyCharacteristicUuidV1[] = "1235"; +const char kPasskeyCharacteristicUuidV2[] = + "FE2C1235-8366-4814-8EB0-01DE32100BEA"; +const char kAccountKeyCharacteristicUuidV1[] = "1236"; +const char kAccountKeyCharacteristicUuidV2[] = + "FE2C1236-8366-4814-8EB0-01DE32100BEA"; + +} // namespace fastpair +} // namespace nearby +} // namespace location + +#endif // THIRD_PARTY_NEARBY_FASTPAIR_COMMON_CONSTANT_H_ diff --git a/fastpair/common/protocol.cc b/fastpair/common/protocol.cc new file mode 100644 index 00000000..57906c99 --- /dev/null +++ b/fastpair/common/protocol.cc @@ -0,0 +1,41 @@ +// Copyright 2022 Google LLC +// +// 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 +// +// https://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. + +#include "fastpair/common/protocol.h" + +#include + +namespace location { +namespace nearby { +namespace fastpair { + +std::ostream& operator<<(std::ostream& stream, Protocol protocol) { + switch (protocol) { + case Protocol::kFastPairInitialPairing: + stream << "[Fast Pair Initial Pairing]"; + break; + case Protocol::kFastPairRetroactivePairing: + stream << "[Fast Pair Retroactive Pairing]"; + break; + case Protocol::kFastPairSubsequentPairing: + stream << "[Fast Pair Subsequent Pairing]"; + break; + } + + return stream; +} + +} // namespace fastpair +} // namespace nearby +} // namespace location diff --git a/fastpair/common/protocol.h b/fastpair/common/protocol.h new file mode 100644 index 00000000..9c2acb63 --- /dev/null +++ b/fastpair/common/protocol.h @@ -0,0 +1,38 @@ +// Copyright 2022 Google LLC +// +// 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 +// +// https://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 THIRD_PARTY_NEARBY_FASTPAIR_COMMON_PROTOCOL_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_COMMON_PROTOCOL_H_ + +#include + +namespace location { +namespace nearby { +namespace fastpair { + +// Pairing scenarios +enum class Protocol { + // Google Fast Pair + kFastPairInitialPairing = 0, + kFastPairRetroactivePairing = 1, + kFastPairSubsequentPairing = 2, +}; + +std::ostream& operator<<(std::ostream& stream, Protocol protocol); + +} // namespace fastpair +} // namespace nearby +} // namespace location + +#endif // THIRD_PARTY_NEARBY_FASTPAIR_COMMON_PROTOCOL_H_ diff --git a/fastpair/scanning/fastpair/BUILD b/fastpair/scanning/fastpair/BUILD index 4859b0df..12071259 100644 --- a/fastpair/scanning/fastpair/BUILD +++ b/fastpair/scanning/fastpair/BUILD @@ -23,9 +23,11 @@ cc_library( "fast_pair_scanner_impl.h", ], visibility = [ + "//:__subpackages__", "//fastpair:__subpackages__", ], deps = [ + "//fastpair/common", "//fastpair/internal/ble", "//internal/platform:base", "//internal/platform:comm", diff --git a/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc b/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc index 1b6f110b..cdf42683 100644 --- a/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc +++ b/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc @@ -18,17 +18,13 @@ #include "absl/functional/bind_front.h" #include "absl/strings/escaping.h" +#include "fastpair/common/constant.h" #include "internal/platform/byte_array.h" #include "internal/platform/logging.h" namespace location { namespace nearby { namespace fastpair { -namespace { - constexpr char kServiceId[] = "Fast Pair"; - constexpr char kFastPairServiceUuid[] = - "0000FE2C-0000-1000-8000-00805F9B34FB"; -} // namespace bool FastPairScannerImpl::StartScanning() { if (ble_.Enable() &&