diff options
author | Sven Gothel <[email protected]> | 2020-10-19 13:23:31 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-19 13:23:31 +0200 |
commit | 9cfa1a4530e7c0b071b5875e8857ee4e4abac209 (patch) | |
tree | 10f6e0c292df9835ec2ae98a7e0c5bf34c42fb3d /src | |
parent | e84963b9bb7bd383dd7f8bbb08b261d247b0332f (diff) |
DBTDevice: Have shared GattGenericAccessSvc owned by GATTHandler, similar to services.
Diffstat (limited to 'src')
-rw-r--r-- | src/direct_bt/DBTDevice.cpp | 11 | ||||
-rw-r--r-- | src/direct_bt/GATTHandler.cpp | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp index 1e3ddfd8..5c3a0603 100644 --- a/src/direct_bt/DBTDevice.cpp +++ b/src/direct_bt/DBTDevice.cpp @@ -553,8 +553,8 @@ std::vector<std::shared_ptr<GATTService>> DBTDevice::getGATTServices() noexcept return gattServices; } - // discovery success, retrieve and parse GenericAccess - gattGenericAccess = gh->getGenericAccess(gattServices); + // discovery success, parse GenericAccess + std::shared_ptr<GattGenericAccessSvc> gattGenericAccess = gh->getGenericAccess(); if( nullptr != gattGenericAccess ) { const uint64_t ts = jau::getCurrentMilliseconds(); EIRDataType updateMask = update(*gattGenericAccess, ts); @@ -603,7 +603,12 @@ bool DBTDevice::pingGATT() noexcept { } std::shared_ptr<GattGenericAccessSvc> DBTDevice::getGATTGenericAccess() { - return gattGenericAccess; + std::shared_ptr<GATTHandler> gh = getGATTHandler(); + if( nullptr == gh ) { + ERR_PRINT("DBTDevice::getGATTGenericAccess: GATTHandler nullptr"); + return nullptr; + } + return gh->getGenericAccess(); } bool DBTDevice::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) { diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/GATTHandler.cpp index c99dd091..0146e28e 100644 --- a/src/direct_bt/GATTHandler.cpp +++ b/src/direct_bt/GATTHandler.cpp @@ -328,6 +328,7 @@ GATTHandler::GATTHandler(const std::shared_ptr<DBTDevice> &device) noexcept GATTHandler::~GATTHandler() noexcept { disconnect(false /* disconnectDevice */, false /* ioErrorCause */); services.clear(); + genericAccess = nullptr; } bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCause) noexcept { @@ -497,6 +498,7 @@ std::vector<GATTServiceRef> & GATTHandler::discoverCompletePrimaryServices(std:: discoverDescriptors(primSrv); } } + genericAccess = getGenericAccess(services); return services; } |