diff --git a/cpp/presence/public/advertisement_generator.cc b/cpp/presence/public/advertisement_generator.cc new file mode 100644 index 00000000..8a32239e --- /dev/null +++ b/cpp/presence/public/advertisement_generator.cc @@ -0,0 +1,30 @@ +// Copyright 2020 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 "third_party/nearby_connections/cpp/presence/public/advertisement_generator.h" + +namespace nearby { +namespace presence { + +AdvertisementGenerator::AdvertisementGenerator() = default; +AdvertisementGenerator::~AdvertisementGenerator() = default; +std::string AdvertisementGenerator::GeneratePresenceServiceUuid() { + return kPresenceServiceUuid; +} +ByteArray AdvertisementGenerator::GeneratePresenceAdvertisementBytes() { + return ByteArray{"12345"}; +} + +} // namespace presence +} // namespace nearby diff --git a/cpp/presence/public/advertisement_generator.h b/cpp/presence/public/advertisement_generator.h new file mode 100644 index 00000000..0e6fe52e --- /dev/null +++ b/cpp/presence/public/advertisement_generator.h @@ -0,0 +1,35 @@ +// Copyright 2020 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_CONNECTIONS_CPP_PRESENCE_PUBLIC_ADVERTISEMENT_GENERATOR_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_CPP_PRESENCE_PUBLIC_ADVERTISEMENT_GENERATOR_H_ + +#include "platform/base/byte_array.h" +namespace nearby { +namespace presence { + +class AdvertisementGenerator { + public: + AdvertisementGenerator(); + ~AdvertisementGenerator(); + std::string GeneratePresenceServiceUuid(); + ByteArray GeneratePresenceAdvertisementBytes(); + + private: + static constexpr std::string kPresenceServiceUuid = "FE2C" +} + +} // namespace presence +} // namespace nearby +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CPP_PRESENCE_PUBLIC_ADVERTISEMENT_GENERATOR_H_ diff --git a/cpp/presence/public/client.cc b/cpp/presence/public/client.cc new file mode 100644 index 00000000..d1a86009 --- /dev/null +++ b/cpp/presence/public/client.cc @@ -0,0 +1,43 @@ +// Copyright 2020 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 "third_party/nearby_connections/cpp/presence/public/client.h" + +#include "platform/base/logging.h" +#include "third_party/nearby_connections/cpp/presence/public/advertisement_generator.h" + +namespace nearby { +namespace presence { + +class PresenceClient { + public: + PresenceClient(); + ~PresenceClient(); + void PresenceClient::StartAdvertising() { + NEARBY_LOGS(INFO) << "uudi: " + << advertisement_generator_.GeneratePresenceServiceUuid(); + NEARBY_LOGS(INFO) + << "Advertisement bytes: " + << advertisement_generator_.GeneratePresenceAdvertisementBytes(); + } + void PresenceClient::StopAdvertising() { + NEARBY_LOGS(INFO) << "Stop advertising."; + } + + private: + AdvertisementGenerator advertisement_generator_; +}; + +} // namespace presence +} // namespace nearby diff --git a/cpp/presence/public/client.h b/cpp/presence/public/client.h new file mode 100644 index 00000000..011dc7c3 --- /dev/null +++ b/cpp/presence/public/client.h @@ -0,0 +1,34 @@ +// Copyright 2020 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_CONNECTIONS_CPP_PRESENCE_PUBLIC_CLIENT_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_CPP_PRESENCE_PUBLIC_CLIENT_H_ +namespace nearby { +namespace presence { + +class PresenceClient { + public: + PresenceClient() = default; + ~PresenceClient() = default; + void StartAdvertising(); + void StopAdvertising(); + + private: + AdvertisementGenerator advertisement_generator_; +}; + +} // namespace presence +} // namespace nearby + +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CPP_PRESENCE_PUBLIC_CLIENT_H_