summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-06-09 05:43:06 +0200
committerSven Gothel <[email protected]>2020-06-09 05:43:06 +0200
commite4956ec63fbcb96d57195a0a4243f4c36b22ee8b (patch)
tree8f6322aa0e0a5e5595a3bbecba8cab6b6bc51279 /api
parentaf6d036f4e4b18cb95e7285b7e894844ba330626 (diff)
HCIHandler: Add 'pass_replies_only_filter' mode (in use now)v2.1.3
pass_replies_only_filter=true will setup the socket and meta-event filter for each command/reply negotiation, reducing received events to the bare minimum. BlueZ kernel hci-socket will filter the events according to the set hci_ufilter mask as well as HCIHandler filters the le-meta events using our (now atomic) metaev_filter_mask. HCIHandler can operate in pass_replies_only_filter=false, i.e. catch all mode, as it may become desired to reimplement the DBTManager module.
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/HCIComm.hpp2
-rw-r--r--api/direct_bt/HCIHandler.hpp13
2 files changed, 9 insertions, 6 deletions
diff --git a/api/direct_bt/HCIComm.hpp b/api/direct_bt/HCIComm.hpp
index 514ea5ee..2e95375f 100644
--- a/api/direct_bt/HCIComm.hpp
+++ b/api/direct_bt/HCIComm.hpp
@@ -104,7 +104,7 @@ namespace direct_bt {
public:
static inline void filter_clear(hci_ufilter *f)
{
- memset(f, 0, sizeof(*f));
+ bzero(f, sizeof(*f));
}
static inline void filter_set_ptype(int t, hci_ufilter *f)
{
diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp
index 357d2b5c..95ab81f7 100644
--- a/api/direct_bt/HCIHandler.hpp
+++ b/api/direct_bt/HCIHandler.hpp
@@ -76,18 +76,22 @@ namespace direct_bt {
static const pid_t pidSelf;
private:
+ const bool pass_replies_only_filter;
const BTMode btMode;
const uint16_t dev_id;
POctets rbuffer;
HCIComm comm;
const int replyTimeoutMS;
std::recursive_mutex mtx;
- uint32_t metaev_filter_mask;
+ hci_ufilter filter_mask;
+ std::atomic<uint32_t> metaev_filter_mask;
- inline void filter_clear_metaevs() { metaev_filter_mask=0; }
- inline void filter_all_metaevs() { metaev_filter_mask=0xffff; }
- inline void filter_set_metaev(HCIMetaEventType mec) { set_bit_uint32(number(mec)-1, metaev_filter_mask); }
inline bool filter_test_metaev(HCIMetaEventType mec) { return 0 != test_bit_uint32(number(mec)-1, metaev_filter_mask); }
+ inline void filter_put_metaevs(const uint32_t mask) { metaev_filter_mask=mask; }
+
+ inline void filter_clear_metaevs(uint32_t &mask) { mask=0; }
+ inline void filter_all_metaevs(uint32_t &mask) { mask=0xffff; }
+ inline void filter_set_metaev(HCIMetaEventType mec, uint32_t &mask) { set_bit_uint32(number(mec)-1, mask); }
LFRingbuffer<std::shared_ptr<HCIEvent>, nullptr> hciEventRing;
std::atomic<pthread_t> hciReaderThreadId;
@@ -101,7 +105,6 @@ namespace direct_bt {
std::shared_ptr<HCIEvent> sendWithReply(HCICommand &req);
std::shared_ptr<HCIEvent> sendWithCmdCompleteReply(HCICommand &req, HCICommandCompleteEvent **res);
- std::shared_ptr<HCIEvent> sendWithCmdStatusReply(HCICommand &req, HCICommandStatusEvent **res);
template<typename hci_cmd_event_struct>
std::shared_ptr<HCIEvent> processSimpleCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIStatusCode *status);