mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Rename GattCharacteristic to GattCharacteristicServer.
This commit is contained in:
@@ -80,7 +80,7 @@ GattServer::CreateCharacteristic(
|
||||
bool GattServer::UpdateCharacteristic(
|
||||
const api::ble_v2::GattCharacteristic& characteristic,
|
||||
const nearby::ByteArray& value) {
|
||||
std::shared_ptr<bluez::GattCharacteristic> chr = nullptr;
|
||||
std::shared_ptr<bluez::GattCharacteristicServer> chr = nullptr;
|
||||
{
|
||||
absl::ReaderMutexLock lock(&services_mutex_);
|
||||
if (services_.count(characteristic.service_uuid) == 0) {
|
||||
@@ -107,7 +107,7 @@ bool GattServer::UpdateCharacteristic(
|
||||
absl::Status GattServer::NotifyCharacteristicChanged(
|
||||
const api::ble_v2::GattCharacteristic& characteristic, bool confirm,
|
||||
const ByteArray& new_value) {
|
||||
std::shared_ptr<bluez::GattCharacteristic> chr = nullptr;
|
||||
std::shared_ptr<bluez::GattCharacteristicServer> chr = nullptr;
|
||||
{
|
||||
absl::ReaderMutexLock lock(&services_mutex_);
|
||||
if (services_.count(characteristic.service_uuid) == 0) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace nearby {
|
||||
namespace linux {
|
||||
namespace bluez {
|
||||
void GattCharacteristic::Update(const nearby::ByteArray &value) {
|
||||
void GattCharacteristicServer::Update(const nearby::ByteArray &value) {
|
||||
std::vector<uint8_t> bytes(value.size());
|
||||
const auto *buf = value.data();
|
||||
for (auto i = 0; i < value.size(); i++) bytes[i] = buf[i];
|
||||
@@ -33,7 +33,7 @@ void GattCharacteristic::Update(const nearby::ByteArray &value) {
|
||||
static_value_ = std::move(bytes);
|
||||
}
|
||||
|
||||
absl::Status GattCharacteristic::NotifyChanged(bool confirm,
|
||||
absl::Status GattCharacteristicServer::NotifyChanged(bool confirm,
|
||||
const ByteArray &new_value) {
|
||||
std::vector<uint8_t> bytes(new_value.size());
|
||||
const auto *buf = new_value.data();
|
||||
@@ -69,7 +69,7 @@ absl::Status GattCharacteristic::NotifyChanged(bool confirm,
|
||||
}
|
||||
}
|
||||
|
||||
void GattCharacteristic::ReadValue(
|
||||
void GattCharacteristicServer::ReadValue(
|
||||
sdbus::Result<std::vector<uint8_t>> &&result,
|
||||
std::map<std::string, sdbus::Variant> options) {
|
||||
{
|
||||
@@ -127,7 +127,7 @@ void GattCharacteristic::ReadValue(
|
||||
});
|
||||
}
|
||||
|
||||
void GattCharacteristic::WriteValue(
|
||||
void GattCharacteristicServer::WriteValue(
|
||||
sdbus::Result<> &&result, std::vector<uint8_t> value,
|
||||
std::map<std::string, sdbus::Variant> options) {
|
||||
uint16_t offset = options["offset"];
|
||||
@@ -172,7 +172,7 @@ void GattCharacteristic::WriteValue(
|
||||
}
|
||||
}
|
||||
|
||||
void GattCharacteristic::StartNotify() {
|
||||
void GattCharacteristicServer::StartNotify() {
|
||||
if ((characteristic_.property |
|
||||
api::ble_v2::GattCharacteristic::Property::kNotify) ==
|
||||
api::ble_v2::GattCharacteristic::Property::kNotify) {
|
||||
@@ -183,7 +183,7 @@ void GattCharacteristic::StartNotify() {
|
||||
}
|
||||
}
|
||||
|
||||
void GattCharacteristic::StopNotify() {
|
||||
void GattCharacteristicServer::StopNotify() {
|
||||
if ((characteristic_.property |
|
||||
api::ble_v2::GattCharacteristic::Property::kNotify) ==
|
||||
api::ble_v2::GattCharacteristic::Property::kNotify) {
|
||||
@@ -194,7 +194,7 @@ void GattCharacteristic::StopNotify() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> GattCharacteristic::Flags() {
|
||||
std::vector<std::string> GattCharacteristicServer::Flags() {
|
||||
auto characteristic = characteristic_;
|
||||
std::vector<std::string> flags;
|
||||
|
||||
|
||||
@@ -38,17 +38,17 @@
|
||||
namespace nearby {
|
||||
namespace linux {
|
||||
namespace bluez {
|
||||
class GattCharacteristic final
|
||||
class GattCharacteristicServer final
|
||||
: public sdbus::AdaptorInterfaces<org::bluez::GattCharacteristic1_adaptor,
|
||||
sdbus::Properties_adaptor,
|
||||
sdbus::ManagedObject_adaptor> {
|
||||
public:
|
||||
GattCharacteristic(const GattCharacteristic &) = delete;
|
||||
GattCharacteristic(GattCharacteristic &&) = delete;
|
||||
GattCharacteristic &operator=(const GattCharacteristic &) = delete;
|
||||
GattCharacteristic &operator=(GattCharacteristic &&) = delete;
|
||||
GattCharacteristicServer(const GattCharacteristicServer &) = delete;
|
||||
GattCharacteristicServer(GattCharacteristicServer &&) = delete;
|
||||
GattCharacteristicServer &operator=(const GattCharacteristicServer &) = delete;
|
||||
GattCharacteristicServer &operator=(GattCharacteristicServer &&) = delete;
|
||||
|
||||
GattCharacteristic(
|
||||
GattCharacteristicServer(
|
||||
sdbus::IConnection &system_bus,
|
||||
const sdbus::ObjectPath &service_object_path, size_t num,
|
||||
const api::ble_v2::GattCharacteristic &characteristic,
|
||||
@@ -68,7 +68,7 @@ class GattCharacteristic final
|
||||
<< org::bluez::GattCharacteristic1_adaptor::INTERFACE_NAME
|
||||
<< " object at " << getObjectPath();
|
||||
}
|
||||
~GattCharacteristic() { unregisterAdaptor(); }
|
||||
~GattCharacteristicServer() { unregisterAdaptor(); }
|
||||
|
||||
void Update(const nearby::ByteArray &value)
|
||||
ABSL_LOCKS_EXCLUDED(static_value_mutex_);
|
||||
|
||||
@@ -30,8 +30,8 @@ bool GattService::AddCharacteristic(
|
||||
api::ble_v2::GattCharacteristic characteristic{
|
||||
characteristic_uuid, service_uuid, permission, property};
|
||||
auto count = characteristics_.size();
|
||||
std::shared_ptr<GattCharacteristic> chr =
|
||||
std::make_shared<GattCharacteristic>(
|
||||
std::shared_ptr<GattCharacteristicServer> chr =
|
||||
std::make_shared<GattCharacteristicServer>(
|
||||
getObject().getConnection(), getObjectPath(), count, characteristic,
|
||||
server_cb_, devices_);
|
||||
try {
|
||||
@@ -50,7 +50,7 @@ bool GattService::AddCharacteristic(
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<GattCharacteristic> GattService::GetCharacteristic(
|
||||
std::shared_ptr<GattCharacteristicServer> GattService::GetCharacteristic(
|
||||
const Uuid &uuid) {
|
||||
absl::ReaderMutexLock lock(&characterstics_mutex_);
|
||||
if (characteristics_.count(uuid) == 0) {
|
||||
|
||||
@@ -83,7 +83,7 @@ class GattService final
|
||||
api::ble_v2::GattCharacteristic::Permission permission,
|
||||
api::ble_v2::GattCharacteristic::Property property)
|
||||
ABSL_LOCKS_EXCLUDED(characterstics_mutex_);
|
||||
std::shared_ptr<GattCharacteristic> GetCharacteristic(const Uuid &uuid)
|
||||
std::shared_ptr<GattCharacteristicServer> GetCharacteristic(const Uuid &uuid)
|
||||
ABSL_LOCKS_EXCLUDED(characterstics_mutex_);
|
||||
|
||||
private:
|
||||
@@ -94,7 +94,7 @@ class GattService final
|
||||
std::vector<sdbus::ObjectPath> Includes() override { return {}; }
|
||||
|
||||
absl::Mutex characterstics_mutex_;
|
||||
absl::flat_hash_map<Uuid, std::shared_ptr<GattCharacteristic>>
|
||||
absl::flat_hash_map<Uuid, std::shared_ptr<GattCharacteristicServer>>
|
||||
characteristics_ ABSL_GUARDED_BY(characterstics_mutex_);
|
||||
|
||||
std::shared_ptr<BluetoothDevices> devices_;
|
||||
|
||||
Reference in New Issue
Block a user