nearby presence with fake advertisement.

PiperOrigin-RevId: 388309745
This commit is contained in:
hais
2021-08-02 14:55:57 -07:00
committed by Copybara-Service
parent 24d9ea6fe6
commit 4851400442
4 changed files with 142 additions and 0 deletions
@@ -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
@@ -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_
+43
View File
@@ -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
+34
View File
@@ -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_