summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/BTDevice.hpp6
-rw-r--r--api/direct_bt/BTGattChar.hpp1
-rw-r--r--api/direct_bt/BTGattHandler.hpp27
-rw-r--r--src/direct_bt/BTDevice.cpp10
-rw-r--r--src/direct_bt/BTGattHandler.cpp33
5 files changed, 41 insertions, 36 deletions
diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp
index d9e1a2cf..bf2f5266 100644
--- a/api/direct_bt/BTDevice.hpp
+++ b/api/direct_bt/BTDevice.hpp
@@ -339,7 +339,7 @@ namespace direct_bt {
* The EInfoReport is updated by new scan-reports (update) and when disconnected (empty).
* @since 2.5.3
*/
- std::shared_ptr<EInfoReport> getEIR() noexcept;
+ EInfoReportRef getEIR() noexcept;
/**
* Return the latest advertised EInfoReport AD_IND variant for this remote device.
@@ -347,7 +347,7 @@ namespace direct_bt {
* The EInfoReport is replaced by new scan-reports only.
* @since 2.6.6
*/
- std::shared_ptr<EInfoReport> getEIRInd() noexcept;
+ EInfoReportRef getEIRInd() noexcept;
/**
* Return the latest advertised EInfoReport AD_SCAN_RSP for this remote device.
@@ -355,7 +355,7 @@ namespace direct_bt {
* The EInfoReport is replaced by new scan-reports only.
* @since 2.6.6
*/
- std::shared_ptr<EInfoReport> getEIRScanRsp() noexcept;
+ EInfoReportRef getEIRScanRsp() noexcept;
std::string toString() const noexcept override { return toString(false); }
diff --git a/api/direct_bt/BTGattChar.hpp b/api/direct_bt/BTGattChar.hpp
index c500ffc2..8882778a 100644
--- a/api/direct_bt/BTGattChar.hpp
+++ b/api/direct_bt/BTGattChar.hpp
@@ -556,6 +556,7 @@ namespace direct_bt {
bool operator!=(const BTGattCharListener& rhs) const noexcept
{ return !(*this == rhs); }
};
+ typedef std::shared_ptr<BTGattCharListener> BTGattCharListenerRef;
class AssociatedBTGattCharListener : public BTGattCharListener {
private:
diff --git a/api/direct_bt/BTGattHandler.hpp b/api/direct_bt/BTGattHandler.hpp
index e51d5fc9..549ff5d3 100644
--- a/api/direct_bt/BTGattHandler.hpp
+++ b/api/direct_bt/BTGattHandler.hpp
@@ -434,10 +434,11 @@ namespace direct_bt {
bool operator!=(const NativeGattCharListener& rhs) const noexcept
{ return !(*this == rhs); }
};
- typedef jau::cow_darray<std::shared_ptr<NativeGattCharListener>> NativeGattCharListenerList_t;
+ typedef std::shared_ptr<NativeGattCharListener> NativeGattCharListenerRef;
+ typedef jau::cow_darray<NativeGattCharListenerRef> NativeGattCharListenerList_t;
typedef jau::darray<NativeGattCharListener::Section> NativeGattCharSections_t;
- typedef jau::cow_darray<std::shared_ptr<BTGattCharListener>> BTGattCharListenerList_t;
+ typedef jau::cow_darray<BTGattCharListenerRef> BTGattCharListenerList_t;
private:
/** BTGattHandler's device weak back-reference */
@@ -807,7 +808,7 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool addCharListener(std::shared_ptr<BTGattCharListener> l) noexcept;
+ bool addCharListener(const BTGattCharListenerRef& l) noexcept;
/**
* Remove the given listener from the list.
@@ -816,7 +817,7 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept;
+ bool removeCharListener(const BTGattCharListenerRef& l) noexcept;
/**
* Remove the given listener from the list.
@@ -836,7 +837,7 @@ namespace direct_bt {
* @param associatedCharacteristic the match criteria to remove any BTGattCharListener from the list
* @return number of removed listener.
*/
- int removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedChar) noexcept;
+ int removeAllAssociatedCharListener(const BTGattCharRef& associatedChar) noexcept;
int removeAllAssociatedCharListener(const BTGattChar * associatedChar) noexcept;
@@ -847,7 +848,7 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool addCharListener(std::shared_ptr<NativeGattCharListener> l) noexcept;
+ bool addCharListener(const NativeGattCharListenerRef& l) noexcept;
/**
* Remove the given listener from the list.
@@ -856,7 +857,7 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool removeCharListener(std::shared_ptr<NativeGattCharListener> l) noexcept;
+ bool removeCharListener(const NativeGattCharListenerRef& l) noexcept;
/**
* Remove all event listener from the list.
@@ -896,7 +897,7 @@ namespace direct_bt {
* @param pduRequest the request
* @param clientSource the GATTRole::Client source device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler
*/
- void notifyNativeRequestSent(const AttPDUMsg& pduRequest, BTDeviceRef clientSource) noexcept;
+ void notifyNativeRequestSent(const AttPDUMsg& pduRequest, const BTDeviceRef& clientSource) noexcept;
/**
* Notify all NativeGattCharListener about a low-level AttPDUMsg reply being received from this GATTRole::Server.
@@ -904,7 +905,7 @@ namespace direct_bt {
* @param pduReply the response
* @param clientDest the GATTRole::Client receiver device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler
*/
- void notifyNativeReplyReceived(const AttPDUMsg& pduReply, BTDeviceRef clientDest) noexcept;
+ void notifyNativeReplyReceived(const AttPDUMsg& pduReply, const BTDeviceRef& clientDest) noexcept;
/**
* Notify all NativeGattCharListener about a completed MTU exchange request and response to and from this GATTRole::Server.
@@ -921,7 +922,7 @@ namespace direct_bt {
void notifyNativeMTUResponse(const uint16_t clientMTU,
const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_reply,
const uint16_t serverMTU, const uint16_t usedMTU,
- BTDeviceRef clientRequester) noexcept;
+ const BTDeviceRef& clientRequester) noexcept;
/**
* Notify all NativeGattCharListener about a completed write request sent to this GATTRole::Server.
@@ -934,7 +935,7 @@ namespace direct_bt {
* @param with_response true if the write requests expects a response, i.e. via AttPDUMsg::Opcode::WRITE_REQ or AttPDUMsg::Opcode::EXECUTE_WRITE_REQ
* @param clientSource the GATTRole::Client source device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler
*/
- void notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections, const bool with_response, BTDeviceRef clientSource) noexcept;
+ void notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections, const bool with_response, const BTDeviceRef& clientSource) noexcept;
/**
* Notify all NativeGattCharListener about a write response received from this GATTRole::Server.
@@ -945,7 +946,7 @@ namespace direct_bt {
* @param error_code in case of an AttErrorRsp reply, the AttErrorRsp::ErrorCode is passed for convenience, otherwise AttErrorRsp::ErrorCode::NO_ERROR.
* @param clientDest the GATTRole::Client receiver device, only known and not nullptr for DBGattServer::Mode:FWD GattServerHandler
*/
- void notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, BTDeviceRef clientDest) noexcept;
+ void notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, const BTDeviceRef& clientDest) noexcept;
/**
* Notify all NativeGattCharListener about a completed read request and response to and from this GATTRole::Server.
@@ -961,7 +962,7 @@ namespace direct_bt {
*/
void notifyNativeReadResponse(const uint16_t handle, const uint16_t value_offset,
const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_reply, const jau::TROOctets& data_reply,
- BTDeviceRef clientRequester) noexcept;
+ const BTDeviceRef& clientRequester) noexcept;
/**
* Enable or disable sending an immediate confirmation for received indication events from the device.
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index efbabb4f..351184f8 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -116,17 +116,17 @@ std::string const BTDevice::getName() const noexcept {
return res;
}
-std::shared_ptr<EInfoReport> BTDevice::getEIR() noexcept {
+EInfoReportRef BTDevice::getEIR() noexcept {
const std::lock_guard<std::mutex> lock(mtx_eir); // RAII-style acquire and relinquish via destructor
return eir;
}
-std::shared_ptr<EInfoReport> BTDevice::getEIRInd() noexcept {
+EInfoReportRef BTDevice::getEIRInd() noexcept {
const std::lock_guard<std::mutex> lock(mtx_eir); // RAII-style acquire and relinquish via destructor
return eir_ind;
}
-std::shared_ptr<EInfoReport> BTDevice::getEIRScanRsp() noexcept {
+EInfoReportRef BTDevice::getEIRScanRsp() noexcept {
const std::lock_guard<std::mutex> lock(mtx_eir); // RAII-style acquire and relinquish via destructor
return eir_scan_rsp;
}
@@ -256,11 +256,11 @@ EIRDataType BTDevice::update(GattGenericAccessSvc const &data, const uint64_t ti
return res;
}
-bool BTDevice::addStatusListener(std::shared_ptr<AdapterStatusListener> l) {
+bool BTDevice::addStatusListener(const AdapterStatusListenerRef& l) {
return adapter.addStatusListener(*this, l);
}
-bool BTDevice::removeStatusListener(std::shared_ptr<AdapterStatusListener> l) {
+bool BTDevice::removeStatusListener(const AdapterStatusListenerRef& l) {
return adapter.removeStatusListener(l);
}
diff --git a/src/direct_bt/BTGattHandler.cpp b/src/direct_bt/BTGattHandler.cpp
index 156e1dde..20d46dd8 100644
--- a/src/direct_bt/BTGattHandler.cpp
+++ b/src/direct_bt/BTGattHandler.cpp
@@ -102,10 +102,10 @@ bool BTGattHandler::validateConnected() noexcept {
return true;
}
-static jau::cow_darray<std::shared_ptr<BTGattCharListener>>::equal_comparator _btGattCharListenerRefEqComparator =
- [](const std::shared_ptr<BTGattCharListener> &a, const std::shared_ptr<BTGattCharListener> &b) -> bool { return *a == *b; };
+static jau::cow_darray<BTGattCharListenerRef>::equal_comparator _btGattCharListenerRefEqComparator =
+ [](const BTGattCharListenerRef& a, const BTGattCharListenerRef& b) -> bool { return *a == *b; };
-bool BTGattHandler::addCharListener(std::shared_ptr<BTGattCharListener> l) noexcept {
+bool BTGattHandler::addCharListener(const BTGattCharListenerRef& l) noexcept {
if( nullptr == l ) {
ERR_PRINT("GATTCharacteristicListener ref is null");
return false;
@@ -113,7 +113,7 @@ bool BTGattHandler::addCharListener(std::shared_ptr<BTGattCharListener> l) noexc
return btGattCharListenerList.push_back_unique(l, _btGattCharListenerRefEqComparator);
}
-bool BTGattHandler::removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept {
+bool BTGattHandler::removeCharListener(const BTGattCharListenerRef& l) noexcept {
if( nullptr == l ) {
ERR_PRINT("GATTCharacteristicListener ref is null");
return false;
@@ -138,10 +138,10 @@ bool BTGattHandler::removeCharListener(const BTGattCharListener * l) noexcept {
return false;
}
-static jau::cow_darray<std::shared_ptr<BTGattHandler::NativeGattCharListener>>::equal_comparator _nativeGattCharListenerRefEqComparator =
- [](const std::shared_ptr<BTGattHandler::NativeGattCharListener> &a, const std::shared_ptr<BTGattHandler::NativeGattCharListener> &b) -> bool { return *a == *b; };
+static jau::cow_darray<BTGattHandler::NativeGattCharListenerRef>::equal_comparator _nativeGattCharListenerRefEqComparator =
+ [](const BTGattHandler::NativeGattCharListenerRef& a, const BTGattHandler::NativeGattCharListenerRef& b) -> bool { return *a == *b; };
-bool BTGattHandler::addCharListener(std::shared_ptr<NativeGattCharListener> l) noexcept {
+bool BTGattHandler::addCharListener(const BTGattHandler::NativeGattCharListenerRef& l) noexcept {
if( nullptr == l ) {
ERR_PRINT("NativeGattCharListener ref is null");
return false;
@@ -149,7 +149,7 @@ bool BTGattHandler::addCharListener(std::shared_ptr<NativeGattCharListener> l) n
return nativeGattCharListenerList.push_back_unique(l, _nativeGattCharListenerRefEqComparator);
}
-bool BTGattHandler::removeCharListener(std::shared_ptr<NativeGattCharListener> l) noexcept {
+bool BTGattHandler::removeCharListener(const BTGattHandler::NativeGattCharListenerRef& l) noexcept {
if( nullptr == l ) {
ERR_PRINT("NativeGattCharListener ref is null");
return false;
@@ -177,7 +177,7 @@ void BTGattHandler::printCharListener() noexcept {
}
}
-int BTGattHandler::removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedCharacteristic) noexcept {
+int BTGattHandler::removeAllAssociatedCharListener(const BTGattCharRef& associatedCharacteristic) noexcept {
if( nullptr == associatedCharacteristic ) {
ERR_PRINT("Given GATTCharacteristic ref is null");
return false;
@@ -214,7 +214,7 @@ int BTGattHandler::removeAllCharListener() noexcept {
return count;
}
-void BTGattHandler::notifyNativeRequestSent(const AttPDUMsg& pduRequest, BTDeviceRef clientSource) noexcept {
+void BTGattHandler::notifyNativeRequestSent(const AttPDUMsg& pduRequest, const BTDeviceRef& clientSource) noexcept {
BTDeviceRef serverDest = getDeviceUnchecked();
if( nullptr != serverDest ) {
int i=0;
@@ -231,7 +231,7 @@ void BTGattHandler::notifyNativeRequestSent(const AttPDUMsg& pduRequest, BTDevic
}
}
-void BTGattHandler::notifyNativeReplyReceived(const AttPDUMsg& pduReply, BTDeviceRef clientDest) noexcept {
+void BTGattHandler::notifyNativeReplyReceived(const AttPDUMsg& pduReply, const BTDeviceRef& clientDest) noexcept {
BTDeviceRef serverSource = getDeviceUnchecked();
if( nullptr != serverSource ) {
int i=0;
@@ -251,7 +251,8 @@ void BTGattHandler::notifyNativeReplyReceived(const AttPDUMsg& pduReply, BTDevic
void BTGattHandler::notifyNativeMTUResponse(const uint16_t clientMTU_,
const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_reply,
const uint16_t serverMTU_, const uint16_t usedMTU_,
- BTDeviceRef clientRequester) noexcept {
+ const BTDeviceRef& clientRequester) noexcept
+{
BTDeviceRef serverReplier = getDeviceUnchecked();
if( nullptr != serverReplier ) {
int i=0;
@@ -268,7 +269,9 @@ void BTGattHandler::notifyNativeMTUResponse(const uint16_t clientMTU_,
}
}
-void BTGattHandler::notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections, const bool with_response, BTDeviceRef clientSource) noexcept {
+void BTGattHandler::notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections,
+ const bool with_response, const BTDeviceRef& clientSource) noexcept
+{
BTDeviceRef serverDest = getDeviceUnchecked();
if( nullptr != serverDest ) {
int i=0;
@@ -285,7 +288,7 @@ void BTGattHandler::notifyNativeWriteRequest(const uint16_t handle, const jau::T
}
}
-void BTGattHandler::notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, BTDeviceRef clientDest) noexcept {
+void BTGattHandler::notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, const BTDeviceRef& clientDest) noexcept {
BTDeviceRef serverSource = getDeviceUnchecked();
if( nullptr != serverSource ) {
int i=0;
@@ -304,7 +307,7 @@ void BTGattHandler::notifyNativeWriteResponse(const AttPDUMsg& pduReply, const A
void BTGattHandler::notifyNativeReadResponse(const uint16_t handle, const uint16_t value_offset,
const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, const jau::TROOctets& data_reply,
- BTDeviceRef clientRequester) noexcept {
+ const BTDeviceRef& clientRequester) noexcept {
BTDeviceRef serverReplier = getDeviceUnchecked();
if( nullptr != serverReplier ) {
int i=0;