aboutsummaryrefslogtreecommitdiff
path: root/ble/BluetoothImpl.h
diff options
context:
space:
mode:
Diffstat (limited to 'ble/BluetoothImpl.h')
-rw-r--r--ble/BluetoothImpl.h40
1 files changed, 17 insertions, 23 deletions
diff --git a/ble/BluetoothImpl.h b/ble/BluetoothImpl.h
index 5b53cd4..c41712c 100644
--- a/ble/BluetoothImpl.h
+++ b/ble/BluetoothImpl.h
@@ -110,7 +110,7 @@ public:
return valueHandle;
}
- shared_ptr<BluetoothGattDescriptor> getDescriptor(Uuid uuid) const override {
+ BluetoothGattDescriptorPtr getDescriptor(Uuid uuid) const override {
for (auto &d: descriptors) {
if (d->getUuid() == uuid) {
return d;
@@ -120,7 +120,7 @@ public:
return {};
}
- void addDescriptor(shared_ptr<BluetoothGattDescriptor> &&d) {
+ void addDescriptor(BluetoothGattDescriptorPtr &&d) {
descriptors.push_back(std::move(d));
}
@@ -166,17 +166,17 @@ public:
return endGroupHandle;
}
- vector<shared_ptr<BluetoothGattCharacteristic>> getCharacteristics() const override {
- vector<shared_ptr<BluetoothGattCharacteristic>> cs(characteristics.size());
+ vector<BluetoothGattCharacteristicPtr> getCharacteristics() const override {
+ vector<BluetoothGattCharacteristicPtr> cs(characteristics.size());
std::copy(begin(characteristics), end(characteristics), begin(cs));
return cs;
}
- virtual void addCharacteristic(shared_ptr<BluetoothGattCharacteristic> &&characteristic) {
+ virtual void addCharacteristic(BluetoothGattCharacteristicPtr &&characteristic) {
characteristics.emplace_back(characteristic);
}
- o<shared_ptr<BluetoothGattCharacteristic>> findCharacteristic(Uuid uuid) override {
+ o<BluetoothGattCharacteristicPtr> findCharacteristic(Uuid uuid) override {
for (auto &c: characteristics) {
if (c->getUuid() == uuid) {
return {c};
@@ -191,7 +191,7 @@ protected:
const Uuid uuid;
const uint16_t handle;
const uint16_t endGroupHandle;
- vector<shared_ptr<BluetoothGattCharacteristic>> characteristics;
+ vector<BluetoothGattCharacteristicPtr> characteristics;
};
template<class _D, class _S>
@@ -201,12 +201,8 @@ public:
return device;
}
-// virtual Collection <BluetoothGattService> getServices() const {
-// return CollectionImpl<BluetoothGattService, vector<_S>>(services);
-// }
-
- vector<shared_ptr<BluetoothGattService>> getServices() const override {
- vector<shared_ptr<BluetoothGattService>> ss(services.size());
+ vector <BluetoothGattServicePtr> getServices() const override {
+ vector<BluetoothGattServicePtr> ss(services.size());
std::copy(begin(services), end(services), begin(ss));
return ss;
}
@@ -214,32 +210,30 @@ public:
o <BluetoothGattServicePtr> findService(Uuid uuid) override {
for (auto &s: services) {
if (s->getUuid() == uuid) {
- return o<shared_ptr<BluetoothGattService>>(s);
+ return o<BluetoothGattServicePtr>(s);
}
}
- return o<shared_ptr<BluetoothGattService>>();
+ return {};
}
- void addService(shared_ptr<_S> service) {
+ void addService(std::shared_ptr<_S> service) {
services.emplace_back(service);
}
protected:
- explicit DefaultBluetoothGatt(_D &device) : LogSetup("BluetoothGatt"), device(device) {
- }
+ explicit DefaultBluetoothGatt(_D &device, BluetoothCallback *callback) :
+ LogSetup("BluetoothGatt"), device(device), callback(callback) {}
~DefaultBluetoothGatt() override = default;
void removeServices() {
-// for (auto s: services) {
-// delete s;
-// }
services.clear();
}
_D &device;
- vector<shared_ptr<_S>> services;
+ vector <std::shared_ptr<_S>> services;
+ BluetoothCallback *callback;
};
template<class A>
@@ -293,7 +287,7 @@ protected:
Mac &mac;
};
-shared_ptr <BluetoothAdapter> getAdapterImpl(string name);
+BluetoothAdapterPtr getAdapterImpl(string name);
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;