aboutsummaryrefslogtreecommitdiffstats
path: root/src/direct_bt/BTGattHandler.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-02-05 13:10:02 +0100
committerSven Gothel <[email protected]>2022-02-05 13:10:02 +0100
commite570552af8de36d78e369591384082aa0b59e88b (patch)
tree8c360a162c52860c25a8006b32b331b677609f00 /src/direct_bt/BTGattHandler.cpp
parent49933e253b671c6017c925eb09c5359e86a4c154 (diff)
BTGattHandler::NativeGattCharListener: Add optional low- and high-level user notification callbacks, allowing better protocol tracking for DBGattServer::Mode:FWD (repeater)
Diffstat (limited to 'src/direct_bt/BTGattHandler.cpp')
-rw-r--r--src/direct_bt/BTGattHandler.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/direct_bt/BTGattHandler.cpp b/src/direct_bt/BTGattHandler.cpp
index 76a72ad6..8fbb57f1 100644
--- a/src/direct_bt/BTGattHandler.cpp
+++ b/src/direct_bt/BTGattHandler.cpp
@@ -208,6 +208,93 @@ int BTGattHandler::removeAllCharListener() noexcept {
return count;
}
+void BTGattHandler::notifyNativeRequestSent(const AttPDUMsg& pduRequest, BTDeviceRef clientSource) noexcept {
+ BTDeviceRef serverDest = getDeviceUnchecked();
+ if( nullptr != serverDest ) {
+ int i=0;
+ jau::for_each_fidelity(nativeGattCharListenerList, [&](std::shared_ptr<BTGattHandler::NativeGattCharListener> &l) {
+ try {
+ l->requestSent(pduRequest, serverDest, clientSource);
+ } catch (std::exception &e) {
+ ERR_PRINT("GATTHandler::requestSent-CBs %d/%zd: NativeGattCharListener %s: Caught exception %s",
+ i+1, nativeGattCharListenerList.size(),
+ jau::to_hexstring((void*)l.get()).c_str(), e.what());
+ }
+ i++;
+ });
+ }
+}
+
+void BTGattHandler::notifyNativeReplyReceived(const AttPDUMsg& pduReply, BTDeviceRef clientDest) noexcept {
+ BTDeviceRef serverSource = getDeviceUnchecked();
+ if( nullptr != serverSource ) {
+ int i=0;
+ jau::for_each_fidelity(nativeGattCharListenerList, [&](std::shared_ptr<BTGattHandler::NativeGattCharListener> &l) {
+ try {
+ l->replyReceived(pduReply, serverSource, clientDest);
+ } catch (std::exception &e) {
+ ERR_PRINT("GATTHandler::replyReceived-CBs %d/%zd: NativeGattCharListener %s: Caught exception %s",
+ i+1, nativeGattCharListenerList.size(),
+ jau::to_hexstring((void*)l.get()).c_str(), e.what());
+ }
+ i++;
+ });
+ }
+}
+
+void BTGattHandler::notifyNativeWriteRequest(const uint16_t handle, const jau::TROOctets& data, const NativeGattCharSections_t& sections, const bool with_response, BTDeviceRef clientSource) noexcept {
+ BTDeviceRef serverDest = getDeviceUnchecked();
+ if( nullptr != serverDest ) {
+ int i=0;
+ jau::for_each_fidelity(nativeGattCharListenerList, [&](std::shared_ptr<BTGattHandler::NativeGattCharListener> &l) {
+ try {
+ l->writeRequest(handle, data, sections, with_response, serverDest, clientSource);
+ } catch (std::exception &e) {
+ ERR_PRINT("GATTHandler::writeRequest-CBs %d/%zd: NativeGattCharListener %s: Caught exception %s",
+ i+1, nativeGattCharListenerList.size(),
+ jau::to_hexstring((void*)l.get()).c_str(), e.what());
+ }
+ i++;
+ });
+ }
+}
+
+void BTGattHandler::notifyNativeWriteResponse(const AttPDUMsg& pduReply, const AttErrorRsp::ErrorCode error_code, BTDeviceRef clientDest) noexcept {
+ BTDeviceRef serverSource = getDeviceUnchecked();
+ if( nullptr != serverSource ) {
+ int i=0;
+ jau::for_each_fidelity(nativeGattCharListenerList, [&](std::shared_ptr<BTGattHandler::NativeGattCharListener> &l) {
+ try {
+ l->writeResponse(pduReply, error_code, serverSource, clientDest);
+ } catch (std::exception &e) {
+ ERR_PRINT("GATTHandler::writeResponse-CBs %d/%zd: NativeGattCharListener %s: Caught exception %s",
+ i+1, nativeGattCharListenerList.size(),
+ jau::to_hexstring((void*)l.get()).c_str(), e.what());
+ }
+ i++;
+ });
+ }
+}
+
+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 {
+ BTDeviceRef serverReplier = getDeviceUnchecked();
+ if( nullptr != serverReplier ) {
+ int i=0;
+ jau::for_each_fidelity(nativeGattCharListenerList, [&](std::shared_ptr<BTGattHandler::NativeGattCharListener> &l) {
+ try {
+ l->readResponse(handle, value_offset, pduReply, error_code, data_reply, serverReplier, clientRequester);
+ } catch (std::exception &e) {
+ ERR_PRINT("GATTHandler::readResponse-CBs %d/%zd: NativeGattCharListener %s: Caught exception %s",
+ i+1, nativeGattCharListenerList.size(),
+ jau::to_hexstring((void*)l.get()).c_str(), e.what());
+ }
+ i++;
+ });
+ }
+}
+
void BTGattHandler::setSendIndicationConfirmation(const bool v) {
sendIndicationConfirmation = v;
}