summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-06-04 04:11:12 +0200
committerSven Gothel <[email protected]>2020-06-04 04:11:12 +0200
commit73f5b4fc21d7a14aa174f2c48657ca3f2229dda1 (patch)
tree1b455d3e699600eb9f0c1ccc09d10ffd8052929b /examples
parent1c449ba2a4cede1e942ff9df181bf96a408d2c67 (diff)
Introduce HCITypes + HCIHandler: Providing C++ basics for full HCI support; Misc..
Introduce HCITypes + HCIHandler: Providing C++ basics for full HCI support ============================================================================ - HCITypes defines the HCI command and event data structures, similar to MgmtTypes and ATTPDUTypes. For more coding efficiency we use template command and event classes, allowing to reuse the HCIIoctl struct types being wrapped in the C++ classes for flow and lifecycle control. HCITypes further includes all essential 'enum class' command opcodes, event types etc, ensuring type safety. - HCIHandler defines the command/event workflow similar to GATTHandler and DBTManager. One HCIHandler per DBTAdapter is being used, each HCIHandler using its event reader thread and ringbuffer. Socket event filtering and manual le-meta filtering ensures reduced workload (DoS safety). Similar to HCITypes, we use template function to utilize the template command and event classes, reuising the HCIIoctl struct types... HCIHandler can be extended for more functionality as well as used to implement our own DBTManager, i.e. Reducing HCIEvents to MgmtEvents with callback support. At least this is a viable option now, if so desired (non-linux, etc). - HCIComm: Contains the core I/O functionality only, dropped all semantic HCI code. The latter resides in HCIHandler now. - DBTAdapter now uses HCIHander instead of HCIComm, renamed field to simply 'hci' Misc.. ======= - reduced all ringbuffer capacity to 128 from 256 - Moved Mgmt*EventCallback from DBTManager to MgmtTypes, as we might want to reuse the MgmtTypes incl callbacks for alternative DBTManager implementations. - Added 'enum class' to underlying number type conversion pattern: <NumberType> number('enum class type') Avoiding the many static_cast<NumberType>(..) directives. - align all Type -> String method names: 'get<Type>String(Type)' - BasicTypes: Add safe uint32_t bitfield mask helper
Diffstat (limited to 'examples')
-rw-r--r--examples/direct_bt_scanner00/dbt_scanner00.cpp8
-rw-r--r--examples/direct_bt_scanner01/dbt_scanner01.cpp10
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp8
-rw-r--r--examples/java/ScannerTinyB10.java2
4 files changed, 14 insertions, 14 deletions
diff --git a/examples/direct_bt_scanner00/dbt_scanner00.cpp b/examples/direct_bt_scanner00/dbt_scanner00.cpp
index 1c86bce6..56702d2f 100644
--- a/examples/direct_bt_scanner00/dbt_scanner00.cpp
+++ b/examples/direct_bt_scanner00/dbt_scanner00.cpp
@@ -48,9 +48,9 @@ class MyAdapterStatusListener : public AdapterStatusListener {
void adapterSettingsChanged(DBTAdapter const &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
fprintf(stderr, "****** Native Adapter SETTINGS_CHANGED: %s -> %s, changed %s\n",
- adapterSettingsToString(oldmask).c_str(),
- adapterSettingsToString(newmask).c_str(),
- adapterSettingsToString(changedmask).c_str());
+ getAdapterSettingsString(oldmask).c_str(),
+ getAdapterSettingsString(newmask).c_str(),
+ getAdapterSettingsString(changedmask).c_str());
fprintf(stderr, "Status DBTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
@@ -73,7 +73,7 @@ class MyAdapterStatusListener : public AdapterStatusListener {
(void)timestamp;
}
void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
- fprintf(stderr, "****** UPDATED: %s of %s\n", eirDataMaskToString(updateMask).c_str(), device->toString(true).c_str());
+ fprintf(stderr, "****** UPDATED: %s of %s\n", getEIRDataMaskString(updateMask).c_str(), device->toString(true).c_str());
(void)timestamp;
}
void deviceConnected(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
diff --git a/examples/direct_bt_scanner01/dbt_scanner01.cpp b/examples/direct_bt_scanner01/dbt_scanner01.cpp
index 7050de32..cffbafbe 100644
--- a/examples/direct_bt_scanner01/dbt_scanner01.cpp
+++ b/examples/direct_bt_scanner01/dbt_scanner01.cpp
@@ -47,9 +47,9 @@ class MyAdapterStatusListener : public AdapterStatusListener {
void adapterSettingsChanged(DBTAdapter const &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
fprintf(stderr, "****** Native Adapter SETTINGS_CHANGED: %s -> %s, changed %s\n",
- adapterSettingsToString(oldmask).c_str(),
- adapterSettingsToString(newmask).c_str(),
- adapterSettingsToString(changedmask).c_str());
+ getAdapterSettingsString(oldmask).c_str(),
+ getAdapterSettingsString(newmask).c_str(),
+ getAdapterSettingsString(changedmask).c_str());
fprintf(stderr, "Status DBTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
@@ -72,7 +72,7 @@ class MyAdapterStatusListener : public AdapterStatusListener {
(void)timestamp;
}
void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
- fprintf(stderr, "****** UPDATED: %s of %s\n", eirDataMaskToString(updateMask).c_str(), device->toString(true).c_str());
+ fprintf(stderr, "****** UPDATED: %s of %s\n", getEIRDataMaskString(updateMask).c_str(), device->toString(true).c_str());
(void)timestamp;
}
void deviceConnected(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
const int64_t t0 = getCurrentMilliseconds();
if( doHCI_Connect ) {
- std::shared_ptr<HCIComm> hci = adapter.openHCI();
+ std::shared_ptr<HCIHandler> hci = adapter.openHCI();
if( nullptr == hci || !hci->isOpen() ) {
fprintf(stderr, "Couldn't open HCI from %s\n", adapter.toString().c_str());
exit(1);
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index 6ef64543..0161af35 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -101,9 +101,9 @@ class MyAdapterStatusListener : public AdapterStatusListener {
void adapterSettingsChanged(DBTAdapter const &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
fprintf(stderr, "****** SETTINGS_CHANGED: %s -> %s, changed %s\n",
- adapterSettingsToString(oldmask).c_str(),
- adapterSettingsToString(newmask).c_str(),
- adapterSettingsToString(changedmask).c_str());
+ getAdapterSettingsString(oldmask).c_str(),
+ getAdapterSettingsString(newmask).c_str(),
+ getAdapterSettingsString(changedmask).c_str());
fprintf(stderr, "Status DBTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
@@ -137,7 +137,7 @@ class MyAdapterStatusListener : public AdapterStatusListener {
void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
if( SHOW_UPDATE_EVENTS ) {
- fprintf(stderr, "****** UPDATED: %s of %s\n", eirDataMaskToString(updateMask).c_str(), device->toString(true).c_str());
+ fprintf(stderr, "****** UPDATED: %s of %s\n", getEIRDataMaskString(updateMask).c_str(), device->toString(true).c_str());
}
(void)timestamp;
}
diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java
index b7d721a0..74c9497e 100644
--- a/examples/java/ScannerTinyB10.java
+++ b/examples/java/ScannerTinyB10.java
@@ -138,7 +138,7 @@ public class ScannerTinyB10 {
deviceProcessingTask.setDaemon(true); // detach thread
deviceProcessingTask.start();
} else {
- System.err.println("****** CONNECTED-1: NOP %s" + device.toString());
+ System.err.println("****** CONNECTED-1: NOP " + device.toString());
}
}