mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
nearby presence with fake advertisement.
PiperOrigin-RevId: 388309745
This commit is contained in:
@@ -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_
|
||||
@@ -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
|
||||
@@ -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_
|
||||
Reference in New Issue
Block a user