summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-01-25 18:44:32 +0100
committerSven Gothel <[email protected]>2021-01-25 18:44:32 +0100
commite7d892210343dc50c8978954f8daa71395584f2e (patch)
tree4d5f1dfcede30af5cad2a7afb97b535f40600a85
parentfeaff07f5942ee6ff2bd94e70bf140c678379490 (diff)
Java: New API Layout: Shorten named [Bluetooth -> BT], [Characteristic -> Char] etc (align naming with direct_bt == java; reduce java code footprint and too long code lines)
-rw-r--r--api/direct_bt/ATTPDUTypes.hpp74
-rw-r--r--api/direct_bt/BTAdapter.hpp (renamed from api/direct_bt/DBTAdapter.hpp)194
-rw-r--r--api/direct_bt/BTDevice.hpp (renamed from api/direct_bt/DBTDevice.hpp)128
-rw-r--r--api/direct_bt/BTGattChar.hpp (renamed from api/direct_bt/GATTCharacteristic.hpp)184
-rw-r--r--api/direct_bt/BTGattDesc.hpp (renamed from api/direct_bt/GATTDescriptor.hpp)52
-rw-r--r--api/direct_bt/BTGattHandler.hpp (renamed from api/direct_bt/GATTHandler.hpp)128
-rw-r--r--api/direct_bt/BTGattService.hpp (renamed from api/direct_bt/GATTService.hpp)36
-rw-r--r--api/direct_bt/BTManager.hpp (renamed from api/direct_bt/DBTManager.hpp)46
-rw-r--r--api/direct_bt/BTTypes0.hpp (renamed from api/direct_bt/BTTypes.hpp)16
-rw-r--r--api/direct_bt/BTTypes1.hpp (renamed from api/direct_bt/DBTTypes.hpp)31
-rw-r--r--api/direct_bt/DirectBT.hpp9
-rw-r--r--api/direct_bt/GattNumbers.hpp (renamed from api/direct_bt/GATTNumbers.hpp)4
-rw-r--r--api/direct_bt/GattTypes.hpp (renamed from api/direct_bt/GATTTypes.hpp)6
-rw-r--r--api/direct_bt/HCIComm.hpp2
-rw-r--r--api/direct_bt/HCIHandler.hpp6
-rw-r--r--api/direct_bt/HCITypes.hpp2
-rw-r--r--api/direct_bt/L2CAPComm.hpp6
-rw-r--r--api/direct_bt/MgmtTypes.hpp4
-rw-r--r--api/direct_bt/SMPHandler.hpp10
-rw-r--r--api/direct_bt/SMPTypes.hpp2
-rw-r--r--examples/direct_bt_scanner00/dbt_scanner00.cpp60
-rw-r--r--examples/direct_bt_scanner01/dbt_scanner01.cpp62
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp108
-rw-r--r--examples/java/AsyncTinyB.java34
-rw-r--r--examples/java/DBTScanner10.java146
-rw-r--r--examples/java/HelloTinyB.java56
-rw-r--r--examples/java/Notification.java38
-rw-r--r--examples/java/ScannerTinyB00.java66
-rw-r--r--examples/java/ScannerTinyB01.java134
-rw-r--r--examples/java/ScannerTinyB02.java80
-rw-r--r--java/jau/direct_bt/DBTAdapter.java146
-rw-r--r--java/jau/direct_bt/DBTDevice.java156
-rw-r--r--java/jau/direct_bt/DBTEvent.java18
-rw-r--r--java/jau/direct_bt/DBTGattChar.java (renamed from java/jau/direct_bt/DBTGattCharacteristic.java)120
-rw-r--r--java/jau/direct_bt/DBTGattDesc.java (renamed from java/jau/direct_bt/DBTGattDescriptor.java)36
-rw-r--r--java/jau/direct_bt/DBTGattService.java68
-rw-r--r--java/jau/direct_bt/DBTManager.java194
-rw-r--r--java/jau/direct_bt/DBTNativeDownlink.java4
-rw-r--r--java/jau/direct_bt/DBTObject.java10
-rw-r--r--java/jni/BTFactory.cxx (renamed from java/jni/BluetoothFactory.cxx)6
-rw-r--r--java/jni/BTUtils.cxx (renamed from java/jni/BluetoothUtils.cxx)8
-rw-r--r--java/jni/direct_bt/CMakeLists.txt10
-rw-r--r--java/jni/direct_bt/DBTAdapter.cxx152
-rw-r--r--java/jni/direct_bt/DBTDevice.cxx188
-rw-r--r--java/jni/direct_bt/DBTGattChar.cxx (renamed from java/jni/direct_bt/DBTGattCharacteristic.cxx)52
-rw-r--r--java/jni/direct_bt/DBTGattDesc.cxx (renamed from java/jni/direct_bt/DBTGattDescriptor.cxx)24
-rw-r--r--java/jni/direct_bt/DBTGattService.cxx36
-rw-r--r--java/jni/direct_bt/DBTManager.cxx36
-rw-r--r--java/jni/direct_bt/DBTNativeDownlink.cxx2
-rw-r--r--java/jni/direct_bt/DBTObject.cxx2
-rw-r--r--java/jni/helper_base.cxx4
-rw-r--r--java/jni/helper_base.hpp4
-rw-r--r--java/jni/tinyb/CMakeLists.txt4
-rw-r--r--java/jni/tinyb/DBusGattService.cxx2
-rw-r--r--java/org/direct_bt/AdapterSettings.java4
-rw-r--r--java/org/direct_bt/AdapterStatusListener.java74
-rw-r--r--java/org/direct_bt/BTAdapter.java (renamed from java/org/direct_bt/BluetoothAdapter.java)42
-rw-r--r--java/org/direct_bt/BTCallback.java (renamed from java/org/direct_bt/BluetoothCallback.java)2
-rw-r--r--java/org/direct_bt/BTDevice.java (renamed from java/org/direct_bt/BluetoothDevice.java)116
-rw-r--r--java/org/direct_bt/BTEvent.java (renamed from java/org/direct_bt/BluetoothEvent.java)4
-rw-r--r--java/org/direct_bt/BTException.java (renamed from java/org/direct_bt/BluetoothException.java)4
-rw-r--r--java/org/direct_bt/BTFactory.java (renamed from java/org/direct_bt/BluetoothFactory.java)52
-rw-r--r--java/org/direct_bt/BTGattChar.java (renamed from java/org/direct_bt/BluetoothGattCharacteristic.java)54
-rw-r--r--java/org/direct_bt/BTGattCharListener.java (renamed from java/org/direct_bt/GATTCharacteristicListener.java)58
-rw-r--r--java/org/direct_bt/BTGattDesc.java (renamed from java/org/direct_bt/BluetoothGattDescriptor.java)10
-rw-r--r--java/org/direct_bt/BTGattService.java (renamed from java/org/direct_bt/BluetoothGattService.java)88
-rw-r--r--java/org/direct_bt/BTManager.java (renamed from java/org/direct_bt/BluetoothManager.java)72
-rw-r--r--java/org/direct_bt/BTNotification.java (renamed from java/org/direct_bt/BluetoothNotification.java)2
-rw-r--r--java/org/direct_bt/BTObject.java (renamed from java/org/direct_bt/BluetoothObject.java)6
-rw-r--r--java/org/direct_bt/BTType.java (renamed from java/org/direct_bt/BluetoothType.java)2
-rw-r--r--java/org/direct_bt/BTUtils.java (renamed from java/org/direct_bt/BluetoothUtils.java)6
-rw-r--r--java/org/direct_bt/EUI48.java2
-rw-r--r--java/org/direct_bt/ObjectArgCallback.java2
-rw-r--r--java/org/direct_bt/ObjectArrayArgCallback.java2
-rw-r--r--java/org/direct_bt/PlatformToolkit.java18
-rw-r--r--java/org/direct_bt/SMPLongTermKeyInfo.java6
-rw-r--r--java/org/direct_bt/SMPSignatureResolvingKeyInfo.java2
-rw-r--r--java/tinyb/dbus/DBusAdapter.java56
-rw-r--r--java/tinyb/dbus/DBusBluetoothException.java4
-rw-r--r--java/tinyb/dbus/DBusDevice.java79
-rw-r--r--java/tinyb/dbus/DBusEvent.java18
-rw-r--r--java/tinyb/dbus/DBusGattCharacteristic.java50
-rw-r--r--java/tinyb/dbus/DBusGattDescriptor.java20
-rw-r--r--java/tinyb/dbus/DBusGattService.java26
-rw-r--r--java/tinyb/dbus/DBusManager.java68
-rw-r--r--java/tinyb/dbus/DBusObject.java16
-rw-r--r--scripts/run-java-scanner00.sh4
-rw-r--r--scripts/run-java-scanner01.sh6
-rw-r--r--scripts/run-java-scanner02.sh6
-rwxr-xr-xscripts/run-java-scanner10.sh11
-rw-r--r--src/direct_bt/BTAdapter.cpp (renamed from src/direct_bt/DBTAdapter.cpp)222
-rw-r--r--src/direct_bt/BTDevice.cpp (renamed from src/direct_bt/DBTDevice.cpp)202
-rw-r--r--src/direct_bt/BTGattChar.cpp (renamed from src/direct_bt/GATTCharacteristic.cpp)92
-rw-r--r--src/direct_bt/BTGattDesc.cpp (renamed from src/direct_bt/GATTDescriptor.cpp)40
-rw-r--r--src/direct_bt/BTGattHandler.cpp (renamed from src/direct_bt/GATTHandler.cpp)160
-rw-r--r--src/direct_bt/BTGattService.cpp (renamed from src/direct_bt/GATTService.cpp)24
-rw-r--r--src/direct_bt/BTManager.cpp (renamed from src/direct_bt/DBTManager.cpp)211
-rw-r--r--src/direct_bt/BTTypes0.cpp (renamed from src/direct_bt/BTTypes.cpp)100
-rw-r--r--src/direct_bt/BTTypes1.cpp (renamed from src/direct_bt/DBTTypes.cpp)2
-rw-r--r--src/direct_bt/CMakeLists.txt28
-rw-r--r--src/direct_bt/GATTNumbers.cpp2
-rw-r--r--src/direct_bt/HCIHandler.cpp2
-rw-r--r--src/direct_bt/L2CAPComm.cpp4
-rw-r--r--src/direct_bt/MgmtTypes.cpp2
-rw-r--r--src/direct_bt/SMPHandler.cpp18
-rw-r--r--test/direct_bt/test_attpdu01.cpp2
106 files changed, 2597 insertions, 2512 deletions
diff --git a/api/direct_bt/ATTPDUTypes.hpp b/api/direct_bt/ATTPDUTypes.hpp
index b5af035c..96e0b956 100644
--- a/api/direct_bt/ATTPDUTypes.hpp
+++ b/api/direct_bt/ATTPDUTypes.hpp
@@ -38,7 +38,7 @@
#include <jau/basic_types.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "OctetTypes.hpp"
@@ -50,82 +50,82 @@
* using its platform agnostic HCI, GATT, SMP and L2CAP client-side protocol implementation.
*
* Direct-BT implements the following layers
- * - DBTManager for adapter configuration and adapter add/removal notifications (ChangedAdapterSetFunc())
+ * - BTManager for adapter configuration and adapter add/removal notifications (ChangedAdapterSetFunc())
* - Using *BlueZ Kernel Manager Control Channel* via MgmtMsg communication.
* - *HCI Handling* via HCIHandler using HCIPacket implementing connect/disconnect w/ tracking, device discovery, etc
* - *ATT PDU* AttPDUMsg via L2CAP for low level packet communication
- * - *GATT Support* via GATTHandler using AttPDUMsg over L2CAPComm, providing
- * - GATTService
- * - GATTCharacteristic
- * - GATTDescriptor
+ * - *GATT Support* via BTGattHandler using AttPDUMsg over L2CAPComm, providing
+ * - BTGattService
+ * - BTGattChar
+ * - BTGattDesc
* - *SMP PDU* SMPPDUMsg via L2CAP for Security Manager Protocol (SMP) communication
* - *SMP Support* via SMPHandler using SMPPDUMsg over L2CAPComm, providing (Not yet supported by Linux/BlueZ)
* - LE Secure Connections
* - LE legacy pairing
* - On Linux/BlueZ, LE Secure Connections and LE legacy pairing is supported using
- * - ::BTSecurityLevel setting via DBTDevice / L2CAPComm per connection and
- * - ::SMPIOCapability via DBTManager (per adapter) and DBTDevice (per connection)
+ * - ::BTSecurityLevel setting via BTDevice / L2CAPComm per connection and
+ * - ::SMPIOCapability via BTManager (per adapter) and BTDevice (per connection)
* - SMPPDUMsg SMP event tracking over HCI/ACL/L2CAP, observing operations
*
- * DBTManager utilizes the *BlueZ Kernel Manager Control Channel*
+ * BTManager utilizes the *BlueZ Kernel Manager Control Channel*
* for adapter configuration and adapter add/removal notifications (ChangedAdapterSetFunc()).
*
* To support other platforms than Linux/BlueZ, we will have to
- * - Move specified HCI host features used in DBTManager to HCIHandler, SMPHandler,.. - and -
+ * - Move specified HCI host features used in BTManager to HCIHandler, SMPHandler,.. - and -
* - Add specialization for each new platform using their non-platform-agnostic features.
*
* - - - - - - - - - - - - - - -
*
* From a user perspective the following hierarchy is provided
- * - DBTManager has zero or more
- * - DBTAdapter has zero or more
- * - DBTDevice has zero or more
- * - GATTService has zero or more
- * - GATTCharacteristic has zero or more
- * - GATTDescriptor
+ * - BTManager has zero or more
+ * - BTAdapter has zero or more
+ * - BTDevice has zero or more
+ * - BTGattService has zero or more
+ * - BTGattChar has zero or more
+ * - BTGattDesc
*
* - - - - - - - - - - - - - - -
*
* Object lifecycle with all instances and marked weak back-references to their owner
- * - DBTManager singleton instance for all
- * - DBTAdapter ownership by DBTManager
- * - DBTDevice ownership by DBTAdapter
- * - GATTHandler ownership by DBTDevice, with weak DBTDevice back-reference
- * - GATTService ownership by GATTHandler, with weak GATTHandler back-reference
- * - GATTCharacteristic ownership by GATTService, with weak GATTService back-reference
- * - GATTDescriptor ownership by GATTCharacteristic, with weak GATTCharacteristic back-reference
+ * - BTManager singleton instance for all
+ * - BTAdapter ownership by DBTManager
+ * - BTDevice ownership by DBTAdapter
+ * - BTGattHandler ownership by BTDevice, with weak BTDevice back-reference
+ * - BTGattService ownership by BTGattHandler, with weak BTGattHandler back-reference
+ * - BTGattChar ownership by BTGattService, with weak BTGattService back-reference
+ * - BTGattDesc ownership by BTGattChar, with weak BTGattChar back-reference
*
* - - - - - - - - - - - - - - -
*
* Mapped names from C++ implementation to Java implementation and to Java interface:
*
- * C++ | Java Implementation | Java Interface |
- * :------------------| :---------------------| :---------------------------|
- * DBTManager | DBTManager | BluetoothManager |
- * DBTAdapter | DBTAdapter | BluetoothAdapter |
- * DBTDevice | DBTDevice | BluetoothDevice |
- * GATTService | DBTGattService | BluetoothGattService |
- * GATTCharacteristic | DBTGattCharacteristic | BluetoothGattCharacteristic |
- * GATTDescriptor | DBTGattDescriptor | BluetoothGattDescriptor |
+ * C++ <br> `direct_bt` | Java Implementation <br> `jau.direct_bt` | Java Interface <br> `org.direct_bt` |
+ * :----------------| :---------------------| :--------------------|
+ * BTManager | DBTManager | BTManager |
+ * BTAdapter | DBTAdapter | BTAdapter |
+ * BTDevice | DBTDevice | BTDevice |
+ * BTGattService | DBTGattService | BTGattService |
+ * BTGattChar | DBTGattChar | BTGattChar |
+ * BTGattDesc | DBTGattDesc | BTGattDesc |
*
* - - - - - - - - - - - - - - -
*
* A fully event driven workflow from discovery to GATT programming is supported.
*
* AdapterStatusListener allows listening to adapter changes and device discovery
- * and GATTCharacteristicListener to GATT indications and notifications.
+ * and BTGattCharListener to GATT indications and notifications.
*
* Main event listener can be attached to these objects
* which maintain a set of unique listener instances without duplicates.
*
- * - DBTAdapter
+ * - BTAdapter
* - AdapterStatusListener
*
- * - GATTHandler
- * - GATTCharacteristicListener
+ * - BTGattHandler
+ * - BTGattCharListener
*
- * Other API attachment method exists for GATTCharacteristicListener,
- * however, they only exists for convenience and end up to be attached to GATTHandler.
+ * Other API attachment method exists for BTGattCharListener,
+ * however, they only exists for convenience and end up to be attached to BTGattHandler.
*
*
* - - - - - - - - - - - - - - -
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/BTAdapter.hpp
index b69a1c37..62350022 100644
--- a/api/direct_bt/DBTAdapter.hpp
+++ b/api/direct_bt/BTAdapter.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef DBT_ADAPTER_HPP_
-#define DBT_ADAPTER_HPP_
+#ifndef BT_ADAPTER_HPP_
+#define BT_ADAPTER_HPP_
#include <cstring>
#include <string>
@@ -37,28 +37,28 @@
#include <jau/darray.hpp>
#include <jau/cow_darray.hpp>
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
-#include "DBTDevice.hpp"
+#include "BTDevice.hpp"
#include "HCIHandler.hpp"
namespace direct_bt {
- class DBTAdapter; // forward
- class DBTManager; // forward
+ class BTAdapter; // forward
+ class BTManager; // forward
/**
- * {@link DBTAdapter} status listener for {@link DBTDevice} discovery events: Added, updated and removed;
- * as well as for certain {@link DBTAdapter} events.
+ * {@link BTAdapter} status listener for {@link BTDevice} discovery events: Added, updated and removed;
+ * as well as for certain {@link BTAdapter} events.
* <p>
* User implementations shall return as early as possible to avoid blocking the event-handler thread,
* if not specified within the methods otherwise (see AdapterStatusListener::deviceReady()).<br>
- * Especially complex mutable operations on DBTDevice or DBTAdapter should be issued off-thread!
+ * Especially complex mutable operations on BTDevice or BTAdapter should be issued off-thread!
* </p>
* <p>
- * A listener instance may be attached to a {@link DBTAdapter} via
- * {@link DBTAdapter::addStatusListener(std::shared_ptr<AdapterStatusListener>)}.
+ * A listener instance may be attached to a {@link BTAdapter} via
+ * {@link BTAdapter::addStatusListener(std::shared_ptr<AdapterStatusListener>)}.
* </p>
* <p>
* The listener receiver maintains a unique set of listener instances without duplicates.
@@ -77,24 +77,24 @@ namespace direct_bt {
* Defaults to true;
* </p>
*/
- virtual bool matchDevice(const DBTDevice & device) {
+ virtual bool matchDevice(const BTDevice & device) {
(void)device;
return true;
}
/**
- * DBTAdapter setting(s) changed.
+ * BTAdapter setting(s) changed.
* @param adapter the adapter which settings have changed.
- * @param oldmask the previous settings mask. AdapterSetting::NONE indicates the initial setting notification, see DBTAdapter::addStatusListener().
+ * @param oldmask the previous settings mask. AdapterSetting::NONE indicates the initial setting notification, see BTAdapter::addStatusListener().
* @param newmask the new settings mask
- * @param changedmask the changes settings mask. AdapterSetting::NONE indicates the initial setting notification, see DBTAdapter::addStatusListener().
+ * @param changedmask the changes settings mask. AdapterSetting::NONE indicates the initial setting notification, see BTAdapter::addStatusListener().
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
*/
- virtual void adapterSettingsChanged(DBTAdapter &adapter, const AdapterSetting oldmask, const AdapterSetting newmask,
+ virtual void adapterSettingsChanged(BTAdapter &adapter, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) = 0;
/**
- * DBTAdapter's discovery state has changed, i.e. enabled or disabled.
+ * BTAdapter's discovery state has changed, i.e. enabled or disabled.
* @param adapter the adapter which discovering state has changed.
* @param currentMeta the current meta ScanType
* @param changedType denotes the changed ScanType
@@ -104,53 +104,53 @@ namespace direct_bt {
*
* changeScanType(const ScanType current, const bool enable, const ScanType enableChanged) noexcept {
*/
- virtual void discoveringChanged(DBTAdapter &adapter, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) = 0;
+ virtual void discoveringChanged(BTAdapter &adapter, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) = 0;
/**
- * A DBTDevice has been newly discovered.
+ * A BTDevice has been newly discovered.
* <p>
* The boolean return value informs the adapter whether the device shall be made persistent for connection {@code true},
* or that it can be discarded {@code false}.<br>
* If no registered AdapterStatusListener::deviceFound() implementation returns {@code true},
* the device instance will be removed from all internal lists and can no longer being used.<br>
* If any registered AdapterStatusListener::deviceFound() implementation returns {@code true},
- * the device will be made persistent, is ready to connect and DBTDevice::remove() shall be called after usage.
+ * the device will be made persistent, is ready to connect and BTDevice::remove() shall be called after usage.
* </p>
* @param device the found device
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
- * @return true if the device shall be made persistent and DBTDevice::remove() issued later. Otherwise false to remove device right away.
+ * @return true if the device shall be made persistent and BTDevice::remove() issued later. Otherwise false to remove device right away.
*/
- virtual bool deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) = 0;
+ virtual bool deviceFound(std::shared_ptr<BTDevice> device, const uint64_t timestamp) = 0;
/**
- * An already discovered DBTDevice has been updated.
+ * An already discovered BTDevice has been updated.
* @param device the updated device
* @param updateMask the update mask of changed data
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
*/
- virtual void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) = 0;
+ virtual void deviceUpdated(std::shared_ptr<BTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) = 0;
/**
- * DBTDevice got connected
+ * BTDevice got connected
* @param device the device which has been connected, holding the new connection handle.
* @param handle the new connection handle, which has been assigned to the device already
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
*/
- virtual void deviceConnected(std::shared_ptr<DBTDevice> device, const uint16_t handle, const uint64_t timestamp) = 0;
+ virtual void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) = 0;
/**
- * An already connected DBTDevice's ::SMPPairingState has changed.
+ * An already connected BTDevice's ::SMPPairingState has changed.
* @param device the device which PairingMode has been changed.
- * @param state the current ::SMPPairingState of the connected device, see DBTDevice::getCurrentPairingState()
- * @param mode the current ::PairingMode of the connected device, see DBTDevice::getCurrentPairingMode()
+ * @param state the current ::SMPPairingState of the connected device, see BTDevice::getCurrentPairingState()
+ * @param mode the current ::PairingMode of the connected device, see BTDevice::getCurrentPairingMode()
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
- * @see DBTDevice::setPairingPasskey()
- * @see DBTDevice::setPairingNumericComparison()
+ * @see BTDevice::setPairingPasskey()
+ * @see BTDevice::setPairingNumericComparison()
*/
- virtual void devicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) = 0;
+ virtual void devicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) = 0;
/**
- * DBTDevice is ready for user (GATT) processing, i.e. already connected, optionally paired and ATT MTU size negotiated via connected GATT.
+ * BTDevice is ready for user (GATT) processing, i.e. already connected, optionally paired and ATT MTU size negotiated via connected GATT.
* <p>
* Method is being called from a dedicated native thread, hence restrictions on method duration and complex mutable operations don't apply here.
* </p>
@@ -158,16 +158,16 @@ namespace direct_bt {
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
* @see ::SMPPairingState::COMPLETED
*/
- virtual void deviceReady(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) = 0;
+ virtual void deviceReady(std::shared_ptr<BTDevice> device, const uint64_t timestamp) = 0;
/**
- * DBTDevice got disconnected
+ * BTDevice got disconnected
* @param device the device which has been disconnected with zeroed connection handle.
* @param reason the HCIStatusCode reason for disconnection
* @param handle the disconnected connection handle, which has been unassigned from the device already
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
*/
- virtual void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) = 0;
+ virtual void deviceDisconnected(std::shared_ptr<BTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) = 0;
virtual ~AdapterStatusListener() {}
@@ -191,7 +191,7 @@ namespace direct_bt {
// *************************************************
/**
- * DBTAdapter represents one Bluetooth Controller.
+ * BTAdapter represents one Bluetooth Controller.
* <p>
* Controlling Environment variables:
* <pre>
@@ -199,13 +199,13 @@ namespace direct_bt {
* </pre>
* </p>
*/
- class DBTAdapter : public DBTObject
+ class BTAdapter : public BTObject
{
private:
- friend DBTManager;
+ friend BTManager;
const bool debug_event, debug_lock;
- DBTManager& mgmt;
+ BTManager& mgmt;
AdapterInfo adapterInfo;
public:
@@ -227,35 +227,35 @@ namespace direct_bt {
std::atomic<bool> keep_le_scan_alive; // = false;
SMPIOCapability iocap_defaultval = SMPIOCapability::UNSET;
- const DBTDevice* single_conn_device_ptr = nullptr;
+ const BTDevice* single_conn_device_ptr = nullptr;
std::mutex mtx_single_conn_device;
std::condition_variable cv_single_conn_device;
- typedef jau::darray<std::shared_ptr<DBTDevice>> device_list_t;
+ typedef jau::darray<std::shared_ptr<BTDevice>> device_list_t;
/** All discovered devices: Transient until removeDiscoveredDevices(), startDiscovery(). */
device_list_t discoveredDevices;
/** All connected devices: Transient until disconnect or removal. */
device_list_t connectedDevices;
/** All persistent shared devices: Persistent until removal. */
- device_list_t sharedDevices; // All active shared devices. Final holder of DBTDevice lifecycle!
+ device_list_t sharedDevices; // All active shared devices. Final holder of BTDevice lifecycle!
typedef jau::cow_darray<std::shared_ptr<AdapterStatusListener>> statusListenerList_t;
statusListenerList_t statusListenerList;
mutable std::mutex mtx_discoveredDevices;
mutable std::mutex mtx_connectedDevices;
mutable std::mutex mtx_discovery;
- mutable std::mutex mtx_sharedDevices; // final mutex of all DBTDevice lifecycle
+ mutable std::mutex mtx_sharedDevices; // final mutex of all BTDevice lifecycle
bool validateDevInfo() noexcept;
- static std::shared_ptr<DBTDevice> findDevice(device_list_t & devices, const EUI48 & address, const BDAddressType addressType) noexcept;
- static std::shared_ptr<DBTDevice> findDevice(device_list_t & devices, DBTDevice const & device) noexcept;
+ static std::shared_ptr<BTDevice> findDevice(device_list_t & devices, const EUI48 & address, const BDAddressType addressType) noexcept;
+ static std::shared_ptr<BTDevice> findDevice(device_list_t & devices, BTDevice const & device) noexcept;
/** Private class only for private make_shared(). */
- class ctor_cookie { friend DBTAdapter; ctor_cookie(const uint16_t secret) { (void)secret; } };
+ class ctor_cookie { friend BTAdapter; ctor_cookie(const uint16_t secret) { (void)secret; } };
- /** Private std::make_shared<DBTAdapter>(..) vehicle for friends. */
- static std::shared_ptr<DBTAdapter> make_shared(DBTManager& mgmt_, const AdapterInfo& adapterInfo_) {
- return std::make_shared<DBTAdapter>(DBTAdapter::ctor_cookie(0), mgmt_, adapterInfo_);
+ /** Private std::make_shared<BTAdapter>(..) vehicle for friends. */
+ static std::shared_ptr<BTAdapter> make_shared(BTManager& mgmt_, const AdapterInfo& adapterInfo_) {
+ return std::make_shared<BTAdapter>(BTAdapter::ctor_cookie(0), mgmt_, adapterInfo_);
}
/**
@@ -266,37 +266,37 @@ namespace direct_bt {
*/
void poweredOff() noexcept;
- friend std::shared_ptr<DBTDevice> DBTDevice::getSharedInstance() const noexcept;
- friend std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo() noexcept;
- friend void DBTDevice::sendMgmtEvDeviceDisconnected(std::unique_ptr<MgmtEvent> evt) noexcept;
- friend HCIStatusCode DBTDevice::disconnect(const HCIStatusCode reason) noexcept;
- friend void DBTDevice::remove() noexcept;
- friend HCIStatusCode DBTDevice::connectLE(uint16_t interval, uint16_t window,
+ friend std::shared_ptr<BTDevice> BTDevice::getSharedInstance() const noexcept;
+ friend std::shared_ptr<ConnectionInfo> BTDevice::getConnectionInfo() noexcept;
+ friend void BTDevice::sendMgmtEvDeviceDisconnected(std::unique_ptr<MgmtEvent> evt) noexcept;
+ friend HCIStatusCode BTDevice::disconnect(const HCIStatusCode reason) noexcept;
+ friend void BTDevice::remove() noexcept;
+ friend HCIStatusCode BTDevice::connectLE(uint16_t interval, uint16_t window,
uint16_t min_interval, uint16_t max_interval,
uint16_t latency, uint16_t supervision_timeout);
- friend HCIStatusCode DBTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch);
- friend void DBTDevice::processL2CAPSetup(std::shared_ptr<DBTDevice> sthis);
- friend bool DBTDevice::updatePairingState(std::shared_ptr<DBTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept;
- friend void DBTDevice::hciSMPMsgCallback(std::shared_ptr<DBTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept;
- friend void DBTDevice::processDeviceReady(std::shared_ptr<DBTDevice> sthis, const uint64_t timestamp);
- friend jau::darray<std::shared_ptr<GATTService>> DBTDevice::getGATTServices() noexcept;
-
- bool lockConnect(const DBTDevice & device, const bool wait, const SMPIOCapability io_cap) noexcept;
- bool unlockConnect(const DBTDevice & device) noexcept;
+ friend HCIStatusCode BTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch);
+ friend void BTDevice::processL2CAPSetup(std::shared_ptr<BTDevice> sthis);
+ friend bool BTDevice::updatePairingState(std::shared_ptr<BTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept;
+ friend void BTDevice::hciSMPMsgCallback(std::shared_ptr<BTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept;
+ friend void BTDevice::processDeviceReady(std::shared_ptr<BTDevice> sthis, const uint64_t timestamp);
+ friend jau::darray<std::shared_ptr<BTGattService>> BTDevice::getGattServices() noexcept;
+
+ bool lockConnect(const BTDevice & device, const bool wait, const SMPIOCapability io_cap) noexcept;
+ bool unlockConnect(const BTDevice & device) noexcept;
bool unlockConnectAny() noexcept;
- bool addConnectedDevice(const std::shared_ptr<DBTDevice> & device) noexcept;
- bool removeConnectedDevice(const DBTDevice & device) noexcept;
+ bool addConnectedDevice(const std::shared_ptr<BTDevice> & device) noexcept;
+ bool removeConnectedDevice(const BTDevice & device) noexcept;
int disconnectAllDevices(const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ) noexcept;
- std::shared_ptr<DBTDevice> findConnectedDevice (const EUI48 & address, const BDAddressType & addressType) noexcept;
+ std::shared_ptr<BTDevice> findConnectedDevice (const EUI48 & address, const BDAddressType & addressType) noexcept;
- bool addDiscoveredDevice(std::shared_ptr<DBTDevice> const &device) noexcept;
+ bool addDiscoveredDevice(std::shared_ptr<BTDevice> const &device) noexcept;
- void removeDevice(DBTDevice & device) noexcept;
+ void removeDevice(BTDevice & device) noexcept;
- bool addSharedDevice(std::shared_ptr<DBTDevice> const &device) noexcept;
- std::shared_ptr<DBTDevice> getSharedDevice(const DBTDevice & device) noexcept;
- void removeSharedDevice(const DBTDevice & device) noexcept;
+ bool addSharedDevice(std::shared_ptr<BTDevice> const &device) noexcept;
+ std::shared_ptr<BTDevice> getSharedDevice(const BTDevice & device) noexcept;
+ void removeSharedDevice(const BTDevice & device) noexcept;
bool mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept;
bool mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept;
@@ -325,8 +325,8 @@ namespace direct_bt {
bool hciSMPMsgCallback(const BDAddressAndType & addressAndType,
const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept;
- void sendDevicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept;
- void sendDeviceReady(std::shared_ptr<DBTDevice> device, uint64_t timestamp) noexcept;
+ void sendDevicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept;
+ void sendDeviceReady(std::shared_ptr<BTDevice> device, uint64_t timestamp) noexcept;
void startDiscoveryBackground() noexcept;
void checkDiscoveryState() noexcept;
@@ -335,26 +335,26 @@ namespace direct_bt {
const uint64_t timestampMS) noexcept;
void sendAdapterSettingsInitial(AdapterStatusListener & asl, const uint64_t timestampMS) noexcept;
- void sendDeviceUpdated(std::string cause, std::shared_ptr<DBTDevice> device, uint64_t timestamp, EIRDataType updateMask) noexcept;
+ void sendDeviceUpdated(std::string cause, std::shared_ptr<BTDevice> device, uint64_t timestamp, EIRDataType updateMask) noexcept;
public:
- /** Private ctor for private DBTAdapter::make_shared() intended for friends. */
- DBTAdapter(const DBTAdapter::ctor_cookie& cc, DBTManager& mgmt_, const AdapterInfo& adapterInfo_) noexcept;
+ /** Private ctor for private BTAdapter::make_shared() intended for friends. */
+ BTAdapter(const BTAdapter::ctor_cookie& cc, BTManager& mgmt_, const AdapterInfo& adapterInfo_) noexcept;
- DBTAdapter(const DBTAdapter&) = delete;
- void operator=(const DBTAdapter&) = delete;
+ BTAdapter(const BTAdapter&) = delete;
+ void operator=(const BTAdapter&) = delete;
/**
* Releases this instance.
*/
- ~DBTAdapter() noexcept;
+ ~BTAdapter() noexcept;
/**
* Closes this instance, usually being called by destructor or when this adapter is being removed
- * as recognized and handled by DBTManager.
+ * as recognized and handled by BTManager.
* <p>
- * Renders this adapter's DBTAdapter#isValid() state to false.
+ * Renders this adapter's BTAdapter#isValid() state to false.
* </p>
*/
void close() noexcept;
@@ -368,7 +368,7 @@ namespace direct_bt {
/**
* Returns whether the adapter is valid, plugged in and powered.
- * @return true if DBTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is set.
+ * @return true if BTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is set.
* @see #isSuspended()
* @see #isValid()
*/
@@ -378,7 +378,7 @@ namespace direct_bt {
/**
* Returns whether the adapter is suspended, i.e. valid and plugged in, but not powered.
- * @return true if DBTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is not set.
+ * @return true if BTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is not set.
* @see #isPowered()
* @see #isValid()
*/
@@ -396,13 +396,13 @@ namespace direct_bt {
/**
* Returns whether the adapter is valid, i.e. reference is valid, plugged in and generally operational,
- * but not necessarily DBTAdapter::isPowered() powered.
- * @return true if this adapter references are valid and hasn't been DBTAdapter::close() 'ed
+ * but not necessarily BTAdapter::isPowered() powered.
+ * @return true if this adapter references are valid and hasn't been BTAdapter::close() 'ed
* @see #isPowered()
* @see #isSuspended()
*/
bool isValid() const noexcept {
- return DBTObject::isValid();
+ return BTObject::isValid();
}
/**
@@ -469,9 +469,9 @@ namespace direct_bt {
HCIStatusCode reset() noexcept;
/**
- * Returns a reference to the used singleton DBTManager instance, used to create this adapter.
+ * Returns a reference to the used singleton BTManager instance, used to create this adapter.
*/
- DBTManager& getManager() const noexcept { return mgmt; }
+ BTManager& getManager() const noexcept { return mgmt; }
/**
* Returns a reference to the aggregated HCIHandler instance.
@@ -651,7 +651,7 @@ namespace direct_bt {
* use 'DeviceStatusListener::deviceFound(..)' callback.
* </p>
*/
- jau::darray<std::shared_ptr<DBTDevice>> getDiscoveredDevices() const noexcept;
+ jau::darray<std::shared_ptr<BTDevice>> getDiscoveredDevices() const noexcept;
/** Discards all discovered devices. Returns number of removed discovered devices. */
int removeDiscoveredDevices() noexcept;
@@ -659,22 +659,22 @@ namespace direct_bt {
/** Discards matching discovered devices. Returns {@code true} if found and removed, otherwise false. */
bool removeDiscoveredDevice(const BDAddressAndType & addressAndType) noexcept;
- /** Returns shared DBTDevice if found, otherwise nullptr */
- std::shared_ptr<DBTDevice> findDiscoveredDevice (const EUI48 & address, const BDAddressType addressType) noexcept;
+ /** Returns shared BTDevice if found, otherwise nullptr */
+ std::shared_ptr<BTDevice> findDiscoveredDevice (const EUI48 & address, const BDAddressType addressType) noexcept;
- /** Returns shared DBTDevice if found, otherwise nullptr */
- std::shared_ptr<DBTDevice> findSharedDevice (const EUI48 & address, const BDAddressType addressType) noexcept;
+ /** Returns shared BTDevice if found, otherwise nullptr */
+ std::shared_ptr<BTDevice> findSharedDevice (const EUI48 & address, const BDAddressType addressType) noexcept;
std::string toString() const noexcept override { return toString(true); }
std::string toString(bool includeDiscoveredDevices) const noexcept;
/**
* This is a debug facility only, to observe consistency
- * of the internally maintained lists of shared_ptr<DBTDevice>.
+ * of the internally maintained lists of shared_ptr<BTDevice>.
*/
void printSharedPtrListOfDevices() noexcept;
};
} // namespace direct_bt
-#endif /* DBT_ADAPTER_HPP_ */
+#endif /* BT_ADAPTER_HPP_ */
diff --git a/api/direct_bt/DBTDevice.hpp b/api/direct_bt/BTDevice.hpp
index 92b56b46..a2f529d6 100644
--- a/api/direct_bt/DBTDevice.hpp
+++ b/api/direct_bt/BTDevice.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef DBT_DEVICE_HPP_
-#define DBT_DEVICE_HPP_
+#ifndef BT_DEVICE_HPP_
+#define BT_DEVICE_HPP_
#include <cstring>
#include <string>
@@ -35,14 +35,14 @@
#include <jau/darray.hpp>
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
#include "HCIIoctl.hpp"
#include "HCIComm.hpp"
#include "MgmtTypes.hpp"
#include "SMPHandler.hpp"
-#include "GATTHandler.hpp"
+#include "BTGattHandler.hpp"
namespace direct_bt {
@@ -50,15 +50,15 @@ namespace direct_bt {
// *************************************************
// *************************************************
- class DBTAdapter; // forward
+ class BTAdapter; // forward
- class DBTDevice : public DBTObject
+ class BTDevice : public BTObject
{
- friend DBTAdapter; // managing us: ctor and update(..) during discovery
- friend GATTHandler; // may issue detailed disconnect(..)
+ friend BTAdapter; // managing us: ctor and update(..) during discovery
+ friend BTGattHandler; // may issue detailed disconnect(..)
private:
- DBTAdapter & adapter;
+ BTAdapter & adapter;
L2CAPComm l2cap_att;
uint64_t ts_last_discovery;
uint64_t ts_last_update;
@@ -74,7 +74,7 @@ namespace direct_bt {
std::shared_ptr<SMPHandler> smpHandler = nullptr;
std::recursive_mutex mtx_smpHandler;
#endif
- std::shared_ptr<GATTHandler> gattHandler = nullptr;
+ std::shared_ptr<BTGattHandler> gattHandler = nullptr;
std::recursive_mutex mtx_gattHandler;
std::recursive_mutex mtx_connect;
std::recursive_mutex mtx_data;
@@ -115,11 +115,11 @@ namespace direct_bt {
jau::sc_atomic_bool sync_pairing;
/** Private class only for private make_shared(). */
- class ctor_cookie { friend DBTDevice; ctor_cookie(const uint16_t secret) { (void)secret; } };
+ class ctor_cookie { friend BTDevice; ctor_cookie(const uint16_t secret) { (void)secret; } };
- /** Private std::make_shared<DBTDevice>(..) vehicle for friends. */
- static std::shared_ptr<DBTDevice> make_shared(DBTAdapter & adapter, EInfoReport const & r) {
- return std::make_shared<DBTDevice>(DBTDevice::ctor_cookie(0), adapter, r);
+ /** Private std::make_shared<BTDevice>(..) vehicle for friends. */
+ static std::shared_ptr<BTDevice> make_shared(BTAdapter & adapter, EInfoReport const & r) {
+ return std::make_shared<BTDevice>(BTDevice::ctor_cookie(0), adapter, r);
}
/** Add advertised service (GAP discovery) */
@@ -136,8 +136,8 @@ namespace direct_bt {
EIRDataType update(GattGenericAccessSvc const &data, const uint64_t timestamp) noexcept;
void notifyDisconnected() noexcept;
- void notifyConnected(std::shared_ptr<DBTDevice> sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept;
- void notifyLEFeatures(std::shared_ptr<DBTDevice> sthis, const LEFeatures features) noexcept;
+ void notifyConnected(std::shared_ptr<BTDevice> sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept;
+ void notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const LEFeatures features) noexcept;
/**
* Setup L2CAP channel connection to device incl. optional security encryption level off-thread.
@@ -146,7 +146,7 @@ namespace direct_bt {
* initiated by the latter.
* </p>
*/
- void processL2CAPSetup(std::shared_ptr<DBTDevice> sthis);
+ void processL2CAPSetup(std::shared_ptr<BTDevice> sthis);
/**
* Established SMP host connection and security for L2CAP connection if sec_level > BTSecurityLevel::NONE.
@@ -164,19 +164,19 @@ namespace direct_bt {
* @param sec_level sec_level <= BTSecurityLevel::NONE will not set security level and returns false.
* @return true if a security level > BTSecurityLevel::NONE has been set successfully, false if no security level has been set or if it failed.
*/
- bool connectSMP(std::shared_ptr<DBTDevice> sthis, const BTSecurityLevel sec_level) noexcept;
+ bool connectSMP(std::shared_ptr<BTDevice> sthis, const BTSecurityLevel sec_level) noexcept;
bool checkPairingKeyDistributionComplete(const std::string& timestamp) const noexcept;
- bool updatePairingState(std::shared_ptr<DBTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept;
+ bool updatePairingState(std::shared_ptr<BTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept;
/**
- * Forwarded from HCIHandler -> DBTAdapter -> this DBTDevice
+ * Forwarded from HCIHandler -> BTAdapter -> this BTDevice
* <p>
* Will be initiated by processL2CAPSetup()'s security_level setup after connectLE(..), i.e. notifyConnected() and notifyLEFeatures().
* </p>
*/
- void hciSMPMsgCallback(std::shared_ptr<DBTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept;
+ void hciSMPMsgCallback(std::shared_ptr<BTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept;
/**
* Setup GATT via connectGATT() off-thread.
@@ -186,7 +186,7 @@ namespace direct_bt {
* Called from either processL2CAPSetup() w/o security or with SMP security readiness from hciSMPMsgCallback().
* </p>
*/
- void processDeviceReady(std::shared_ptr<DBTDevice> sthis, const uint64_t timestamp);
+ void processDeviceReady(std::shared_ptr<BTDevice> sthis, const uint64_t timestamp);
/**
* Returns a newly established GATT connection.
@@ -197,7 +197,7 @@ namespace direct_bt {
* The GATTHandler is managed by this device instance and closed via disconnectGATT().
* </p>
*/
- bool connectGATT(std::shared_ptr<DBTDevice> sthis) noexcept;
+ bool connectGATT(std::shared_ptr<BTDevice> sthis) noexcept;
/**
* Will be performed within disconnect() and notifyDisconnected().
@@ -218,16 +218,16 @@ namespace direct_bt {
/** Device's unique mac address and type tuple. */
const BDAddressAndType addressAndType; // FIXME: Mutable for resolvable -> identity during pairing?
- /** Private ctor for private DBTDevice::make_shared() intended for friends. */
- DBTDevice(const DBTDevice::ctor_cookie& cc, DBTAdapter & adapter, EInfoReport const & r);
+ /** Private ctor for private BTDevice::make_shared() intended for friends. */
+ BTDevice(const BTDevice::ctor_cookie& cc, BTAdapter & adapter, EInfoReport const & r);
- DBTDevice(const DBTDevice&) = delete;
- void operator=(const DBTDevice&) = delete;
+ BTDevice(const BTDevice&) = delete;
+ void operator=(const BTDevice&) = delete;
/**
* Releases this instance after calling {@link #remove()}.
*/
- ~DBTDevice() noexcept;
+ ~BTDevice() noexcept;
std::string get_java_class() const noexcept override {
return java_class();
@@ -237,10 +237,10 @@ namespace direct_bt {
}
/** Returns the managing adapter */
- DBTAdapter & getAdapter() const { return adapter; }
+ BTAdapter & getAdapter() const { return adapter; }
/** Returns the shared pointer of this instance managed by the adapter. */
- std::shared_ptr<DBTDevice> getSharedInstance() const noexcept;
+ std::shared_ptr<BTDevice> getSharedInstance() const noexcept;
/**
* Returns the timestamp in monotonic milliseconds when this device instance has been created,
@@ -292,7 +292,7 @@ namespace direct_bt {
* Return a list of advertised services as recognized at discovery, pre GATT discovery.
* <p>
* To receive a complete list of GATT services including characteristics etc,
- * use {@link #getGATTServices()}.
+ * use {@link #getGattService()}.
* </p>
*/
jau::darray<std::shared_ptr<uuid_t>> getAdvertisedServices() const noexcept;
@@ -306,7 +306,7 @@ namespace direct_bt {
* otherwise returns nullptr.
* <p>
* Before this method returns, the internal rssi and tx_power will be updated if any changed
- * and therefore all DBTAdapterStatusListener's deviceUpdated(..) method called for notification.
+ * and therefore all BTAdapterStatusListener's deviceUpdated(..) method called for notification.
* </p>
*/
std::shared_ptr<ConnectionInfo> getConnectionInfo() noexcept;
@@ -341,7 +341,7 @@ namespace direct_bt {
* Set window to the same value as the interval, enables continuous scanning.
* </p>
* <p>
- * The associated DBTAdapter's HCIHandler instance is used to connect,
+ * The associated BTAdapter's HCIHandler instance is used to connect,
* see HCIHandler::le_create_conn().
* </p>
*
@@ -375,7 +375,7 @@ namespace direct_bt {
* The device is tracked by the managing adapter.
* </p>
* <p>
- * The associated DBTAdapter's HCIHandler instance is used to connect,
+ * The associated BTAdapter's HCIHandler instance is used to connect,
* see HCIHandler::create_conn().
* </p>
* @return HCIStatusCode::SUCCESS if the command has been accepted, otherwise HCIStatusCode may disclose reason for rejection.
@@ -435,7 +435,7 @@ namespace direct_bt {
* in use by another thread due to discovery post disconnect!
* </p>
* <p>
- * The associated DBTAdapter's HCIHandler instance is used to disconnect,
+ * The associated BTAdapter's HCIHandler instance is used to disconnect,
* see HCIHandler::disconnect().
* </p>
* @return HCIStatusCode::SUCCESS if the command has been accepted, otherwise HCIStatusCode may disclose reason for rejection.
@@ -503,7 +503,7 @@ namespace direct_bt {
* <p>
* Method returns false if ::BTSecurityLevel::UNSET has been given,
* operation fails, this device has already being connected,
- * or DBTDevice::connectLE() or DBTDevice::connectBREDR() has been issued already.
+ * or BTDevice::connectLE() or BTDevice::connectBREDR() has been issued already.
* </p>
* <p>
* To ensure a consistent authentication setup,
@@ -540,7 +540,7 @@ namespace direct_bt {
* <p>
* Method returns false if ::SMPIOCapability::UNSET has been given,
* operation fails, this device has already being connected,
- * or DBTDevice::connectLE() or DBTDevice::connectBREDR() has been issued already.
+ * or BTDevice::connectLE() or BTDevice::connectBREDR() has been issued already.
* </p>
* @param[in] io_cap ::SMPIOCapability to be applied, ::SMPIOCapability::UNSET will be ignored and method fails.
* @see ::BTSecurityLevel
@@ -570,7 +570,7 @@ namespace direct_bt {
* <p>
* Method returns false if ::BTSecurityLevel::UNSET or ::SMPIOCapability::UNSET has been given,
* operation fails, this device has already being connected,
- * or DBTDevice::connectLE() or DBTDevice::connectBREDR() has been issued already.
+ * or BTDevice::connectLE() or BTDevice::connectBREDR() has been issued already.
* </p>
* <p>
* Method either changes both parameter for the upcoming connection or none at all.
@@ -608,7 +608,7 @@ namespace direct_bt {
* <p>
* Method returns false if ::BTSecurityLevel::UNSET and ::SMPIOCapability::UNSET has been given,
* operation fails, this device has already being connected,
- * or DBTDevice::connectLE() or DBTDevice::connectBREDR() has been issued already.
+ * or BTDevice::connectLE() or BTDevice::connectBREDR() has been issued already.
* </p>
* <p>
* Method either changes both parameter for the upcoming connection or none at all.
@@ -730,8 +730,8 @@ namespace direct_bt {
*/
void remove() noexcept;
- /** Returns the connected GATTHandler or nullptr, see connectGATT(), getGATTServices() and disconnect(). */
- std::shared_ptr<GATTHandler> getGATTHandler() noexcept;
+ /** Returns the connected GATTHandler or nullptr, see connectGATT(), getGattService() and disconnect(). */
+ std::shared_ptr<BTGattHandler> getGattHandler() noexcept;
/**
* Returns a list of shared GATTService available on this device if successful,
@@ -746,18 +746,18 @@ namespace direct_bt {
* In case no GATT connection has been established it will be created via connectGATT().
* </p>
*/
- jau::darray<std::shared_ptr<GATTService>> getGATTServices() noexcept;
+ jau::darray<std::shared_ptr<BTGattService>> getGattServices() noexcept;
/**
* Returns the matching GATTService for the given uuid.
* <p>
- * Implementation calls getGATTServices().
+ * Implementation calls getGattService().
* </p>
*/
- std::shared_ptr<GATTService> findGATTService(std::shared_ptr<uuid_t> const &uuid);
+ std::shared_ptr<BTGattService> findGattService(std::shared_ptr<uuid_t> const &uuid);
- /** Returns the shared GenericAccess instance, retrieved by {@link #getGATTServices()} or nullptr if not available. */
- std::shared_ptr<GattGenericAccessSvc> getGATTGenericAccess();
+ /** Returns the shared GenericAccess instance, retrieved by {@link #getGattService()} or nullptr if not available. */
+ std::shared_ptr<GattGenericAccessSvc> getGattGenericAccess();
/**
* Issues a GATT ping to the device, validating whether it is still reachable.
@@ -770,62 +770,62 @@ namespace direct_bt {
* A disconnect will finally being issued.
* </p>
* <p>
- * GATT services must have been initialized via {@link #getGATTServices()}, otherwise {@code false} is being returned.
+ * GATT services must have been initialized via {@link #getGattService()}, otherwise {@code false} is being returned.
* </p>
* @return {@code true} if successful, otherwise false in case no GATT services exists or is not connected .. etc.
*/
bool pingGATT() noexcept;
/**
- * Add the given GATTCharacteristicListener to the listener list if not already present.
+ * Add the given BTGattCharListener to the listener list if not already present.
* <p>
* Convenience delegation call to GATTHandler
* </p>
* <p>
* To enable the actual BLE notification and/or indication, one needs to call
- * GATTCharacteristic::configNotificationIndication(bool, bool, bool[])
- * or GATTCharacteristic::enableNotificationOrIndication(bool enabledState[2]).
+ * BTGattChar::configNotificationIndication(bool, bool, bool[])
+ * or BTGattChar::enableNotificationOrIndication(bool enabledState[2]).
* </p>
- * @param listener A GATTCharacteristicListener instance, listening to all BluetoothGattCharacteristic events of this device
+ * @param listener A BTGattCharListener instance, listening to all BluetoothGattCharacteristic events of this device
* @return true if the given listener is not element of the list and has been newly added, otherwise false.
* @throws IllegalStateException if the GATTHandler is null, i.e. not connected
*/
- bool addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l);
+ bool addCharListener(std::shared_ptr<BTGattCharListener> l);
/**
- * Remove the given {@link GATTCharacteristicListener} from the listener list.
+ * Remove the given {@link BTGattCharListener} from the listener list.
* <p>
* If the GATTHandler is null, i.e. not connected, {@code false} is being returned.
* </p>
- * @param listener A {@link GATTCharacteristicListener} instance
+ * @param listener A {@link BTGattCharListener} instance
* @return true if the given listener is an element of the list and has been removed, otherwise false.
*/
- bool removeCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) noexcept;
+ bool removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept;
/**
- * Remove all {@link GATTCharacteristicListener} from the list, which are associated to the given {@link GATTCharacteristic}.
+ * Remove all {@link BTGattCharListener} from the list, which are associated to the given {@link BTGattChar}.
* <p>
- * Implementation tests all listener's GATTCharacteristicListener::match(const GATTCharacteristic & characteristic)
+ * Implementation tests all listener's BTGattCharListener::match(const BTGattChar & characteristic)
* to match with the given associated characteristic.
* </p>
- * @param associatedCharacteristic the match criteria to remove any GATTCharacteristicListener from the list
+ * @param associatedCharacteristic the match criteria to remove any BTGattCharListener from the list
* @return number of removed listener.
*/
- int removeAllAssociatedCharacteristicListener(std::shared_ptr<GATTCharacteristic> associatedCharacteristic) noexcept;
+ int removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedCharacteristic) noexcept;
/**
- * Remove all {@link GATTCharacteristicListener} from the list.
+ * Remove all {@link BTGattCharListener} from the list.
* @return number of removed listener.
*/
- int removeAllCharacteristicListener() noexcept;
+ int removeAllCharListener() noexcept;
};
- inline bool operator==(const DBTDevice& lhs, const DBTDevice& rhs) noexcept
+ inline bool operator==(const BTDevice& lhs, const BTDevice& rhs) noexcept
{ return lhs.getAddressAndType() == rhs.getAddressAndType(); }
- inline bool operator!=(const DBTDevice& lhs, const DBTDevice& rhs) noexcept
+ inline bool operator!=(const BTDevice& lhs, const BTDevice& rhs) noexcept
{ return !(lhs == rhs); }
} // namespace direct_bt
-#endif /* DBT_DEVICE_HPP_ */
+#endif /* BT_DEVICE_HPP_ */
diff --git a/api/direct_bt/GATTCharacteristic.hpp b/api/direct_bt/BTGattChar.hpp
index c663be02..d2b43008 100644
--- a/api/direct_bt/GATTCharacteristic.hpp
+++ b/api/direct_bt/BTGattChar.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef GATT_CHARACTERISTIC_HPP_
-#define GATT_CHARACTERISTIC_HPP_
+#ifndef BT_GATT_CHARACTERISTIC_HPP_
+#define BT_GATT_CHARACTERISTIC_HPP_
#include <cstring>
#include <string>
@@ -37,30 +37,30 @@
#include <jau/java_uplink.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "OctetTypes.hpp"
#include "ATTPDUTypes.hpp"
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
-#include "GATTDescriptor.hpp"
+#include "BTGattDesc.hpp"
/**
* - - - - - - - - - - - - - - -
*
- * Module GATTCharacteristic:
+ * Module BTGattChar:
*
* - BT Core Spec v5.2: Vol 3, Part G Generic Attribute Protocol (GATT)
* - BT Core Spec v5.2: Vol 3, Part G GATT: 2.6 GATT Profile Hierarchy
*/
namespace direct_bt {
- class GATTCharacteristicListener; // forward
+ class BTGattCharListener; // forward
- class GATTHandler; // forward
- class GATTService; // forward
- typedef std::shared_ptr<GATTService> GATTServiceRef;
+ class BTGattHandler; // forward
+ class BTGattService; // forward
+ typedef std::shared_ptr<BTGattService> BTGattServiceRef;
/**
* <p>
@@ -74,10 +74,10 @@ namespace direct_bt {
* and the value the Characteristics Property, Characteristics Value Handle _and_ Characteristics UUID.
* </p>
*/
- class GATTCharacteristic : public DBTObject {
+ class BTGattChar : public BTObject {
private:
/** Characteristics's service weak back-reference */
- std::weak_ptr<GATTService> wbr_service;
+ std::weak_ptr<BTGattService> wbr_service;
bool enabledNotifyState = false;
bool enabledIndicateState = false;
@@ -137,12 +137,12 @@ namespace direct_bt {
std::unique_ptr<const uuid_t> value_type;
/** List of Characteristic Descriptions as shared reference */
- jau::darray<GATTDescriptorRef> descriptorList;
+ jau::darray<BTGattDescRef> descriptorList;
/* Optional Client Characteristic Configuration index within descriptorList */
- int clientCharacteristicsConfigIndex = -1;
+ int clientCharConfigIndex = -1;
- GATTCharacteristic(const GATTServiceRef & service_, const uint16_t service_handle_, const uint16_t handle_,
+ BTGattChar(const BTGattServiceRef & service_, const uint16_t service_handle_, const uint16_t handle_,
const PropertyBitVal properties_, const uint16_t value_handle_, std::unique_ptr<const uuid_t> && value_type_) noexcept
: wbr_service(service_), service_handle(service_handle_), handle(handle_),
properties(properties_), value_handle(value_handle_), value_type(std::move(value_type_)) {}
@@ -151,15 +151,15 @@ namespace direct_bt {
return java_class();
}
static std::string java_class() noexcept {
- return std::string(JAVA_DBT_PACKAGE "DBTGattCharacteristic");
+ return std::string(JAVA_DBT_PACKAGE "DBTGattChar");
}
- std::shared_ptr<GATTService> getServiceUnchecked() const noexcept { return wbr_service.lock(); }
- std::shared_ptr<GATTService> getServiceChecked() const;
- std::shared_ptr<GATTHandler> getGATTHandlerUnchecked() const noexcept;
- std::shared_ptr<GATTHandler> getGATTHandlerChecked() const;
- std::shared_ptr<DBTDevice> getDeviceUnchecked() const noexcept;
- std::shared_ptr<DBTDevice> getDeviceChecked() const;
+ std::shared_ptr<BTGattService> getServiceUnchecked() const noexcept { return wbr_service.lock(); }
+ std::shared_ptr<BTGattService> getServiceChecked() const;
+ std::shared_ptr<BTGattHandler> getGattHandlerUnchecked() const noexcept;
+ std::shared_ptr<BTGattHandler> getGattHandlerChecked() const;
+ std::shared_ptr<BTDevice> getDeviceUnchecked() const noexcept;
+ std::shared_ptr<BTDevice> getDeviceChecked() const;
bool hasProperties(const PropertyBitVal v) const noexcept { return v == ( properties & v ); }
@@ -170,14 +170,14 @@ namespace direct_bt {
void clearDescriptors() noexcept {
descriptorList.clear();
- clientCharacteristicsConfigIndex = -1;
+ clientCharConfigIndex = -1;
}
- GATTDescriptorRef getClientCharacteristicConfig() noexcept {
- if( 0 > clientCharacteristicsConfigIndex ) {
+ BTGattDescRef getClientCharConfig() noexcept {
+ if( 0 > clientCharConfigIndex ) {
return nullptr;
}
- return descriptorList.at(static_cast<size_t>(clientCharacteristicsConfigIndex)); // abort if out of bounds
+ return descriptorList.at(static_cast<size_t>(clientCharConfigIndex)); // abort if out of bounds
}
/**
@@ -200,10 +200,10 @@ namespace direct_bt {
* @param enableIndication
* @param enabledState array of size 2, holding the resulting enabled state for notification and indication.
* @return false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present,
- * or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed.
+ * or there is no BTGattDesc of type ClientCharacteristicConfiguration, or if the operation has failed.
* Otherwise returns true.
* @throws IllegalStateException if notification or indication is set to be enabled
- * and the {@link DBTDevice's}'s {@link GATTHandler} is null, i.e. not connected
+ * and the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
*/
bool configNotificationIndication(const bool enableNotification, const bool enableIndication, bool enabledState[2]);
@@ -222,40 +222,40 @@ namespace direct_bt {
* </p>
* @param enabledState array of size 2, holding the resulting enabled state for notification and indication.
* @return false if this characteristic has no PropertyBitVal::Notify or PropertyBitVal::Indication present,
- * or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed.
+ * or there is no BTGattDesc of type ClientCharacteristicConfiguration, or if the operation has failed.
* Otherwise returns true.
* @throws IllegalStateException if notification or indication is set to be enabled
- * and the {@link DBTDevice's}'s {@link GATTHandler} is null, i.e. not connected
+ * and the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
*/
bool enableNotificationOrIndication(bool enabledState[2]);
/**
- * Add the given GATTCharacteristicListener to the listener list if not already present.
+ * Add the given BTGattCharListener to the listener list if not already present.
* <p>
* Occurring notifications and indications, if enabled via configNotificationIndication(bool, bool, bool[])
* or enableNotificationOrIndication(bool[]),
- * will call the respective GATTCharacteristicListener callback method.
+ * will call the respective BTGattCharListener callback method.
* </p>
* <p>
* Returns true if the given listener is not element of the list and has been newly added,
* otherwise false.
* </p>
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
+ * Convenience delegation call to BTGattHandler via BTDevice
* </p>
* <p>
- * To restrict the listener to listen only to this GATTCharacteristic instance,
- * user has to implement GATTCharacteristicListener::match(GATTCharacteristicRef) accordingly.
+ * To restrict the listener to listen only to this BTGattChar instance,
+ * user has to implement BTGattCharListener::match(BTGattCharRef) accordingly.
* <br>
- * For this purpose, use may derive from AssociatedGATTCharacteristicListener,
+ * For this purpose, use may derive from AssociatedBTGattCharListener,
* which provides these simple matching filter facilities.
* </p>
- * @throws IllegalStateException if the {@link DBTDevice's}'s {@link GATTHandler} is null, i.e. not connected
+ * @throws IllegalStateException if the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
*/
- bool addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l);
+ bool addCharListener(std::shared_ptr<BTGattCharListener> l);
/**
- * Add the given GATTCharacteristicListener to the listener list if not already present
+ * Add the given BTGattCharListener to the listener list if not already present
* and if enabling the notification <i>or</i> indication for this characteristic at BLE level was successful.<br>
* Notification and/or indication configuration is only performed per characteristic if changed.
* <p>
@@ -264,7 +264,7 @@ namespace direct_bt {
* Implementation uses enableNotificationOrIndication(bool[]) to enable either.
* </p>
* <p>
- * Occurring notifications and indications will call the respective GATTCharacteristicListener
+ * Occurring notifications and indications will call the respective BTGattCharListener
* callback method.
* </p>
* <p>
@@ -273,61 +273,61 @@ namespace direct_bt {
* otherwise false.
* </p>
* <p>
- * To restrict the listener to listen only to this GATTCharacteristic instance,
- * user has to implement GATTCharacteristicListener::match(GATTCharacteristicRef) accordingly.
+ * To restrict the listener to listen only to this BTGattChar instance,
+ * user has to implement BTGattCharListener::match(BTGattCharRef) accordingly.
* <br>
- * For this purpose, use may derive from AssociatedGATTCharacteristicListener,
+ * For this purpose, use may derive from AssociatedBTGattCharListener,
* which provides these simple matching filter facilities.
* </p>
* @param enabledState array of size 2, holding the resulting enabled state for notification and indication
* using enableNotificationOrIndication(bool[])
- * @throws IllegalStateException if the {@link DBTDevice's}'s {@link GATTHandler} is null, i.e. not connected
+ * @throws IllegalStateException if the {@link BTDevice's}'s {@link BTGattHandler} is null, i.e. not connected
*/
- bool addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l, bool enabledState[2]);
+ bool addCharListener(std::shared_ptr<BTGattCharListener> l, bool enabledState[2]);
/**
* Disables the notification and/or indication for this characteristic at BLE level
* if {@code disableIndicationNotification == true}
- * and removes the given {@link GATTCharacteristicListener} from the listener list.
+ * and removes the given {@link BTGattCharListener} from the listener list.
* <p>
* Returns true if the given listener is an element of the list and has been removed,
* otherwise false.
* </p>
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
- * performing addCharacteristicListener(..)
+ * Convenience delegation call to BTGattHandler via BTDevice
+ * performing addCharListener(..)
* and {@link #configNotificationIndication(bool, bool, bool[]) if {@code disableIndicationNotification == true}.
* </p>
* <p>
- * If the DBTDevice's GATTHandler is null, i.e. not connected, {@code false} is being returned.
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, {@code false} is being returned.
* </p>
* @param l
* @param disableIndicationNotification if true, disables the notification and/or indication for this characteristic
* using {@link #configNotificationIndication(bool, bool, bool[])
* @return
*/
- bool removeCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l, bool disableIndicationNotification);
+ bool removeCharListener(std::shared_ptr<BTGattCharListener> l, bool disableIndicationNotification);
/**
* Disables the notification and/or indication for this characteristic at BLE level
* if {@code disableIndicationNotification == true}
- * and removes all {@link GATTCharacteristicListener} from the listener list.
+ * and removes all {@link BTGattCharListener} from the listener list.
* <p>
* Returns the number of removed event listener.
* </p>
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
- * performing addCharacteristicListener(..)
+ * Convenience delegation call to BTGattHandler via BTDevice
+ * performing addCharListener(..)
* and configNotificationIndication(..) if {@code disableIndicationNotification == true}.
* </p>
* <p>
- * If the DBTDevice's GATTHandler is null, i.e. not connected, {@code zero} is being returned.
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, {@code zero} is being returned.
* </p>
* @param disableIndicationNotification if true, disables the notification and/or indication for this characteristic
* using {@link #configNotificationIndication(bool, bool, bool[])
* @return
*/
- int removeAllCharacteristicListener(bool disableIndicationNotification);
+ int removeAllCharListener(bool disableIndicationNotification);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.1 Read Characteristic Value
@@ -346,10 +346,10 @@ namespace direct_bt {
* if required until the response returns zero.
* </p>
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
+ * Convenience delegation call to BTGattHandler via BTDevice
* <p>
* </p>
- * If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
* </p>
*/
bool readValue(POctets & res, int expectedLength=-1);
@@ -357,10 +357,10 @@ namespace direct_bt {
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
+ * Convenience delegation call to BTGattHandler via BTDevice
* <p>
* </p>
- * If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
* </p>
*/
bool writeValue(const TROOctets & value);
@@ -368,82 +368,82 @@ namespace direct_bt {
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
+ * Convenience delegation call to BTGattHandler via BTDevice
* <p>
* </p>
- * If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
* </p>
*/
bool writeValueNoResp(const TROOctets & value);
};
- typedef std::shared_ptr<GATTCharacteristic> GATTCharacteristicRef;
+ typedef std::shared_ptr<BTGattChar> BTGattCharRef;
- inline bool operator==(const GATTCharacteristic& lhs, const GATTCharacteristic& rhs) noexcept
+ inline bool operator==(const BTGattChar& lhs, const BTGattChar& rhs) noexcept
{ return lhs.handle == rhs.handle; /** unique attribute handles */ }
- inline bool operator!=(const GATTCharacteristic& lhs, const GATTCharacteristic& rhs) noexcept
+ inline bool operator!=(const BTGattChar& lhs, const BTGattChar& rhs) noexcept
{ return !(lhs == rhs); }
/**
- * {@link GATTCharacteristic} event listener for notification and indication events.
+ * {@link BTGattChar} event listener for notification and indication events.
* <p>
- * A listener instance may be attached to a {@link BluetoothGattCharacteristic} via
- * {@link GATTCharacteristic::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener>)} to listen to events,
- * see method's API doc for {@link GATTCharacteristic} filtering.
+ * A listener instance may be attached to a {@link BTGattChar} via
+ * {@link BTGattChar::addCharListener(std::shared_ptr<BTGattCharListener>)} to listen to events,
+ * see method's API doc for {@link BTGattChar} filtering.
* </p>
* <p>
- * User may utilize {@link AssociatedGATTCharacteristicListener} to listen to only one {@link GATTCharacteristic}.
+ * User may utilize {@link AssociatedBTGattCharListener} to listen to only one {@link BTGattChar}.
* </p>
* <p>
- * A listener instance may be attached to a {@link GATTHandler} via
- * {@link GATTHandler::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener>)}
+ * A listener instance may be attached to a {@link BTGattHandler} via
+ * {@link BTGattHandler::addCharListener(std::shared_ptr<BTGattCharListener>)}
* to listen to all events of the device or the matching filtered events.
* </p>
* <p>
* The listener receiver maintains a unique set of listener instances without duplicates.
* </p>
*/
- class GATTCharacteristicListener {
+ class BTGattCharListener {
public:
/**
* Custom filter for all event methods,
* which will not be called if this method returns false.
* <p>
* User may override this method to test whether the methods shall be called
- * for the given GATTCharacteristic.
+ * for the given BTGattChar.
* </p>
* <p>
* Defaults to true;
* </p>
*/
- virtual bool match(const GATTCharacteristic & characteristic) noexcept {
+ virtual bool match(const BTGattChar & characteristic) noexcept {
(void)characteristic;
return true;
}
/**
* Called from native BLE stack, initiated by a received notification associated
- * with the given {@link GATTCharacteristic}.
- * @param charDecl {@link GATTCharacteristic} related to this notification
+ * with the given {@link BTGattChar}.
+ * @param charDecl {@link BTGattChar} related to this notification
* @param charValue the notification value
* @param timestamp the indication monotonic timestamp, see getCurrentMilliseconds()
*/
- virtual void notificationReceived(GATTCharacteristicRef charDecl,
+ virtual void notificationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp) = 0;
/**
* Called from native BLE stack, initiated by a received indication associated
- * with the given {@link GATTCharacteristic}.
- * @param charDecl {@link GATTCharacteristic} related to this indication
+ * with the given {@link BTGattChar}.
+ * @param charDecl {@link BTGattChar} related to this indication
* @param charValue the indication value
* @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#getCurrentMilliseconds()}
* @param confirmationSent if true, the native stack has sent the confirmation, otherwise user is required to do so.
*/
- virtual void indicationReceived(GATTCharacteristicRef charDecl,
+ virtual void indicationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp,
const bool confirmationSent) = 0;
- virtual ~GATTCharacteristicListener() noexcept {}
+ virtual ~BTGattCharListener() noexcept {}
/**
* Default comparison operator, merely testing for same memory reference.
@@ -451,32 +451,32 @@ namespace direct_bt {
* Specializations may override.
* </p>
*/
- virtual bool operator==(const GATTCharacteristicListener& rhs) const noexcept
+ virtual bool operator==(const BTGattCharListener& rhs) const noexcept
{ return this == &rhs; }
- bool operator!=(const GATTCharacteristicListener& rhs) const noexcept
+ bool operator!=(const BTGattCharListener& rhs) const noexcept
{ return !(*this == rhs); }
};
- class AssociatedGATTCharacteristicListener : public GATTCharacteristicListener{
+ class AssociatedBTGattCharListener : public BTGattCharListener{
private:
- const GATTCharacteristic * associatedCharacteristic;
+ const BTGattChar * associatedChar;
public:
/**
- * Passing the associated GATTCharacteristic to filter out non matching events.
+ * Passing the associated BTGattChar to filter out non matching events.
*/
- AssociatedGATTCharacteristicListener(const GATTCharacteristic * characteristicMatch) noexcept
- : associatedCharacteristic(characteristicMatch) { }
+ AssociatedBTGattCharListener(const BTGattChar * characteristicMatch) noexcept
+ : associatedChar(characteristicMatch) { }
- bool match(const GATTCharacteristic & characteristic) noexcept override {
- if( nullptr == associatedCharacteristic ) {
+ bool match(const BTGattChar & characteristic) noexcept override {
+ if( nullptr == associatedChar ) {
return true;
}
- return *associatedCharacteristic == characteristic;
+ return *associatedChar == characteristic;
}
};
} // namespace direct_bt
-#endif /* GATT_CHARACTERISTIC_HPP_ */
+#endif /* BT_GATT_CHARACTERISTIC_HPP_ */
diff --git a/api/direct_bt/GATTDescriptor.hpp b/api/direct_bt/BTGattDesc.hpp
index 0ee77667..81e11145 100644
--- a/api/direct_bt/GATTDescriptor.hpp
+++ b/api/direct_bt/BTGattDesc.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef GATT_DESCRIPTOR_HPP_
-#define GATT_DESCRIPTOR_HPP_
+#ifndef BT_GATT_DESCRIPTOR_HPP_
+#define BT_GATT_DESCRIPTOR_HPP_
#include <cstring>
#include <string>
@@ -35,11 +35,11 @@
#include <atomic>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "OctetTypes.hpp"
#include "ATTPDUTypes.hpp"
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
/**
* - - - - - - - - - - - - - - -
@@ -51,18 +51,18 @@
*/
namespace direct_bt {
- class DBTDevice; // forward
- class GATTHandler; // forward
- class GATTCharacteristic; // forward
- typedef std::shared_ptr<GATTCharacteristic> GATTCharacteristicRef;
+ class BTDevice; // forward
+ class BTGattHandler; // forward
+ class BTGattChar; // forward
+ typedef std::shared_ptr<BTGattChar> BTGattCharRef;
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3 Characteristic Descriptor
*/
- class GATTDescriptor : public DBTObject {
+ class BTGattDesc : public BTObject {
private:
/** Descriptor's characteristic weak back-reference */
- std::weak_ptr<GATTCharacteristic> wbr_characteristic;
+ std::weak_ptr<BTGattChar> wbr_char;
std::string toShortString() const noexcept;
@@ -112,21 +112,21 @@ namespace direct_bt {
/* Characteristics Descriptor's Value */
POctets value;
- GATTDescriptor(const GATTCharacteristicRef & characteristic, std::unique_ptr<const uuid_t> && type_,
+ BTGattDesc(const BTGattCharRef & characteristic, std::unique_ptr<const uuid_t> && type_,
const uint16_t handle_) noexcept
- : wbr_characteristic(characteristic), type(std::move(type_)), handle(handle_), value(/* intentional zero sized */) {}
+ : wbr_char(characteristic), type(std::move(type_)), handle(handle_), value(/* intentional zero sized */) {}
std::string get_java_class() const noexcept override {
return java_class();
}
static std::string java_class() noexcept {
- return std::string(JAVA_DBT_PACKAGE "DBTGattDescriptor");
+ return std::string(JAVA_DBT_PACKAGE "DBTGattDesc");
}
- std::shared_ptr<GATTCharacteristic> getCharacteristicUnchecked() const noexcept { return wbr_characteristic.lock(); }
- std::shared_ptr<GATTCharacteristic> getCharacteristicChecked() const;
- std::shared_ptr<GATTHandler> getGATTHandlerChecked() const;
- std::shared_ptr<DBTDevice> getDeviceChecked() const;
+ std::shared_ptr<BTGattChar> getGattCharUnchecked() const noexcept { return wbr_char.lock(); }
+ std::shared_ptr<BTGattChar> getGattCharChecked() const;
+ std::shared_ptr<BTGattHandler> getGattHandlerChecked() const;
+ std::shared_ptr<BTDevice> getDeviceChecked() const;
virtual std::string toString() const noexcept override;
@@ -134,7 +134,7 @@ namespace direct_bt {
bool isExtendedProperties() const noexcept { return TYPE_EXT_PROP == *type; }
/* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration (Characteristic Descriptor, optional, single, uint16_t bitfield) */
- bool isClientCharacteristicConfiguration() const noexcept{ return TYPE_CCC_DESC == *type; }
+ bool isClientCharConfig() const noexcept{ return TYPE_CCC_DESC == *type; }
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.12.1 Read Characteristic Descriptor
@@ -153,8 +153,8 @@ namespace direct_bt {
* if required until the response returns zero.
* </p>
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
- * If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
+ * Convenience delegation call to BTGattHandler via BTDevice
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
* </p>
*/
bool readValue(int expectedLength=-1);
@@ -168,20 +168,20 @@ namespace direct_bt {
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration
* </p>
* <p>
- * Convenience delegation call to GATTHandler via DBTDevice
- * If the DBTDevice's GATTHandler is null, i.e. not connected, an IllegalStateException is thrown.
+ * Convenience delegation call to BTGattHandler via BTDevice
+ * If the BTDevice's BTGattHandler is null, i.e. not connected, an IllegalStateException is thrown.
* </p>
*/
bool writeValue();
};
- typedef std::shared_ptr<GATTDescriptor> GATTDescriptorRef;
+ typedef std::shared_ptr<BTGattDesc> BTGattDescRef;
- inline bool operator==(const GATTDescriptor& lhs, const GATTDescriptor& rhs) noexcept
+ inline bool operator==(const BTGattDesc& lhs, const BTGattDesc& rhs) noexcept
{ return lhs.handle == rhs.handle; /** unique attribute handles */ }
- inline bool operator!=(const GATTDescriptor& lhs, const GATTDescriptor& rhs) noexcept
+ inline bool operator!=(const BTGattDesc& lhs, const BTGattDesc& rhs) noexcept
{ return !(lhs == rhs); }
} // namespace direct_bt
-#endif /* GATT_DESCRIPTOR_HPP_ */
+#endif /* BT_GATT_DESCRIPTOR_HPP_ */
diff --git a/api/direct_bt/GATTHandler.hpp b/api/direct_bt/BTGattHandler.hpp
index 1e2767e8..0ccc2e52 100644
--- a/api/direct_bt/GATTHandler.hpp
+++ b/api/direct_bt/BTGattHandler.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef GATT_HANDLER_HPP_
-#define GATT_HANDLER_HPP_
+#ifndef BT_GATT_HANDLER_HPP_
+#define BT_GATT_HANDLER_HPP_
#include <cstring>
#include <string>
@@ -40,15 +40,15 @@
#include <jau/cow_darray.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "L2CAPComm.hpp"
#include "ATTPDUTypes.hpp"
-#include "GATTTypes.hpp"
+#include "GattTypes.hpp"
/**
* - - - - - - - - - - - - - - -
*
- * Module GATTHandler:
+ * Module BTGattHandler:
*
* - BT Core Spec v5.2: Vol 3, Part G Generic Attribute Protocol (GATT)
* - BT Core Spec v5.2: Vol 3, Part G GATT: 2.6 GATT Profile Hierarchy
@@ -56,7 +56,7 @@
*/
namespace direct_bt {
- class DBTDevice; // forward
+ class BTDevice; // forward
/**
* GATT Singleton runtime environment properties
@@ -64,9 +64,9 @@ namespace direct_bt {
* Also see {@link DBTEnv::getExplodingProperties(const std::string & prefixDomain)}.
* </p>
*/
- class GATTEnv : public jau::root_environment {
+ class BTGattEnv : public jau::root_environment {
private:
- GATTEnv() noexcept;
+ BTGattEnv() noexcept;
const bool exploding; // just to trigger exploding properties
@@ -112,7 +112,7 @@ namespace direct_bt {
const bool DEBUG_DATA;
public:
- static GATTEnv& get() noexcept {
+ static BTGattEnv& get() noexcept {
/**
* Thread safe starting with C++11 6.7:
*
@@ -123,7 +123,7 @@ namespace direct_bt {
*
* Avoiding non-working double checked locking.
*/
- static GATTEnv e;
+ static BTGattEnv e;
return e;
}
};
@@ -134,10 +134,10 @@ namespace direct_bt {
* Implementation utilizes a lock free ringbuffer receiving data within its separate thread.
* </p>
* <p>
- * Controlling Environment variables, see {@link GATTEnv}.
+ * Controlling Environment variables, see {@link BTGattEnv}.
* </p>
*/
- class GATTHandler {
+ class BTGattHandler {
public:
enum class Defaults : int32_t {
/* BT Core Spec v5.2: Vol 3, Part F 3.2.8: Maximum length of an attribute value. */
@@ -149,10 +149,10 @@ namespace direct_bt {
static constexpr int number(const Defaults d) { return static_cast<int>(d); }
private:
- const GATTEnv & env;
+ const BTGattEnv & env;
- /** GATTHandle's device weak back-reference */
- std::weak_ptr<DBTDevice> wbr_device;
+ /** BTGattHandler's device weak back-reference */
+ std::weak_ptr<BTDevice> wbr_device;
L2CAPComm& l2cap;
const std::string deviceString;
@@ -172,12 +172,12 @@ namespace direct_bt {
/** send immediate confirmation of indication events from device, defaults to true. */
jau::relaxed_atomic_bool sendIndicationConfirmation = true;
- typedef jau::cow_darray<std::shared_ptr<GATTCharacteristicListener>> characteristicListenerList_t;
+ typedef jau::cow_darray<std::shared_ptr<BTGattCharListener>> characteristicListenerList_t;
characteristicListenerList_t characteristicListenerList;
uint16_t serverMTU;
std::atomic<uint16_t> usedMTU; // concurrent use in ctor(set), send and l2capReaderThreadImpl
- jau::darray<GATTServiceRef> services;
+ jau::darray<BTGattServiceRef> services;
std::shared_ptr<GattGenericAccessSvc> genericAccess = nullptr;
bool validateConnected() noexcept;
@@ -233,29 +233,29 @@ namespace direct_bt {
public:
/**
- * Constructing a new GATTHandler instance with its opened and connected L2CAP channel.
+ * Constructing a new BTGattHandler instance with its opened and connected L2CAP channel.
* <p>
* After successful l2cap connection, the MTU will be exchanged.
* See getServerMTU() and getUsedMTU(), the latter is in use.
* </p>
*/
- GATTHandler(const std::shared_ptr<DBTDevice> & device, L2CAPComm& l2cap_att) noexcept;
+ BTGattHandler(const std::shared_ptr<BTDevice> & device, L2CAPComm& l2cap_att) noexcept;
- GATTHandler(const GATTHandler&) = delete;
- void operator=(const GATTHandler&) = delete;
+ BTGattHandler(const BTGattHandler&) = delete;
+ void operator=(const BTGattHandler&) = delete;
/** Destructor closing this instance including L2CAP channel, see {@link #disconnect()}. */
- ~GATTHandler() noexcept;
+ ~BTGattHandler() noexcept;
- std::shared_ptr<DBTDevice> getDeviceUnchecked() const noexcept { return wbr_device.lock(); }
- std::shared_ptr<DBTDevice> getDeviceChecked() const;
+ std::shared_ptr<BTDevice> getDeviceUnchecked() const noexcept { return wbr_device.lock(); }
+ std::shared_ptr<BTDevice> getDeviceChecked() const;
bool isConnected() const noexcept { return is_connected ; }
bool hasIOError() const noexcept { return has_ioerror; }
std::string getStateString() const noexcept { return L2CAPComm::getStateString(is_connected, has_ioerror); }
/**
- * Disconnect this GATTHandler and optionally the associated device
+ * Disconnect this BTGattHandler and optionally the associated device
* @param disconnectDevice if true, associated device will also be disconnected, otherwise not.
* @param ioErrorCause if true, reason for disconnection is an IO error
* @return true if successful, otherwise false
@@ -266,31 +266,31 @@ namespace direct_bt {
inline uint16_t getUsedMTU() const noexcept { return usedMTU; }
/**
- * Find and return the GATTCharacterisicsDecl within internal primary services
+ * Find and return the BTGattChar within internal primary services
* via given characteristic value handle.
* <p>
* Returns nullptr if not found.
* </p>
*/
- GATTCharacteristicRef findCharacterisicsByValueHandle(const uint16_t charValueHandle) noexcept;
+ BTGattCharRef findCharacterisicsByValueHandle(const uint16_t charValueHandle) noexcept;
/**
- * Find and return the GATTCharacterisicsDecl within given list of primary services
+ * Find and return the BTGattChar within given list of primary services
* via given characteristic value handle.
* <p>
* Returns nullptr if not found.
* </p>
*/
- GATTCharacteristicRef findCharacterisicsByValueHandle(const uint16_t charValueHandle, jau::darray<GATTServiceRef> &services) noexcept;
+ BTGattCharRef findCharacterisicsByValueHandle(const uint16_t charValueHandle, jau::darray<BTGattServiceRef> &services) noexcept;
/**
- * Find and return the GATTCharacterisicsDecl within given primary service
+ * Find and return the BTGattChar within given primary service
* via given characteristic value handle.
* <p>
* Returns nullptr if not found.
* </p>
*/
- GATTCharacteristicRef findCharacterisicsByValueHandle(const uint16_t charValueHandle, GATTServiceRef service) noexcept;
+ BTGattCharRef findCharacterisicsByValueHandle(const uint16_t charValueHandle, BTGattServiceRef service) noexcept;
/**
* Discover all primary services _and_ all its characteristics declarations
@@ -298,20 +298,20 @@ namespace direct_bt {
* <p>
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.4.1 Discover All Primary Services
* </p>
- * Method returns reference to GATTHandler's internal GATTService vector of discovered services
+ * Method returns reference to BTGattHandler's internal BTGattService vector of discovered services
*
- * @param shared_this shared pointer of this instance, used to forward a weak_ptr to GATTService for back-reference. Reference is validated.
- * @return GATTHandler's internal GATTService vector of discovered services
+ * @param shared_this shared pointer of this instance, used to forward a weak_ptr to BTGattService for back-reference. Reference is validated.
+ * @return BTGattHandler's internal BTGattService vector of discovered services
*/
- jau::darray<GATTServiceRef> & discoverCompletePrimaryServices(std::shared_ptr<GATTHandler> shared_this);
+ jau::darray<BTGattServiceRef> & discoverCompletePrimaryServices(std::shared_ptr<BTGattHandler> shared_this);
/**
- * Returns a reference of the internal kept GATTService list.
+ * Returns a reference of the internal kept BTGattService list.
* <p>
* The internal list will be populated via {@link #discoverCompletePrimaryServices()}.
* </p>
*/
- inline jau::darray<GATTServiceRef> & getServices() noexcept { return services; }
+ inline jau::darray<BTGattServiceRef> & getServices() noexcept { return services; }
/**
* Returns the internal kept shared GattGenericAccessSvc instance.
@@ -326,11 +326,11 @@ namespace direct_bt {
* <p>
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.4.1 Discover All Primary Services
* </p>
- * @param shared_this shared pointer of this instance, used to forward a weak_ptr to GATTService for back-reference. Reference is validated.
+ * @param shared_this shared pointer of this instance, used to forward a weak_ptr to BTGattService for back-reference. Reference is validated.
* @param result vector containing all discovered primary services
* @return true on success, otherwise false
*/
- bool discoverPrimaryServices(std::shared_ptr<GATTHandler> shared_this, jau::darray<GATTServiceRef> & result);
+ bool discoverPrimaryServices(std::shared_ptr<BTGattHandler> shared_this, jau::darray<BTGattServiceRef> & result);
/**
* Discover all characteristics of a service and declaration attributes _only_.
@@ -341,12 +341,12 @@ namespace direct_bt {
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.1 Characterisic Declaration Attribute Value
* </p>
*/
- bool discoverCharacteristics(GATTServiceRef & service);
+ bool discoverCharacteristics(BTGattServiceRef & service);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.7.1 Discover All Characteristic Descriptors
*/
- bool discoverDescriptors(GATTServiceRef & service);
+ bool discoverDescriptors(BTGattServiceRef & service);
/**
* Generic read GATT value and long value
@@ -381,7 +381,7 @@ namespace direct_bt {
* if required until the response returns zero.
* </p>
*/
- bool readCharacteristicValue(const GATTCharacteristic & c, POctets & res, int expectedLength=-1);
+ bool readCharacteristicValue(const BTGattChar & c, POctets & res, int expectedLength=-1);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.12.1 Read Characteristic Descriptor
@@ -400,7 +400,7 @@ namespace direct_bt {
* if required until the response returns zero.
* </p>
*/
- bool readDescriptorValue(GATTDescriptor & cd, int expectedLength=-1);
+ bool readDescriptorValue(BTGattDesc & cd, int expectedLength=-1);
/**
* Generic write GATT value and long value
@@ -416,17 +416,17 @@ namespace direct_bt {
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration
* </p>
*/
- bool writeDescriptorValue(const GATTDescriptor & cd);
+ bool writeDescriptorValue(const BTGattDesc & cd);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value
*/
- bool writeCharacteristicValue(const GATTCharacteristic & c, const TROOctets & value);
+ bool writeCharacteristicValue(const BTGattChar & c, const TROOctets & value);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response
*/
- bool writeCharacteristicValueNoResp(const GATTCharacteristic & c, const TROOctets & value);
+ bool writeCharacteristicValueNoResp(const BTGattChar & c, const TROOctets & value);
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration
@@ -438,10 +438,10 @@ namespace direct_bt {
* and higher potential bandwidth may deliver material higher performance.
* </p>
* <p>
- * Throws an IllegalArgumentException if the given GATTDescriptor is not a ClientCharacteristicConfiguration.
+ * Throws an IllegalArgumentException if the given BTGattDesc is not a ClientCharacteristicConfiguration.
* </p>
*/
- bool configNotificationIndication(GATTDescriptor & cd, const bool enableNotification, const bool enableIndication);
+ bool configNotificationIndication(BTGattDesc & cd, const bool enableNotification, const bool enableIndication);
/**
* Add the given listener to the list if not already present.
@@ -450,7 +450,7 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l);
+ bool addCharListener(std::shared_ptr<BTGattCharListener> l);
/**
* Remove the given listener from the list.
@@ -459,7 +459,7 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool removeCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) noexcept;
+ bool removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept;
/**
* Remove the given listener from the list.
@@ -468,21 +468,21 @@ namespace direct_bt {
* otherwise false.
* </p>
*/
- bool removeCharacteristicListener(const GATTCharacteristicListener * l) noexcept;
+ bool removeCharListener(const BTGattCharListener * l) noexcept;
/**
- * Remove all {@link GATTCharacteristicListener} from the list, which are associated to the given {@link GATTCharacteristic}.
+ * Remove all {@link BTGattCharListener} from the list, which are associated to the given {@link BTGattChar}.
* <p>
- * Implementation tests all listener's GATTCharacteristicListener::match(const GATTCharacteristic & characteristic)
+ * Implementation tests all listener's BTGattCharListener::match(const BTGattChar & characteristic)
* to match with the given associated characteristic.
* </p>
- * @param associatedCharacteristic the match criteria to remove any GATTCharacteristicListener from the list
+ * @param associatedCharacteristic the match criteria to remove any BTGattCharListener from the list
* @return number of removed listener.
*/
- int removeAllAssociatedCharacteristicListener(std::shared_ptr<GATTCharacteristic> associatedCharacteristic) noexcept;
+ int removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedChar) noexcept;
- int removeAllAssociatedCharacteristicListener(const GATTCharacteristic * associatedCharacteristic) noexcept;
+ int removeAllAssociatedCharListener(const BTGattChar * associatedChar) noexcept;
/**
* Remove all event listener from the list.
@@ -490,7 +490,7 @@ namespace direct_bt {
* Returns the number of removed event listener.
* </p>
*/
- int removeAllCharacteristicListener() noexcept ;
+ int removeAllCharListener() noexcept ;
/**
* Enable or disable sending an immediate confirmation for received indication events from the device.
@@ -498,7 +498,7 @@ namespace direct_bt {
* Default value is true.
* </p>
* <p>
- * This setting is per GATTHandler and hence per DBTDevice.
+ * This setting is per BTGattHandler and hence per BTDevice.
* </p>
*/
void setSendIndicationConfirmation(const bool v);
@@ -509,7 +509,7 @@ namespace direct_bt {
* Default value is true.
* </p>
* <p>
- * This setting is per GATTHandler and hence per DBTDevice.
+ * This setting is per BTGattHandler and hence per BTDevice.
* </p>
*/
bool getSendIndicationConfirmation() noexcept;
@@ -518,11 +518,11 @@ namespace direct_bt {
/** Higher level semantic functionality **/
/*****************************************************/
- std::shared_ptr<GattGenericAccessSvc> getGenericAccess(jau::darray<GATTServiceRef> & primServices);
- std::shared_ptr<GattGenericAccessSvc> getGenericAccess(jau::darray<GATTCharacteristicRef> & genericAccessCharDeclList);
+ std::shared_ptr<GattGenericAccessSvc> getGenericAccess(jau::darray<BTGattServiceRef> & primServices);
+ std::shared_ptr<GattGenericAccessSvc> getGenericAccess(jau::darray<BTGattCharRef> & genericAccessCharDeclList);
- std::shared_ptr<GattDeviceInformationSvc> getDeviceInformation(jau::darray<GATTServiceRef> & primServices);
- std::shared_ptr<GattDeviceInformationSvc> getDeviceInformation(jau::darray<GATTCharacteristicRef> & deviceInfoCharDeclList);
+ std::shared_ptr<GattDeviceInformationSvc> getDeviceInformation(jau::darray<BTGattServiceRef> & primServices);
+ std::shared_ptr<GattDeviceInformationSvc> getDeviceInformation(jau::darray<BTGattCharRef> & deviceInfoCharDeclList);
/**
* Issues a ping to the device, validating whether it is still reachable.
@@ -540,4 +540,4 @@ namespace direct_bt {
} // namespace direct_bt
-#endif /* GATT_HANDLER_HPP_ */
+#endif /* BT_GATT_HANDLER_HPP_ */
diff --git a/api/direct_bt/GATTService.hpp b/api/direct_bt/BTGattService.hpp
index f81f4661..cfbe090f 100644
--- a/api/direct_bt/GATTService.hpp
+++ b/api/direct_bt/BTGattService.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef GATT_SERVICE_HPP_
-#define GATT_SERVICE_HPP_
+#ifndef BT_GATT_SERVICE_HPP_
+#define BT_GATT_SERVICE_HPP_
#include <cstring>
#include <string>
@@ -38,13 +38,13 @@
#include <jau/darray.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "OctetTypes.hpp"
#include "ATTPDUTypes.hpp"
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
-#include "GATTCharacteristic.hpp"
+#include "BTGattChar.hpp"
/**
* - - - - - - - - - - - - - - -
@@ -56,18 +56,18 @@
*/
namespace direct_bt {
- class GATTHandler; // forward
- class DBTDevice; // forward
+ class BTGattHandler; // forward
+ class BTDevice; // forward
/**
* Representing a complete [Primary] Service Declaration
* including its list of Characteristic Declarations,
* which also may include its client config if available.
*/
- class GATTService : public DBTObject {
+ class BTGattService : public BTObject {
private:
/** Service's GATTHandler weak back-reference */
- std::weak_ptr<GATTHandler> wbr_handler;
+ std::weak_ptr<BTGattHandler> wbr_handler;
std::string toShortString() const noexcept;
@@ -94,9 +94,9 @@ namespace direct_bt {
std::unique_ptr<const uuid_t> type;
/** List of Characteristic Declarations as shared reference */
- jau::darray<GATTCharacteristicRef> characteristicList;
+ jau::darray<BTGattCharRef> characteristicList;
- GATTService(const std::shared_ptr<GATTHandler> &handler_, const bool isPrimary_,
+ BTGattService(const std::shared_ptr<BTGattHandler> &handler_, const bool isPrimary_,
const uint16_t startHandle_, const uint16_t endHandle_, std::unique_ptr<const uuid_t> && type_) noexcept
: wbr_handler(handler_), isPrimary(isPrimary_), startHandle(startHandle_), endHandle(endHandle_), type(std::move(type_)), characteristicList() {
characteristicList.reserve(10);
@@ -109,21 +109,21 @@ namespace direct_bt {
return std::string(JAVA_DBT_PACKAGE "DBTGattService");
}
- std::shared_ptr<GATTHandler> getGATTHandlerUnchecked() const noexcept { return wbr_handler.lock(); }
- std::shared_ptr<GATTHandler> getGATTHandlerChecked() const;
+ std::shared_ptr<BTGattHandler> getGattHandlerUnchecked() const noexcept { return wbr_handler.lock(); }
+ std::shared_ptr<BTGattHandler> getGattHandlerChecked() const;
- std::shared_ptr<DBTDevice> getDeviceUnchecked() const noexcept;
- std::shared_ptr<DBTDevice> getDeviceChecked() const;
+ std::shared_ptr<BTDevice> getDeviceUnchecked() const noexcept;
+ std::shared_ptr<BTDevice> getDeviceChecked() const;
std::string toString() const noexcept override;
};
- inline bool operator==(const GATTService& lhs, const GATTService& rhs) noexcept
+ inline bool operator==(const BTGattService& lhs, const BTGattService& rhs) noexcept
{ return lhs.startHandle == rhs.startHandle && lhs.endHandle == rhs.endHandle; /** unique attribute handles */ }
- inline bool operator!=(const GATTService& lhs, const GATTService& rhs) noexcept
+ inline bool operator!=(const BTGattService& lhs, const BTGattService& rhs) noexcept
{ return !(lhs == rhs); }
} // namespace direct_bt
-#endif /* GATT_SERVICE_HPP_ */
+#endif /* BT_GATT_SERVICE_HPP_ */
diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/BTManager.hpp
index e538704d..5f37b2cc 100644
--- a/api/direct_bt/DBTManager.hpp
+++ b/api/direct_bt/BTManager.hpp
@@ -40,16 +40,16 @@
#include <jau/darray.hpp>
#include <jau/cow_darray.hpp>
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "BTIoctl.hpp"
#include "OctetTypes.hpp"
#include "HCIComm.hpp"
#include "MgmtTypes.hpp"
-#include "DBTAdapter.hpp"
+#include "BTAdapter.hpp"
namespace direct_bt {
- class DBTManager; // forward
+ class BTManager; // forward
/**
* Managment Singleton runtime environment properties
@@ -58,7 +58,7 @@ namespace direct_bt {
* </p>
*/
class MgmtEnv : public jau::root_environment {
- friend class DBTManager;
+ friend class BTManager;
private:
MgmtEnv() noexcept;
@@ -160,7 +160,7 @@ namespace direct_bt {
* @see DBTManager::addChangedAdapterSetCallback()
* @see DBTManager::removeChangedAdapterSetCallback()
*/
- typedef bool (*ChangedAdapterSetFunc)(bool added, std::shared_ptr<DBTAdapter>& adapter);
+ typedef bool (*ChangedAdapterSetFunc)(bool added, std::shared_ptr<BTAdapter>& adapter);
/**
* Callback jau::FunctionDef to receive change events regarding the system's adapter set,
@@ -186,7 +186,7 @@ namespace direct_bt {
* @see DBTManager::addChangedAdapterSetCallback()
* @see DBTManager::removeChangedAdapterSetCallback()
*/
- typedef jau::FunctionDef<bool, bool, std::shared_ptr<DBTAdapter>&> ChangedAdapterSetCallback;
+ typedef jau::FunctionDef<bool, bool, std::shared_ptr<BTAdapter>&> ChangedAdapterSetCallback;
typedef jau::cow_darray<ChangedAdapterSetCallback> ChangedAdapterSetCallbackList;
/**
@@ -198,7 +198,7 @@ namespace direct_bt {
* Controlling Environment variables, see {@link MgmtEnv}.
* </p>
*/
- class DBTManager : public jau::JavaUplink {
+ class BTManager : public jau::JavaUplink {
public:
enum Defaults : int32_t {
/* BT Core Spec v5.2: Vol 3, Part F 3.2.8: Maximum length of an attribute value. */
@@ -208,7 +208,7 @@ namespace direct_bt {
static const pid_t pidSelf;
private:
- friend DBTAdapter::~DBTAdapter() noexcept;
+ friend BTAdapter::~BTAdapter() noexcept;
static std::mutex mtx_singleton;
@@ -250,7 +250,7 @@ namespace direct_bt {
ChangedAdapterSetCallbackList mgmtChangedAdapterSetCallbackList;
- typedef jau::cow_darray<std::shared_ptr<DBTAdapter>> adapters_t;
+ typedef jau::cow_darray<std::shared_ptr<BTAdapter>> adapters_t;
adapters_t adapters;
/**
@@ -274,34 +274,34 @@ namespace direct_bt {
* Instantiate singleton.
* @param btMode default {@link BTMode} when initializing new adapter. If BTMode::NONE given, MgmtEnv::DEFAULT_BTMODE is being used.
*/
- DBTManager(const BTMode defaultBTMode) noexcept;
+ BTManager(const BTMode defaultBTMode) noexcept;
- DBTManager(const DBTManager&) = delete;
- void operator=(const DBTManager&) = delete;
+ BTManager(const BTManager&) = delete;
+ void operator=(const BTManager&) = delete;
void setAdapterMode(const uint16_t dev_id, const uint8_t ssp, const uint8_t bredr, const uint8_t le) noexcept;
std::unique_ptr<AdapterInfo> initAdapter(const uint16_t dev_id, const BTMode btMode) noexcept;
- void shutdownAdapter(DBTAdapter& adapter) noexcept;
+ void shutdownAdapter(BTAdapter& adapter) noexcept;
void processAdapterAdded(std::unique_ptr<MgmtEvent> e) noexcept;
void processAdapterRemoved(std::unique_ptr<MgmtEvent> e) noexcept;
bool mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept;
bool mgmtEventAnyCB(const MgmtEvent& e) noexcept;
- std::shared_ptr<DBTAdapter> addAdapter(const AdapterInfo& ai) noexcept;
+ std::shared_ptr<BTAdapter> addAdapter(const AdapterInfo& ai) noexcept;
/**
* Removes the AdapterInfo with the given dev_id
* @return the removed instance or nullptr if not found.
*/
- std::shared_ptr<DBTAdapter> removeAdapter(const uint16_t dev_id) noexcept;
+ std::shared_ptr<BTAdapter> removeAdapter(const uint16_t dev_id) noexcept;
/**
* Removal entry for DBTAdapter::~DBTAdapter
* @param adapter pointer to the dtor'ed adapter
* @return true if contained and removed, otherwise false
*/
- bool removeAdapter(DBTAdapter* adapter) noexcept;
+ bool removeAdapter(BTAdapter* adapter) noexcept;
public:
/**
@@ -312,7 +312,7 @@ namespace direct_bt {
* @param btMode default {@link BTMode} when initializing new adapter. If BTMode::NONE given (default), MgmtEnv::DEFAULT_BTMODE is being used.
* @return singleton instance.
*/
- static DBTManager& get(const BTMode defaultBTMode=BTMode::NONE) {
+ static BTManager& get(const BTMode defaultBTMode=BTMode::NONE) {
/**
* Thread safe starting with C++11 6.7:
*
@@ -323,10 +323,10 @@ namespace direct_bt {
*
* Avoiding non-working double checked locking.
*/
- static DBTManager s(defaultBTMode);
+ static BTManager s(defaultBTMode);
return s;
}
- ~DBTManager() noexcept { close(); }
+ ~BTManager() noexcept { close(); }
void close() noexcept;
@@ -359,17 +359,17 @@ namespace direct_bt {
/**
* Returns a list of currently added DBTAdapter.
*/
- jau::darray<std::shared_ptr<DBTAdapter>> getAdapters() { return *adapters.snapshot(); }
+ jau::darray<std::shared_ptr<BTAdapter>> getAdapters() { return *adapters.snapshot(); }
/**
* Returns the DBTAdapter with the given address or nullptr if not found.
*/
- std::shared_ptr<DBTAdapter> getAdapter(const EUI48 &mac) const noexcept;
+ std::shared_ptr<BTAdapter> getAdapter(const EUI48 &mac) const noexcept;
/**
* Returns the DBTAdapter with the given dev_id, or nullptr if not found.
*/
- std::shared_ptr<DBTAdapter> getAdapter(const uint16_t dev_id) const noexcept;
+ std::shared_ptr<BTAdapter> getAdapter(const uint16_t dev_id) const noexcept;
/**
* Returns the default AdapterInfo.
@@ -378,7 +378,7 @@ namespace direct_bt {
* or function returns nullptr if none is AdapterSetting::POWERED.
* </p>
*/
- std::shared_ptr<DBTAdapter> getDefaultAdapter() const noexcept;
+ std::shared_ptr<BTAdapter> getDefaultAdapter() const noexcept;
bool setIOCapability(const uint16_t dev_id, const SMPIOCapability io_cap, SMPIOCapability& pre_io_cap) noexcept;
SMPIOCapability getIOCapability(const uint16_t dev_id) const noexcept;
diff --git a/api/direct_bt/BTTypes.hpp b/api/direct_bt/BTTypes0.hpp
index 641b5e20..58953fbe 100644
--- a/api/direct_bt/BTTypes.hpp
+++ b/api/direct_bt/BTTypes0.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef BT_TYPES_HPP_
-#define BT_TYPES_HPP_
+#ifndef BT_TYPES0_HPP_
+#define BT_TYPES0_HPP_
#include <cstring>
#include <string>
@@ -40,13 +40,13 @@
namespace direct_bt {
- class BluetoothException : public jau::RuntimeException {
+ class BTException : public jau::RuntimeException {
public:
- BluetoothException(std::string const m, const char* file, int line) noexcept
- : RuntimeException("BluetoothException", m, file, line) {}
+ BTException(std::string const m, const char* file, int line) noexcept
+ : RuntimeException("BTException", m, file, line) {}
- BluetoothException(const char *m, const char* file, int line) noexcept
- : RuntimeException("BluetoothException", m, file, line) {}
+ BTException(const char *m, const char* file, int line) noexcept
+ : RuntimeException("BTException", m, file, line) {}
};
@@ -755,4 +755,4 @@ namespace direct_bt {
} // namespace direct_bt
-#endif /* BT_TYPES_HPP_ */
+#endif /* BT_TYPES0_HPP_ */
diff --git a/api/direct_bt/DBTTypes.hpp b/api/direct_bt/BTTypes1.hpp
index 5a81360e..e2ea00f9 100644
--- a/api/direct_bt/DBTTypes.hpp
+++ b/api/direct_bt/BTTypes1.hpp
@@ -23,8 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef DBT_TYPES_HPP_
-#define DBT_TYPES_HPP_
+#ifndef BT_TYPES1_HPP_
+#define BT_TYPES1_HPP_
#include <mutex>
#include <atomic>
@@ -34,28 +34,27 @@
#include "UUID.hpp"
#include "BTAddress.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
-#define JAVA_DBT_PACKAGE "direct_bt/tinyb/"
-#define JAVA_MAIN_PACKAGE "org/tinyb"
-#define JAVA_HCI_PACKAGE "tinyb/hci"
+#define JAVA_DBT_PACKAGE "jau/direct_bt/"
+#define JAVA_MAIN_PACKAGE "org/direct_bt"
namespace direct_bt {
- class DBTAdapter; // forward
- class DBTDevice; // forward
+ class BTAdapter; // forward
+ class BTDevice; // forward
- class DBTObject : public jau::JavaUplink
+ class BTObject : public jau::JavaUplink
{
protected:
std::atomic_bool valid;
- DBTObject() noexcept : valid(true) {}
+ BTObject() noexcept : valid(true) {}
public:
virtual std::string toString() const noexcept override { return "DBTObject["+aptrHexString(this)+"]"; }
- virtual ~DBTObject() noexcept {
+ virtual ~BTObject() noexcept {
valid = false;
}
@@ -101,8 +100,8 @@ namespace direct_bt {
class NameAndShortName
{
- friend class DBTManager; // top manager
- friend class DBTAdapter; // direct manager
+ friend class BTManager; // top manager
+ friend class BTAdapter; // direct manager
private:
std::string name;
@@ -182,8 +181,8 @@ namespace direct_bt {
class AdapterInfo
{
- friend class DBTManager; // top manager
- friend class DBTAdapter; // direct manager
+ friend class BTManager; // top manager
+ friend class BTAdapter; // direct manager
public:
const uint16_t dev_id;
@@ -278,4 +277,4 @@ namespace direct_bt {
} // namespace direct_bt
-#endif /* DBT_TYPES_HPP_ */
+#endif /* BT_TYPES1_HPP_ */
diff --git a/api/direct_bt/DirectBT.hpp b/api/direct_bt/DirectBT.hpp
index 3c6f2367..98755c49 100644
--- a/api/direct_bt/DirectBT.hpp
+++ b/api/direct_bt/DirectBT.hpp
@@ -40,12 +40,13 @@
#include <jau/darray.hpp>
-#include "DBTTypes.hpp"
+#include "BTTypes0.hpp"
-#include "DBTDevice.hpp"
+#include "BTDevice.hpp"
-#include "DBTAdapter.hpp"
+#include "BTAdapter.hpp"
+
+#include "BTManager.hpp"
-#include "DBTManager.hpp"
#endif /* DIRECTBT_HPP_ */
diff --git a/api/direct_bt/GATTNumbers.hpp b/api/direct_bt/GattNumbers.hpp
index 8b23ce38..97726ff3 100644
--- a/api/direct_bt/GATTNumbers.hpp
+++ b/api/direct_bt/GattNumbers.hpp
@@ -33,13 +33,13 @@
#include "UUID.hpp"
#include "OctetTypes.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "ieee11073/DataTypes.hpp"
/**
* - - - - - - - - - - - - - - -
*
- * GATTNumbers.hpp Module for Higher level GATT value and service types like GattServiceType, GattCharacteristicType,
+ * GattNumbers.hpp Module for Higher level GATT value and service types like GattServiceType, GattCharacteristicType,
* GattCharacteristicProperty, GattRequirementSpec .. and finally GattServiceCharacteristic.
*
* - https://www.bluetooth.com/specifications/gatt/services/
diff --git a/api/direct_bt/GATTTypes.hpp b/api/direct_bt/GattTypes.hpp
index 96c8f372..6b681c81 100644
--- a/api/direct_bt/GATTTypes.hpp
+++ b/api/direct_bt/GattTypes.hpp
@@ -37,14 +37,14 @@
#include <jau/java_uplink.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "OctetTypes.hpp"
#include "ATTPDUTypes.hpp"
/* Only to resolve high level service and characteristic names */
-#include "GATTNumbers.hpp"
+#include "GattNumbers.hpp"
-#include "GATTService.hpp"
+#include "BTGattService.hpp"
/**
* - - - - - - - - - - - - - - -
diff --git a/api/direct_bt/HCIComm.hpp b/api/direct_bt/HCIComm.hpp
index 2d308986..8929567d 100644
--- a/api/direct_bt/HCIComm.hpp
+++ b/api/direct_bt/HCIComm.hpp
@@ -32,7 +32,7 @@
#include <memory>
#include <mutex>
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "BTIoctl.hpp"
#include "HCIIoctl.hpp"
#include "HCITypes.hpp"
diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp
index eca18053..2fe37b48 100644
--- a/api/direct_bt/HCIHandler.hpp
+++ b/api/direct_bt/HCIHandler.hpp
@@ -39,7 +39,7 @@
#include <jau/ringbuffer.hpp>
#include <jau/java_uplink.hpp>
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "BTIoctl.hpp"
#include "OctetTypes.hpp"
#include "HCIComm.hpp"
@@ -469,7 +469,7 @@ namespace direct_bt {
* Hence this parameter influences the responsiveness on a link loss.
* A too small number may render the link too unstable, it should be at least 6 times of the connection interval.
* <br>
- * To detect a link loss one can also send a regular ping to check whether the peripheral is still responding, see GATTHandler::ping().
+ * To detect a link loss one can also send a regular ping to check whether the peripheral is still responding, see BTGattHandler::ping().
* </p>
* <p>
* Implementation tries to mitigate HCIStatusCode::COMMAND_DISALLOWED failure due to any pending connection commands,
@@ -622,5 +622,5 @@ namespace std
}
#endif
-#endif /* DBT_HANDLER_HPP_ */
+#endif /* HCI_HANDLER_HPP_ */
diff --git a/api/direct_bt/HCITypes.hpp b/api/direct_bt/HCITypes.hpp
index 813b2fa0..4e9a7c7c 100644
--- a/api/direct_bt/HCITypes.hpp
+++ b/api/direct_bt/HCITypes.hpp
@@ -35,7 +35,7 @@
#include <jau/basic_types.hpp>
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "BTIoctl.hpp"
#include "OctetTypes.hpp"
#include "HCIIoctl.hpp"
diff --git a/api/direct_bt/L2CAPComm.hpp b/api/direct_bt/L2CAPComm.hpp
index 01dbbefa..c92731eb 100644
--- a/api/direct_bt/L2CAPComm.hpp
+++ b/api/direct_bt/L2CAPComm.hpp
@@ -37,7 +37,7 @@
#include <jau/environment.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
/**
* - - - - - - - - - - - - - - -
@@ -48,7 +48,7 @@
*/
namespace direct_bt {
- class DBTDevice; // forward
+ class BTDevice; // forward
/**
* L2CAP Singleton runtime environment properties
@@ -164,7 +164,7 @@ namespace direct_bt {
* @param sec_level sec_level < BTSecurityLevel::NONE will not set security level
* @return true if connection has been established, otherwise false
*/
- bool open(const DBTDevice& device, const BTSecurityLevel sec_level=BTSecurityLevel::NONE);
+ bool open(const BTDevice& device, const BTSecurityLevel sec_level=BTSecurityLevel::NONE);
bool isOpen() const { return is_open; }
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index f8d96dd1..dcee6a18 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -36,12 +36,12 @@
#include <jau/cow_darray.hpp>
#include <jau/packed_attribute.hpp>
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "BTIoctl.hpp"
#include "OctetTypes.hpp"
#include "HCIComm.hpp"
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
#include "SMPTypes.hpp"
namespace direct_bt {
diff --git a/api/direct_bt/SMPHandler.hpp b/api/direct_bt/SMPHandler.hpp
index 09e4e590..c2140d6f 100644
--- a/api/direct_bt/SMPHandler.hpp
+++ b/api/direct_bt/SMPHandler.hpp
@@ -41,7 +41,7 @@
#include <jau/cow_darray.hpp>
#include "UUID.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
#include "L2CAPComm.hpp"
#include "SMPTypes.hpp"
@@ -168,7 +168,7 @@ namespace direct_bt {
const SMPEnv & env;
/** GATTHandle's device weak back-reference */
- std::weak_ptr<DBTDevice> wbr_device;
+ std::weak_ptr<BTDevice> wbr_device;
const std::string deviceString;
std::recursive_mutex mtx_command;
@@ -200,7 +200,7 @@ namespace direct_bt {
void clearAllCallbacks() noexcept;
public:
- SMPHandler(const std::shared_ptr<DBTDevice> & device) noexcept;
+ SMPHandler(const std::shared_ptr<BTDevice> & device) noexcept;
SMPHandler(const SMPHandler&) = delete;
void operator=(const SMPHandler&) = delete;
@@ -208,8 +208,8 @@ namespace direct_bt {
/** Destructor closing this instance including L2CAP channel, see {@link #disconnect()}. */
~SMPHandler() noexcept;
- std::shared_ptr<DBTDevice> getDeviceUnchecked() const noexcept { return wbr_device.lock(); }
- std::shared_ptr<DBTDevice> getDeviceChecked() const;
+ std::shared_ptr<BTDevice> getDeviceUnchecked() const noexcept { return wbr_device.lock(); }
+ std::shared_ptr<BTDevice> getDeviceChecked() const;
bool isConnected() const noexcept { return is_connected ; }
bool hasIOError() const noexcept { return has_ioerror; }
diff --git a/api/direct_bt/SMPTypes.hpp b/api/direct_bt/SMPTypes.hpp
index 3da5fc74..1a332b18 100644
--- a/api/direct_bt/SMPTypes.hpp
+++ b/api/direct_bt/SMPTypes.hpp
@@ -36,7 +36,7 @@
#include <jau/basic_types.hpp>
#include "OctetTypes.hpp"
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
/**
* - - - - - - - - - - - - - - -
diff --git a/examples/direct_bt_scanner00/dbt_scanner00.cpp b/examples/direct_bt_scanner00/dbt_scanner00.cpp
index 4b3fc30a..28c6d544 100644
--- a/examples/direct_bt_scanner00/dbt_scanner00.cpp
+++ b/examples/direct_bt_scanner00/dbt_scanner00.cpp
@@ -39,7 +39,7 @@ using namespace jau;
/**
* This C++ direct_bt scanner example is a TinyB backward compatible and not fully event driven.
* It uses a more simple high-level approach via semantic GATT types (Service, Characteristic, ..)
- * without bothering with fine implementation details of GATTHandler.
+ * without bothering with fine implementation details of BTGattHandler.
* <p>
* For a more technical and low-level approach see dbt_scanner01.cpp!
* </p>
@@ -48,29 +48,29 @@ using namespace jau;
* </p>
*/
-std::shared_ptr<DBTDevice> deviceFound = nullptr;
+std::shared_ptr<BTDevice> deviceFound = nullptr;
std::mutex mtxDeviceFound;
std::condition_variable cvDeviceFound;
class MyAdapterStatusListener : public AdapterStatusListener {
- void adapterSettingsChanged(DBTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
+ void adapterSettingsChanged(BTAdapter &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",
getAdapterSettingMaskString(oldmask).c_str(),
getAdapterSettingMaskString(newmask).c_str(),
getAdapterSettingMaskString(changedmask).c_str());
- fprintf(stderr, "Status DBTAdapter:\n");
+ fprintf(stderr, "Status BTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
}
- void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
+ void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
fprintf(stderr, "****** DISCOVERING: meta %s, changed[%s, enabled %d, keepAlive %d]: %s\n",
getScanTypeString(currentMeta).c_str(), getScanTypeString(changedType).c_str(), changedEnabled, keepAlive, a.toString().c_str());
(void)timestamp;
}
- bool deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ bool deviceFound(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
fprintf(stderr, "****** FOUND__: %s\n", device->toString(true).c_str());
fprintf(stderr, "Status Adapter:\n");
fprintf(stderr, "%s\n", device->getAdapter().toString().c_str());
@@ -82,25 +82,25 @@ class MyAdapterStatusListener : public AdapterStatusListener {
}
(void)timestamp;
}
- void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
+ void deviceUpdated(std::shared_ptr<BTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
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 uint16_t handle, const uint64_t timestamp) override {
+ void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override {
fprintf(stderr, "****** CONNECTED: %s\n", device->toString(true).c_str());
(void)handle;
(void)timestamp;
}
- void devicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
+ void devicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
fprintf(stderr, "****** PAIRING STATE: state %s, mode %s, %s\n",
getSMPPairingStateString(state).c_str(), getPairingModeString(mode).c_str(), device->toString().c_str());
(void)timestamp;
}
- void deviceReady(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ void deviceReady(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
fprintf(stderr, "****** READY: %s\n", device->toString().c_str());
(void)timestamp;
}
- void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
+ void deviceDisconnected(std::shared_ptr<BTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
fprintf(stderr, "****** DISCONNECTED: Reason 0x%X (%s), old handle %s: %s\n",
static_cast<uint8_t>(reason), getHCIStatusCodeString(reason).c_str(),
uint16HexString(handle).c_str(), device->toString(true).c_str());
@@ -115,14 +115,14 @@ class MyAdapterStatusListener : public AdapterStatusListener {
static const uuid16_t _TEMPERATURE_MEASUREMENT(GattCharacteristicType::TEMPERATURE_MEASUREMENT);
-class MyGATTEventListener : public AssociatedGATTCharacteristicListener {
+class MyGATTEventListener : public AssociatedBTGattCharListener {
public:
- MyGATTEventListener(const GATTCharacteristic * characteristicMatch)
- : AssociatedGATTCharacteristicListener(characteristicMatch) {}
+ MyGATTEventListener(const BTGattChar * characteristicMatch)
+ : AssociatedBTGattCharListener(characteristicMatch) {}
- void notificationReceived(GATTCharacteristicRef charDecl, const TROOctets& charValue, const uint64_t timestamp) override {
- const std::shared_ptr<DBTDevice> dev = charDecl->getDeviceChecked();
+ void notificationReceived(BTGattCharRef charDecl, const TROOctets& charValue, const uint64_t timestamp) override {
+ const std::shared_ptr<BTDevice> dev = charDecl->getDeviceChecked();
const uint64_t tR = getCurrentMilliseconds();
fprintf(stderr, "****** GATT Notify (td %" PRIu64 " ms, dev-discovered %" PRIu64 " ms): From %s\n",
(tR-timestamp), (tR-dev->ts_creation), dev->toString().c_str());
@@ -132,11 +132,11 @@ class MyGATTEventListener : public AssociatedGATTCharacteristicListener {
fprintf(stderr, "****** rawv %s\n", charValue.toString().c_str());
}
- void indicationReceived(GATTCharacteristicRef charDecl,
+ void indicationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp,
const bool confirmationSent) override
{
- const std::shared_ptr<DBTDevice> dev = charDecl->getDeviceChecked();
+ const std::shared_ptr<BTDevice> dev = charDecl->getDeviceChecked();
const uint64_t tR = getCurrentMilliseconds();
fprintf(stderr, "****** GATT Indication (confirmed %d, td(msg %" PRIu64 " ms, dev-discovered %" PRIu64 " ms): From %s\n",
confirmationSent, (tR-timestamp), (tR-dev->ts_creation), dev->toString().c_str());
@@ -194,9 +194,9 @@ int main(int argc, char *argv[])
fprintf(stderr, "Press ENTER to continue\n");
getchar();
}
- DBTManager & mngr = DBTManager::get();
+ BTManager & mngr = BTManager::get();
- std::shared_ptr<DBTAdapter> adapter = mngr.getAdapter(dev_id);
+ std::shared_ptr<BTAdapter> adapter = mngr.getAdapter(dev_id);
if( nullptr == adapter ) {
fprintf(stderr, "adapter dev_id %d not available.\n", dev_id);
exit(1);
@@ -222,7 +222,7 @@ int main(int argc, char *argv[])
goto out;
}
- std::shared_ptr<DBTDevice> device = nullptr;
+ std::shared_ptr<BTDevice> device = nullptr;
{
std::unique_lock<std::mutex> lockRead(mtxDeviceFound); // RAII-style acquire and relinquish via destructor
while( nullptr == device ) { // FIXME deadlock, waiting forever!
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
//
// GATT Service Processing
//
- jau::darray<GATTServiceRef> primServices = device->getGATTServices(); // implicit GATT connect...
+ jau::darray<BTGattServiceRef> primServices = device->getGattServices(); // implicit GATT connect...
if( primServices.size() > 0 ) {
const uint64_t t5 = getCurrentMilliseconds();
{
@@ -273,12 +273,12 @@ int main(int argc, char *argv[])
" total %" PRIu64 " ms\n\n",
td15, (t5 - device->getCreationTimestamp()), td05);
}
- std::shared_ptr<GattGenericAccessSvc> ga = device->getGATTGenericAccess();
+ std::shared_ptr<GattGenericAccessSvc> ga = device->getGattGenericAccess();
if( nullptr != ga ) {
fprintf(stderr, " GenericAccess: %s\n\n", ga->toString().c_str());
}
{
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr != gatt && gatt->isConnected() ) {
std::shared_ptr<GattDeviceInformationSvc> di = gatt->getDeviceInformation(primServices);
if( nullptr != di ) {
@@ -288,15 +288,15 @@ int main(int argc, char *argv[])
}
for(size_t i=0; i<primServices.size(); i++) {
- GATTService & primService = *primServices.at(i);
+ BTGattService & primService = *primServices.at(i);
fprintf(stderr, " [%2.2d] Service %s\n", (int)i, primService.toString().c_str());
fprintf(stderr, " [%2.2d] Service Characteristics\n", (int)i);
- jau::darray<GATTCharacteristicRef> & serviceCharacteristics = primService.characteristicList;
+ jau::darray<BTGattCharRef> & serviceCharacteristics = primService.characteristicList;
for(size_t j=0; j<serviceCharacteristics.size(); j++) {
- GATTCharacteristic & serviceChar = *serviceCharacteristics.at(j);
+ BTGattChar & serviceChar = *serviceCharacteristics.at(j);
fprintf(stderr, " [%2.2d.%2.2d] Decla: %s\n", (int)i, (int)j, serviceChar.toString().c_str());
- if( serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Read) ) {
- POctets value(GATTHandler::number(GATTHandler::Defaults::MAX_ATT_MTU), 0);
+ if( serviceChar.hasProperties(BTGattChar::PropertyBitVal::Read) ) {
+ POctets value(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0);
if( serviceChar.readValue(value) ) {
std::string sval = dfa_utf8_decode(value.get_ptr(), value.getSize());
fprintf(stderr, " [%2.2d.%2.2d] Value: %s ('%s')\n", (int)i, (int)j, value.toString().c_str(), sval.c_str());
@@ -307,7 +307,7 @@ int main(int argc, char *argv[])
fprintf(stderr, " [%2.2d.%2.2d] Config Notification(%d), Indication(%d): Result %d\n",
(int)i, (int)j, cccdEnableResult[0], cccdEnableResult[1], cccdRet);
if( cccdRet ) {
- serviceChar.addCharacteristicListener( std::shared_ptr<GATTCharacteristicListener>( new MyGATTEventListener(&serviceChar) ) );
+ serviceChar.addCharListener( std::shared_ptr<BTGattCharListener>( new MyGATTEventListener(&serviceChar) ) );
}
}
}
diff --git a/examples/direct_bt_scanner01/dbt_scanner01.cpp b/examples/direct_bt_scanner01/dbt_scanner01.cpp
index 7e3a8db7..75943e8c 100644
--- a/examples/direct_bt_scanner01/dbt_scanner01.cpp
+++ b/examples/direct_bt_scanner01/dbt_scanner01.cpp
@@ -38,7 +38,7 @@ using namespace jau;
/**
* This C++ direct_bt scanner example is a TinyB backward compatible and not fully event driven.
- * It uses a more fine grained control via GATTHandler.
+ * It uses a more fine grained control via BTGattHandler
* <p>
* For a more user convenient and readable approach see dbt_scanner00.cpp or dbt_scanner10.cpp!
* </p>
@@ -47,29 +47,29 @@ using namespace jau;
* </p>
*/
-std::shared_ptr<DBTDevice> deviceFound = nullptr;
+std::shared_ptr<BTDevice> deviceFound = nullptr;
std::mutex mtxDeviceFound;
std::condition_variable cvDeviceFound;
class MyAdapterStatusListener : public AdapterStatusListener {
- void adapterSettingsChanged(DBTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
+ void adapterSettingsChanged(BTAdapter &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",
getAdapterSettingMaskString(oldmask).c_str(),
getAdapterSettingMaskString(newmask).c_str(),
getAdapterSettingMaskString(changedmask).c_str());
- fprintf(stderr, "Status DBTAdapter:\n");
+ fprintf(stderr, "Status BTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
}
- void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
+ void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
fprintf(stderr, "****** DISCOVERING: meta %s, changed[%s, enabled %d, keepAlive %d]: %s\n",
getScanTypeString(currentMeta).c_str(), getScanTypeString(changedType).c_str(), changedEnabled, keepAlive, a.toString().c_str());
(void)timestamp;
}
- bool deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ bool deviceFound(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
fprintf(stderr, "****** FOUND__: %s\n", device->toString(true).c_str());
fprintf(stderr, "Status Adapter:\n");
fprintf(stderr, "%s\n", device->getAdapter().toString().c_str());
@@ -81,25 +81,25 @@ class MyAdapterStatusListener : public AdapterStatusListener {
}
(void)timestamp;
}
- void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
+ void deviceUpdated(std::shared_ptr<BTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
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 uint16_t handle, const uint64_t timestamp) override {
+ void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override {
fprintf(stderr, "****** CONNECTED: %s\n", device->toString(true).c_str());
(void)handle;
(void)timestamp;
}
- void devicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
+ void devicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
fprintf(stderr, "****** PAIRING STATE: state %s, mode %s, %s\n",
getSMPPairingStateString(state).c_str(), getPairingModeString(mode).c_str(), device->toString().c_str());
(void)timestamp;
}
- void deviceReady(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ void deviceReady(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
fprintf(stderr, "****** READY: %s\n", device->toString().c_str());
(void)timestamp;
}
- void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
+ void deviceDisconnected(std::shared_ptr<BTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
fprintf(stderr, "****** DISCONNECTED: Reason 0x%X (%s), old handle %s: %s\n",
static_cast<uint8_t>(reason), getHCIStatusCodeString(reason).c_str(),
uint16HexString(handle).c_str(), device->toString(true).c_str());
@@ -114,11 +114,11 @@ class MyAdapterStatusListener : public AdapterStatusListener {
static const uuid16_t _TEMPERATURE_MEASUREMENT(GattCharacteristicType::TEMPERATURE_MEASUREMENT);
-class MyGATTEventListener : public GATTCharacteristicListener {
+class MyGattCharListener : public BTGattCharListener {
- void notificationReceived(GATTCharacteristicRef charDecl,
+ void notificationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp) override {
- const std::shared_ptr<DBTDevice> dev = charDecl->getDeviceChecked();
+ const std::shared_ptr<BTDevice> dev = charDecl->getDeviceChecked();
const uint64_t tR = getCurrentMilliseconds();
fprintf(stderr, "****** GATT Notify (td %" PRIu64 " ms, dev-discovered %" PRIu64 " ms): From %s\n",
(tR-timestamp), (tR-dev->ts_creation), dev->toString().c_str());
@@ -128,11 +128,11 @@ class MyGATTEventListener : public GATTCharacteristicListener {
fprintf(stderr, "****** rawv %s\n", charValue.toString().c_str());
}
- void indicationReceived(GATTCharacteristicRef charDecl,
+ void indicationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp,
const bool confirmationSent) override
{
- const std::shared_ptr<DBTDevice> dev = charDecl->getDeviceChecked();
+ const std::shared_ptr<BTDevice> dev = charDecl->getDeviceChecked();
const uint64_t tR = getCurrentMilliseconds();
fprintf(stderr, "****** GATT Indication (confirmed %d, td(msg %" PRIu64 " ms, dev-discovered %" PRIu64 " ms): From %s\n",
confirmationSent, (tR-timestamp), (tR-dev->ts_creation), dev->toString().c_str());
@@ -192,9 +192,9 @@ int main(int argc, char *argv[])
fprintf(stderr, "Press ENTER to continue\n");
getchar();
}
- DBTManager & mngr = DBTManager::get();
+ BTManager & mngr = BTManager::get();
- std::shared_ptr<DBTAdapter> adapter = mngr.getAdapter(dev_id);
+ std::shared_ptr<BTAdapter> adapter = mngr.getAdapter(dev_id);
if( nullptr == adapter ) {
fprintf(stderr, "adapter dev_id %d not available.\n", dev_id);
exit(1);
@@ -220,7 +220,7 @@ int main(int argc, char *argv[])
goto out;
}
- std::shared_ptr<DBTDevice> device = nullptr;
+ std::shared_ptr<BTDevice> device = nullptr;
{
std::unique_lock<std::mutex> lockRead(mtxDeviceFound); // RAII-style acquire and relinquish via destructor
while( nullptr == device ) { // FIXME deadlock, waiting forever!
@@ -269,13 +269,13 @@ int main(int argc, char *argv[])
//
const uint64_t t4 = getCurrentMilliseconds();
// let's check further for full GATT
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr != gatt ) {
fprintf(stderr, "GATT usedMTU %d (server) -> %d (used)\n", gatt->getServerMTU(), gatt->getUsedMTU());
- gatt->addCharacteristicListener( std::shared_ptr<GATTCharacteristicListener>( new MyGATTEventListener() ) );
+ gatt->addCharListener( std::shared_ptr<BTGattCharListener>( new MyGattCharListener() ) );
- jau::darray<GATTServiceRef> & primServices = gatt->discoverCompletePrimaryServices(gatt);
+ jau::darray<BTGattServiceRef> & primServices = gatt->discoverCompletePrimaryServices(gatt);
const uint64_t t5 = getCurrentMilliseconds();
{
const uint64_t td45 = t5 - t4; // connect -> gatt complete
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
" total %" PRIu64 " ms\n\n",
td45, (t5 - device->getCreationTimestamp()), td05);
}
- std::shared_ptr<GattGenericAccessSvc> ga = device->getGATTGenericAccess();
+ std::shared_ptr<GattGenericAccessSvc> ga = device->getGattGenericAccess();
if( nullptr != ga ) {
fprintf(stderr, " GenericAccess: %s\n\n", ga->toString().c_str());
}
@@ -299,23 +299,23 @@ int main(int argc, char *argv[])
}
for(size_t i=0; i<primServices.size() && gatt->isConnected(); i++) {
- GATTService & primService = *primServices.at(i);
+ BTGattService & primService = *primServices.at(i);
fprintf(stderr, " [%2.2d] Service %s\n", (int)i, primService.toString().c_str());
fprintf(stderr, " [%2.2d] Service Characteristics\n", (int)i);
- jau::darray<GATTCharacteristicRef> & serviceCharacteristics = primService.characteristicList;
+ jau::darray<BTGattCharRef> & serviceCharacteristics = primService.characteristicList;
for(size_t j=0; j<serviceCharacteristics.size() && gatt->isConnected(); j++) {
- GATTCharacteristic & serviceChar = *serviceCharacteristics.at(j);
+ BTGattChar & serviceChar = *serviceCharacteristics.at(j);
fprintf(stderr, " [%2.2d.%2.2d] Decla: %s\n", (int)i, (int)j, serviceChar.toString().c_str());
- if( serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Read) ) {
- POctets value(GATTHandler::number(GATTHandler::Defaults::MAX_ATT_MTU), 0);
+ if( serviceChar.hasProperties(BTGattChar::PropertyBitVal::Read) ) {
+ POctets value(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0);
if( gatt->readCharacteristicValue(serviceChar, value) ) {
fprintf(stderr, " [%2.2d.%2.2d] Value: %s\n", (int)i, (int)j, value.toString().c_str());
}
}
- GATTDescriptorRef cccd = serviceChar.getClientCharacteristicConfig();
+ BTGattDescRef cccd = serviceChar.getClientCharConfig();
if( nullptr != cccd ) {
- const bool enableNotification = serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Notify);
- const bool enableIndication = serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Indicate);
+ const bool enableNotification = serviceChar.hasProperties(BTGattChar::PropertyBitVal::Notify);
+ const bool enableIndication = serviceChar.hasProperties(BTGattChar::PropertyBitVal::Indicate);
if( enableNotification || enableIndication ) {
bool res = gatt->configNotificationIndication(*cccd, enableNotification, enableIndication);
fprintf(stderr, " [%2.2d.%2.2d] Config Notification(%d), Indication(%d): Result %d\n",
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index 4a2245b3..891febf3 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -90,13 +90,13 @@ static int pairing_passkey = NO_PASSKEY;
static BTSecurityLevel sec_level = BTSecurityLevel::UNSET;
static SMPIOCapability io_capabilities = SMPIOCapability::UNSET;
-static void connectDiscoveredDevice(std::shared_ptr<DBTDevice> device);
+static void connectDiscoveredDevice(std::shared_ptr<BTDevice> device);
-static void processReadyDevice(std::shared_ptr<DBTDevice> device);
+static void processReadyDevice(std::shared_ptr<BTDevice> device);
-static void removeDevice(std::shared_ptr<DBTDevice> device);
-static void resetAdapter(DBTAdapter *a, int mode);
-static bool startDiscovery(DBTAdapter *a, std::string msg);
+static void removeDevice(std::shared_ptr<BTDevice> device);
+static void resetAdapter(BTAdapter *a, int mode);
+static bool startDiscovery(BTAdapter *a, std::string msg);
static std::unordered_set<BDAddressAndType> devicesInProcessing;
@@ -248,7 +248,7 @@ struct MySignatureResolvingKeyInfo {
class MyAdapterStatusListener : public AdapterStatusListener {
- void adapterSettingsChanged(DBTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
+ void adapterSettingsChanged(BTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
const bool initialSetting = AdapterSetting::NONE == oldmask;
if( initialSetting ) {
@@ -258,7 +258,7 @@ class MyAdapterStatusListener : public AdapterStatusListener {
fprintf(stderr, "****** SETTINGS_CHANGED: %s -> %s, changed %s\n", getAdapterSettingMaskString(oldmask).c_str(),
getAdapterSettingMaskString(newmask).c_str(), getAdapterSettingMaskString(changedmask).c_str());
}
- fprintf(stderr, "Status DBTAdapter:\n");
+ fprintf(stderr, "Status BTAdapter:\n");
fprintf(stderr, "%s\n", a.toString().c_str());
(void)timestamp;
@@ -271,13 +271,13 @@ class MyAdapterStatusListener : public AdapterStatusListener {
}
}
- void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
+ void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
fprintf(stderr, "****** DISCOVERING: meta %s, changed[%s, enabled %d, keepAlive %d]: %s\n",
getScanTypeString(currentMeta).c_str(), getScanTypeString(changedType).c_str(), changedEnabled, keepAlive, a.toString().c_str());
(void)timestamp;
}
- bool deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ bool deviceFound(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
(void)timestamp;
if( BDAddressType::BDADDR_LE_PUBLIC != device->getAddressAndType().type
@@ -308,20 +308,20 @@ class MyAdapterStatusListener : public AdapterStatusListener {
}
}
- void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
+ void deviceUpdated(std::shared_ptr<BTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
if( SHOW_UPDATE_EVENTS ) {
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 uint16_t handle, const uint64_t timestamp) override {
+ void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override {
fprintf(stderr, "****** CONNECTED: %s\n", device->toString(true).c_str());
(void)handle;
(void)timestamp;
}
- void devicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
+ void devicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
fprintf(stderr, "****** PAIRING STATE: state %s, mode %s, %s\n",
getSMPPairingStateString(state).c_str(), getPairingModeString(mode).c_str(), device->toString().c_str());
(void)timestamp;
@@ -343,16 +343,16 @@ class MyAdapterStatusListener : public AdapterStatusListener {
break;
case SMPPairingState::PASSKEY_EXPECTED: {
if( pairing_passkey != NO_PASSKEY ) {
- std::thread dc(&DBTDevice::setPairingPasskey, device, static_cast<uint32_t>(pairing_passkey)); // @suppress("Invalid arguments")
+ std::thread dc(&BTDevice::setPairingPasskey, device, static_cast<uint32_t>(pairing_passkey)); // @suppress("Invalid arguments")
dc.detach();
} /* else {
- std::thread dc(&DBTDevice::setPairingPasskeyNegative, device); // @suppress("Invalid arguments")
+ std::thread dc(&BTDevice::setPairingPasskeyNegative, device); // @suppress("Invalid arguments")
dc.detach();
} */
// next: KEY_DISTRIBUTION or FAILED
} break;
case SMPPairingState::NUMERIC_COMPARE_EXPECTED: {
- std::thread dc(&DBTDevice::setPairingNumericComparison, device, true); // @suppress("Invalid arguments")
+ std::thread dc(&BTDevice::setPairingNumericComparison, device, true); // @suppress("Invalid arguments")
dc.detach();
// next: KEY_DISTRIBUTION or FAILED
} break;
@@ -370,7 +370,7 @@ class MyAdapterStatusListener : public AdapterStatusListener {
}
}
- void deviceReady(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ void deviceReady(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
(void)timestamp;
if( !isDeviceProcessing( device->getAddressAndType() ) &&
( waitForDevices.empty() ||
@@ -389,7 +389,7 @@ class MyAdapterStatusListener : public AdapterStatusListener {
}
}
- void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
+ void deviceDisconnected(std::shared_ptr<BTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
fprintf(stderr, "****** DISCONNECTED: Reason 0x%X (%s), old handle %s: %s\n",
static_cast<uint8_t>(reason), getHCIStatusCodeString(reason).c_str(),
uint16HexString(handle).c_str(), device->toString(true).c_str());
@@ -415,14 +415,14 @@ class MyAdapterStatusListener : public AdapterStatusListener {
static const uuid16_t _TEMPERATURE_MEASUREMENT(GattCharacteristicType::TEMPERATURE_MEASUREMENT);
-class MyGATTEventListener : public AssociatedGATTCharacteristicListener {
+class MyGATTEventListener : public AssociatedBTGattCharListener {
public:
- MyGATTEventListener(const GATTCharacteristic * characteristicMatch)
- : AssociatedGATTCharacteristicListener(characteristicMatch) {}
+ MyGATTEventListener(const BTGattChar * characteristicMatch)
+ : AssociatedBTGattCharListener(characteristicMatch) {}
- void notificationReceived(GATTCharacteristicRef charDecl, const TROOctets& char_value, const uint64_t timestamp) override {
- const std::shared_ptr<DBTDevice> dev = charDecl->getDeviceChecked();
+ void notificationReceived(BTGattCharRef charDecl, const TROOctets& char_value, const uint64_t timestamp) override {
+ const std::shared_ptr<BTDevice> dev = charDecl->getDeviceChecked();
const uint64_t tR = getCurrentMilliseconds();
fprintf(stderr, "****** GATT Notify (td %" PRIu64 " ms, dev-discovered %" PRIu64 " ms): From %s\n",
(tR-timestamp), (tR-dev->getLastDiscoveryTimestamp()), dev->toString().c_str());
@@ -432,11 +432,11 @@ class MyGATTEventListener : public AssociatedGATTCharacteristicListener {
fprintf(stderr, "****** rawv %s\n", char_value.toString().c_str());
}
- void indicationReceived(GATTCharacteristicRef charDecl,
+ void indicationReceived(BTGattCharRef charDecl,
const TROOctets& char_value, const uint64_t timestamp,
const bool confirmationSent) override
{
- const std::shared_ptr<DBTDevice> dev = charDecl->getDeviceChecked();
+ const std::shared_ptr<BTDevice> dev = charDecl->getDeviceChecked();
const uint64_t tR = getCurrentMilliseconds();
fprintf(stderr, "****** GATT Indication (confirmed %d, td(msg %" PRIu64 " ms, dev-discovered %" PRIu64 " ms): From %s\n",
confirmationSent, (tR-timestamp), (tR-dev->getLastDiscoveryTimestamp()), dev->toString().c_str());
@@ -453,7 +453,7 @@ class MyGATTEventListener : public AssociatedGATTCharacteristicListener {
}
};
-static void connectDiscoveredDevice(std::shared_ptr<DBTDevice> device) {
+static void connectDiscoveredDevice(std::shared_ptr<BTDevice> device) {
fprintf(stderr, "****** Connecting Device: Start %s\n", device->toString().c_str());
if( UNPAIR_DEVICE_PRE ) {
@@ -491,7 +491,7 @@ static void connectDiscoveredDevice(std::shared_ptr<DBTDevice> device) {
}
}
-static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
+static void processReadyDevice(std::shared_ptr<BTDevice> device) {
fprintf(stderr, "****** Processing Ready Device: Start %s\n", device->toString().c_str());
device->getAdapter().stopDiscovery(); // make sure for pending connections on failed connect*(..) command
const uint64_t t1 = getCurrentMilliseconds();
@@ -536,7 +536,7 @@ static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
device->getAdapter().printSharedPtrListOfDevices();
}
try {
- jau::darray<GATTServiceRef> primServices = device->getGATTServices();
+ jau::darray<BTGattServiceRef> primServices = device->getGattServices();
if( 0 == primServices.size() ) {
fprintf(stderr, "****** Processing Ready Device: getServices() failed %s\n", device->toString().c_str());
goto exit;
@@ -544,7 +544,7 @@ static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
fprintf(stderr, " **** JAU C-01 Service Count %d\n", (int)primServices.size());
int _i=0;
for(auto it = primServices.begin(); it != primServices.end(); it++) { // JAU FIXME
- GATTServiceRef primSrv = *it;
+ BTGattServiceRef primSrv = *it;
fprintf(stderr, " [%2.2d] JAU C-01 Service %s\n", (int)_i, primSrv->toString().c_str());
++_i;
}
@@ -566,15 +566,15 @@ static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
#if 0
{
// WIP: Implement a simple Characteristic ping-pong writeValue <-> notify transmission for stress testing.
- DBTManager & manager = device->getAdapter().getManager();
+ BTManager & manager = device->getAdapter().getManager();
if( nullptr != charIdentifier && charIdentifier.length() > 0 ) {
- GATTCharacteristic * char2 = (GATTCharacteristic*) nullptr;
+ BTGattChar * char2 = (BTGattChar*) nullptr;
// manager.find(BluetoothType.GATT_CHARACTERISTIC, null, charIdentifier, device);
fprintf(stderr, "Char UUID %s\n", charIdentifier.c_str());
fprintf(stderr, " over device : %s\n", char2->toString().c_str());
if( nullptr != char2 ) {
bool cccdEnableResult[2];
- bool cccdRet = char2->addCharacteristicListener( std::shared_ptr<GATTCharacteristicListener>( new MyGATTEventListener(char2) ),
+ bool cccdRet = char2->addCharListener( std::shared_ptr<BTGattCharListener>( new MyGATTEventListener(char2) ),
cccdEnableResult );
if( !QUIET ) {
fprintf(stderr, "Added CharPingPongListenerRes Notification(%d), Indication(%d): Result %d\n",
@@ -592,12 +592,12 @@ static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
}
#endif
- std::shared_ptr<GattGenericAccessSvc> ga = device->getGATTGenericAccess();
+ std::shared_ptr<GattGenericAccessSvc> ga = device->getGattGenericAccess();
if( nullptr != ga && !QUIET ) {
fprintf(stderr, " GenericAccess: %s\n\n", ga->toString().c_str());
}
{
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr != gatt && gatt->isConnected() ) {
std::shared_ptr<GattDeviceInformationSvc> di = gatt->getDeviceInformation(primServices);
if( nullptr != di && !QUIET ) {
@@ -607,28 +607,28 @@ static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
}
for(size_t i=0; i<primServices.size(); i++) { // JAU FIXME
- GATTServiceRef primServiceRef = primServices.at(i);
+ BTGattServiceRef primServiceRef = primServices.at(i);
fprintf(stderr, " [%2.2d] Service - Ptr %p\n", (int)i, primServiceRef.get());
if( nullptr != primServiceRef ) {
- GATTService & primService = *primServiceRef;
+ BTGattService & primService = *primServiceRef;
fprintf(stderr, " [%2.2d] Service %s\n", (int)i, primService.toString().c_str());
}
}
// raise (SIGABRT); // JAU FIXME
for(size_t i=0; i<primServices.size(); i++) {
- GATTService & primService = *primServices.at(i);
+ BTGattService & primService = *primServices.at(i);
if( !QUIET ) {
// fprintf(stderr, " [%2.2d] Service %s\n", (int)i, primService.toString().c_str());
fprintf(stderr, " [%2.2d] Service Characteristics\n", (int)i);
}
- jau::darray<GATTCharacteristicRef> & serviceCharacteristics = primService.characteristicList;
+ jau::darray<BTGattCharRef> & serviceCharacteristics = primService.characteristicList;
for(size_t j=0; j<serviceCharacteristics.size(); j++) {
- GATTCharacteristic & serviceChar = *serviceCharacteristics.at(j);
+ BTGattChar & serviceChar = *serviceCharacteristics.at(j);
if( !QUIET ) {
fprintf(stderr, " [%2.2d.%2.2d] CharDef: %s\n", (int)i, (int)j, serviceChar.toString().c_str());
}
- if( serviceChar.hasProperties(GATTCharacteristic::PropertyBitVal::Read) ) {
- POctets value(GATTHandler::number(GATTHandler::Defaults::MAX_ATT_MTU), 0);
+ if( serviceChar.hasProperties(BTGattChar::PropertyBitVal::Read) ) {
+ POctets value(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0);
if( serviceChar.readValue(value) ) {
std::string sval = dfa_utf8_decode(value.get_ptr(), value.getSize());
if( !QUIET ) {
@@ -636,15 +636,15 @@ static void processReadyDevice(std::shared_ptr<DBTDevice> device) {
}
}
}
- jau::darray<GATTDescriptorRef> & charDescList = serviceChar.descriptorList;
+ jau::darray<BTGattDescRef> & charDescList = serviceChar.descriptorList;
for(size_t k=0; k<charDescList.size(); k++) {
- GATTDescriptor & charDesc = *charDescList.at(k);
+ BTGattDesc & charDesc = *charDescList.at(k);
if( !QUIET ) {
fprintf(stderr, " [%2.2d.%2.2d.%2.2d] Desc: %s\n", (int)i, (int)j, (int)k, charDesc.toString().c_str());
}
}
bool cccdEnableResult[2];
- bool cccdRet = serviceChar.addCharacteristicListener( std::shared_ptr<GATTCharacteristicListener>( new MyGATTEventListener(&serviceChar) ),
+ bool cccdRet = serviceChar.addCharListener( std::shared_ptr<BTGattCharListener>( new MyGATTEventListener(&serviceChar) ),
cccdEnableResult );
if( !QUIET ) {
fprintf(stderr, " [%2.2d.%2.2d] addCharacteristicListener Notification(%d), Indication(%d): Result %d\n",
@@ -711,7 +711,7 @@ exit:
}
}
-static void removeDevice(std::shared_ptr<DBTDevice> device) {
+static void removeDevice(std::shared_ptr<BTDevice> device) {
fprintf(stderr, "****** Remove Device: removing: %s\n", device->getAddressAndType().toString().c_str());
device->getAdapter().stopDiscovery();
@@ -724,19 +724,19 @@ static void removeDevice(std::shared_ptr<DBTDevice> device) {
}
}
-static void resetAdapter(DBTAdapter *a, int mode) {
+static void resetAdapter(BTAdapter *a, int mode) {
fprintf(stderr, "****** Reset Adapter: reset[%d] start: %s\n", mode, a->toString().c_str());
HCIStatusCode res = a->reset();
fprintf(stderr, "****** Reset Adapter: reset[%d] end: %s, %s\n", mode, getHCIStatusCodeString(res).c_str(), a->toString().c_str());
}
-static bool startDiscovery(DBTAdapter *a, std::string msg) {
+static bool startDiscovery(BTAdapter *a, std::string msg) {
HCIStatusCode status = a->startDiscovery( true );
fprintf(stderr, "****** Start discovery (%s) result: %s\n", msg.c_str(), getHCIStatusCodeString(status).c_str());
return HCIStatusCode::SUCCESS == status;
}
-static bool initAdapter(std::shared_ptr<DBTAdapter>& adapter) {
+static bool initAdapter(std::shared_ptr<BTAdapter>& adapter) {
if( !adapter->isPowered() ) { // should have been covered above
fprintf(stderr, "Adapter not powered (2): %s\n", adapter->toString().c_str());
return false;
@@ -768,7 +768,7 @@ static bool initAdapter(std::shared_ptr<DBTAdapter>& adapter) {
return true;
}
-static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<DBTAdapter>& adapter) {
+static bool myChangedAdapterSetFunc(const bool added, std::shared_ptr<BTAdapter>& adapter) {
if( added ) {
if( initAdapter( adapter ) ) {
fprintf(stderr, "****** Adapter ADDED__: InitOK. %s\n", adapter->toString().c_str());
@@ -786,7 +786,7 @@ void test() {
timestamp_t0 = getCurrentMilliseconds();
- DBTManager & mngr = DBTManager::get();
+ BTManager & mngr = BTManager::get();
mngr.addChangedAdapterSetCallback(myChangedAdapterSetFunc);
while( !done ) {
@@ -807,9 +807,9 @@ void test() {
//
// just a manually controlled pull down to show status, not required
//
- jau::darray<std::shared_ptr<DBTAdapter>> adapterList = mngr.getAdapters();
+ jau::darray<std::shared_ptr<BTAdapter>> adapterList = mngr.getAdapters();
- jau::for_each_const(adapterList, [](const std::shared_ptr<DBTAdapter>& adapter) {
+ jau::for_each_const(adapterList, [](const std::shared_ptr<BTAdapter>& adapter) {
fprintf(stderr, "****** EOL Adapter's Devices - pre close: %s\n", adapter->toString().c_str());
adapter->printSharedPtrListOfDevices();
});
@@ -819,7 +819,7 @@ void test() {
mngr.close();
}
- jau::for_each_const(adapterList, [](const std::shared_ptr<DBTAdapter>& adapter) {
+ jau::for_each_const(adapterList, [](const std::shared_ptr<BTAdapter>& adapter) {
fprintf(stderr, "****** EOL Adapter's Devices - post close: %s\n", adapter->toString().c_str());
adapter->printSharedPtrListOfDevices();
});
@@ -938,10 +938,10 @@ int main(int argc, char *argv[])
test();
fprintf(stderr, "****** TEST end\n");
if( true ) {
- // Just for testing purpose, i.e. triggering DBTManager::close() within the test controlled app,
+ // Just for testing purpose, i.e. triggering BTManager::close() within the test controlled app,
// instead of program shutdown.
fprintf(stderr, "****** Manager close start\n");
- DBTManager & mngr = DBTManager::get(); // already existing
+ BTManager & mngr = BTManager::get(); // already existing
mngr.close();
fprintf(stderr, "****** Manager close end\n");
}
diff --git a/examples/java/AsyncTinyB.java b/examples/java/AsyncTinyB.java
index 7675242c..f9092121 100644
--- a/examples/java/AsyncTinyB.java
+++ b/examples/java/AsyncTinyB.java
@@ -1,11 +1,11 @@
import java.util.concurrent.locks.*;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
import org.direct_bt.HCIStatusCode;
import java.lang.reflect.InvocationTargetException;
@@ -15,7 +15,7 @@ public class AsyncTinyB {
// private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
- static void printDevice(final BluetoothDevice device) {
+ static void printDevice(final BTDevice device) {
System.out.print("Address = " + device.getAddressAndType());
System.out.print(" Name = " + device.getName());
System.out.print(" Connected = " + device.getConnected());
@@ -47,13 +47,13 @@ public class AsyncTinyB {
* library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
* reference to it is obtained through the getBluetoothManager method.
*/
- final BluetoothManager manager;
+ final BTManager manager;
try {
- manager = BluetoothFactory.getDBusBluetoothManager();
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ manager = BTFactory.getDBusBluetoothManager();
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
- System.err.println("Failed to initialized "+BluetoothFactory.DBusImplementationID);
+ System.err.println("Failed to initialized "+BTFactory.DBusImplementationID);
throw new RuntimeException(e);
}
@@ -70,14 +70,14 @@ public class AsyncTinyB {
* After discovery is started, new devices will be detected. We can find the device we are interested in
* through the manager's find method.
*/
- final BluetoothDevice sensor = manager.find(null, args[0], null, 10000);
+ final BTDevice sensor = manager.find(null, args[0], null, 10000);
/*
* After we find the device we can stop looking for other devices.
*/
try {
manager.stopDiscovery();
- } catch (final BluetoothException e) {
+ } catch (final BTException e) {
System.err.println("Discovery could not be stopped right now");
}
@@ -118,7 +118,7 @@ public class AsyncTinyB {
* http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf. The service we are looking for has the
* short UUID AA00 which we insert into the TI Base UUID: f000XXXX-0451-4000-b000-000000000000
*/
- final BluetoothGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
+ final BTGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
if (tempService == null) {
System.err.println("This device does not have the temperature service we are looking for.");
@@ -127,9 +127,9 @@ public class AsyncTinyB {
}
System.out.println("Found service " + tempService.getUUID());
- final BluetoothGattCharacteristic tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
- final BluetoothGattCharacteristic tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
- final BluetoothGattCharacteristic tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
+ final BTGattChar tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
+ final BTGattChar tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
+ final BTGattChar tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
if (tempValue == null || tempConfig == null || tempPeriod == null) {
System.err.println("Could not find the correct characteristics.");
diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java
index 60a7b6f6..c4a45bc3 100644
--- a/examples/java/DBTScanner10.java
+++ b/examples/java/DBTScanner10.java
@@ -49,20 +49,20 @@ import org.direct_bt.BDAddressType;
import org.direct_bt.BLERandomAddressType;
import org.direct_bt.BTMode;
import org.direct_bt.BTSecurityLevel;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
-import org.direct_bt.BluetoothUtils;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
+import org.direct_bt.BTUtils;
import org.direct_bt.EIRDataTypeSet;
import org.direct_bt.EUI48;
-import org.direct_bt.GATTCharacteristicListener;
+import org.direct_bt.BTGattCharListener;
import org.direct_bt.HCIStatusCode;
import org.direct_bt.HCIWhitelistConnectType;
import org.direct_bt.PairingMode;
@@ -125,14 +125,14 @@ public class DBTScanner10 {
static void printf(final String format, final Object... args) {
final Object[] args2 = new Object[args.length+1];
- args2[0] = BluetoothUtils.elapsedTimeMillis();
+ args2[0] = BTUtils.elapsedTimeMillis();
System.arraycopy(args, 0, args2, 1, args.length);
System.err.printf("[%,9d] "+format, args2);
// System.err.printf("[%,9d] ", BluetoothUtils.getElapsedMillisecond());
// System.err.printf(format, args);
}
static void println(final String msg) {
- System.err.printf("[%,9d] %s%s", BluetoothUtils.elapsedTimeMillis(), msg, System.lineSeparator());
+ System.err.printf("[%,9d] %s%s", BTUtils.elapsedTimeMillis(), msg, System.lineSeparator());
}
static void executeOffThread(final Runnable runobj, final String threadName, final boolean detach) {
@@ -299,7 +299,7 @@ public class DBTScanner10 {
final AdapterStatusListener statusListener = new AdapterStatusListener() {
@Override
- public void adapterSettingsChanged(final BluetoothAdapter adapter, final AdapterSettings oldmask,
+ public void adapterSettingsChanged(final BTAdapter adapter, final AdapterSettings oldmask,
final AdapterSettings newmask, final AdapterSettings changedmask, final long timestamp) {
final boolean initialSetting = oldmask.isEmpty();
if( initialSetting ) {
@@ -320,12 +320,12 @@ public class DBTScanner10 {
}
@Override
- public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
+ public void discoveringChanged(final BTAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
println("****** DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter);
}
@Override
- public boolean deviceFound(final BluetoothDevice device, final long timestamp) {
+ public boolean deviceFound(final BTDevice device, final long timestamp) {
println("****** FOUND__: "+device.toString());
if( BDAddressType.BDADDR_LE_PUBLIC != device.getAddressAndType().type
@@ -344,7 +344,7 @@ public class DBTScanner10 {
{
println("****** FOUND__-0: Connecting "+device.toString());
{
- final long td = BluetoothUtils.currentTimeMillis() - timestamp_t0; // adapter-init -> now
+ final long td = BTUtils.currentTimeMillis() - timestamp_t0; // adapter-init -> now
println("PERF: adapter-init -> FOUND__-0 " + td + " ms");
}
executeOffThread( () -> { connectDiscoveredDevice(device); },
@@ -357,19 +357,19 @@ public class DBTScanner10 {
}
@Override
- public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
+ public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
if( SHOW_UPDATE_EVENTS ) {
println("****** UPDATED: "+updateMask+" of "+device);
}
}
@Override
- public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) {
+ public void deviceConnected(final BTDevice device, final short handle, final long timestamp) {
println("****** CONNECTED-0: "+device.toString());
}
@Override
- public void devicePairingState(final BluetoothDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {
+ public void devicePairingState(final BTDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {
println("****** PAIRING_STATE: state "+state+", mode "+mode+": "+device);
switch( state ) {
case NONE:
@@ -412,7 +412,7 @@ public class DBTScanner10 {
}
@Override
- public void deviceReady(final BluetoothDevice device, final long timestamp) {
+ public void deviceReady(final BTDevice device, final long timestamp) {
if( !devicesInProcessing.contains( device.getAddressAndType() ) &&
( waitForDevices.isEmpty() ||
( matches(waitForDevices, device.getAddressAndType() ) &&
@@ -424,7 +424,7 @@ public class DBTScanner10 {
deviceReadyCount.incrementAndGet();
println("****** READY-0: Processing["+deviceReadyCount.get()+"] "+device.toString());
{
- final long td = BluetoothUtils.currentTimeMillis() - timestamp_t0; // adapter-init -> now
+ final long td = BTUtils.currentTimeMillis() - timestamp_t0; // adapter-init -> now
println("PERF: adapter-init -> READY-0 " + td + " ms");
}
devicesInProcessing.add(device.getAddressAndType());
@@ -435,7 +435,7 @@ public class DBTScanner10 {
}
@Override
- public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
+ public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
println("****** DISCONNECTED: Reason "+reason+", old handle 0x"+Integer.toHexString(handle)+": "+device+" on "+device.getAdapter());
if( REMOVE_DEVICE ) {
@@ -450,7 +450,7 @@ public class DBTScanner10 {
}
};
- private void connectDiscoveredDevice(final BluetoothDevice device) {
+ private void connectDiscoveredDevice(final BTDevice device) {
println("****** Connecting Device: Start " + device.toString());
if( UNPAIR_DEVICE_PRE ) {
@@ -513,7 +513,7 @@ public class DBTScanner10 {
}, true);
}
- private void processReadyDevice(final BluetoothDevice device) {
+ private void processReadyDevice(final BTDevice device) {
println("****** Processing Ready Device: Start " + device.toString());
{
// make sure for pending connections on failed connect*(..) command
@@ -521,7 +521,7 @@ public class DBTScanner10 {
println("****** Processing Ready Device: stopDiscovery result "+r);
}
- final long t1 = BluetoothUtils.currentTimeMillis();
+ final long t1 = BTUtils.currentTimeMillis();
boolean success = false;
{
@@ -559,13 +559,13 @@ public class DBTScanner10 {
// GATT Service Processing
//
try {
- final List<BluetoothGattService> primServices = device.getServices(); // implicit GATT connect...
+ final List<BTGattService> primServices = device.getServices(); // implicit GATT connect...
if( null == primServices || 0 == primServices.size() ) {
// Cheating the flow, but avoiding: goto, do-while-false and lastly unreadable intendations
// And it is an error case nonetheless ;-)
throw new RuntimeException("Processing Ready Device: getServices() failed " + device.toString());
}
- final long t5 = BluetoothUtils.currentTimeMillis();
+ final long t5 = BTUtils.currentTimeMillis();
if( !QUIET ) {
final long td01 = t1 - timestamp_t0; // adapter-init -> processing-start
final long td15 = t5 - t1; // get-gatt-services
@@ -580,26 +580,26 @@ public class DBTScanner10 {
}
{
// WIP: Implement a simple Characteristic ping-pong writeValue <-> notify transmission for stress testing.
- final BluetoothManager manager = device.getAdapter().getManager();
+ final BTManager manager = device.getAdapter().getManager();
if( null != charIdentifier && charIdentifier.length() > 0 ) {
- final BluetoothGattCharacteristic char2 = (BluetoothGattCharacteristic)
- manager.find(BluetoothType.GATT_CHARACTERISTIC, null, charIdentifier, device);
+ final BTGattChar char2 = (BTGattChar)
+ manager.find(BTType.GATT_CHARACTERISTIC, null, charIdentifier, device);
println("Char UUID "+charIdentifier);
println(" over device : "+char2);
if( null != char2 ) {
- final GATTCharacteristicListener charPingPongListener = new GATTCharacteristicListener(null) {
+ final BTGattCharListener charPingPongListener = new BTGattCharListener(null) {
@Override
- public void notificationReceived(final BluetoothGattCharacteristic charDecl,
+ public void notificationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp) {
println("****** PingPong GATT notificationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true));
+ ", value "+BTUtils.bytesHexString(value, 0, -1, true, true, true));
}
@Override
- public void indicationReceived(final BluetoothGattCharacteristic charDecl,
+ public void indicationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp, final boolean confirmationSent) {
println("****** PingPong GATT indicationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true));
+ ", value "+BTUtils.bytesHexString(value, 0, -1, true, true, true));
}
};
final boolean enabledState[] = { false, false };
@@ -618,26 +618,26 @@ public class DBTScanner10 {
}
}
{
- final GATTCharacteristicListener myCharacteristicListener = new GATTCharacteristicListener(null) {
+ final BTGattCharListener myCharacteristicListener = new BTGattCharListener(null) {
@Override
- public void notificationReceived(final BluetoothGattCharacteristic charDecl,
+ public void notificationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp) {
println("****** GATT notificationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true));
+ ", value "+BTUtils.bytesHexString(value, 0, -1, true, true, true));
shutdownTest();
}
@Override
- public void indicationReceived(final BluetoothGattCharacteristic charDecl,
+ public void indicationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp, final boolean confirmationSent) {
println("****** GATT indicationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true));
+ ", value "+BTUtils.bytesHexString(value, 0, -1, true, true, true));
shutdownTest();
}
};
final boolean addedCharacteristicListenerRes =
- BluetoothGattService.addCharacteristicListenerToAll(device, primServices, myCharacteristicListener);
+ BTGattService.addCharListenerToAll(device, primServices, myCharacteristicListener);
if( !QUIET ) {
println("Added GATTCharacteristicListener: "+addedCharacteristicListenerRes);
}
@@ -645,32 +645,32 @@ public class DBTScanner10 {
try {
int i=0;
- for(final Iterator<BluetoothGattService> srvIter = primServices.iterator(); srvIter.hasNext(); i++) {
- final BluetoothGattService primService = srvIter.next();
+ for(final Iterator<BTGattService> srvIter = primServices.iterator(); srvIter.hasNext(); i++) {
+ final BTGattService primService = srvIter.next();
if( !QUIET ) {
printf(" [%02d] Service %s, uuid %s\n", i, primService.toString(), primService.getUUID());
printf(" [%02d] Service Characteristics\n", i);
}
int j=0;
- final List<BluetoothGattCharacteristic> serviceCharacteristics = primService.getCharacteristics();
- for(final Iterator<BluetoothGattCharacteristic> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
- final BluetoothGattCharacteristic serviceChar = charIter.next();
+ final List<BTGattChar> serviceCharacteristics = primService.getChars();
+ for(final Iterator<BTGattChar> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
+ final BTGattChar serviceChar = charIter.next();
if( !QUIET ) {
printf(" [%02d.%02d] CharDef: %s, uuid %s\n", i, j, serviceChar.toString(), serviceChar.getUUID());
}
final List<String> properties = Arrays.asList(serviceChar.getFlags());
if( properties.contains("read") ) {
final byte[] value = serviceChar.readValue();
- final String svalue = BluetoothUtils.decodeUTF8String(value, 0, value.length);
+ final String svalue = BTUtils.decodeUTF8String(value, 0, value.length);
if( !QUIET ) {
printf(" [%02d.%02d] CharVal: %s ('%s')\n",
- i, j, BluetoothUtils.bytesHexString(value, 0, -1, true, true, true), svalue);
+ i, j, BTUtils.bytesHexString(value, 0, -1, true, true, true), svalue);
}
}
int k=0;
- final List<BluetoothGattDescriptor> charDescList = serviceChar.getDescriptors();
- for(final Iterator<BluetoothGattDescriptor> descIter = charDescList.iterator(); descIter.hasNext(); k++) {
- final BluetoothGattDescriptor charDesc = descIter.next();
+ final List<BTGattDesc> charDescList = serviceChar.getDescriptors();
+ for(final Iterator<BTGattDesc> descIter = charDescList.iterator(); descIter.hasNext(); k++) {
+ final BTGattDesc charDesc = descIter.next();
if( !QUIET ) {
printf(" [%02d.%02d.%02d] Desc: %s, uuid %s\n", i, j, k, charDesc.toString(), charDesc.getUUID());
}
@@ -743,7 +743,7 @@ public class DBTScanner10 {
}
}
- private void removeDevice(final BluetoothDevice device) {
+ private void removeDevice(final BTDevice device) {
println("****** Remove Device: removing: "+device.getAddressAndType());
device.getAdapter().stopDiscovery();
@@ -756,19 +756,19 @@ public class DBTScanner10 {
}
}
- private void resetAdapter(final BluetoothAdapter adapter, final int mode) {
+ private void resetAdapter(final BTAdapter adapter, final int mode) {
println("****** Reset Adapter: reset["+mode+"] start: "+adapter.toString());
final HCIStatusCode res = adapter.reset();
println("****** Reset Adapter: reset["+mode+"] end: "+res+", "+adapter.toString());
}
- private boolean startDiscovery(final BluetoothAdapter adapter, final String msg) {
+ private boolean startDiscovery(final BTAdapter adapter, final String msg) {
final HCIStatusCode status = adapter.startDiscovery( true );
println("****** Start discovery ("+msg+") result: "+status);
return HCIStatusCode.SUCCESS == status;
}
- private boolean initAdapter(final BluetoothAdapter adapter) {
+ private boolean initAdapter(final BTAdapter adapter) {
if( !adapter.isPowered() ) { // should have been covered above
println("Adapter not powered (2): "+adapter.toString());
return false;
@@ -809,10 +809,10 @@ public class DBTScanner10 {
return true;
}
- private final BluetoothManager.ChangedAdapterSetListener myChangedAdapterSetListener =
- new BluetoothManager.ChangedAdapterSetListener() {
+ private final BTManager.ChangedAdapterSetListener myChangedAdapterSetListener =
+ new BTManager.ChangedAdapterSetListener() {
@Override
- public void adapterAdded(final BluetoothAdapter adapter) {
+ public void adapterAdded(final BTAdapter adapter) {
if( initAdapter( adapter ) ) {
println("****** Adapter ADDED__: InitOK. " + adapter);
} else {
@@ -821,13 +821,13 @@ public class DBTScanner10 {
}
@Override
- public void adapterRemoved(final BluetoothAdapter adapter) {
+ public void adapterRemoved(final BTAdapter adapter) {
println("****** Adapter REMOVED: " + adapter);
}
};
- public void runTest(final BluetoothManager manager) {
- timestamp_t0 = BluetoothUtils.currentTimeMillis();
+ public void runTest(final BTManager manager) {
+ timestamp_t0 = BTUtils.currentTimeMillis();
boolean done = false;
@@ -855,11 +855,11 @@ public class DBTScanner10 {
//
// just a manually controlled pull down to show status, not required
//
- final List<BluetoothAdapter> adapters = manager.getAdapters();
+ final List<BTAdapter> adapters = manager.getAdapters();
- adapters.forEach(new Consumer<BluetoothAdapter>() {
+ adapters.forEach(new Consumer<BTAdapter>() {
@Override
- public void accept(final BluetoothAdapter a) {
+ public void accept(final BTAdapter a) {
println("****** EOL Adapter's Devices - pre_ close: " + a);
} } );
{
@@ -869,9 +869,9 @@ public class DBTScanner10 {
// All implicit via destructor or shutdown hook!
manager.shutdown(); /* implies: adapter.close(); */
}
- adapters.forEach(new Consumer<BluetoothAdapter>() {
+ adapters.forEach(new Consumer<BTAdapter>() {
@Override
- public void accept(final BluetoothAdapter a) {
+ public void accept(final BTAdapter a) {
println("****** EOL Adapter's Devices - post close: " + a);
} } );
@@ -903,10 +903,10 @@ public class DBTScanner10 {
System.err.println("Setting 'org.tinyb.btmode' to "+btmode.toString());
}
}
- final BluetoothManager manager;
+ final BTManager manager;
try {
- manager = BluetoothFactory.getDirectBTBluetoothManager();
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ manager = BTFactory.getDirectBTBluetoothManager();
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
System.err.println("Unable to instantiate DirectBT BluetoothManager");
@@ -1010,7 +1010,7 @@ public class DBTScanner10 {
test.runTest(manager);
}
- static class BooleanNotification implements BluetoothNotification<Boolean> {
+ static class BooleanNotification implements BTNotification<Boolean> {
private final long t0;
private final String name;
private boolean v;
@@ -1024,7 +1024,7 @@ public class DBTScanner10 {
@Override
public void run(final Boolean v) {
synchronized(this) {
- final long t1 = BluetoothUtils.currentTimeMillis();
+ final long t1 = BTUtils.currentTimeMillis();
this.v = v.booleanValue();
System.out.println("###### "+name+": "+v+" in td "+(t1-t0)+" ms!");
this.notifyAll();
diff --git a/examples/java/HelloTinyB.java b/examples/java/HelloTinyB.java
index 89b76221..a7a2181d 100644
--- a/examples/java/HelloTinyB.java
+++ b/examples/java/HelloTinyB.java
@@ -7,19 +7,19 @@ import java.util.concurrent.locks.ReentrantLock;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
import org.direct_bt.EUI48;
import org.direct_bt.HCIStatusCode;
public class HelloTinyB {
static boolean running = true;
- static void printDevice(final BluetoothDevice device) {
+ static void printDevice(final BTDevice device) {
System.out.print("Address = " + device.getAddressAndType());
System.out.print(" Name = " + device.getName());
System.out.print(" Connected = " + device.getConnected());
@@ -35,14 +35,14 @@ public class HelloTinyB {
* getDevices method. We can the look through the list of devices to find the device with the MAC which we provided
* as a parameter. We continue looking until we find it, or we try 15 times (1 minutes).
*/
- static BluetoothDevice getDevice(final BluetoothManager manager, final BDAddressAndType addressAndType) throws InterruptedException {
- BluetoothDevice sensor = null;
+ static BTDevice getDevice(final BTManager manager, final BDAddressAndType addressAndType) throws InterruptedException {
+ BTDevice sensor = null;
for (int i = 0; (i < 15) && running; ++i) {
- final List<BluetoothDevice> list = manager.getDevices();
+ final List<BTDevice> list = manager.getDevices();
if (list == null)
return null;
- for (final BluetoothDevice device : list) {
+ for (final BTDevice device : list) {
printDevice(device);
/*
* Here we check if the address matches.
@@ -66,16 +66,16 @@ public class HelloTinyB {
* http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf. The service we are looking for has the
* short UUID AA00 which we insert into the TI Base UUID: f000XXXX-0451-4000-b000-000000000000
*/
- static BluetoothGattService getService(final BluetoothDevice device, final String UUID) throws InterruptedException {
+ static BTGattService getService(final BTDevice device, final String UUID) throws InterruptedException {
System.out.println("Services exposed by device:");
- BluetoothGattService tempService = null;
- List<BluetoothGattService> bluetoothServices = null;
+ BTGattService tempService = null;
+ List<BTGattService> bluetoothServices = null;
do {
bluetoothServices = device.getServices();
if (bluetoothServices == null)
return null;
- for (final BluetoothGattService service : bluetoothServices) {
+ for (final BTGattService service : bluetoothServices) {
System.out.println("UUID: " + service.getUUID());
if (service.getUUID().equals(UUID))
tempService = service;
@@ -85,12 +85,12 @@ public class HelloTinyB {
return tempService;
}
- static BluetoothGattCharacteristic getCharacteristic(final BluetoothGattService service, final String UUID) {
- final List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
+ static BTGattChar getCharacteristic(final BTGattService service, final String UUID) {
+ final List<BTGattChar> characteristics = service.getChars();
if (characteristics == null)
return null;
- for (final BluetoothGattCharacteristic characteristic : characteristics) {
+ for (final BTGattChar characteristic : characteristics) {
if (characteristic.getUUID().equals(UUID))
return characteristic;
}
@@ -118,13 +118,13 @@ public class HelloTinyB {
* library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
* reference to it is obtained through the getBluetoothManager method.
*/
- final BluetoothManager manager;
+ final BTManager manager;
try {
- manager = BluetoothFactory.getDBusBluetoothManager();
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ manager = BTFactory.getDBusBluetoothManager();
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
- System.err.println("Failed to initialized "+BluetoothFactory.DBusImplementationID);
+ System.err.println("Failed to initialized "+BTFactory.DBusImplementationID);
throw new RuntimeException(e);
}
@@ -136,14 +136,14 @@ public class HelloTinyB {
final boolean discoveryStarted = manager.startDiscovery();
System.out.println("The discovery started: " + (discoveryStarted ? "true" : "false"));
- final BluetoothDevice sensor = getDevice(manager, new BDAddressAndType(new EUI48(args[0]), BDAddressType.BDADDR_UNDEFINED));
+ final BTDevice sensor = getDevice(manager, new BDAddressAndType(new EUI48(args[0]), BDAddressType.BDADDR_UNDEFINED));
/*
* After we find the device we can stop looking for other devices.
*/
try {
manager.stopDiscovery();
- } catch (final BluetoothException e) {
+ } catch (final BTException e) {
System.err.println("Discovery could not be stopped.");
}
@@ -180,7 +180,7 @@ public class HelloTinyB {
});
- final BluetoothGattService tempService = getService(sensor, "f000aa00-0451-4000-b000-000000000000");
+ final BTGattService tempService = getService(sensor, "f000aa00-0451-4000-b000-000000000000");
if (tempService == null) {
System.err.println("This device does not have the temperature service we are looking for.");
@@ -189,9 +189,9 @@ public class HelloTinyB {
}
System.out.println("Found service " + tempService.getUUID());
- final BluetoothGattCharacteristic tempValue = getCharacteristic(tempService, "f000aa01-0451-4000-b000-000000000000");
- final BluetoothGattCharacteristic tempConfig = getCharacteristic(tempService, "f000aa02-0451-4000-b000-000000000000");
- final BluetoothGattCharacteristic tempPeriod = getCharacteristic(tempService, "f000aa03-0451-4000-b000-000000000000");
+ final BTGattChar tempValue = getCharacteristic(tempService, "f000aa01-0451-4000-b000-000000000000");
+ final BTGattChar tempConfig = getCharacteristic(tempService, "f000aa02-0451-4000-b000-000000000000");
+ final BTGattChar tempPeriod = getCharacteristic(tempService, "f000aa03-0451-4000-b000-000000000000");
if (tempValue == null || tempConfig == null || tempPeriod == null) {
System.err.println("Could not find the correct characteristics.");
diff --git a/examples/java/Notification.java b/examples/java/Notification.java
index b8debdb7..a2120a59 100644
--- a/examples/java/Notification.java
+++ b/examples/java/Notification.java
@@ -27,16 +27,16 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
import org.direct_bt.HCIStatusCode;
-class ValueNotification implements BluetoothNotification<byte[]> {
+class ValueNotification implements BTNotification<byte[]> {
@Override
public void run(final byte[] tempRaw) {
@@ -65,7 +65,7 @@ class ValueNotification implements BluetoothNotification<byte[]> {
}
-class ConnectedNotification implements BluetoothNotification<Boolean> {
+class ConnectedNotification implements BTNotification<Boolean> {
@Override
public void run(final Boolean connected) {
@@ -78,7 +78,7 @@ public class Notification {
// private static final float SCALE_LSB = 0.03125f;
static boolean running = true;
- static void printDevice(final BluetoothDevice device) {
+ static void printDevice(final BTDevice device) {
System.out.print("Address = " + device.getAddressAndType());
System.out.print(" Name = " + device.getName());
System.out.print(" Connected = " + device.getConnected());
@@ -110,13 +110,13 @@ public class Notification {
* library is through the BluetoothManager. There can be only one BluetoothManager at one time, and the
* reference to it is obtained through the getBluetoothManager method.
*/
- final BluetoothManager manager;
+ final BTManager manager;
try {
- manager = BluetoothFactory.getDBusBluetoothManager();
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ manager = BTFactory.getDBusBluetoothManager();
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
- System.err.println("Failed to initialized "+BluetoothFactory.DBusImplementationID);
+ System.err.println("Failed to initialized "+BTFactory.DBusImplementationID);
throw new RuntimeException(e);
}
@@ -133,7 +133,7 @@ public class Notification {
* After discovery is started, new devices will be detected. We can find the device we are interested in
* through the manager's find method.
*/
- final BluetoothDevice sensor = manager.find(null, args[0], null, 10000);
+ final BTDevice sensor = manager.find(null, args[0], null, 10000);
if (sensor == null) {
System.err.println("No sensor found with the provided address.");
@@ -179,7 +179,7 @@ public class Notification {
* http://processors.wiki.ti.com/images/a/a8/BLE_SensorTag_GATT_Server.pdf. The service we are looking for has the
* short UUID AA00 which we insert into the TI Base UUID: f000XXXX-0451-4000-b000-000000000000
*/
- final BluetoothGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
+ final BTGattService tempService = sensor.find( "f000aa00-0451-4000-b000-000000000000");
if (tempService == null) {
System.err.println("This device does not have the temperature service we are looking for.");
@@ -188,9 +188,9 @@ public class Notification {
}
System.out.println("Found service " + tempService.getUUID());
- final BluetoothGattCharacteristic tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
- final BluetoothGattCharacteristic tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
- final BluetoothGattCharacteristic tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
+ final BTGattChar tempValue = tempService.find("f000aa01-0451-4000-b000-000000000000");
+ final BTGattChar tempConfig = tempService.find("f000aa02-0451-4000-b000-000000000000");
+ final BTGattChar tempPeriod = tempService.find("f000aa03-0451-4000-b000-000000000000");
if (tempValue == null || tempConfig == null || tempPeriod == null) {
System.err.println("Could not find the correct characteristics.");
diff --git a/examples/java/ScannerTinyB00.java b/examples/java/ScannerTinyB00.java
index 95631160..aa6a4551 100644
--- a/examples/java/ScannerTinyB00.java
+++ b/examples/java/ScannerTinyB00.java
@@ -29,16 +29,16 @@ import java.util.List;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothUtils;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTUtils;
import org.direct_bt.EUI48;
import org.direct_bt.HCIStatusCode;
@@ -57,7 +57,7 @@ public class ScannerTinyB00 {
static long TO_DISCOVER = 60000;
public static void main(final String[] args) throws InterruptedException {
- String bluetoothManagerClazzName = BluetoothFactory.DirectBTImplementationID.BluetoothManagerClassName;
+ String bluetoothManagerClazzName = BTFactory.DirectBTImplementationID.BluetoothManagerClassName;
int dev_id = 0; // default
BDAddressAndType mac = null;
int mode = 0;
@@ -95,20 +95,20 @@ public class ScannerTinyB00 {
mode = mode %10;
final boolean isDirectBT;
- final BluetoothManager manager;
+ final BTManager manager;
{
- BluetoothManager _manager = null;
- final BluetoothFactory.ImplementationIdentifier implID = BluetoothFactory.getImplementationIdentifier(bluetoothManagerClazzName);
+ BTManager _manager = null;
+ final BTFactory.ImplementationIdentifier implID = BTFactory.getImplementationIdentifier(bluetoothManagerClazzName);
if( null == implID ) {
System.err.println("Unable to find BluetoothManager "+bluetoothManagerClazzName);
System.exit(-1);
}
- isDirectBT = BluetoothFactory.DirectBTImplementationID.equals(implID);
+ isDirectBT = BTFactory.DirectBTImplementationID.equals(implID);
System.err.println("Using BluetoothManager "+bluetoothManagerClazzName);
System.err.println("Using Implementation "+implID+", isDirectBT "+isDirectBT);
try {
- _manager = BluetoothFactory.getBluetoothManager( implID );
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ _manager = BTFactory.getBluetoothManager( implID );
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
System.err.println("Unable to instantiate BluetoothManager via "+implID);
@@ -117,9 +117,9 @@ public class ScannerTinyB00 {
}
manager = _manager;
}
- final BluetoothAdapter adapter;
+ final BTAdapter adapter;
{
- final List<BluetoothAdapter> adapters = manager.getAdapters();
+ final List<BTAdapter> adapters = manager.getAdapters();
for(int i=0; i < adapters.size(); i++) {
System.err.println("Adapter["+i+"]: "+adapters.get(i));
}
@@ -143,7 +143,7 @@ public class ScannerTinyB00 {
final HCIStatusCode discoveryStatus = useAdapter ? adapter.startDiscovery(true) : manager.startDiscovery(true);
System.err.println("The discovery started: " + discoveryStatus + " for mac "+mac+", mode "+mode+", useAdapter "+useAdapter);
- BluetoothDevice sensor = null;
+ BTDevice sensor = null;
if( 0 == mode ) {
if( useAdapter ) {
@@ -154,9 +154,9 @@ public class ScannerTinyB00 {
} else {
boolean timeout = false;
while( null == sensor && !timeout ) {
- final List<BluetoothDevice> devices = useAdapter ? adapter.getDiscoveredDevices() : manager.getDevices();
- for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
- final BluetoothDevice d = id.next();
+ final List<BTDevice> devices = useAdapter ? adapter.getDiscoveredDevices() : manager.getDevices();
+ for(final Iterator<BTDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
+ final BTDevice d = id.next();
if(d.getAddressAndType().equals(mac)) {
sensor = d;
break;
@@ -212,7 +212,7 @@ public class ScannerTinyB00 {
System.exit(-1);
}
- final List<BluetoothGattService> allBluetoothServices = sensor.getServices();
+ final List<BTGattService> allBluetoothServices = sensor.getServices();
if (allBluetoothServices.isEmpty()) {
System.err.println("No BluetoothGattService found!");
System.exit(1);
@@ -223,23 +223,23 @@ public class ScannerTinyB00 {
sensor.remove();
} while( forever );
}
- private static void printDevice(final BluetoothDevice device) {
+ private static void printDevice(final BTDevice device) {
System.err.println("Address = " + device.getAddressAndType());
System.err.println(" Name = " + device.getName());
System.err.println(" Connected = " + device.getConnected());
System.err.println();
}
- private static void printAllServiceInfo(final List<BluetoothGattService> allBluetoothServices) {
+ private static void printAllServiceInfo(final List<BTGattService> allBluetoothServices) {
try {
- for (final BluetoothGattService service : allBluetoothServices) {
+ for (final BTGattService service : allBluetoothServices) {
System.err.println("Service UUID: " + service.getUUID());
- final List<BluetoothGattCharacteristic> v = service.getCharacteristics();
- for (final BluetoothGattCharacteristic c : v) {
+ final List<BTGattChar> v = service.getChars();
+ for (final BTGattChar c : v) {
System.err.println(" Characteristic UUID: " + c.getUUID());
- final List<BluetoothGattDescriptor> descriptors = c.getDescriptors();
+ final List<BTGattDesc> descriptors = c.getDescriptors();
- for (final BluetoothGattDescriptor d : descriptors) {
+ for (final BTGattDesc d : descriptors) {
System.err.println(" Descriptor UUID: " + d.getUUID());
}
if (c.getUUID().contains("2a29-")) {
@@ -274,14 +274,14 @@ public class ScannerTinyB00 {
if (c.getUUID().contains("2a23-")) {
final byte[] tempRaw = c.readValue();
- System.err.println(" System ID: " + BluetoothUtils.bytesHexString(tempRaw, 0, -1, true, true, true));
+ System.err.println(" System ID: " + BTUtils.bytesHexString(tempRaw, 0, -1, true, true, true));
}
}
}
} catch (final RuntimeException e) {
}
}
- static class BooleanNotification implements BluetoothNotification<Boolean> {
+ static class BooleanNotification implements BTNotification<Boolean> {
private final long t0;
private final String name;
private boolean v;
diff --git a/examples/java/ScannerTinyB01.java b/examples/java/ScannerTinyB01.java
index 4bd443dd..e2c9614b 100644
--- a/examples/java/ScannerTinyB01.java
+++ b/examples/java/ScannerTinyB01.java
@@ -33,19 +33,19 @@ import org.direct_bt.AdapterSettings;
import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
-import org.direct_bt.BluetoothUtils;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
+import org.direct_bt.BTUtils;
import org.direct_bt.EIRDataTypeSet;
import org.direct_bt.EUI48;
-import org.direct_bt.GATTCharacteristicListener;
+import org.direct_bt.BTGattCharListener;
import org.direct_bt.HCIStatusCode;
import org.direct_bt.ScanType;
@@ -73,7 +73,7 @@ public class ScannerTinyB01 {
public static void main(final String[] args) throws InterruptedException {
final boolean waitForEnter=false;
long t0_discovery = TO_DISCOVER;
- String bluetoothManagerClazzName = BluetoothFactory.DirectBTImplementationID.BluetoothManagerClassName;
+ String bluetoothManagerClazzName = BTFactory.DirectBTImplementationID.BluetoothManagerClassName;
int dev_id = 0; // default
int mode = 0;
int max_loops = 1;
@@ -119,20 +119,20 @@ public class ScannerTinyB01 {
}
final boolean isDirectBT;
- final BluetoothManager manager;
+ final BTManager manager;
{
- BluetoothManager _manager = null;
- final BluetoothFactory.ImplementationIdentifier implID = BluetoothFactory.getImplementationIdentifier(bluetoothManagerClazzName);
+ BTManager _manager = null;
+ final BTFactory.ImplementationIdentifier implID = BTFactory.getImplementationIdentifier(bluetoothManagerClazzName);
if( null == implID ) {
System.err.println("Unable to find BluetoothManager "+bluetoothManagerClazzName);
System.exit(-1);
}
- isDirectBT = BluetoothFactory.DirectBTImplementationID.equals(implID);
+ isDirectBT = BTFactory.DirectBTImplementationID.equals(implID);
System.err.println("Using BluetoothManager "+bluetoothManagerClazzName);
System.err.println("Using Implementation "+implID+", isDirectBT "+isDirectBT);
try {
- _manager = BluetoothFactory.getBluetoothManager( implID );
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ _manager = BTFactory.getBluetoothManager( implID );
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
System.err.println("Unable to instantiate BluetoothManager via "+implID);
@@ -141,9 +141,9 @@ public class ScannerTinyB01 {
}
manager = _manager;
}
- final BluetoothAdapter adapter;
+ final BTAdapter adapter;
{
- final List<BluetoothAdapter> adapters = manager.getAdapters();
+ final List<BTAdapter> adapters = manager.getAdapters();
for(int i=0; i < adapters.size(); i++) {
System.err.println("Adapter["+i+"]: "+adapters.get(i));
}
@@ -158,11 +158,11 @@ public class ScannerTinyB01 {
}
}
- final BluetoothDevice[] matchingDiscoveredDeviceBucket = { null };
+ final BTDevice[] matchingDiscoveredDeviceBucket = { null };
final AdapterStatusListener statusListener = new AdapterStatusListener() {
@Override
- public void adapterSettingsChanged(final BluetoothAdapter adapter, final AdapterSettings oldmask,
+ public void adapterSettingsChanged(final BTAdapter adapter, final AdapterSettings oldmask,
final AdapterSettings newmask, final AdapterSettings changedmask, final long timestamp) {
System.err.println("****** SETTINGS: "+oldmask+" -> "+newmask+", changed "+changedmask);
System.err.println("Status Adapter:");
@@ -170,14 +170,14 @@ public class ScannerTinyB01 {
}
@Override
- public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
+ public void discoveringChanged(final BTAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
System.err.println("****** DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter);
System.err.println("Status Adapter:");
System.err.println(adapter.toString());
}
@Override
- public boolean deviceFound(final BluetoothDevice device, final long timestamp) {
+ public boolean deviceFound(final BTDevice device, final long timestamp) {
final boolean matches = BDAddressAndType.ANY_DEVICE.matches(waitForDevice) || device.getAddressAndType().matches(waitForDevice);
System.err.println("****** FOUND__: "+device.toString()+" - match "+matches);
System.err.println("Status Adapter:");
@@ -195,25 +195,25 @@ public class ScannerTinyB01 {
}
@Override
- public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
+ public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
final boolean matches = BDAddressAndType.ANY_DEVICE.matches(waitForDevice) || device.getAddressAndType().equals(waitForDevice);
System.err.println("****** UPDATED: "+updateMask+" of "+device+" - match "+matches);
}
@Override
- public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) {
+ public void deviceConnected(final BTDevice device, final short handle, final long timestamp) {
final boolean matches = BDAddressAndType.ANY_DEVICE.matches(waitForDevice) || device.getAddressAndType().equals(waitForDevice);
System.err.println("****** CONNECTED: "+device+" - matches "+matches);
}
@Override
- public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
+ public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
System.err.println("****** DISCONNECTED: Reason "+reason+", old handle 0x"+Integer.toHexString(handle)+": "+device+" on "+device.getAdapter());
}
};
adapter.addStatusListener(statusListener, null);
- final long timestamp_t0 = BluetoothUtils.currentTimeMillis();
+ final long timestamp_t0 = BTUtils.currentTimeMillis();
adapter.enableDiscoverableNotifications(new BooleanNotification("Discoverable", timestamp_t0));
@@ -229,7 +229,7 @@ public class ScannerTinyB01 {
loop++;
System.err.println("****** Loop "+loop);
- final long t0 = BluetoothUtils.currentTimeMillis();
+ final long t0 = BTUtils.currentTimeMillis();
final HCIStatusCode discoveryStatus = adapter.startDiscovery(true);
@@ -237,14 +237,14 @@ public class ScannerTinyB01 {
if( HCIStatusCode.SUCCESS != discoveryStatus ) {
break;
}
- BluetoothDevice sensor = null;
+ BTDevice sensor = null;
if( 0 == mode ) {
synchronized(matchingDiscoveredDeviceBucket) {
boolean timeout = false;
while( !timeout && null == matchingDiscoveredDeviceBucket[0] ) {
matchingDiscoveredDeviceBucket.wait(t0_discovery);
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
timeout = ( tn - t0 ) > t0_discovery;
}
sensor = matchingDiscoveredDeviceBucket[0];
@@ -255,7 +255,7 @@ public class ScannerTinyB01 {
while( null == sensor && !timeout ) {
sensor = adapter.find(null, waitForDevice, t0_discovery);
if( null == sensor ) {
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
timeout = ( tn - t0 ) > t0_discovery;
Thread.sleep(60);
}
@@ -263,22 +263,22 @@ public class ScannerTinyB01 {
} else {
boolean timeout = false;
while( null == sensor && !timeout ) {
- final List<BluetoothDevice> devices = adapter.getDiscoveredDevices();
- for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
- final BluetoothDevice d = id.next();
+ final List<BTDevice> devices = adapter.getDiscoveredDevices();
+ for(final Iterator<BTDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
+ final BTDevice d = id.next();
if( BDAddressAndType.ANY_DEVICE.matches(waitForDevice) || d.getAddressAndType().equals(waitForDevice) ) {
sensor = d;
break;
}
}
if( null == sensor ) {
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
timeout = ( tn - t0 ) > t0_discovery;
Thread.sleep(60);
}
}
}
- final long t1 = BluetoothUtils.currentTimeMillis();
+ final long t1 = BTUtils.currentTimeMillis();
if (sensor == null) {
System.err.println("No sensor found within "+(t1-t0)+" ms");
continue; // forever loop
@@ -293,22 +293,22 @@ public class ScannerTinyB01 {
sensor.enableConnectedNotifications(connectedNotification);
sensor.enableServicesResolvedNotifications(servicesResolvedNotification);
- final long t2 = BluetoothUtils.currentTimeMillis();
+ final long t2 = BTUtils.currentTimeMillis();
final long t3;
HCIStatusCode res;
if ( ( res = sensor.connect() ) == HCIStatusCode.SUCCESS ) {
- t3 = BluetoothUtils.currentTimeMillis();
+ t3 = BTUtils.currentTimeMillis();
System.err.println("Sensor connect issued: "+(t3-t2)+" ms, total "+(t3-t0)+" ms");
System.err.println("Sensor connectedNotification: "+connectedNotification.getValue());
} else {
- t3 = BluetoothUtils.currentTimeMillis();
+ t3 = BTUtils.currentTimeMillis();
System.out.println("connect command failed, res "+res+": "+(t3-t2)+" ms, total "+(t3-t0)+" ms");
// we tolerate the failed immediate connect, as it might happen at a later time
}
synchronized( servicesResolvedNotification ) {
while( !servicesResolvedNotification.getValue() ) {
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
if( tn - t3 > TO_CONNECT_AND_RESOLVE ) {
break;
}
@@ -317,26 +317,26 @@ public class ScannerTinyB01 {
}
final long t4;
if ( servicesResolvedNotification.getValue() ) {
- t4 = BluetoothUtils.currentTimeMillis();
+ t4 = BTUtils.currentTimeMillis();
System.err.println("Sensor servicesResolved: "+(t4-t3)+" ms, total "+(t4-t0)+" ms");
} else {
- t4 = BluetoothUtils.currentTimeMillis();
+ t4 = BTUtils.currentTimeMillis();
System.out.println("Sensor service not resolved: "+(t4-t3)+" ms, total "+(t4-t0)+" ms");
System.exit(-1);
}
- final List<BluetoothGattService> primServices = sensor.getServices();
+ final List<BTGattService> primServices = sensor.getServices();
if ( null == primServices || primServices.isEmpty() ) {
System.err.println("No BluetoothGattService found!");
} else {
{
for(final String characteristic : characteristicList) {
- final BluetoothGattCharacteristic char0 = (BluetoothGattCharacteristic)
- manager.find(BluetoothType.GATT_CHARACTERISTIC, null, characteristic, null, 1000);
- final BluetoothGattCharacteristic char1 = (BluetoothGattCharacteristic)
- manager.find(BluetoothType.GATT_CHARACTERISTIC, null, characteristic, sensor.getAdapter(), 1000);
- final BluetoothGattCharacteristic char2 = (BluetoothGattCharacteristic)
- manager.find(BluetoothType.GATT_CHARACTERISTIC, null, characteristic, sensor, 1000);
+ final BTGattChar char0 = (BTGattChar)
+ manager.find(BTType.GATT_CHARACTERISTIC, null, characteristic, null, 1000);
+ final BTGattChar char1 = (BTGattChar)
+ manager.find(BTType.GATT_CHARACTERISTIC, null, characteristic, sensor.getAdapter(), 1000);
+ final BTGattChar char2 = (BTGattChar)
+ manager.find(BTType.GATT_CHARACTERISTIC, null, characteristic, sensor, 1000);
System.err.println("Char UUID "+characteristic);
System.err.println(" over manager: "+char0);
System.err.println(" over adapter: "+char1);
@@ -344,41 +344,41 @@ public class ScannerTinyB01 {
}
}
- final GATTCharacteristicListener myCharacteristicListener = new GATTCharacteristicListener(null) {
+ final BTGattCharListener myCharacteristicListener = new BTGattCharListener(null) {
@Override
- public void notificationReceived(final BluetoothGattCharacteristic charDecl,
+ public void notificationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp) {
System.err.println("****** GATT notificationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true));
+ ", value "+BTUtils.bytesHexString(value, 0, -1, true, true, true));
}
@Override
- public void indicationReceived(final BluetoothGattCharacteristic charDecl,
+ public void indicationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp, final boolean confirmationSent) {
System.err.println("****** GATT indicationReceived: "+charDecl+
- ", value "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true));
+ ", value "+BTUtils.bytesHexString(value, 0, -1, true, true, true));
}
};
final boolean addedCharacteristicListenerRes =
- BluetoothGattService.addCharacteristicListenerToAll(sensor, primServices, myCharacteristicListener);
+ BTGattService.addCharListenerToAll(sensor, primServices, myCharacteristicListener);
System.err.println("Added GATTCharacteristicListener: "+addedCharacteristicListenerRes);
int i=0, j=0;
- for(final Iterator<BluetoothGattService> srvIter = primServices.iterator(); srvIter.hasNext(); i++) {
- final BluetoothGattService primService = srvIter.next();
+ for(final Iterator<BTGattService> srvIter = primServices.iterator(); srvIter.hasNext(); i++) {
+ final BTGattService primService = srvIter.next();
System.err.printf(" [%02d] Service %s\n", i, primService.toString());
System.err.printf(" [%02d] Service Characteristics\n", i);
- final List<BluetoothGattCharacteristic> serviceCharacteristics = primService.getCharacteristics();
- for(final Iterator<BluetoothGattCharacteristic> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
- final BluetoothGattCharacteristic serviceChar = charIter.next();
+ final List<BTGattChar> serviceCharacteristics = primService.getChars();
+ for(final Iterator<BTGattChar> charIter = serviceCharacteristics.iterator(); charIter.hasNext(); j++) {
+ final BTGattChar serviceChar = charIter.next();
System.err.printf(" [%02d.%02d] Decla: %s\n", i, j, serviceChar.toString());
final List<String> properties = Arrays.asList(serviceChar.getFlags());
if( properties.contains("read") ) {
try {
final byte[] value = serviceChar.readValue();
- final String svalue = BluetoothUtils.decodeUTF8String(value, 0, value.length);
+ final String svalue = BTUtils.decodeUTF8String(value, 0, value.length);
System.err.printf(" [%02d.%02d] Value: %s ('%s')\n",
- i, j, BluetoothUtils.bytesHexString(value, 0, -1, true, true, true), svalue);
+ i, j, BTUtils.bytesHexString(value, 0, -1, true, true, true), svalue);
} catch( final Exception ex) {
System.err.println("Caught "+ex.getMessage());
ex.printStackTrace();
@@ -388,7 +388,7 @@ public class ScannerTinyB01 {
}
Thread.sleep(1000); // FIXME: Wait for notifications
- final boolean remRes = BluetoothGattService.removeCharacteristicListenerFromAll(sensor, primServices, myCharacteristicListener);
+ final boolean remRes = BTGattService.removeCharListenerFromAll(sensor, primServices, myCharacteristicListener);
System.err.println("Removed GATTCharacteristicListener: "+remRes);
}
sensor.disconnect();
@@ -412,13 +412,13 @@ public class ScannerTinyB01 {
manager.shutdown();
System.err.println("ScannerTinyB01 XX");
}
- private static void printDevice(final BluetoothDevice device) {
+ private static void printDevice(final BTDevice device) {
System.err.println("Address = " + device.getAddressAndType());
System.err.println(" Name = " + device.getName());
System.err.println(" Connected = " + device.getConnected());
System.err.println();
}
- static class BooleanNotification implements BluetoothNotification<Boolean> {
+ static class BooleanNotification implements BTNotification<Boolean> {
private final long t0;
private final String name;
private boolean v;
@@ -432,7 +432,7 @@ public class ScannerTinyB01 {
@Override
public void run(final Boolean v) {
synchronized(this) {
- final long t1 = BluetoothUtils.currentTimeMillis();
+ final long t1 = BTUtils.currentTimeMillis();
this.v = v.booleanValue();
System.out.println("###### "+name+": "+v+" in td "+(t1-t0)+" ms!");
this.notifyAll();
diff --git a/examples/java/ScannerTinyB02.java b/examples/java/ScannerTinyB02.java
index ff971578..186c6474 100644
--- a/examples/java/ScannerTinyB02.java
+++ b/examples/java/ScannerTinyB02.java
@@ -31,13 +31,13 @@ import org.direct_bt.AdapterSettings;
import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothUtils;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTUtils;
import org.direct_bt.EIRDataTypeSet;
import org.direct_bt.EUI48;
import org.direct_bt.HCIStatusCode;
@@ -102,13 +102,13 @@ public class ScannerTinyB02 {
} catch(final Exception e) { }
}
- final BluetoothFactory.ImplementationIdentifier implID = 0 == factory ? BluetoothFactory.DirectBTImplementationID : BluetoothFactory.DBusImplementationID;
- final BluetoothManager manager;
+ final BTFactory.ImplementationIdentifier implID = 0 == factory ? BTFactory.DirectBTImplementationID : BTFactory.DBusImplementationID;
+ final BTManager manager;
{
- BluetoothManager _manager = null;
+ BTManager _manager = null;
try {
- _manager = BluetoothFactory.getBluetoothManager( implID );
- } catch (BluetoothException | NoSuchMethodException | SecurityException
+ _manager = BTFactory.getBluetoothManager( implID );
+ } catch (BTException | NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException | ClassNotFoundException e) {
System.err.println("Unable to instantiate BluetoothManager via "+implID);
@@ -117,9 +117,9 @@ public class ScannerTinyB02 {
}
manager = _manager;
}
- final BluetoothAdapter adapter;
+ final BTAdapter adapter;
{
- final List<BluetoothAdapter> adapters = manager.getAdapters();
+ final List<BTAdapter> adapters = manager.getAdapters();
for(int i=0; i < adapters.size(); i++) {
System.err.println("Adapter["+i+"]: "+adapters.get(i));
}
@@ -134,11 +134,11 @@ public class ScannerTinyB02 {
}
}
- final BluetoothDevice[] matchingDiscoveredDeviceBucket = { null };
+ final BTDevice[] matchingDiscoveredDeviceBucket = { null };
final AdapterStatusListener statusListener = new AdapterStatusListener() {
@Override
- public void adapterSettingsChanged(final BluetoothAdapter adapter, final AdapterSettings oldmask,
+ public void adapterSettingsChanged(final BTAdapter adapter, final AdapterSettings oldmask,
final AdapterSettings newmask, final AdapterSettings changedmask, final long timestamp) {
System.err.println("****** SETTINGS: "+oldmask+" -> "+newmask+", changed "+changedmask);
System.err.println("Status Adapter:");
@@ -146,14 +146,14 @@ public class ScannerTinyB02 {
}
@Override
- public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
+ public void discoveringChanged(final BTAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
System.err.println("****** DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter);
System.err.println("Status Adapter:");
System.err.println(adapter.toString());
}
@Override
- public boolean deviceFound(final BluetoothDevice device, final long timestamp) {
+ public boolean deviceFound(final BTDevice device, final long timestamp) {
final boolean matches = BDAddressAndType.ANY_DEVICE.matches(waitForDevice) || device.getAddressAndType().equals(waitForDevice);
System.err.println("****** FOUND__: "+device.toString()+" - match "+matches);
System.err.println("Status Adapter:");
@@ -171,25 +171,25 @@ public class ScannerTinyB02 {
}
@Override
- public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
+ public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
final boolean matches = BDAddressAndType .ANY_DEVICE.matches(waitForDevice) || device.getAddressAndType().equals(waitForDevice);
System.err.println("****** UPDATED: "+updateMask+" of "+device+" - match "+matches);
}
@Override
- public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) {
+ public void deviceConnected(final BTDevice device, final short handle, final long timestamp) {
final boolean matches = BDAddressAndType .ANY_DEVICE.matches(waitForDevice) || device.getAddressAndType().equals(waitForDevice);
System.err.println("****** CONNECTED: "+device+" - matches "+matches);
}
@Override
- public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
+ public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
System.err.println("****** DISCONNECTED: Reason "+reason+", old handle 0x"+Integer.toHexString(handle)+": "+device+" on "+device.getAdapter());
}
};
adapter.addStatusListener(statusListener, null);
- final long timestamp_t0 = BluetoothUtils.currentTimeMillis();
+ final long timestamp_t0 = BTUtils.currentTimeMillis();
adapter.enableDiscoverableNotifications(new BooleanNotification("Discoverable", timestamp_t0));
@@ -205,7 +205,7 @@ public class ScannerTinyB02 {
loop++;
System.err.println("****** Loop "+loop);
- final long t0 = BluetoothUtils.currentTimeMillis();
+ final long t0 = BTUtils.currentTimeMillis();
final boolean discoveryStarted = true; // adapter.startDiscovery(true);
{
@@ -223,14 +223,14 @@ public class ScannerTinyB02 {
if( !discoveryStarted ) {
break;
}
- BluetoothDevice sensor = null;
+ BTDevice sensor = null;
if( 0 == mode ) {
synchronized(matchingDiscoveredDeviceBucket) {
boolean timeout = false;
while( !timeout && null == matchingDiscoveredDeviceBucket[0] ) {
matchingDiscoveredDeviceBucket.wait(t0_discovery);
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
timeout = ( tn - t0 ) > t0_discovery;
}
sensor = matchingDiscoveredDeviceBucket[0];
@@ -241,10 +241,10 @@ public class ScannerTinyB02 {
} else {
boolean timeout = false;
while( null == sensor && !timeout ) {
- final List<BluetoothDevice> devices = adapter.getDiscoveredDevices();
+ final List<BTDevice> devices = adapter.getDiscoveredDevices();
int i=0;
- for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
- final BluetoothDevice d = id.next();
+ for(final Iterator<BTDevice> id = devices.iterator(); id.hasNext() && !timeout; ) {
+ final BTDevice d = id.next();
final boolean match = BDAddressAndType .ANY_DEVICE.matches(waitForDevice) || d.getAddressAndType().equals(waitForDevice);
System.err.println("****** Has "+i+"/"+devices.size()+": match "+match+": "+d.toString());
i++;
@@ -254,14 +254,14 @@ public class ScannerTinyB02 {
}
}
if( null == sensor ) {
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
timeout = ( tn - t0 ) > t0_discovery;
System.err.print(".");
Thread.sleep(60);
}
}
}
- final long t1 = BluetoothUtils.currentTimeMillis();
+ final long t1 = BTUtils.currentTimeMillis();
if (sensor == null) {
System.err.println("No sensor found within "+(t1-t0)+" ms");
continue; // forever loop
@@ -286,22 +286,22 @@ public class ScannerTinyB02 {
sensor.enableConnectedNotifications(connectedNotification);
sensor.enableServicesResolvedNotifications(servicesResolvedNotification);
- final long t2 = BluetoothUtils.currentTimeMillis();
+ final long t2 = BTUtils.currentTimeMillis();
final long t3;
HCIStatusCode res;
if ( (res = sensor.connect() ) == HCIStatusCode.SUCCESS ) {
- t3 = BluetoothUtils.currentTimeMillis();
+ t3 = BTUtils.currentTimeMillis();
System.err.println("Sensor connect issued: "+(t3-t2)+" ms, total "+(t3-t0)+" ms");
System.err.println("Sensor connectedNotification: "+connectedNotification.getValue());
} else {
- t3 = BluetoothUtils.currentTimeMillis();
+ t3 = BTUtils.currentTimeMillis();
System.out.println("connect command failed, res "+res+": "+(t3-t2)+" ms, total "+(t3-t0)+" ms");
// we tolerate the failed immediate connect, as it might happen at a later time
}
synchronized( servicesResolvedNotification ) {
while( !servicesResolvedNotification.getValue() ) {
- final long tn = BluetoothUtils.currentTimeMillis();
+ final long tn = BTUtils.currentTimeMillis();
if( tn - t3 > TO_CONNECT ) {
break;
}
@@ -310,15 +310,15 @@ public class ScannerTinyB02 {
}
final long t4;
if ( servicesResolvedNotification.getValue() ) {
- t4 = BluetoothUtils.currentTimeMillis();
+ t4 = BTUtils.currentTimeMillis();
System.err.println("Sensor servicesResolved: "+(t4-t3)+" ms, total "+(t4-t0)+" ms");
} else {
- t4 = BluetoothUtils.currentTimeMillis();
+ t4 = BTUtils.currentTimeMillis();
System.out.println("Could not connect device: "+(t4-t3)+" ms, total "+(t4-t0)+" ms");
// System.exit(-1);
}
- final BluetoothDevice _sensor = sensor;
+ final BTDevice _sensor = sensor;
final Thread lalaTask = new Thread( new Runnable() {
@Override
public void run() {
@@ -350,13 +350,13 @@ public class ScannerTinyB02 {
manager.shutdown();
System.err.println("ScannerTinyB01 XX");
}
- private static void printDevice(final BluetoothDevice device) {
+ private static void printDevice(final BTDevice device) {
System.err.println("Address = " + device.getAddressAndType());
System.err.println(" Name = " + device.getName());
System.err.println(" Connected = " + device.getConnected());
System.err.println();
}
- static class BooleanNotification implements BluetoothNotification<Boolean> {
+ static class BooleanNotification implements BTNotification<Boolean> {
private final long t0;
private final String name;
private boolean v;
@@ -370,7 +370,7 @@ public class ScannerTinyB02 {
@Override
public void run(final Boolean v) {
synchronized(this) {
- final long t1 = BluetoothUtils.currentTimeMillis();
+ final long t1 = BTUtils.currentTimeMillis();
this.v = v.booleanValue();
System.out.println("###### "+name+": "+v+" in td "+(t1-t0)+" ms!");
this.notifyAll();
diff --git a/java/jau/direct_bt/DBTAdapter.java b/java/jau/direct_bt/DBTAdapter.java
index 79b61d6e..a421dd69 100644
--- a/java/jau/direct_bt/DBTAdapter.java
+++ b/java/jau/direct_bt/DBTAdapter.java
@@ -38,16 +38,16 @@ import org.direct_bt.AdapterSettings;
import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
import org.direct_bt.EIRDataTypeSet;
import org.direct_bt.EUI48;
import org.direct_bt.HCIStatusCode;
@@ -57,7 +57,7 @@ import org.direct_bt.SMPPairingState;
import org.direct_bt.ScanType;
import org.direct_bt.TransportType;
-public class DBTAdapter extends DBTObject implements BluetoothAdapter
+public class DBTAdapter extends DBTObject implements BTAdapter
{
private static final boolean DEBUG = DBTManager.DEBUG;
@@ -75,16 +75,16 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
private final AtomicBoolean isClosing = new AtomicBoolean(false);
private final AtomicBoolean powered_state = new AtomicBoolean(false); // AdapterSettings
- private BluetoothNotification<Boolean> userPairableNotificationCB = null;
+ private BTNotification<Boolean> userPairableNotificationCB = null;
private final AtomicBoolean isDiscoverable = new AtomicBoolean(false); // AdapterSettings
- private BluetoothNotification<Boolean> userDiscoverableNotificationCB = null;
+ private BTNotification<Boolean> userDiscoverableNotificationCB = null;
private final AtomicBoolean isPairable = new AtomicBoolean(false); // AdapterSettings
- private BluetoothNotification<Boolean> userPoweredNotificationCB = null;
+ private BTNotification<Boolean> userPoweredNotificationCB = null;
private final AtomicReference<ScanType> currentMetaScanType = new AtomicReference<ScanType>(ScanType.NONE); // AdapterStatusListener and powerdOff
- private BluetoothNotification<Boolean> userDiscoveringNotificationCB = null;
+ private BTNotification<Boolean> userDiscoveringNotificationCB = null;
- private final List<BluetoothDevice> discoveredDevices = new ArrayList<BluetoothDevice>();
+ private final List<BTDevice> discoveredDevices = new ArrayList<BTDevice>();
/* pp */ DBTAdapter(final long nativeInstance, final byte byteAddress[/*6*/], final String name, final int dev_id)
{
@@ -96,7 +96,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
@Override
- public final BluetoothManager getManager() { return DBTManager.getManager(); }
+ public final BTManager getManager() { return DBTManager.getManager(); }
@Override
public void close() {
@@ -116,8 +116,8 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
stopDiscovery();
- final List<BluetoothDevice> devices = getDiscoveredDevices();
- for(final Iterator<BluetoothDevice> id = devices.iterator(); id.hasNext(); ) {
+ final List<BTDevice> devices = getDiscoveredDevices();
+ for(final Iterator<BTDevice> id = devices.iterator(); id.hasNext(); ) {
final DBTDevice d = (DBTDevice) id.next();
d.close();
}
@@ -162,17 +162,17 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public int getDevID() { return dev_id; }
@Override
- public BluetoothType getBluetoothType() { return class_type(); }
+ public BTType getBluetoothType() { return class_type(); }
- static BluetoothType class_type() { return BluetoothType.ADAPTER; }
+ static BTType class_type() { return BTType.ADAPTER; }
@Override
- public BluetoothDevice find(final String name, final BDAddressAndType addressAndType, final long timeoutMS) {
+ public BTDevice find(final String name, final BDAddressAndType addressAndType, final long timeoutMS) {
return findDeviceInCache(name, addressAndType);
}
@Override
- public BluetoothDevice find(final String name, final BDAddressAndType addressAndType) {
+ public BTDevice find(final String name, final BDAddressAndType addressAndType) {
return find(name, addressAndType, 0);
}
@@ -211,7 +211,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public long getBluetoothClass() { throw new UnsupportedOperationException(); } // FIXME
@Override
- public final BluetoothAdapter clone() { throw new UnsupportedOperationException(); } // FIXME
+ public final BTAdapter clone() { throw new UnsupportedOperationException(); } // FIXME
@Override
public String getInterfaceName() { throw new UnsupportedOperationException(); } // FIXME
@@ -238,7 +238,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
/* Java callbacks */
@Override
- public void enablePoweredNotifications(final BluetoothNotification<Boolean> callback) {
+ public void enablePoweredNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userPoweredNotificationCB = callback;
}
@@ -255,7 +255,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public boolean getDiscoverable() { return isDiscoverable.get(); }
@Override
- public void enableDiscoverableNotifications(final BluetoothNotification<Boolean> callback) {
+ public void enableDiscoverableNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userDiscoverableNotificationCB = callback;
}
@@ -279,7 +279,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
@Override
- public final void enableDiscoveringNotifications(final BluetoothNotification<Boolean> callback) {
+ public final void enableDiscoveringNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userDiscoveringNotificationCB = callback;
}
@@ -296,7 +296,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public final boolean getPairable() { return isPairable.get(); }
@Override
- public void enablePairableNotifications(final BluetoothNotification<Boolean> callback) {
+ public void enablePairableNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userPairableNotificationCB = callback;
}
@@ -342,10 +342,10 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
public native boolean setDiscoverable(boolean value);
@Override
- public final BluetoothDevice connectDevice(final BDAddressAndType addressAndType) {
+ public final BTDevice connectDevice(final BDAddressAndType addressAndType) {
return connectDeviceImpl(addressAndType.address.b, addressAndType.type.value);
}
- private native BluetoothDevice connectDeviceImpl(byte[] address, byte addressType);
+ private native BTDevice connectDeviceImpl(byte[] address, byte addressType);
@Override
public native boolean setPairable(boolean value);
@@ -373,12 +373,12 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
/* discovery */
@Override
- public boolean startDiscovery() throws BluetoothException {
+ public boolean startDiscovery() throws BTException {
return HCIStatusCode.SUCCESS == startDiscovery(true);
}
@Override
- public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException {
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException {
synchronized( discoveryLock ) {
// Ignoring 'isDiscovering', as native implementation also handles change of 'keepAlive'.
// The discoveredDevices shall always get cleared.
@@ -386,28 +386,28 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
return HCIStatusCode.get( startDiscoveryImpl(keepAlive) ); // event callbacks will be generated by implementation
}
}
- private native byte startDiscoveryImpl(boolean keepAlive) throws BluetoothException;
+ private native byte startDiscoveryImpl(boolean keepAlive) throws BTException;
@Override
- public HCIStatusCode stopDiscovery() throws BluetoothException {
+ public HCIStatusCode stopDiscovery() throws BTException {
synchronized( discoveryLock ) {
// Ignoring 'isDiscovering', be consistent with startDiscovery
return HCIStatusCode.get( stopDiscoveryImpl() ); // event callbacks will be generated by implementation
}
}
- private native byte stopDiscoveryImpl() throws BluetoothException;
+ private native byte stopDiscoveryImpl() throws BTException;
@Override
- public List<BluetoothDevice> getDiscoveredDevices() {
+ public List<BTDevice> getDiscoveredDevices() {
synchronized(discoveredDevicesLock) {
- return new ArrayList<BluetoothDevice>(discoveredDevices);
+ return new ArrayList<BTDevice>(discoveredDevices);
}
}
// std::vector<std::shared_ptr<direct_bt::HCIDevice>> discoveredDevices = adapter.getDiscoveredDevices();
- private native List<BluetoothDevice> getDiscoveredDevicesImpl();
+ private native List<BTDevice> getDiscoveredDevicesImpl();
@Override
- public int removeDiscoveredDevices() throws BluetoothException {
+ public int removeDiscoveredDevices() throws BTException {
final int cj = removeDiscoveredDevicesImpl2j();
final int cn = removeDiscoveredDevicesImpl1();
if( cj != cn ) {
@@ -417,7 +417,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
return cn;
}
- private native int removeDiscoveredDevicesImpl1() throws BluetoothException;
+ private native int removeDiscoveredDevicesImpl1() throws BTException;
private int removeDiscoveredDevicesImpl2j() {
synchronized(discoveredDevicesLock) {
final int n = discoveredDevices.size();
@@ -425,7 +425,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
return n;
}
}
- /* pp */ boolean removeDiscoveredDevice(final BluetoothDevice device) {
+ /* pp */ boolean removeDiscoveredDevice(final BTDevice device) {
synchronized(discoveredDevicesLock) {
return discoveredDevices.remove(device);
}
@@ -445,8 +445,8 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
private native boolean removeDiscoveredDeviceImpl1(final byte[] address, final byte addressType);
private boolean removeDiscoveredDeviceImpl2j(final BDAddressAndType addressAndType) {
synchronized(discoveredDevicesLock) {
- for( final Iterator<BluetoothDevice> iter = discoveredDevices.iterator(); iter.hasNext(); ) {
- final BluetoothDevice device = iter.next();
+ for( final Iterator<BTDevice> iter = discoveredDevices.iterator(); iter.hasNext(); ) {
+ final BTDevice device = iter.next();
if( device.getAddressAndType().equals(addressAndType) ) {
iter.remove();
return true;
@@ -457,7 +457,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
@Override
- public native boolean addStatusListener(final AdapterStatusListener l, final BluetoothDevice deviceMatch);
+ public native boolean addStatusListener(final AdapterStatusListener l, final BTDevice deviceMatch);
@Override
public boolean removeStatusListener(final AdapterStatusListener l) {
@@ -492,7 +492,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
private final AdapterStatusListener statusListener = new AdapterStatusListener() {
@Override
- public void adapterSettingsChanged(final BluetoothAdapter a, final AdapterSettings oldmask, final AdapterSettings newmask,
+ public void adapterSettingsChanged(final BTAdapter a, final AdapterSettings oldmask, final AdapterSettings newmask,
final AdapterSettings changedmask, final long timestamp) {
final boolean initialSetting = oldmask.isEmpty();
if( DEBUG ) {
@@ -543,7 +543,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
}
@Override
- public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
+ public void discoveringChanged(final BTAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) {
if( DEBUG ) {
System.err.println("Adapter.StatusListener.DISCOVERING: meta "+currentMeta+", changed["+changedType+", enabled "+changedEnabled+", keepAlive "+keepAlive+"] on "+adapter);
}
@@ -560,7 +560,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
}
@Override
- public boolean deviceFound(final BluetoothDevice device, final long timestamp) {
+ public boolean deviceFound(final BTDevice device, final long timestamp) {
if( DEBUG ) {
System.err.println("Adapter.FOUND: "+device+" on "+device.getAdapter());
}
@@ -571,7 +571,7 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
@Override
- public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
+ public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
final boolean rssiUpdated = updateMask.isSet( EIRDataTypeSet.DataType.RSSI );
final boolean mdUpdated = updateMask.isSet( EIRDataTypeSet.DataType.MANUF_DATA );
if( DEBUG && !rssiUpdated && !mdUpdated) {
@@ -581,28 +581,28 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
}
@Override
- public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) {
+ public void deviceConnected(final BTDevice device, final short handle, final long timestamp) {
if( DEBUG ) {
System.err.println("Adapter.CONNECTED: "+device+" on "+device.getAdapter());
}
}
@Override
- public void devicePairingState(final BluetoothDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {
+ public void devicePairingState(final BTDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {
if( DEBUG ) {
System.err.println("Adapter.PAIRING_STATE: state "+state+", mode "+mode+": "+device);
}
}
@Override
- public void deviceReady(final BluetoothDevice device, final long timestamp) {
+ public void deviceReady(final BTDevice device, final long timestamp) {
if( DEBUG ) {
System.err.println("Adapter.READY: "+device);
}
}
@Override
- public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
+ public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
if( DEBUG ) {
System.err.println("Adapter.DISCONNECTED: Reason "+reason+", old handle 0x"+Integer.toHexString(handle)+": "+device+" on "+device.getAdapter());
}
@@ -617,35 +617,35 @@ public class DBTAdapter extends DBTObject implements BluetoothAdapter
* <ul>
* <li>{@link DBTDevice}</li>
* <li>{@link DBTGattService}</li>
- * <li>{@link DBTGattCharacteristic}</li>
- * <li>{@link DBTGattDescriptor}</li>
+ * <li>{@link DBTGattChar}</li>
+ * <li>{@link DBTGattDesc}</li>
* </ul>
- * or alternatively in {@link BluetoothObject} space
+ * or alternatively in {@link BTObject} space
* <ul>
- * <li>{@link BluetoothType#DEVICE} -> {@link BluetoothDevice}</li>
- * <li>{@link BluetoothType#GATT_SERVICE} -> {@link BluetoothGattService}</li>
- * <li>{@link BluetoothType#GATT_CHARACTERISTIC} -> {@link BluetoothGattCharacteristic}</li>
- * <li>{@link BluetoothType#GATT_DESCRIPTOR} -> {@link BluetoothGattDescriptor}</li>
+ * <li>{@link BTType#DEVICE} -> {@link BTDevice}</li>
+ * <li>{@link BTType#GATT_SERVICE} -> {@link BTGattService}</li>
+ * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li>
+ * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li>
* </ul>
* </p>
- * @param name name of the desired {@link BluetoothType#DEVICE device}.
+ * @param name name of the desired {@link BTType#DEVICE device}.
* Maybe {@code null}.
- * @param identifier EUI48 address of the desired {@link BluetoothType#DEVICE device}
- * or UUID of the desired {@link BluetoothType#GATT_SERVICE service},
- * {@link BluetoothType#GATT_CHARACTERISTIC characteristic} or {@link BluetoothType#GATT_DESCRIPTOR descriptor} to be found.
+ * @param identifier EUI48 address of the desired {@link BTType#DEVICE device}
+ * or UUID of the desired {@link BTType#GATT_SERVICE service},
+ * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found.
* Maybe {@code null}, in which case the first object of the desired type is being returned - if existing.
* @param type specify the type of the object to be found, either
- * {@link BluetoothType#DEVICE device},
- * {@link BluetoothType#GATT_SERVICE service}, {@link BluetoothType#GATT_CHARACTERISTIC characteristic}
- * or {@link BluetoothType#GATT_DESCRIPTOR descriptor}.
- * {@link BluetoothType#NONE none} means anything.
+ * {@link BTType#DEVICE device},
+ * {@link BTType#GATT_SERVICE service}, {@link BTType#GATT_CHARACTERISTIC characteristic}
+ * or {@link BTType#GATT_DESCRIPTOR descriptor}.
+ * {@link BTType#NONE none} means anything.
*/
- /* pp */ DBTObject findInCache(final String name, final String identifier, final BluetoothType type) {
- final boolean anyType = BluetoothType.NONE == type;
- final boolean deviceType = BluetoothType.DEVICE == type;
- final boolean serviceType = BluetoothType.GATT_SERVICE == type;
- final boolean charType = BluetoothType.GATT_CHARACTERISTIC== type;
- final boolean descType = BluetoothType.GATT_DESCRIPTOR == type;
+ /* pp */ DBTObject findInCache(final String name, final String identifier, final BTType type) {
+ final boolean anyType = BTType.NONE == type;
+ final boolean deviceType = BTType.DEVICE == type;
+ final boolean serviceType = BTType.GATT_SERVICE == type;
+ final boolean charType = BTType.GATT_CHARACTERISTIC== type;
+ final boolean descType = BTType.GATT_DESCRIPTOR == type;
if( !anyType && !deviceType && !serviceType && !charType && !descType ) {
return null;
diff --git a/java/jau/direct_bt/DBTDevice.java b/java/jau/direct_bt/DBTDevice.java
index 7bad208c..d582358e 100644
--- a/java/jau/direct_bt/DBTDevice.java
+++ b/java/jau/direct_bt/DBTDevice.java
@@ -35,17 +35,17 @@ import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
import org.direct_bt.BTSecurityLevel;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
import org.direct_bt.EIRDataTypeSet;
import org.direct_bt.EUI48;
-import org.direct_bt.GATTCharacteristicListener;
+import org.direct_bt.BTGattCharListener;
import org.direct_bt.HCIStatusCode;
import org.direct_bt.PairingMode;
import org.direct_bt.SMPIOCapability;
@@ -54,7 +54,7 @@ import org.direct_bt.SMPLongTermKeyInfo;
import org.direct_bt.SMPPairingState;
import org.direct_bt.SMPSignatureResolvingKeyInfo;
-public class DBTDevice extends DBTObject implements BluetoothDevice
+public class DBTDevice extends DBTObject implements BTDevice
{
private static final boolean DEBUG = DBTManager.DEBUG;
@@ -74,29 +74,29 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
private final Object userCallbackLock = new Object();
private final long blockedNotificationRef = 0;
- private BluetoothNotification<Boolean> userBlockedNotificationsCB = null;
+ private BTNotification<Boolean> userBlockedNotificationsCB = null;
private final AtomicBoolean isBlocked = new AtomicBoolean(false);
private final long pairedNotificationRef = 0;
- private BluetoothNotification<Boolean> userPairedNotificationsCB = null;
+ private BTNotification<Boolean> userPairedNotificationsCB = null;
private final AtomicBoolean isPaired = new AtomicBoolean(false);
private final long trustedNotificationRef = 0;
- private BluetoothNotification<Boolean> userTrustedNotificationsCB = null;
+ private BTNotification<Boolean> userTrustedNotificationsCB = null;
private final AtomicBoolean isTrusted = new AtomicBoolean(false);
- private BluetoothNotification<Boolean> userConnectedNotificationsCB = null;
+ private BTNotification<Boolean> userConnectedNotificationsCB = null;
private final AtomicBoolean isConnected = new AtomicBoolean(false);
- private BluetoothNotification<Short> userRSSINotificationsCB = null;
- private BluetoothNotification<Map<Short, byte[]> > userManufDataNotificationsCB = null;
- private BluetoothNotification<Boolean> userServicesResolvedNotificationsCB = null;
+ private BTNotification<Short> userRSSINotificationsCB = null;
+ private BTNotification<Map<Short, byte[]> > userManufDataNotificationsCB = null;
+ private BTNotification<Boolean> userServicesResolvedNotificationsCB = null;
private final AtomicBoolean servicesResolved = new AtomicBoolean(false);
private short appearance = 0;
final AdapterStatusListener statusListener = new AdapterStatusListener() {
@Override
- public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
+ public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) {
final boolean nameUpdated = updateMask.isSet( EIRDataTypeSet.DataType.NAME );
final boolean rssiUpdated = updateMask.isSet( EIRDataTypeSet.DataType.RSSI );
final boolean mdUpdated = updateMask.isSet( EIRDataTypeSet.DataType.MANUF_DATA );
@@ -119,7 +119,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
}
@Override
- public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) {
+ public void deviceConnected(final BTDevice device, final short handle, final long timestamp) {
if( isConnected.compareAndSet(false, true) ) {
synchronized(userCallbackLock) {
if( null != userConnectedNotificationsCB ) {
@@ -134,7 +134,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
}
@Override
- public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
+ public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) {
devicePaired(false);
if( isConnected.compareAndSet(true, false) ) {
@@ -153,7 +153,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
};
- final private BluetoothNotification<Boolean> blockedNotificationsCB = new BluetoothNotification<Boolean>() {
+ final private BTNotification<Boolean> blockedNotificationsCB = new BTNotification<Boolean>() {
@Override
public void run(final Boolean value) {
if( DEBUG ) {
@@ -182,14 +182,14 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
}
}
- final private BluetoothNotification<Boolean> pairedNotificationsCB = new BluetoothNotification<Boolean>() {
+ final private BTNotification<Boolean> pairedNotificationsCB = new BTNotification<Boolean>() {
@Override
public void run(final Boolean value) {
devicePaired( value.booleanValue() );
}
};
- final private BluetoothNotification<Boolean> trustedNotificationsCB = new BluetoothNotification<Boolean>() {
+ final private BTNotification<Boolean> trustedNotificationsCB = new BTNotification<Boolean>() {
@Override
public void run(final Boolean value) {
if( DEBUG ) {
@@ -298,17 +298,17 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
private native String getNameImpl();
@Override
- public BluetoothType getBluetoothType() { return class_type(); }
+ public BTType getBluetoothType() { return class_type(); }
- static BluetoothType class_type() { return BluetoothType.DEVICE; }
+ static BTType class_type() { return BTType.DEVICE; }
@Override
- public BluetoothGattService find(final String UUID, final long timeoutMS) {
- return (DBTGattService) findInCache(UUID, BluetoothType.GATT_SERVICE);
+ public BTGattService find(final String UUID, final long timeoutMS) {
+ return (DBTGattService) findInCache(UUID, BTType.GATT_SERVICE);
}
@Override
- public BluetoothGattService find(final String UUID) {
+ public BTGattService find(final String UUID) {
return find(UUID, 0);
}
@@ -318,7 +318,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
public int getBluetoothClass() { throw new UnsupportedOperationException(); } // FIXME
@Override
- public final BluetoothDevice clone() { throw new UnsupportedOperationException(); } // FIXME
+ public final BTDevice clone() { throw new UnsupportedOperationException(); } // FIXME
@Override
public final SMPKeyMask getAvailableSMPKeys(final boolean responder) {
@@ -351,7 +351,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
private final native void getSignatureResolvingKeyInfoImpl(final boolean responder, final byte[] sink);
@Override
- public final boolean pair() throws BluetoothException {
+ public final boolean pair() throws BTException {
return false;
}
@@ -412,7 +412,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
public HCIStatusCode setPairingPasskey(final int passkey) {
return HCIStatusCode.get( setPairingPasskeyImpl(passkey) );
}
- private native byte setPairingPasskeyImpl(final int passkey) throws BluetoothException;
+ private native byte setPairingPasskeyImpl(final int passkey) throws BTException;
@Override
public HCIStatusCode setPairingNumericComparison(final boolean equal) {
@@ -433,7 +433,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
private native byte getPairingStateImpl();
@Override
- public final boolean cancelPairing() throws BluetoothException {
+ public final boolean cancelPairing() throws BTException {
// FIXME: Not supporter (yet)
return false;
}
@@ -451,7 +451,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
/* DBT method calls: Connection */
@Override
- public final void enableConnectedNotifications(final BluetoothNotification<Boolean> callback) {
+ public final void enableConnectedNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userConnectedNotificationsCB = callback;
}
@@ -470,22 +470,22 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
public final short getConnectionHandle() { return hciConnHandle; }
@Override
- public final HCIStatusCode disconnect() throws BluetoothException {
+ public final HCIStatusCode disconnect() throws BTException {
if( isConnected.get() ) {
return HCIStatusCode.get( disconnectImpl() ); // event callbacks will be generated by implementation
}
return HCIStatusCode.CONNECTION_TERMINATED_BY_LOCAL_HOST;
}
- private native byte disconnectImpl() throws BluetoothException;
+ private native byte disconnectImpl() throws BTException;
@Override
- public final HCIStatusCode connect() throws BluetoothException {
+ public final HCIStatusCode connect() throws BTException {
if( !isConnected.get() ) {
return HCIStatusCode.get( connectDefaultImpl() ); // event callbacks will be generated by implementation
}
return HCIStatusCode.CONNECTION_ALREADY_EXISTS;
}
- private native byte connectDefaultImpl() throws BluetoothException;
+ private native byte connectDefaultImpl() throws BTException;
@Override
public HCIStatusCode connectLE(final short le_scan_interval, final short le_scan_window,
@@ -510,7 +510,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
/* DBT Java callbacks */
@Override
- public final void enableRSSINotifications(final BluetoothNotification<Short> callback) {
+ public final void enableRSSINotifications(final BTNotification<Short> callback) {
synchronized(userCallbackLock) {
userRSSINotificationsCB = callback;
}
@@ -525,7 +525,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
@Override
- public final void enableManufacturerDataNotifications(final BluetoothNotification<Map<Short, byte[]> > callback) {
+ public final void enableManufacturerDataNotifications(final BTNotification<Map<Short, byte[]> > callback) {
synchronized(userCallbackLock) {
userManufDataNotificationsCB = callback;
}
@@ -540,7 +540,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
@Override
- public final void enableServicesResolvedNotifications(final BluetoothNotification<Boolean> callback) {
+ public final void enableServicesResolvedNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userServicesResolvedNotificationsCB = callback;
}
@@ -560,7 +560,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
public short getAppearance() { return appearance; }
@Override
- public void enableBlockedNotifications(final BluetoothNotification<Boolean> callback) {
+ public void enableBlockedNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userBlockedNotificationsCB = callback;
}
@@ -580,8 +580,8 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
@Override
- public void enableServiceDataNotifications(final BluetoothNotification<Map<String, byte[]> > callback) {
- // FIXME: Isn't this GATTCharacteristic data notification/indication? Then map it or drop!
+ public void enableServiceDataNotifications(final BTNotification<Map<String, byte[]> > callback) {
+ // FIXME: Isn't this BTGattChar data notification/indication? Then map it or drop!
}
@Override
@@ -595,7 +595,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
@Override
- public void enablePairedNotifications(final BluetoothNotification<Boolean> callback) {
+ public void enablePairedNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userPairedNotificationsCB = callback;
}
@@ -612,7 +612,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
public final boolean getPaired() { return isPaired.get(); }
@Override
- public void enableTrustedNotifications(final BluetoothNotification<Boolean> callback) {
+ public void enableTrustedNotifications(final BTNotification<Boolean> callback) {
synchronized(userCallbackLock) {
userTrustedNotificationsCB = callback;
}
@@ -650,12 +650,12 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
private native String toStringImpl();
- private native void enableBlockedNotificationsImpl(BluetoothNotification<Boolean> callback);
+ private native void enableBlockedNotificationsImpl(BTNotification<Boolean> callback);
private native void disableBlockedNotificationsImpl();
private native void setBlockedImpl(final boolean value);
// Note that this is only called natively for unpaired, i.e. paired:=false. Using deviceConnected for paired:=true.
- private native void enablePairedNotificationsImpl(BluetoothNotification<Boolean> callback);
+ private native void enablePairedNotificationsImpl(BTNotification<Boolean> callback);
private native void disablePairedNotificationsImpl();
/**
@@ -669,28 +669,28 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
/* DBT native method calls: */
@Override
- public native boolean connectProfile(String arg_UUID) throws BluetoothException;
+ public native boolean connectProfile(String arg_UUID) throws BTException;
@Override
- public native boolean disconnectProfile(String arg_UUID) throws BluetoothException;
+ public native boolean disconnectProfile(String arg_UUID) throws BTException;
/**
* {@inheritDoc}
*/
@Override
- public final boolean remove() throws BluetoothException {
+ public final boolean remove() throws BTException {
// close: clear java-listener, super.close()
// -> DBTNativeDownlink.delete(): deleteNativeJavaObject(..), deleteImpl(..) -> DBTDevice::remove()
close();
// return removeImpl();
return true;
}
- private native boolean removeImpl() throws BluetoothException;
+ private native boolean removeImpl() throws BTException;
@Override
- public List<BluetoothGattService> getServices() {
+ public List<BTGattService> getServices() {
try {
- final List<BluetoothGattService> services = getServicesImpl();
+ final List<BTGattService> services = getServicesImpl();
updateServiceCache(services);
return services;
} catch (final Throwable t) {
@@ -701,7 +701,7 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
return null;
}
- private native List<BluetoothGattService> getServicesImpl();
+ private native List<BTGattService> getServicesImpl();
@Override
public boolean pingGATT() {
@@ -747,19 +747,19 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
protected native void deleteImpl(long nativeInstance);
@Override
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener) {
- return addCharacteristicListener(listener, (DBTGattCharacteristic)listener.getAssociatedCharacteristic());
+ public boolean addCharListener(final BTGattCharListener listener) {
+ return addCharListener(listener, (DBTGattChar)listener.getAssociatedChar());
}
- private native boolean addCharacteristicListener(final GATTCharacteristicListener listener, final DBTGattCharacteristic associatedCharacteristic);
+ private native boolean addCharListener(final BTGattCharListener listener, final DBTGattChar associatedCharacteristic);
@Override
- public native boolean removeCharacteristicListener(final GATTCharacteristicListener l);
+ public native boolean removeCharListener(final BTGattCharListener l);
@Override
- public native int removeAllAssociatedCharacteristicListener(final BluetoothGattCharacteristic associatedCharacteristic);
+ public native int removeAllAssociatedCharListener(final BTGattChar associatedCharacteristic);
@Override
- public native int removeAllCharacteristicListener();
+ public native int removeAllCharListener();
/* local functionality */
@@ -771,11 +771,11 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
}
}
- private void updateServiceCache(final List<BluetoothGattService> services) {
+ private void updateServiceCache(final List<BTGattService> services) {
synchronized(serviceCache) {
clearServiceCache();
if( null != services ) {
- for(final BluetoothGattService service : services) {
+ for(final BTGattService service : services) {
serviceCache.add( new WeakReference<DBTGattService>( (DBTGattService)service ) );
}
}
@@ -805,29 +805,29 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
* The returned {@link DBTObject} may be of type
* <ul>
* <li>{@link DBTGattService}</li>
- * <li>{@link DBTGattCharacteristic}</li>
- * <li>{@link DBTGattDescriptor}</li>
+ * <li>{@link DBTGattChar}</li>
+ * <li>{@link DBTGattDesc}</li>
* </ul>
- * or alternatively in {@link BluetoothObject} space
+ * or alternatively in {@link BTObject} space
* <ul>
- * <li>{@link BluetoothType#GATT_SERVICE} -> {@link BluetoothGattService}</li>
- * <li>{@link BluetoothType#GATT_CHARACTERISTIC} -> {@link BluetoothGattCharacteristic}</li>
- * <li>{@link BluetoothType#GATT_DESCRIPTOR} -> {@link BluetoothGattDescriptor}</li>
+ * <li>{@link BTType#GATT_SERVICE} -> {@link BTGattService}</li>
+ * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li>
+ * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li>
* </ul>
* </p>
- * @param uuid UUID of the desired {@link BluetoothType#GATT_SERVICE service},
- * {@link BluetoothType#GATT_CHARACTERISTIC characteristic} or {@link BluetoothType#GATT_DESCRIPTOR descriptor} to be found.
+ * @param uuid UUID of the desired {@link BTType#GATT_SERVICE service},
+ * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found.
* Maybe {@code null}, in which case the first object of the desired type is being returned - if existing.
* @param type specify the type of the object to be found, either
- * {@link BluetoothType#GATT_SERVICE service}, {@link BluetoothType#GATT_CHARACTERISTIC characteristic}
- * or {@link BluetoothType#GATT_DESCRIPTOR descriptor}.
- * {@link BluetoothType#NONE none} means anything.
+ * {@link BTType#GATT_SERVICE service}, {@link BTType#GATT_CHARACTERISTIC characteristic}
+ * or {@link BTType#GATT_DESCRIPTOR descriptor}.
+ * {@link BTType#NONE none} means anything.
*/
- /* pp */ DBTObject findInCache(final String uuid, final BluetoothType type) {
- final boolean anyType = BluetoothType.NONE == type;
- final boolean serviceType = BluetoothType.GATT_SERVICE == type;
- final boolean charType = BluetoothType.GATT_CHARACTERISTIC== type;
- final boolean descType = BluetoothType.GATT_DESCRIPTOR == type;
+ /* pp */ DBTObject findInCache(final String uuid, final BTType type) {
+ final boolean anyType = BTType.NONE == type;
+ final boolean serviceType = BTType.GATT_SERVICE == type;
+ final boolean charType = BTType.GATT_CHARACTERISTIC== type;
+ final boolean descType = BTType.GATT_DESCRIPTOR == type;
if( !anyType && !serviceType && !charType && !descType ) {
return null;
diff --git a/java/jau/direct_bt/DBTEvent.java b/java/jau/direct_bt/DBTEvent.java
index de27dabe..bd176944 100644
--- a/java/jau/direct_bt/DBTEvent.java
+++ b/java/jau/direct_bt/DBTEvent.java
@@ -25,16 +25,16 @@
package jau.direct_bt;
-import org.direct_bt.BluetoothCallback;
-import org.direct_bt.BluetoothEvent;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTCallback;
+import org.direct_bt.BTEvent;
+import org.direct_bt.BTType;
-public class DBTEvent implements BluetoothEvent
+public class DBTEvent implements BTEvent
{
private long nativeInstance;
@Override
- public native BluetoothType getType();
+ public native BTType getType();
@Override
public native String getName();
@Override
@@ -44,12 +44,12 @@ public class DBTEvent implements BluetoothEvent
@Override
public native boolean hasCallback();
- private native void init(BluetoothType type, String name, String identifier,
- DBTObject parent, BluetoothCallback cb, Object data);
+ private native void init(BTType type, String name, String identifier,
+ DBTObject parent, BTCallback cb, Object data);
private native void delete();
- public DBTEvent(final BluetoothType type, final String name, final String identifier,
- final DBTObject parent, final BluetoothCallback cb, final Object data)
+ public DBTEvent(final BTType type, final String name, final String identifier,
+ final DBTObject parent, final BTCallback cb, final Object data)
{
init(type, name, identifier, parent, cb, data);
}
diff --git a/java/jau/direct_bt/DBTGattCharacteristic.java b/java/jau/direct_bt/DBTGattChar.java
index 5ec0940f..86863e5c 100644
--- a/java/jau/direct_bt/DBTGattCharacteristic.java
+++ b/java/jau/direct_bt/DBTGattChar.java
@@ -29,18 +29,18 @@ import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.List;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
-import org.direct_bt.BluetoothUtils;
-import org.direct_bt.GATTCharacteristicListener;
-
-public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCharacteristic
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
+import org.direct_bt.BTUtils;
+import org.direct_bt.BTGattCharListener;
+
+public class DBTGattChar extends DBTObject implements BTGattChar
{
private static final boolean DEBUG = DBTManager.DEBUG;
@@ -74,7 +74,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
/* Optional Client Characteristic Configuration index within descriptorList */
private final int clientCharacteristicsConfigIndex;
- /* pp */ final List<BluetoothGattDescriptor> descriptorList;
+ /* pp */ final List<BTGattDesc> descriptorList;
private final boolean supCharValueCacheNotification;
@@ -82,7 +82,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
boolean enabledIndicateState = false;
private byte[] cachedValue = null;
- private BluetoothNotification<byte[]> valueNotificationCB = null;
+ private BTNotification<byte[]> valueNotificationCB = null;
private boolean updateCachedValue(final byte[] value, final boolean notify) {
boolean valueChanged = false;
@@ -101,7 +101,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
return valueChanged;
}
- /* pp */ DBTGattCharacteristic(final long nativeInstance, final DBTGattService service,
+ /* pp */ DBTGattChar(final long nativeInstance, final DBTGattService service,
final short handle, final String[] properties,
final boolean hasNotify, final boolean hasIndicate,
final String value_type_uuid, final short value_handle,
@@ -120,19 +120,19 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
this.descriptorList = getDescriptorsImpl();
this.supCharValueCacheNotification = DBTManager.getManager().getSettings().isCharacteristicValueCacheNotificationSupported();
- if( ( BluetoothFactory.DEBUG || supCharValueCacheNotification ) &&
+ if( ( BTFactory.DEBUG || supCharValueCacheNotification ) &&
( hasNotify || hasIndicate )
)
{
// This characteristicListener serves TinyB 'enableValueNotification(..)' and 'getValue()' (cached value)
// backwards compatibility only!
- final GATTCharacteristicListener characteristicListener = new GATTCharacteristicListener(this) {
+ final BTGattCharListener characteristicListener = new BTGattCharListener(this) {
@Override
- public void notificationReceived(final BluetoothGattCharacteristic charDecl, final byte[] value, final long timestamp) {
- final DBTGattCharacteristic cd = (DBTGattCharacteristic)charDecl;
- if( !cd.equals(DBTGattCharacteristic.this) ) {
+ public void notificationReceived(final BTGattChar charDecl, final byte[] value, final long timestamp) {
+ final DBTGattChar cd = (DBTGattChar)charDecl;
+ if( !cd.equals(DBTGattChar.this) ) {
throw new InternalError("Filtered GATTCharacteristicListener.notificationReceived: Wrong Characteristic: Got "+charDecl+
- ", expected "+DBTGattCharacteristic.this.toString());
+ ", expected "+DBTGattChar.this.toString());
}
final boolean valueChanged;
if( supCharValueCacheNotification ) {
@@ -142,16 +142,16 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
}
if( DEBUG ) {
System.err.println("GATTCharacteristicListener.notificationReceived: "+charDecl+
- ", value[changed "+valueChanged+", len "+value.length+": "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true)+"]");
+ ", value[changed "+valueChanged+", len "+value.length+": "+BTUtils.bytesHexString(value, 0, -1, true, true, true)+"]");
}
}
@Override
- public void indicationReceived(final BluetoothGattCharacteristic charDecl, final byte[] value, final long timestamp,
+ public void indicationReceived(final BTGattChar charDecl, final byte[] value, final long timestamp,
final boolean confirmationSent) {
- final DBTGattCharacteristic cd = (DBTGattCharacteristic)charDecl;
- if( !cd.equals(DBTGattCharacteristic.this) ) {
+ final DBTGattChar cd = (DBTGattChar)charDecl;
+ if( !cd.equals(DBTGattChar.this) ) {
throw new InternalError("Filtered GATTCharacteristicListener.indicationReceived: Wrong Characteristic: Got "+charDecl+
- ", expected "+DBTGattCharacteristic.this.toString());
+ ", expected "+DBTGattChar.this.toString());
}
final boolean valueChanged;
if( supCharValueCacheNotification ) {
@@ -161,7 +161,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
}
if( DEBUG ) {
System.err.println("GATTCharacteristicListener.indicationReceived: "+charDecl+
- ", value[changed "+valueChanged+", len "+value.length+": "+BluetoothUtils.bytesHexString(value, 0, -1, true, true, true)+
+ ", value[changed "+valueChanged+", len "+value.length+": "+BTUtils.bytesHexString(value, 0, -1, true, true, true)+
"], confirmationSent "+confirmationSent);
}
}
@@ -182,10 +182,10 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
@Override
public boolean equals(final Object obj)
{
- if (obj == null || !(obj instanceof DBTGattCharacteristic)) {
+ if (obj == null || !(obj instanceof DBTGattChar)) {
return false;
}
- final DBTGattCharacteristic other = (DBTGattCharacteristic)obj;
+ final DBTGattChar other = (DBTGattChar)obj;
return handle == other.handle; /** unique attribute handles */
}
@@ -193,29 +193,29 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
public String getUUID() { return value_type_uuid; }
@Override
- public BluetoothType getBluetoothType() { return class_type(); }
+ public BTType getBluetoothType() { return class_type(); }
- static BluetoothType class_type() { return BluetoothType.GATT_CHARACTERISTIC; }
+ static BTType class_type() { return BTType.GATT_CHARACTERISTIC; }
@Override
- public BluetoothGattCharacteristic clone()
+ public BTGattChar clone()
{ throw new UnsupportedOperationException(); } // FIXME
@Override
- public BluetoothGattDescriptor find(final String UUID, final long timeoutMS) {
+ public BTGattDesc find(final String UUID, final long timeoutMS) {
if( !checkServiceCache() ) {
return null;
}
- return (DBTGattDescriptor) findInCache(UUID, BluetoothType.GATT_DESCRIPTOR);
+ return (DBTGattDesc) findInCache(UUID, BTType.GATT_DESCRIPTOR);
}
@Override
- public BluetoothGattDescriptor find(final String UUID) {
+ public BTGattDesc find(final String UUID) {
return find(UUID, 0);
}
@Override
- public final BluetoothGattService getService() { return wbr_service.get(); }
+ public final BTGattService getService() { return wbr_service.get(); }
@Override
public final String[] getFlags() { return properties; }
@@ -224,7 +224,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
public final byte[] getValue() { return cachedValue; }
@Override
- public final byte[] readValue() throws BluetoothException {
+ public final byte[] readValue() throws BTException {
if( supCharValueCacheNotification ) {
final byte[] value = readValueImpl();
updateCachedValue(value, true);
@@ -235,7 +235,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
}
@Override
- public final boolean writeValue(final byte[] value, final boolean withResponse) throws BluetoothException {
+ public final boolean writeValue(final byte[] value, final boolean withResponse) throws BTException {
final boolean res = writeValueImpl(value, withResponse);
if( supCharValueCacheNotification && res ) {
updateCachedValue(value, false);
@@ -244,7 +244,7 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
}
@Override
- public final List<BluetoothGattDescriptor> getDescriptors() { return descriptorList; }
+ public final List<BTGattDesc> getDescriptors() { return descriptorList; }
@Override
public final synchronized boolean configNotificationIndication(final boolean enableNotification, final boolean enableIndication, final boolean enabledState[/*2*/])
@@ -302,24 +302,24 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
}
@Override
- public final boolean addCharacteristicListener(final GATTCharacteristicListener listener) {
- return getService().getDevice().addCharacteristicListener(listener);
+ public final boolean addCharacteristicListener(final BTGattCharListener listener) {
+ return getService().getDevice().addCharListener(listener);
}
@Override
- public final boolean addCharacteristicListener(final GATTCharacteristicListener listener, final boolean enabledState[/*2*/]) {
+ public final boolean addCharacteristicListener(final BTGattCharListener listener, final boolean enabledState[/*2*/]) {
if( !enableNotificationOrIndication(enabledState) ) {
return false;
}
- return getService().getDevice().addCharacteristicListener(listener);
+ return getService().getDevice().addCharListener(listener);
}
@Override
- public final boolean removeCharacteristicListener(final GATTCharacteristicListener l, final boolean disableIndicationNotification) {
+ public final boolean removeCharacteristicListener(final BTGattCharListener l, final boolean disableIndicationNotification) {
if( disableIndicationNotification ) {
configNotificationIndication(false /* enableNotification */, false /* enableIndication */, new boolean[2]);
}
- return getService().getDevice().removeCharacteristicListener(l);
+ return getService().getDevice().removeCharListener(l);
}
@Override
@@ -328,11 +328,11 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
configNotificationIndication(false /* enableNotification */, false /* enableIndication */, new boolean[2]);
}
valueNotificationCB = null;
- return getService().getDevice().removeAllAssociatedCharacteristicListener(this);
+ return getService().getDevice().removeAllAssociatedCharListener(this);
}
@Override
- public final synchronized void enableValueNotifications(final BluetoothNotification<byte[]> callback) {
+ public final synchronized void enableValueNotifications(final BTNotification<byte[]> callback) {
if( !configNotificationIndication(true /* enableNotification */, true /* enableIndication */, new boolean[2]) ) {
valueNotificationCB = null;
} else {
@@ -382,11 +382,11 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
private native String toStringImpl();
- private native byte[] readValueImpl() throws BluetoothException;
+ private native byte[] readValueImpl() throws BTException;
- private native boolean writeValueImpl(byte[] argValue, boolean withResponse) throws BluetoothException;
+ private native boolean writeValueImpl(byte[] argValue, boolean withResponse) throws BTException;
- private native List<BluetoothGattDescriptor> getDescriptorsImpl();
+ private native List<BTGattDesc> getDescriptorsImpl();
@Override
protected native void deleteImpl(long nativeInstance);
@@ -408,29 +408,29 @@ public class DBTGattCharacteristic extends DBTObject implements BluetoothGattCha
* <p>
* The returned {@link DBTObject} may be of type
* <ul>
- * <li>{@link DBTGattDescriptor}</li>
+ * <li>{@link DBTGattDesc}</li>
* </ul>
- * or alternatively in {@link BluetoothObject} space
+ * or alternatively in {@link BTObject} space
* <ul>
- * <li>{@link BluetoothType#GATT_DESCRIPTOR} -> {@link BluetoothGattDescriptor}</li>
+ * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li>
* </ul>
* </p>
* @param uuid UUID of the desired
- * {@link BluetoothType#GATT_DESCRIPTOR descriptor} to be found.
+ * {@link BTType#GATT_DESCRIPTOR descriptor} to be found.
* Maybe {@code null}, in which case the first object of the desired type is being returned - if existing.
- * @param type specify the type of the object to be found, a {@link BluetoothType#GATT_DESCRIPTOR descriptor}.
- * {@link BluetoothType#NONE none} means anything.
+ * @param type specify the type of the object to be found, a {@link BTType#GATT_DESCRIPTOR descriptor}.
+ * {@link BTType#NONE none} means anything.
*/
- /* pp */ DBTObject findInCache(final String uuid, final BluetoothType type) {
- final boolean anyType = BluetoothType.NONE == type;
- final boolean descType = BluetoothType.GATT_DESCRIPTOR == type;
+ /* pp */ DBTObject findInCache(final String uuid, final BTType type) {
+ final boolean anyType = BTType.NONE == type;
+ final boolean descType = BTType.GATT_DESCRIPTOR == type;
if( !anyType && !descType ) {
return null;
}
final int size = descriptorList.size();
for(int i = 0; i < size; i++ ) {
- final DBTGattDescriptor descr = (DBTGattDescriptor) descriptorList.get(i);
+ final DBTGattDesc descr = (DBTGattDesc) descriptorList.get(i);
if( null == uuid || descr.getUUID().equals(uuid) ) {
return descr;
}
diff --git a/java/jau/direct_bt/DBTGattDescriptor.java b/java/jau/direct_bt/DBTGattDesc.java
index f375cc38..7c080e39 100644
--- a/java/jau/direct_bt/DBTGattDescriptor.java
+++ b/java/jau/direct_bt/DBTGattDesc.java
@@ -28,15 +28,15 @@ package jau.direct_bt;
import java.lang.ref.WeakReference;
import java.util.Arrays;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
-public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescriptor
+public class DBTGattDesc extends DBTObject implements BTGattDesc
{
/** Descriptor's characteristic weak back-reference */
- final WeakReference<DBTGattCharacteristic> wbr_characteristic;
+ final WeakReference<DBTGattChar> wbr_characteristic;
/** Type of Descriptor */
private final String type_uuid;
@@ -50,7 +50,7 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
private final short handle;
private byte[] cachedValue;
- private BluetoothNotification<byte[]> valueNotificationCB = null;
+ private BTNotification<byte[]> valueNotificationCB = null;
private boolean updateCachedValue(final byte[] value, final boolean notify) {
boolean valueChanged = false;
@@ -69,11 +69,11 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
return valueChanged;
}
- /* pp */ DBTGattDescriptor(final long nativeInstance, final DBTGattCharacteristic characteristic,
+ /* pp */ DBTGattDesc(final long nativeInstance, final DBTGattChar characteristic,
final String type_uuid, final short handle, final byte[] value)
{
super(nativeInstance, handle /* hash */);
- this.wbr_characteristic = new WeakReference<DBTGattCharacteristic>(characteristic);
+ this.wbr_characteristic = new WeakReference<DBTGattChar>(characteristic);
this.type_uuid = type_uuid;
this.handle = handle;
this.cachedValue = value;
@@ -91,10 +91,10 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
@Override
public boolean equals(final Object obj)
{
- if (obj == null || !(obj instanceof DBTGattDescriptor)) {
+ if (obj == null || !(obj instanceof DBTGattDesc)) {
return false;
}
- final DBTGattDescriptor other = (DBTGattDescriptor)obj;
+ final DBTGattDesc other = (DBTGattDesc)obj;
return handle == other.handle; /** unique attribute handles */
}
@@ -102,16 +102,16 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
public String getUUID() { return type_uuid; }
@Override
- public BluetoothType getBluetoothType() { return class_type(); }
+ public BTType getBluetoothType() { return class_type(); }
- static BluetoothType class_type() { return BluetoothType.GATT_DESCRIPTOR; }
+ static BTType class_type() { return BTType.GATT_DESCRIPTOR; }
@Override
- public final BluetoothGattDescriptor clone()
+ public final BTGattDesc clone()
{ throw new UnsupportedOperationException(); } // FIXME
@Override
- public final DBTGattCharacteristic getCharacteristic() { return wbr_characteristic.get(); }
+ public final DBTGattChar getCharacteristic() { return wbr_characteristic.get(); }
@Override
public final byte[] getValue() { return cachedValue; }
@@ -124,7 +124,7 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
}
@Override
- public final boolean writeValue(final byte[] value) throws BluetoothException {
+ public final boolean writeValue(final byte[] value) throws BTException {
final boolean res = writeValueImpl(value);
if( res ) {
updateCachedValue(value, false);
@@ -133,7 +133,7 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
}
@Override
- public final synchronized void enableValueNotifications(final BluetoothNotification<byte[]> callback) {
+ public final synchronized void enableValueNotifications(final BTNotification<byte[]> callback) {
valueNotificationCB = callback;
}
@@ -164,7 +164,7 @@ public class DBTGattDescriptor extends DBTObject implements BluetoothGattDescrip
private native byte[] readValueImpl();
- private native boolean writeValueImpl(byte[] argValue) throws BluetoothException;
+ private native boolean writeValueImpl(byte[] argValue) throws BTException;
@Override
protected native void deleteImpl(long nativeInstance);
diff --git a/java/jau/direct_bt/DBTGattService.java b/java/jau/direct_bt/DBTGattService.java
index f836b920..4e65ba8b 100644
--- a/java/jau/direct_bt/DBTGattService.java
+++ b/java/jau/direct_bt/DBTGattService.java
@@ -28,14 +28,14 @@ package jau.direct_bt;
import java.lang.ref.WeakReference;
import java.util.List;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
-
-public class DBTGattService extends DBTObject implements BluetoothGattService
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
+
+public class DBTGattService extends DBTObject implements BTGattService
{
/** Service's device weak back-reference */
final WeakReference<DBTDevice> wbr_device;
@@ -44,7 +44,7 @@ public class DBTGattService extends DBTObject implements BluetoothGattService
private final String type_uuid;
private final short handleStart;
private final short handleEnd;
- /* pp */ final List<BluetoothGattCharacteristic> characteristicList;
+ /* pp */ final List<BTGattChar> charList;
/* pp */ DBTGattService(final long nativeInstance, final DBTDevice device, final boolean isPrimary,
final String type_uuid, final short handleStart, final short handleEnd)
@@ -55,7 +55,7 @@ public class DBTGattService extends DBTObject implements BluetoothGattService
this.type_uuid = type_uuid;
this.handleStart = handleStart;
this.handleEnd = handleEnd;
- this.characteristicList = getCharacteristicsImpl();
+ this.charList = getCharsImpl();
}
@Override
@@ -72,35 +72,35 @@ public class DBTGattService extends DBTObject implements BluetoothGattService
public String getUUID() { return type_uuid; }
@Override
- public BluetoothType getBluetoothType() { return class_type(); }
+ public BTType getBluetoothType() { return class_type(); }
- static BluetoothType class_type() { return BluetoothType.GATT_SERVICE; }
+ static BTType class_type() { return BTType.GATT_SERVICE; }
@Override
- public final BluetoothGattService clone()
+ public final BTGattService clone()
{ throw new UnsupportedOperationException(); } // FIXME
@Override
- public BluetoothGattCharacteristic find(final String UUID, final long timeoutMS) {
+ public BTGattChar find(final String UUID, final long timeoutMS) {
if( !checkServiceCache() ) {
return null;
}
- return (DBTGattCharacteristic) findInCache(UUID, BluetoothType.GATT_CHARACTERISTIC);
+ return (DBTGattChar) findInCache(UUID, BTType.GATT_CHARACTERISTIC);
}
@Override
- public BluetoothGattCharacteristic find(final String UUID) {
+ public BTGattChar find(final String UUID) {
return find(UUID, 0);
}
@Override
- public final BluetoothDevice getDevice() { return wbr_device.get(); }
+ public final BTDevice getDevice() { return wbr_device.get(); }
@Override
public final boolean getPrimary() { return isPrimary; }
@Override
- public final List<BluetoothGattCharacteristic> getCharacteristics() { return characteristicList; }
+ public final List<BTGattChar> getChars() { return charList; }
/**
* Returns the service start handle.
@@ -130,7 +130,7 @@ public class DBTGattService extends DBTObject implements BluetoothGattService
private native String toStringImpl();
- private native List<BluetoothGattCharacteristic> getCharacteristicsImpl();
+ private native List<BTGattChar> getCharsImpl();
@Override
protected native void deleteImpl(long nativeInstance);
@@ -148,34 +148,34 @@ public class DBTGattService extends DBTObject implements BluetoothGattService
* <p>
* The returned {@link DBTObject} may be of type
* <ul>
- * <li>{@link DBTGattCharacteristic}</li>
- * <li>{@link DBTGattDescriptor}</li>
+ * <li>{@link DBTGattChar}</li>
+ * <li>{@link DBTGattDesc}</li>
* </ul>
- * or alternatively in {@link BluetoothObject} space
+ * or alternatively in {@link BTObject} space
* <ul>
- * <li>{@link BluetoothType#GATT_CHARACTERISTIC} -> {@link BluetoothGattCharacteristic}</li>
- * <li>{@link BluetoothType#GATT_DESCRIPTOR} -> {@link BluetoothGattDescriptor}</li>
+ * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li>
+ * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li>
* </ul>
* </p>
* @param uuid UUID of the desired
- * {@link BluetoothType#GATT_CHARACTERISTIC characteristic} or {@link BluetoothType#GATT_DESCRIPTOR descriptor} to be found.
+ * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found.
* Maybe {@code null}, in which case the first object of the desired type is being returned - if existing.
* @param type specify the type of the object to be found, either
- * {@link BluetoothType#GATT_CHARACTERISTIC characteristic}
- * or {@link BluetoothType#GATT_DESCRIPTOR descriptor}.
- * {@link BluetoothType#NONE none} means anything.
+ * {@link BTType#GATT_CHARACTERISTIC characteristic}
+ * or {@link BTType#GATT_DESCRIPTOR descriptor}.
+ * {@link BTType#NONE none} means anything.
*/
- /* pp */ DBTObject findInCache(final String uuid, final BluetoothType type) {
- final boolean anyType = BluetoothType.NONE == type;
- final boolean charType = BluetoothType.GATT_CHARACTERISTIC== type;
- final boolean descType = BluetoothType.GATT_DESCRIPTOR == type;
+ /* pp */ DBTObject findInCache(final String uuid, final BTType type) {
+ final boolean anyType = BTType.NONE == type;
+ final boolean charType = BTType.GATT_CHARACTERISTIC== type;
+ final boolean descType = BTType.GATT_DESCRIPTOR == type;
if( !anyType && !charType && !descType ) {
return null;
}
- final int characteristicSize = characteristicList.size();
+ final int characteristicSize = charList.size();
for(int charIdx = 0; charIdx < characteristicSize; charIdx++ ) {
- final DBTGattCharacteristic characteristic = (DBTGattCharacteristic) characteristicList.get(charIdx);
+ final DBTGattChar characteristic = (DBTGattChar) charList.get(charIdx);
if( ( anyType || charType ) && ( null == uuid || characteristic.getUUID().equals(uuid) ) ) {
return characteristic;
}
diff --git a/java/jau/direct_bt/DBTManager.java b/java/jau/direct_bt/DBTManager.java
index 7ae148e7..ecebbed2 100644
--- a/java/jau/direct_bt/DBTManager.java
+++ b/java/jau/direct_bt/DBTManager.java
@@ -34,22 +34,22 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
import java.util.function.Predicate;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
import org.direct_bt.HCIStatusCode;
-public class DBTManager implements BluetoothManager
+public class DBTManager implements BTManager
{
- protected static final boolean DEBUG = BluetoothFactory.DEBUG;
- protected static final boolean VERBOSE = BluetoothFactory.VERBOSE;
+ protected static final boolean DEBUG = BTFactory.DEBUG;
+ protected static final boolean VERBOSE = BTFactory.VERBOSE;
private static volatile boolean isJVMShuttingDown = false;
private static final List<Runnable> userShutdownHooks = new ArrayList<Runnable>();
@@ -96,7 +96,7 @@ public class DBTManager implements BluetoothManager
}
try {
- final BluetoothManager mgmt = getManager();
+ final BTManager mgmt = getManager();
mgmt.shutdown();
} catch(final Throwable t) {
System.err.println("DBTManager.shutdown: Caught "+t.getClass().getName()+" during DBTManager.shutdown()");
@@ -152,7 +152,7 @@ public class DBTManager implements BluetoothManager
public static void setUnifyUUID128Bit(final boolean v) { unifyUUID128Bit=v; }
private long nativeInstance;
- private final List<BluetoothAdapter> adapters = new CopyOnWriteArrayList<BluetoothAdapter>();
+ private final List<BTAdapter> adapters = new CopyOnWriteArrayList<BTAdapter>();
private final List<ChangedAdapterSetListener> changedAdapterSetListenerList = new CopyOnWriteArrayList<ChangedAdapterSetListener>();
private final Settings settings;
@@ -160,20 +160,20 @@ public class DBTManager implements BluetoothManager
@Override
public final Settings getSettings() { return settings; }
- public BluetoothType getBluetoothType() { return BluetoothType.NONE; }
+ public BTType getBluetoothType() { return BTType.NONE; }
@Override
- public DBTObject find(final BluetoothType type, final String name, final String identifier, final BluetoothObject parent, final long timeoutMS) {
+ public DBTObject find(final BTType type, final String name, final String identifier, final BTObject parent, final long timeoutMS) {
return findInCache((DBTObject)parent, type, name, identifier);
}
@Override
- public DBTObject find(final BluetoothType type, final String name, final String identifier, final BluetoothObject parent) {
+ public DBTObject find(final BTType type, final String name, final String identifier, final BTObject parent) {
return find(type, name, identifier, parent, 0);
}
@Override
- public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent, final long timeoutMS) {
+ public <T extends BTObject> T find(final String name, final String identifier, final BTObject parent, final long timeoutMS) {
// Due to generic type erasure, we cannot determine the matching BluetoothType for the return parameter,
// hence this orig TinyB API method is rather misleading than useful.
throw new UnsupportedOperationException("Generic return type 'find' won't be implemented.");
@@ -181,7 +181,7 @@ public class DBTManager implements BluetoothManager
}
@Override
- public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent) {
+ public <T extends BTObject> T find(final String name, final String identifier, final BTObject parent) {
// Due to generic type erasure, we cannot determine the matching BluetoothType for the return parameter,
// hence this orig TinyB API method is rather misleading than useful.
throw new UnsupportedOperationException("Generic return type 'find' won't be implemented.");
@@ -189,28 +189,28 @@ public class DBTManager implements BluetoothManager
}
@Override
- public BluetoothObject getObject(final BluetoothType type, final String name,
- final String identifier, final BluetoothObject parent) {
+ public BTObject getObject(final BTType type, final String name,
+ final String identifier, final BTObject parent) {
return getObject(type.ordinal(), name, identifier, parent);
}
- private BluetoothObject getObject(final int type, final String name, final String identifier, final BluetoothObject parent)
+ private BTObject getObject(final int type, final String name, final String identifier, final BTObject parent)
{ throw new UnsupportedOperationException(); } // FIXME
@Override
- public List<BluetoothObject> getObjects(final BluetoothType type, final String name,
- final String identifier, final BluetoothObject parent) {
+ public List<BTObject> getObjects(final BTType type, final String name,
+ final String identifier, final BTObject parent) {
return getObjects(type.ordinal(), name, identifier, parent);
}
- private List<BluetoothObject> getObjects(final int type, final String name, final String identifier, final BluetoothObject parent)
+ private List<BTObject> getObjects(final int type, final String name, final String identifier, final BTObject parent)
{ throw new UnsupportedOperationException(); } // FIXME
@Override
- public List<BluetoothAdapter> getAdapters() { return new ArrayList<BluetoothAdapter>(adapters); }
+ public List<BTAdapter> getAdapters() { return new ArrayList<BTAdapter>(adapters); }
@Override
- public BluetoothAdapter getAdapter(final int dev_id) {
- for(final Iterator<BluetoothAdapter> iter = adapters.iterator(); iter.hasNext(); ) {
- final BluetoothAdapter a = iter.next();
+ public BTAdapter getAdapter(final int dev_id) {
+ for(final Iterator<BTAdapter> iter = adapters.iterator(); iter.hasNext(); ) {
+ final BTAdapter a = iter.next();
if( dev_id == a.getDevID() ) {
return a;
}
@@ -219,7 +219,7 @@ public class DBTManager implements BluetoothManager
}
@Override
- public List<BluetoothDevice> getDevices() { return getDefaultAdapter().getDiscoveredDevices(); }
+ public List<BTDevice> getDevices() { return getDefaultAdapter().getDiscoveredDevices(); }
/**
* {@inheritDoc}
@@ -227,23 +227,23 @@ public class DBTManager implements BluetoothManager
* This call could be a quite expensive service query, see below.
* </p>
* <p>
- * This implementation returns all {@link BluetoothGattService} from all {@link BluetoothDevice}s
- * from the {@link #getDefaultAdapter()} using {@link BluetoothDevice#getServices()}.
+ * This implementation returns all {@link BTGattService} from all {@link BTDevice}s
+ * from the {@link #getDefaultAdapter()} using {@link BTDevice#getServices()}.
* </p>
* <p>
- * This implementation does not {@link BluetoothAdapter#startDiscovery() start} an explicit discovery,
- * but previous {@link BluetoothAdapter#getDiscoveredDevices() discovered devices} are being queried.
+ * This implementation does not {@link BTAdapter#startDiscovery() start} an explicit discovery,
+ * but previous {@link BTAdapter#getDiscoveredDevices() discovered devices} are being queried.
* </p>
*/
@Override
- public List<BluetoothGattService> getServices() {
- final List<BluetoothGattService> res = new ArrayList<BluetoothGattService>();
- for(final Iterator<BluetoothAdapter> iterA=adapters.iterator(); iterA.hasNext(); ) {
- final BluetoothAdapter adapter = iterA.next();
- final List<BluetoothDevice> devices = adapter.getDiscoveredDevices();
- for(final Iterator<BluetoothDevice> iterD=devices.iterator(); iterD.hasNext(); ) {
- final BluetoothDevice device = iterD.next();
- final List<BluetoothGattService> devServices = device.getServices();
+ public List<BTGattService> getServices() {
+ final List<BTGattService> res = new ArrayList<BTGattService>();
+ for(final Iterator<BTAdapter> iterA=adapters.iterator(); iterA.hasNext(); ) {
+ final BTAdapter adapter = iterA.next();
+ final List<BTDevice> devices = adapter.getDiscoveredDevices();
+ for(final Iterator<BTDevice> iterD=devices.iterator(); iterD.hasNext(); ) {
+ final BTDevice device = iterD.next();
+ final List<BTGattService> devServices = device.getServices();
if( null != devServices ) {
res.addAll(devServices);
}
@@ -253,14 +253,14 @@ public class DBTManager implements BluetoothManager
}
@Override
- public boolean setDefaultAdapter(final BluetoothAdapter adapter) {
+ public boolean setDefaultAdapter(final BTAdapter adapter) {
return false;
}
@Override
- public BluetoothAdapter getDefaultAdapter() {
- for(final Iterator<BluetoothAdapter> iter = adapters.iterator(); iter.hasNext(); ) {
- final BluetoothAdapter a = iter.next();
+ public BTAdapter getDefaultAdapter() {
+ for(final Iterator<BTAdapter> iter = adapters.iterator(); iter.hasNext(); ) {
+ final BTAdapter a = iter.next();
if( a.isPowered() ) {
return a;
}
@@ -269,25 +269,25 @@ public class DBTManager implements BluetoothManager
}
@Override
- public boolean startDiscovery() throws BluetoothException { return HCIStatusCode.SUCCESS == startDiscovery(true); }
+ public boolean startDiscovery() throws BTException { return HCIStatusCode.SUCCESS == startDiscovery(true); }
@Override
- public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException { return getDefaultAdapter().startDiscovery(keepAlive); }
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException { return getDefaultAdapter().startDiscovery(keepAlive); }
@Override
- public HCIStatusCode stopDiscovery() throws BluetoothException { return getDefaultAdapter().stopDiscovery(); }
+ public HCIStatusCode stopDiscovery() throws BTException { return getDefaultAdapter().stopDiscovery(); }
@SuppressWarnings("deprecation")
@Override
- public boolean getDiscovering() throws BluetoothException { return getDefaultAdapter().getDiscovering(); }
+ public boolean getDiscovering() throws BTException { return getDefaultAdapter().getDiscovering(); }
@Override
public final void addChangedAdapterSetListener(final ChangedAdapterSetListener l) {
changedAdapterSetListenerList.add(l);
- adapters.forEach(new Consumer<BluetoothAdapter>() {
+ adapters.forEach(new Consumer<BTAdapter>() {
@Override
- public void accept(final BluetoothAdapter adapter) {
+ public void accept(final BTAdapter adapter) {
l.adapterAdded(adapter);
}
});
@@ -310,8 +310,8 @@ public class DBTManager implements BluetoothManager
return count[0];
}
- private native List<BluetoothAdapter> getAdapterListImpl();
- private native BluetoothAdapter getAdapterImpl(int dev_id);
+ private native List<BTAdapter> getAdapterListImpl();
+ private native BTAdapter getAdapterImpl(int dev_id);
/**
* Removal entry for DBTAdapter.close()
@@ -334,11 +334,11 @@ public class DBTManager implements BluetoothManager
/** callback from native adapter remove */
/* pp */ final void removeAdapterCB(final int dev_id, final int opc_reason) {
- final BluetoothAdapter[] removed = { null };
+ final BTAdapter[] removed = { null };
final int count[] = { 0 };
- adapters.removeIf(new Predicate<BluetoothAdapter>() {
+ adapters.removeIf(new Predicate<BTAdapter>() {
@Override
- public boolean test(final BluetoothAdapter a) {
+ public boolean test(final BTAdapter a) {
if( 0 == count[0] && dev_id == a.getDevID() ) {
removed[0] = a;
count[0]++;
@@ -370,7 +370,7 @@ public class DBTManager implements BluetoothManager
}
/** callback from native adapter add or POWERED on */
private final void updatedAdapterCB(final int dev_id, final int opc_reason) {
- final BluetoothAdapter preInstance = getAdapter(dev_id);
+ final BTAdapter preInstance = getAdapter(dev_id);
if( null != preInstance ) {
if( DEBUG ) {
System.err.println("DBTManager.updatedAdapterCB[dev_id "+dev_id+", opc 0x"+Integer.toHexString(opc_reason)+
@@ -378,7 +378,7 @@ public class DBTManager implements BluetoothManager
}
return;
}
- final BluetoothAdapter newInstance = getAdapterImpl(dev_id);
+ final BTAdapter newInstance = getAdapterImpl(dev_id);
if( null == newInstance ) {
if( DEBUG ) {
System.err.println("DBTManager.updatedAdapterCB[dev_id "+dev_id+", opc 0x"+Integer.toHexString(opc_reason)+
@@ -401,14 +401,14 @@ public class DBTManager implements BluetoothManager
}
}
- private native void initImpl(final boolean unifyUUID128Bit, final int btMode) throws BluetoothException;
+ private native void initImpl(final boolean unifyUUID128Bit, final int btMode) throws BTException;
private native void deleteImpl(long nativeInstance);
private DBTManager()
{
- initImpl(unifyUUID128Bit, BluetoothFactory.DEFAULT_BTMODE.value);
+ initImpl(unifyUUID128Bit, BTFactory.DEFAULT_BTMODE.value);
try {
adapters.addAll(getAdapterListImpl());
- } catch (final BluetoothException be) {
+ } catch (final BTException be) {
be.printStackTrace();
}
final boolean supCharValCacheNotify;
@@ -440,7 +440,7 @@ public class DBTManager implements BluetoothManager
/** Returns an instance of BluetoothManager, to be used instead of constructor.
* @return An initialized BluetoothManager instance.
*/
- public static BluetoothManager getManager() throws RuntimeException, BluetoothException {
+ public static BTManager getManager() throws RuntimeException, BTException {
return LazySingletonHolder.singleton;
}
/** Initialize-On-Demand Holder Class, similar to C++11's "Magic Statics". */
@@ -455,7 +455,7 @@ public class DBTManager implements BluetoothManager
@Override
public void shutdown() {
- for(final Iterator<BluetoothAdapter> ia= adapters.iterator(); ia.hasNext(); ) {
+ for(final Iterator<BTAdapter> ia= adapters.iterator(); ia.hasNext(); ) {
final DBTAdapter a = (DBTAdapter)ia.next();
a.close();
}
@@ -472,33 +472,33 @@ public class DBTManager implements BluetoothManager
* <li>{@link DBTAdapter}</li>
* <li>{@link DBTDevice}</li>
* <li>{@link DBTGattService}</li>
- * <li>{@link DBTGattCharacteristic}</li>
- * <li>{@link DBTGattDescriptor}</li>
+ * <li>{@link DBTGattChar}</li>
+ * <li>{@link DBTGattDesc}</li>
* </ul>
- * or alternatively in {@link BluetoothObject} space
+ * or alternatively in {@link BTObject} space
* <ul>
- * <li>{@link BluetoothType#ADAPTER} -> {@link BluetoothAdapter}</li>
- * <li>{@link BluetoothType#DEVICE} -> {@link BluetoothDevice}</li>
- * <li>{@link BluetoothType#GATT_SERVICE} -> {@link BluetoothGattService}</li>
- * <li>{@link BluetoothType#GATT_CHARACTERISTIC} -> {@link BluetoothGattCharacteristic}</li>
- * <li>{@link BluetoothType#GATT_DESCRIPTOR} -> {@link BluetoothGattDescriptor}</li>
+ * <li>{@link BTType#ADAPTER} -> {@link BTAdapter}</li>
+ * <li>{@link BTType#DEVICE} -> {@link BTDevice}</li>
+ * <li>{@link BTType#GATT_SERVICE} -> {@link BTGattService}</li>
+ * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li>
+ * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li>
* </ul>
* </p>
- * @param name name of the desired {@link BluetoothType#ADAPTER adapter} or {@link BluetoothType#DEVICE device}.
+ * @param name name of the desired {@link BTType#ADAPTER adapter} or {@link BTType#DEVICE device}.
* Maybe {@code null}.
- * @param identifier EUI48 address of the desired {@link BluetoothType#ADAPTER adapter} or {@link BluetoothType#DEVICE device}
- * or UUID of the desired {@link BluetoothType#GATT_SERVICE service},
- * {@link BluetoothType#GATT_CHARACTERISTIC characteristic} or {@link BluetoothType#GATT_DESCRIPTOR descriptor} to be found.
+ * @param identifier EUI48 address of the desired {@link BTType#ADAPTER adapter} or {@link BTType#DEVICE device}
+ * or UUID of the desired {@link BTType#GATT_SERVICE service},
+ * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found.
* Maybe {@code null}, in which case the first object of the desired type is being returned - if existing.
* @param type specify the type of the object to be found, either
- * {@link BluetoothType#ADAPTER adapter}, {@link BluetoothType#DEVICE device},
- * {@link BluetoothType#GATT_SERVICE service}, {@link BluetoothType#GATT_CHARACTERISTIC characteristic}
- * or {@link BluetoothType#GATT_DESCRIPTOR descriptor}.
- * {@link BluetoothType#NONE none} means anything.
+ * {@link BTType#ADAPTER adapter}, {@link BTType#DEVICE device},
+ * {@link BTType#GATT_SERVICE service}, {@link BTType#GATT_CHARACTERISTIC characteristic}
+ * or {@link BTType#GATT_DESCRIPTOR descriptor}.
+ * {@link BTType#NONE none} means anything.
*/
- /* pp */ DBTObject findInCache(final String name, final String identifier, final BluetoothType type) {
- final boolean anyType = BluetoothType.NONE == type;
- final boolean adapterType = BluetoothType.ADAPTER == type;
+ /* pp */ DBTObject findInCache(final String name, final String identifier, final BTType type) {
+ final boolean anyType = BTType.NONE == type;
+ final boolean adapterType = BTType.ADAPTER == type;
if( null == name && null == identifier && ( anyType || adapterType ) ) {
// special case for 1st valid adapter
@@ -507,7 +507,7 @@ public class DBTManager implements BluetoothManager
}
return null; // no adapter
}
- for(final Iterator<BluetoothAdapter> iter = adapters.iterator(); iter.hasNext(); ) {
+ for(final Iterator<BTAdapter> iter = adapters.iterator(); iter.hasNext(); ) {
final DBTAdapter adapter = (DBTAdapter) iter.next();
if( !adapter.isValid() ) {
continue;
@@ -541,31 +541,31 @@ public class DBTManager implements BluetoothManager
return null;
}
- /* pp */ DBTObject findInCache(final DBTObject parent, final BluetoothType type, final String name, final String identifier) {
+ /* pp */ DBTObject findInCache(final DBTObject parent, final BTType type, final String name, final String identifier) {
if( null == parent ) {
return findInCache(name, identifier, type);
}
- final boolean anyType = BluetoothType.NONE == type;
- final boolean deviceType = BluetoothType.DEVICE == type;
- final boolean serviceType = BluetoothType.GATT_SERVICE == type;
- final boolean charType = BluetoothType.GATT_CHARACTERISTIC== type;
- final boolean descType = BluetoothType.GATT_DESCRIPTOR == type;
+ final boolean anyType = BTType.NONE == type;
+ final boolean deviceType = BTType.DEVICE == type;
+ final boolean serviceType = BTType.GATT_SERVICE == type;
+ final boolean charType = BTType.GATT_CHARACTERISTIC== type;
+ final boolean descType = BTType.GATT_DESCRIPTOR == type;
- final BluetoothType parentType = parent.getBluetoothType();
+ final BTType parentType = parent.getBluetoothType();
- if( BluetoothType.ADAPTER == parentType &&
+ if( BTType.ADAPTER == parentType &&
( anyType || deviceType || serviceType || charType || descType )
)
{
return ((DBTAdapter) parent).findInCache(name, identifier, type);
}
- if( BluetoothType.DEVICE == parentType &&
+ if( BTType.DEVICE == parentType &&
( anyType || serviceType || charType || descType )
)
{
return ((DBTDevice) parent).findInCache(identifier, type);
}
- if( BluetoothType.GATT_SERVICE == parentType &&
+ if( BTType.GATT_SERVICE == parentType &&
( anyType || charType || descType )
)
{
@@ -575,11 +575,11 @@ public class DBTManager implements BluetoothManager
}
return service.findInCache(identifier, type);
}
- if( BluetoothType.GATT_CHARACTERISTIC == parentType &&
+ if( BTType.GATT_CHARACTERISTIC == parentType &&
( anyType || descType )
)
{
- final DBTGattCharacteristic characteristic = (DBTGattCharacteristic) parent;
+ final DBTGattChar characteristic = (DBTGattChar) parent;
if( !characteristic.checkServiceCache() ) {
return null;
}
diff --git a/java/jau/direct_bt/DBTNativeDownlink.java b/java/jau/direct_bt/DBTNativeDownlink.java
index 9e3de0c1..71e72ce1 100644
--- a/java/jau/direct_bt/DBTNativeDownlink.java
+++ b/java/jau/direct_bt/DBTNativeDownlink.java
@@ -27,7 +27,7 @@ package jau.direct_bt;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.direct_bt.BluetoothFactory;
+import org.direct_bt.BTFactory;
public abstract class DBTNativeDownlink
{
@@ -36,7 +36,7 @@ public abstract class DBTNativeDownlink
private final Object nativeLock = new Object();
static {
- BluetoothFactory.checkInitialized();
+ BTFactory.checkInitialized();
}
protected DBTNativeDownlink(final long nativeInstance)
diff --git a/java/jau/direct_bt/DBTObject.java b/java/jau/direct_bt/DBTObject.java
index d8fb4d7d..80266d84 100644
--- a/java/jau/direct_bt/DBTObject.java
+++ b/java/jau/direct_bt/DBTObject.java
@@ -25,10 +25,10 @@
package jau.direct_bt;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
-public abstract class DBTObject extends DBTNativeDownlink implements BluetoothObject
+public abstract class DBTObject extends DBTNativeDownlink implements BTObject
{
private final int hashValue;
@@ -49,7 +49,7 @@ public abstract class DBTObject extends DBTNativeDownlink implements BluetoothOb
this.hashValue = hashValue;
}
- static BluetoothType class_type() { return BluetoothType.NONE; }
+ static BTType class_type() { return BTType.NONE; }
@Override
public abstract boolean equals(final Object obj);
@@ -71,7 +71,7 @@ public abstract class DBTObject extends DBTNativeDownlink implements BluetoothOb
}
@Override
- public BluetoothObject clone()
+ public BTObject clone()
{ throw new UnsupportedOperationException(); } // FIXME
}
diff --git a/java/jni/BluetoothFactory.cxx b/java/jni/BTFactory.cxx
index 30856fa1..ace0a6b3 100644
--- a/java/jni/BluetoothFactory.cxx
+++ b/java/jni/BTFactory.cxx
@@ -23,7 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "org_direct_bt_BluetoothFactory.h"
+#include "org_direct_bt_BTFactory.h"
#include "version.h"
@@ -31,7 +31,7 @@
using namespace jau;
-jstring Java_org_direct_bt_BluetoothFactory_getNativeAPIVersion(JNIEnv *env, jclass clazz)
+jstring Java_org_direct_1bt_BTFactory_getNativeAPIVersion(JNIEnv *env, jclass clazz)
{
try {
(void) clazz;
@@ -44,7 +44,7 @@ jstring Java_org_direct_bt_BluetoothFactory_getNativeAPIVersion(JNIEnv *env, jcl
return nullptr;
}
-void Java_org_direct_bt_BluetoothFactory_setenv(JNIEnv *env, jclass clazz, jstring jname, jstring jval, jboolean overwrite)
+void Java_org_direct_1bt_BTFactory_setenv(JNIEnv *env, jclass clazz, jstring jname, jstring jval, jboolean overwrite)
{
try {
(void) clazz;
diff --git a/java/jni/BluetoothUtils.cxx b/java/jni/BTUtils.cxx
index 7f86f3c5..2071c9e1 100644
--- a/java/jni/BluetoothUtils.cxx
+++ b/java/jni/BTUtils.cxx
@@ -23,7 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "org_direct_bt_BluetoothUtils.h"
+#include "org_direct_bt_BTUtils.h"
#include <cstdint>
#include <cinttypes>
@@ -47,7 +47,7 @@ static const int64_t MilliPerOne = 1000L;
* clock_gettime seems to be well supported at least on kernel >= 4.4.
* Only bfin and sh are missing, while ia64 seems to be complicated.
*/
-jlong Java_org_direct_bt_BluetoothUtils_currentTimeMillis(JNIEnv *env, jclass clazz) {
+jlong Java_org_direct_1bt_BTUtils_currentTimeMillis(JNIEnv *env, jclass clazz) {
(void)env;
(void)clazz;
@@ -57,14 +57,14 @@ jlong Java_org_direct_bt_BluetoothUtils_currentTimeMillis(JNIEnv *env, jclass cl
return (jlong)res;
}
-jlong Java_org_direct_bt_BluetoothUtils_startupTimeMillisImpl(JNIEnv *env, jclass clazz) {
+jlong Java_org_direct_1bt_BTUtils_startupTimeMillisImpl(JNIEnv *env, jclass clazz) {
(void)env;
(void)clazz;
return jau::environment::startupTimeMilliseconds;
}
-jstring Java_org_direct_bt_BluetoothUtils_decodeUTF8String(JNIEnv *env, jclass clazz, jbyteArray jbuffer, jint offset, jint size) {
+jstring Java_org_direct_1bt_BTUtils_decodeUTF8String(JNIEnv *env, jclass clazz, jbyteArray jbuffer, jint offset, jint size) {
(void)clazz;
const int buffer_size = env->GetArrayLength(jbuffer);
diff --git a/java/jni/direct_bt/CMakeLists.txt b/java/jni/direct_bt/CMakeLists.txt
index 814273fa..ec5bddfc 100644
--- a/java/jni/direct_bt/CMakeLists.txt
+++ b/java/jni/direct_bt/CMakeLists.txt
@@ -23,17 +23,17 @@ set (direct_bt_JNI_SRCS
${PROJECT_SOURCE_DIR}/jaulib/java_jni/jni/jni_mem.cxx
${PROJECT_SOURCE_DIR}/jaulib/java_jni/jni/helper_jni.cxx
${PROJECT_SOURCE_DIR}/java/jni/helper_base.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/BluetoothFactory.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/BluetoothUtils.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/BTFactory.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/BTUtils.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/helper_dbt.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTNativeDownlink.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTAdapter.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTDevice.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTEvent.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTGattCharacteristic.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTGattDescriptor.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTGattChar.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTGattDesc.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTGattService.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTManager.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTNativeDownlink.cxx
${PROJECT_SOURCE_DIR}/java/jni/direct_bt/DBTObject.cxx
)
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx
index 3f490011..15348f9b 100644
--- a/java/jni/direct_bt/DBTAdapter.cxx
+++ b/java/jni/direct_bt/DBTAdapter.cxx
@@ -31,33 +31,33 @@
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTAdapter.hpp"
-#include "direct_bt/DBTManager.hpp"
+#include "direct_bt/BTAdapter.hpp"
+#include "direct_bt/BTManager.hpp"
using namespace direct_bt;
-static const std::string _adapterSettingsClassName("org/tinyb/AdapterSettings");
+static const std::string _adapterSettingsClassName("org/direct_bt/AdapterSettings");
static const std::string _adapterSettingsClazzCtorArgs("(I)V");
-static const std::string _eirDataTypeSetClassName("org/tinyb/EIRDataTypeSet");
+static const std::string _eirDataTypeSetClassName("org/direct_bt/EIRDataTypeSet");
static const std::string _eirDataTypeSetClazzCtorArgs("(I)V");
-static const std::string _hciStatusCodeClassName("org/tinyb/HCIStatusCode");
-static const std::string _hciStatusCodeClazzGetArgs("(B)Lorg/tinyb/HCIStatusCode;");
-static const std::string _scanTypeClassName("org/tinyb/ScanType");
-static const std::string _scanTypeClazzGetArgs("(B)Lorg/tinyb/ScanType;");
-static const std::string _pairingModeClassName("org/tinyb/PairingMode");
-static const std::string _pairingModeClazzGetArgs("(B)Lorg/tinyb/PairingMode;");
-static const std::string _pairingStateClassName("org/tinyb/SMPPairingState");
-static const std::string _pairingStateClazzGetArgs("(B)Lorg/tinyb/SMPPairingState;");
-static const std::string _deviceClazzCtorArgs("(JLdirect_bt/tinyb/DBTAdapter;[BBLjava/lang/String;J)V");
-
-static const std::string _adapterSettingsChangedMethodArgs("(Lorg/tinyb/BluetoothAdapter;Lorg/tinyb/AdapterSettings;Lorg/tinyb/AdapterSettings;Lorg/tinyb/AdapterSettings;J)V");
-static const std::string _discoveringChangedMethodArgs("(Lorg/tinyb/BluetoothAdapter;Lorg/tinyb/ScanType;Lorg/tinyb/ScanType;ZZJ)V");
-static const std::string _deviceFoundMethodArgs("(Lorg/tinyb/BluetoothDevice;J)Z");
-static const std::string _deviceUpdatedMethodArgs("(Lorg/tinyb/BluetoothDevice;Lorg/tinyb/EIRDataTypeSet;J)V");
-static const std::string _deviceConnectedMethodArgs("(Lorg/tinyb/BluetoothDevice;SJ)V");
-static const std::string _devicePairingStateMethodArgs("(Lorg/tinyb/BluetoothDevice;Lorg/tinyb/SMPPairingState;Lorg/tinyb/PairingMode;J)V");
-static const std::string _deviceReadyMethodArgs("(Lorg/tinyb/BluetoothDevice;J)V");
-static const std::string _deviceDisconnectedMethodArgs("(Lorg/tinyb/BluetoothDevice;Lorg/tinyb/HCIStatusCode;SJ)V");
+static const std::string _hciStatusCodeClassName("org/direct_bt/HCIStatusCode");
+static const std::string _hciStatusCodeClazzGetArgs("(B)Lorg/direct_bt/HCIStatusCode;");
+static const std::string _scanTypeClassName("org/direct_bt/ScanType");
+static const std::string _scanTypeClazzGetArgs("(B)Lorg/direct_bt/ScanType;");
+static const std::string _pairingModeClassName("org/direct_bt/PairingMode");
+static const std::string _pairingModeClazzGetArgs("(B)Lorg/direct_bt/PairingMode;");
+static const std::string _pairingStateClassName("org/direct_bt/SMPPairingState");
+static const std::string _pairingStateClazzGetArgs("(B)Lorg/direct_bt/SMPPairingState;");
+static const std::string _deviceClazzCtorArgs("(JLjau/direct_bt/DBTAdapter;[BBLjava/lang/String;J)V");
+
+static const std::string _adapterSettingsChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;Lorg/direct_bt/AdapterSettings;J)V");
+static const std::string _discoveringChangedMethodArgs("(Lorg/direct_bt/BTAdapter;Lorg/direct_bt/ScanType;Lorg/direct_bt/ScanType;ZZJ)V");
+static const std::string _deviceFoundMethodArgs("(Lorg/direct_bt/BTDevice;J)Z");
+static const std::string _deviceUpdatedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/EIRDataTypeSet;J)V");
+static const std::string _deviceConnectedMethodArgs("(Lorg/direct_bt/BTDevice;SJ)V");
+static const std::string _devicePairingStateMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/SMPPairingState;Lorg/direct_bt/PairingMode;J)V");
+static const std::string _deviceReadyMethodArgs("(Lorg/direct_bt/BTDevice;J)V");
+static const std::string _deviceDisconnectedMethodArgs("(Lorg/direct_bt/BTDevice;Lorg/direct_bt/HCIStatusCode;SJ)V");
class JNIAdapterStatusListener : public AdapterStatusListener {
private:
@@ -83,7 +83,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
*/
static std::atomic<int> iname_next;
int const iname;
- DBTDevice const * const deviceMatchRef;
+ BTDevice const * const deviceMatchRef;
std::shared_ptr<jau::JavaAnon> adapterObjRef;
JNIGlobalRef adapterSettingsClazzRef;
jmethodID adapterSettingsClazzCtor;
@@ -124,9 +124,9 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
// listenerObjRef dtor will call notifyDelete and clears the nativeInstance handle
}
- JNIAdapterStatusListener(JNIEnv *env, DBTAdapter *adapter,
+ JNIAdapterStatusListener(JNIEnv *env, BTAdapter *adapter,
jclass listenerClazz, jobject statusListenerObj, jmethodID statusListenerNotifyDeleted,
- const DBTDevice * _deviceMatchRef)
+ const BTDevice * _deviceMatchRef)
: iname(iname_next.fetch_add(1)), deviceMatchRef(_deviceMatchRef), listenerObjRef(statusListenerObj, statusListenerNotifyDeleted)
{
adapterObjRef = adapter->getJavaObject();
@@ -137,7 +137,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jclass adapterSettingsClazz = jau::search_class(env, _adapterSettingsClassName.c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == adapterSettingsClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+_adapterSettingsClassName, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+_adapterSettingsClassName, E_FILE_LINE);
}
adapterSettingsClazzRef = JNIGlobalRef(adapterSettingsClazz);
env->DeleteLocalRef(adapterSettingsClazz);
@@ -153,7 +153,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jclass eirDataTypeSetClazz = jau::search_class(env, _eirDataTypeSetClassName.c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == eirDataTypeSetClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+_eirDataTypeSetClassName, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+_eirDataTypeSetClassName, E_FILE_LINE);
}
eirDataTypeSetClazzRef = JNIGlobalRef(eirDataTypeSetClazz);
env->DeleteLocalRef(eirDataTypeSetClazz);
@@ -169,7 +169,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jclass hciErrorCodeClazz = jau::search_class(env, _hciStatusCodeClassName.c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == hciErrorCodeClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+_hciStatusCodeClassName, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+_hciStatusCodeClassName, E_FILE_LINE);
}
hciStatusCodeClazzRef = JNIGlobalRef(hciErrorCodeClazz);
env->DeleteLocalRef(hciErrorCodeClazz);
@@ -185,7 +185,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jclass scanTypeClazz = jau::search_class(env, _scanTypeClassName.c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == scanTypeClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+_scanTypeClassName, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+_scanTypeClassName, E_FILE_LINE);
}
scanTypeClazzRef = JNIGlobalRef(scanTypeClazz);
env->DeleteLocalRef(scanTypeClazz);
@@ -201,7 +201,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jclass pairingModeClazz = jau::search_class(env, _pairingModeClassName.c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == pairingModeClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+_pairingModeClassName, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+_pairingModeClassName, E_FILE_LINE);
}
pairingModeClazzRef = JNIGlobalRef(pairingModeClazz);
env->DeleteLocalRef(pairingModeClazz);
@@ -217,7 +217,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jclass pairingStateClazz = jau::search_class(env, _pairingStateClassName.c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == pairingStateClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+_pairingStateClassName, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+_pairingStateClassName, E_FILE_LINE);
}
pairingStateClazzRef = JNIGlobalRef(pairingStateClazz);
env->DeleteLocalRef(pairingStateClazz);
@@ -230,10 +230,10 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
// deviceClazzRef, deviceClazzCtor
{
- jclass deviceClazz = jau::search_class(env, DBTDevice::java_class().c_str());
+ jclass deviceClazz = jau::search_class(env, BTDevice::java_class().c_str());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == deviceClazz ) {
- throw jau::InternalError("DBTDevice::java_class not found: "+DBTDevice::java_class(), E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class not found: "+BTDevice::java_class(), E_FILE_LINE);
}
deviceClazzRef = JNIGlobalRef(deviceClazz);
env->DeleteLocalRef(deviceClazz);
@@ -241,22 +241,22 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
deviceClazzCtor = jau::search_method(env, deviceClazzRef.getClass(), "<init>", _deviceClazzCtorArgs.c_str(), false);
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == deviceClazzCtor ) {
- throw jau::InternalError("DBTDevice::java_class ctor not found: "+DBTDevice::java_class()+".<init>"+_deviceClazzCtorArgs, E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class ctor not found: "+BTDevice::java_class()+".<init>"+_deviceClazzCtorArgs, E_FILE_LINE);
}
deviceClazzTSLastDiscoveryField = env->GetFieldID(deviceClazzRef.getClass(), "ts_last_discovery", "J");
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == deviceClazzTSLastDiscoveryField ) {
- throw jau::InternalError("DBTDevice::java_class field not found: "+DBTDevice::java_class()+".ts_last_discovery", E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class field not found: "+BTDevice::java_class()+".ts_last_discovery", E_FILE_LINE);
}
deviceClazzTSLastUpdateField = env->GetFieldID(deviceClazzRef.getClass(), "ts_last_update", "J");
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == deviceClazzTSLastUpdateField ) {
- throw jau::InternalError("DBTDevice::java_class field not found: "+DBTDevice::java_class()+".ts_last_update", E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class field not found: "+BTDevice::java_class()+".ts_last_update", E_FILE_LINE);
}
deviceClazzConnectionHandleField = env->GetFieldID(deviceClazzRef.getClass(), "hciConnHandle", "S");
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == deviceClazzConnectionHandleField ) {
- throw jau::InternalError("DBTDevice::java_class field not found: "+DBTDevice::java_class()+".hciConnHandle", E_FILE_LINE);
+ throw jau::InternalError("BTDevice::java_class field not found: "+BTDevice::java_class()+".hciConnHandle", E_FILE_LINE);
}
mAdapterSettingsChanged = jau::search_method(env, listenerClazz, "adapterSettingsChanged", _adapterSettingsChangedMethodArgs.c_str(), false);
@@ -301,14 +301,14 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
}
}
- bool matchDevice(const DBTDevice & device) override {
+ bool matchDevice(const BTDevice & device) override {
if( nullptr == deviceMatchRef ) {
return true;
}
return device == *deviceMatchRef;
}
- void adapterSettingsChanged(DBTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
+ void adapterSettingsChanged(BTAdapter &a, const AdapterSetting oldmask, const AdapterSetting newmask,
const AdapterSetting changedmask, const uint64_t timestamp) override {
JNIEnv *env = *jni_env;
(void)a;
@@ -332,7 +332,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
env->DeleteLocalRef(adapterSettingChanged);
}
- void discoveringChanged(DBTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
+ void discoveringChanged(BTAdapter &a, const ScanType currentMeta, const ScanType changedType, const bool changedEnabled, const bool keepAlive, const uint64_t timestamp) override {
JNIEnv *env = *jni_env;
(void)a;
@@ -349,7 +349,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
jau::java_exception_check_and_throw(env, E_FILE_LINE);
}
- bool deviceFound(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ bool deviceFound(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
JNIEnv *env = *jni_env;
jobject jdevice;
std::shared_ptr<jau::JavaAnon> jDeviceRef0 = device->getJavaObject();
@@ -384,7 +384,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
return JNI_TRUE == res;
}
- void deviceUpdated(std::shared_ptr<DBTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
+ void deviceUpdated(std::shared_ptr<BTDevice> device, const EIRDataType updateMask, const uint64_t timestamp) override {
std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
return; // java device has been pulled
@@ -402,7 +402,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
env->DeleteLocalRef(eirDataTypeSet);
}
- void deviceConnected(std::shared_ptr<DBTDevice> device, const uint16_t handle, const uint64_t timestamp) override {
+ void deviceConnected(std::shared_ptr<BTDevice> device, const uint16_t handle, const uint64_t timestamp) override {
JNIEnv *env = *jni_env;
jobject jdevice;
@@ -441,7 +441,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
env->CallVoidMethod(listenerObjRef.getObject(), mDeviceConnected, jdevice, (jshort)handle, (jlong)timestamp);
jau::java_exception_check_and_throw(env, E_FILE_LINE);
}
- void devicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
+ void devicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, const uint64_t timestamp) override {
std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
return; // java device has been pulled
@@ -463,7 +463,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
env->CallVoidMethod(listenerObjRef.getObject(), mDevicePairingState, jdevice, jstate, jmode, (jlong)timestamp);
jau::java_exception_check_and_throw(env, E_FILE_LINE);
}
- void deviceReady(std::shared_ptr<DBTDevice> device, const uint64_t timestamp) override {
+ void deviceReady(std::shared_ptr<BTDevice> device, const uint64_t timestamp) override {
std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
return; // java device has been pulled
@@ -477,7 +477,7 @@ class JNIAdapterStatusListener : public AdapterStatusListener {
env->CallVoidMethod(listenerObjRef.getObject(), mDeviceReady, jdevice, (jlong)timestamp);
jau::java_exception_check_and_throw(env, E_FILE_LINE);
}
- void deviceDisconnected(std::shared_ptr<DBTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
+ void deviceDisconnected(std::shared_ptr<BTDevice> device, const HCIStatusCode reason, const uint16_t handle, const uint64_t timestamp) override {
std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
if( !jau::JavaGlobalObj::isValid(jDeviceRef) ) {
return; // java device has been pulled
@@ -514,12 +514,12 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addStatusListener(JNIEnv *env, jobject o
return false;
}
}
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
- DBTDevice * deviceMatchRef = nullptr;
+ BTDevice * deviceMatchRef = nullptr;
if( nullptr != jdeviceMatch ) {
- deviceMatchRef = jau::getJavaUplinkObject<DBTDevice>(env, jdeviceMatch);
+ deviceMatchRef = jau::getJavaUplinkObject<BTDevice>(env, jdeviceMatch);
jau::JavaGlobalObj::check(deviceMatchRef->getJavaObject(), E_FILE_LINE);
}
@@ -567,7 +567,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jo
}
jau::clearInstance(env, statusListener);
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( ! adapter->removeStatusListener( pre ) ) {
@@ -590,7 +590,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeStatusListenerImpl(JNIEnv *env, jo
jint Java_jau_direct_1bt_DBTAdapter_removeAllStatusListener(JNIEnv *env, jobject obj) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
return adapter->removeAllStatusListener();
@@ -602,7 +602,7 @@ jint Java_jau_direct_1bt_DBTAdapter_removeAllStatusListener(JNIEnv *env, jobject
jboolean Java_jau_direct_1bt_DBTAdapter_isDeviceWhitelisted(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( nullptr == jaddress ) {
@@ -631,7 +631,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1(JNIEnv *env, j
jshort min_interval, jshort max_interval,
jshort latency, jshort timeout) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( nullptr == jaddress ) {
@@ -659,7 +659,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl1(JNIEnv *env, j
jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, jobject obj,
jbyteArray jaddress, jbyte jaddressType, int jctype) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( nullptr == jaddress ) {
@@ -686,7 +686,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_addDeviceToWhitelistImpl2(JNIEnv *env, j
}
jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( nullptr == jaddress ) {
@@ -713,7 +713,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDeviceFromWhitelistImpl(JNIEnv *en
jstring Java_jau_direct_1bt_DBTAdapter_toStringImpl(JNIEnv *env, jobject obj) {
try {
- DBTAdapter *nativePtr = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *nativePtr = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(nativePtr->getJavaObject(), E_FILE_LINE);
return jau::from_string_to_jstring(env, nativePtr->toString());
} catch(...) {
@@ -726,10 +726,10 @@ void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong n
{
(void)obj;
try {
- DBTAdapter *adapter = jau::castInstance<DBTAdapter>(nativeInstance);
+ BTAdapter *adapter = jau::castInstance<BTAdapter>(nativeInstance);
DBG_PRINT("Java_jau_direct_1bt_DBTAdapter_deleteImpl (close only) %s", adapter->toString().c_str());
adapter->close();
- // No delete: DBTAdapter instance owned by DBTManager
+ // No delete: BTAdapter instance owned by DBTManager
// However, adapter->close() cleans up most..
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -739,7 +739,7 @@ void Java_jau_direct_1bt_DBTAdapter_deleteImpl(JNIEnv *env, jobject obj, jlong n
jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
return adapter->isPowered();
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -750,7 +750,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isPoweredImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
return adapter->isSuspended();
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -761,7 +761,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isSuspendedImpl(JNIEnv *env, jobject obj
jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
return adapter->isValid();
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -772,7 +772,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_isValidImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj, jboolean keepAlive)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
return (jbyte) number( adapter->startDiscovery(keepAlive) );
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -783,7 +783,7 @@ jbyte Java_jau_direct_1bt_DBTAdapter_startDiscoveryImpl(JNIEnv *env, jobject obj
jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
return (jbyte) number( adapter->stopDiscovery() );
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -794,8 +794,8 @@ jbyte Java_jau_direct_1bt_DBTAdapter_stopDiscoveryImpl(JNIEnv *env, jobject obj)
jobject Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, jobject obj)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
- jau::darray<std::shared_ptr<DBTDevice>> array = adapter->getDiscoveredDevices();
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
+ jau::darray<std::shared_ptr<BTDevice>> array = adapter->getDiscoveredDevices();
return convert_vector_sharedptr_to_jarraylist(env, array);
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -806,7 +806,7 @@ jobject Java_jau_direct_1bt_DBTAdapter_getDiscoveredDevicesImpl(JNIEnv *env, job
jint Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1(JNIEnv *env, jobject obj)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
return adapter->removeDiscoveredDevices();
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -817,7 +817,7 @@ jint Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDevicesImpl1(JNIEnv *env, jo
jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType)
{
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( nullptr == jaddress ) {
@@ -848,7 +848,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_removeDiscoveredDeviceImpl1(JNIEnv *env,
jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jboolean value) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
return adapter->setPowered(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
} catch(...) {
@@ -859,7 +859,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_setPowered(JNIEnv *env, jobject obj, jbo
jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
HCIStatusCode res = adapter->reset();
return (jbyte) number(res);
@@ -871,7 +871,7 @@ jbyte Java_jau_direct_1bt_DBTAdapter_resetImpl(JNIEnv *env, jobject obj) {
jstring Java_jau_direct_1bt_DBTAdapter_getAlias(JNIEnv *env, jobject obj) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
return jau::from_string_to_jstring(env, adapter->getLocalName().getName());
} catch(...) {
@@ -882,7 +882,7 @@ jstring Java_jau_direct_1bt_DBTAdapter_getAlias(JNIEnv *env, jobject obj) {
void Java_jau_direct_1bt_DBTAdapter_setAlias(JNIEnv *env, jobject obj, jstring jnewalias) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
std::string newalias = jau::from_jstring_to_string(env, jnewalias);
adapter->setLocalName(newalias, std::string());
@@ -893,7 +893,7 @@ void Java_jau_direct_1bt_DBTAdapter_setAlias(JNIEnv *env, jobject obj, jstring j
jboolean Java_jau_direct_1bt_DBTAdapter_setDiscoverable(JNIEnv *env, jobject obj, jboolean value) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
return adapter->setDiscoverable(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
} catch(...) {
@@ -904,7 +904,7 @@ jboolean Java_jau_direct_1bt_DBTAdapter_setDiscoverable(JNIEnv *env, jobject obj
jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject obj, jbyteArray jaddress, jbyte jaddressType) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
if( nullptr == jaddress ) {
@@ -922,14 +922,14 @@ jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject ob
const EUI48& address = *reinterpret_cast<EUI48 *>(address_ptr);
const BDAddressType addressType = static_cast<BDAddressType>( jaddressType );
- std::shared_ptr<DBTDevice> device = adapter->findSharedDevice(address, addressType);
+ std::shared_ptr<BTDevice> device = adapter->findSharedDevice(address, addressType);
if( nullptr == device ) {
device = adapter->findDiscoveredDevice(address, addressType);
}
if( nullptr != device ) {
direct_bt::HCIHandler & hci = adapter->getHCI();
if( !hci.isOpen() ) {
- throw BluetoothException("Adapter's HCI closed "+adapter->toString(), E_FILE_LINE);
+ throw BTException("Adapter's HCI closed "+adapter->toString(), E_FILE_LINE);
}
std::shared_ptr<jau::JavaAnon> jDeviceRef = device->getJavaObject();
jau::JavaGlobalObj::check(jDeviceRef, E_FILE_LINE);
@@ -945,7 +945,7 @@ jobject Java_jau_direct_1bt_DBTAdapter_connectDeviceImpl(JNIEnv *env, jobject ob
jboolean Java_jau_direct_1bt_DBTAdapter_setPairable(JNIEnv *env, jobject obj, jboolean value) {
try {
- DBTAdapter *adapter = jau::getJavaUplinkObject<DBTAdapter>(env, obj);
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
return adapter->setBondable(JNI_TRUE == value ? true : false) ? JNI_TRUE : JNI_FALSE;
} catch(...) {
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx
index 8409f75d..a52d5d3c 100644
--- a/java/jni/direct_bt/DBTDevice.cxx
+++ b/java/jni/direct_bt/DBTDevice.cxx
@@ -31,36 +31,36 @@
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTDevice.hpp"
-#include "direct_bt/DBTAdapter.hpp"
-#include "direct_bt/DBTManager.hpp"
+#include "direct_bt/BTDevice.hpp"
+#include "direct_bt/BTAdapter.hpp"
+#include "direct_bt/BTManager.hpp"
using namespace direct_bt;
using namespace jau;
-static const std::string _notificationReceivedMethodArgs("(Lorg/tinyb/BluetoothGattCharacteristic;[BJ)V");
-static const std::string _indicationReceivedMethodArgs("(Lorg/tinyb/BluetoothGattCharacteristic;[BJZ)V");
+static const std::string _notificationReceivedMethodArgs("(Lorg/direct_bt/BTGattChar;[BJ)V");
+static const std::string _indicationReceivedMethodArgs("(Lorg/direct_bt/BTGattChar;[BJZ)V");
-class JNICharacteristicListener : public GATTCharacteristicListener {
+class JNICharacteristicListener : public BTGattCharListener {
private:
/**
package org.tinyb;
- public abstract class GATTCharacteristicListener {
+ public abstract class BTGattCharListener {
long nativeInstance;
- public void notificationReceived(final BluetoothGattCharacteristic charDecl,
+ public void notificationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp) {
}
- public void indicationReceived(final BluetoothGattCharacteristic charDecl,
+ public void indicationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp,
final boolean confirmationSent) {
}
};
*/
- const GATTCharacteristic * associatedCharacteristicRef;
+ const BTGattChar * associatedCharacteristicRef;
JNIGlobalRef listenerObj; // keep listener instance alive
JNIGlobalRef associatedCharacteristicObj; // keeps associated characteristic alive, if not null
jmethodID mNotificationReceived = nullptr;
@@ -68,7 +68,7 @@ class JNICharacteristicListener : public GATTCharacteristicListener {
public:
- JNICharacteristicListener(JNIEnv *env, DBTDevice *device, jobject listener, GATTCharacteristic * associatedCharacteristicRef_)
+ JNICharacteristicListener(JNIEnv *env, BTDevice *device, jobject listener, BTGattChar * associatedCharacteristicRef_)
: associatedCharacteristicRef(associatedCharacteristicRef_),
listenerObj(listener)
{
@@ -86,23 +86,23 @@ class JNICharacteristicListener : public GATTCharacteristicListener {
mNotificationReceived = search_method(env, listenerClazz, "notificationReceived", _notificationReceivedMethodArgs.c_str(), false);
java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == mNotificationReceived ) {
- throw InternalError("GATTCharacteristicListener has no notificationReceived"+_notificationReceivedMethodArgs+" method, for "+device->toString(), E_FILE_LINE);
+ throw InternalError("BTGattCharListener has no notificationReceived"+_notificationReceivedMethodArgs+" method, for "+device->toString(), E_FILE_LINE);
}
mIndicationReceived = search_method(env, listenerClazz, "indicationReceived", _indicationReceivedMethodArgs.c_str(), false);
java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == mNotificationReceived ) {
- throw InternalError("GATTCharacteristicListener has no indicationReceived"+_indicationReceivedMethodArgs+" method, for "+device->toString(), E_FILE_LINE);
+ throw InternalError("BTGattCharListener has no indicationReceived"+_indicationReceivedMethodArgs+" method, for "+device->toString(), E_FILE_LINE);
}
}
- bool match(const GATTCharacteristic & characteristic) noexcept override {
+ bool match(const BTGattChar & characteristic) noexcept override {
if( nullptr == associatedCharacteristicRef ) {
return true;
}
return characteristic == *associatedCharacteristicRef;
}
- void notificationReceived(GATTCharacteristicRef charDecl,
+ void notificationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp) override {
std::shared_ptr<jau::JavaAnon> jCharDeclRef = charDecl->getJavaObject();
if( !jau::JavaGlobalObj::isValid(jCharDeclRef) ) {
@@ -122,7 +122,7 @@ class JNICharacteristicListener : public GATTCharacteristicListener {
env->DeleteLocalRef(jval);
}
- void indicationReceived(GATTCharacteristicRef charDecl,
+ void indicationReceived(BTGattCharRef charDecl,
const TROOctets& charValue, const uint64_t timestamp,
const bool confirmationSent) override {
std::shared_ptr<jau::JavaAnon> jCharDeclRef = charDecl->getJavaObject();
@@ -148,7 +148,7 @@ class JNICharacteristicListener : public GATTCharacteristicListener {
void Java_jau_direct_1bt_DBTDevice_initImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -157,7 +157,7 @@ void Java_jau_direct_1bt_DBTDevice_initImpl(JNIEnv *env, jobject obj)
jstring Java_jau_direct_1bt_DBTDevice_getNameImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *nativePtr = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *nativePtr = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(nativePtr->getJavaObject(), E_FILE_LINE);
return from_string_to_jstring(env, nativePtr->getName());
} catch(...) {
@@ -168,7 +168,7 @@ jstring Java_jau_direct_1bt_DBTDevice_getNameImpl(JNIEnv *env, jobject obj) {
jstring Java_jau_direct_1bt_DBTDevice_toStringImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *nativePtr = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *nativePtr = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(nativePtr->getJavaObject(), E_FILE_LINE);
return from_string_to_jstring(env, nativePtr->toString());
} catch(...) {
@@ -177,7 +177,7 @@ jstring Java_jau_direct_1bt_DBTDevice_toStringImpl(JNIEnv *env, jobject obj) {
return nullptr;
}
-jboolean Java_jau_direct_1bt_DBTDevice_addCharacteristicListener(JNIEnv *env, jobject obj, jobject listener, jobject jAssociatedCharacteristic) {
+jboolean Java_jau_direct_1bt_DBTDevice_addCharListener(JNIEnv *env, jobject obj, jobject listener, jobject jAssociatedCharacteristic) {
try {
if( nullptr == listener ) {
throw IllegalArgumentException("characteristicListener argument is null", E_FILE_LINE);
@@ -190,22 +190,22 @@ jboolean Java_jau_direct_1bt_DBTDevice_addCharacteristicListener(JNIEnv *env, jo
return false;
}
}
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
throw IllegalStateException("Characteristic's device GATTHandle not connected: "+ device->toString(), E_FILE_LINE);
}
- GATTCharacteristic * associatedCharacteristicRef = nullptr;
+ BTGattChar * associatedCharacteristicRef = nullptr;
if( nullptr != jAssociatedCharacteristic ) {
- associatedCharacteristicRef = getJavaUplinkObject<GATTCharacteristic>(env, jAssociatedCharacteristic);
+ associatedCharacteristicRef = getJavaUplinkObject<BTGattChar>(env, jAssociatedCharacteristic);
}
- std::shared_ptr<GATTCharacteristicListener> l =
- std::shared_ptr<GATTCharacteristicListener>( new JNICharacteristicListener(env, device, listener, associatedCharacteristicRef) );
+ std::shared_ptr<BTGattCharListener> l =
+ std::shared_ptr<BTGattCharListener>( new JNICharacteristicListener(env, device, listener, associatedCharacteristicRef) );
- if( gatt->addCharacteristicListener(l) ) {
+ if( gatt->addCharListener(l) ) {
setInstance(env, listener, l.get());
return JNI_TRUE;
}
@@ -215,7 +215,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_addCharacteristicListener(JNIEnv *env, jo
return JNI_FALSE;
}
-jboolean Java_jau_direct_1bt_DBTDevice_removeCharacteristicListener(JNIEnv *env, jobject obj, jobject jlistener) {
+jboolean Java_jau_direct_1bt_DBTDevice_removeCharListener(JNIEnv *env, jobject obj, jobject jlistener) {
try {
if( nullptr == jlistener ) {
throw IllegalArgumentException("characteristicListener argument is null", E_FILE_LINE);
@@ -228,20 +228,20 @@ jboolean Java_jau_direct_1bt_DBTDevice_removeCharacteristicListener(JNIEnv *env,
}
setObjectRef<JNICharacteristicListener>(env, jlistener, nullptr, "nativeInstance");
- DBTDevice *device = getJavaUplinkObjectUnchecked<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObjectUnchecked<BTDevice>(env, obj);
if( nullptr == device ) {
// OK to have device being deleted already @ shutdown
return 0;
}
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
- // OK to have GATTHandler being shutdown @ disable
+ // OK to have BTGattHandler being shutdown @ disable
DBG_PRINT("Characteristic's device GATTHandle not connected: %s", device->toString().c_str());
return false;
}
- if( ! gatt->removeCharacteristicListener(pre) ) {
+ if( ! gatt->removeCharListener(pre) ) {
WARN_PRINT("Failed to remove characteristicListener with nativeInstance: %p at %s", pre, device->toString().c_str());
return false;
}
@@ -257,23 +257,23 @@ jint Java_jau_direct_1bt_DBTDevice_removeAllAssociatedCharacteristicListener(JNI
if( nullptr == jAssociatedCharacteristic ) {
throw IllegalArgumentException("associatedCharacteristic argument is null", E_FILE_LINE);
}
- DBTDevice *device = getJavaUplinkObjectUnchecked<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObjectUnchecked<BTDevice>(env, obj);
if( nullptr == device ) {
// OK to have device being deleted already @ shutdown
return 0;
}
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
- // OK to have GATTHandler being shutdown @ disable
+ // OK to have BTGattHandler being shutdown @ disable
DBG_PRINT("Characteristic's device GATTHandle not connected: %s", device->toString().c_str());
return 0;
}
- GATTCharacteristic * associatedCharacteristicRef = getJavaUplinkObject<GATTCharacteristic>(env, jAssociatedCharacteristic);
+ BTGattChar * associatedCharacteristicRef = getJavaUplinkObject<BTGattChar>(env, jAssociatedCharacteristic);
JavaGlobalObj::check(associatedCharacteristicRef->getJavaObject(), E_FILE_LINE);
- return gatt->removeAllAssociatedCharacteristicListener(associatedCharacteristicRef);
+ return gatt->removeAllAssociatedCharListener(associatedCharacteristicRef);
} catch(...) {
rethrow_and_raise_java_exception(env);
}
@@ -282,19 +282,19 @@ jint Java_jau_direct_1bt_DBTDevice_removeAllAssociatedCharacteristicListener(JNI
jint Java_jau_direct_1bt_DBTDevice_removeAllCharacteristicListener(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObjectUnchecked<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObjectUnchecked<BTDevice>(env, obj);
if( nullptr == device ) {
// OK to have device being deleted already @ shutdown
return 0;
}
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
- // OK to have GATTHandler being shutdown @ disable
+ // OK to have BTGattHandler being shutdown @ disable
DBG_PRINT("Characteristic's device GATTHandle not connected: %s", device->toString().c_str());
return 0;
}
- return gatt->removeAllCharacteristicListener();
+ return gatt->removeAllCharListener();
} catch(...) {
rethrow_and_raise_java_exception(env);
}
@@ -305,10 +305,10 @@ void Java_jau_direct_1bt_DBTDevice_deleteImpl(JNIEnv *env, jobject obj, jlong na
{
(void)obj;
try {
- DBTDevice *device = castInstance<DBTDevice>(nativeInstance);
+ BTDevice *device = castInstance<BTDevice>(nativeInstance);
DBG_PRINT("Java_jau_direct_1bt_DBTDevice_deleteImpl (remove only) %s", device->toString().c_str());
device->remove();
- // No delete: DBTDevice instance owned by DBTAdapter
+ // No delete: BTDevice instance owned by BTAdapter
// However, device->remove() might issue destruction
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -318,7 +318,7 @@ void Java_jau_direct_1bt_DBTDevice_deleteImpl(JNIEnv *env, jobject obj, jlong na
jbyte Java_jau_direct_1bt_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return (jint) number( device->disconnect() );
} catch(...) {
@@ -330,7 +330,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_disconnectImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_removeImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
device->remove();
} catch(...) {
@@ -342,7 +342,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_removeImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_connectDefaultImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return (jbyte) number( device->connectDefault() );
} catch(...) {
@@ -354,7 +354,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectDefaultImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl0(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
HCIStatusCode res = device->connectLE();
return (jbyte) number(res);
@@ -370,7 +370,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl1(JNIEnv *env, jobject obj,
jshort latency, jshort timeout)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
HCIStatusCode res = device->connectLE(interval, window, min_interval, max_interval, latency, timeout);
return (jbyte) number(res);
@@ -382,7 +382,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_connectLEImpl1(JNIEnv *env, jobject obj,
jbyte Java_jau_direct_1bt_DBTDevice_getAvailableSMPKeysImpl(JNIEnv *env, jobject obj, jboolean responder) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return number( device->getAvailableSMPKeys(JNI_TRUE == responder) ); // assign data of new key copy to JNI critical-array
@@ -394,7 +394,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getAvailableSMPKeysImpl(JNIEnv *env, jobject
void Java_jau_direct_1bt_DBTDevice_getLongTermKeyInfoImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
if( nullptr == jsink ) {
@@ -418,7 +418,7 @@ void Java_jau_direct_1bt_DBTDevice_getLongTermKeyInfoImpl(JNIEnv *env, jobject o
jbyte Java_jau_direct_1bt_DBTDevice_setLongTermKeyInfoImpl(JNIEnv *env, jobject obj, jbyteArray jsource) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
if( nullptr == jsource ) {
@@ -445,7 +445,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_setLongTermKeyInfoImpl(JNIEnv *env, jobject
void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyInfoImpl(JNIEnv *env, jobject obj, jboolean responder, jbyteArray jsink) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
if( nullptr == jsink ) {
@@ -469,7 +469,7 @@ void Java_jau_direct_1bt_DBTDevice_getSignatureResolvingKeyInfoImpl(JNIEnv *env,
jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
HCIStatusCode res = device->unpair();
return (jbyte) number(res);
@@ -481,7 +481,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_unpairImpl(JNIEnv *env, jobject obj) {
jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityLevelImpl(JNIEnv *env, jobject obj, jbyte jsec_level) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return device->setConnSecurityLevel( getBTSecurityLevel( static_cast<uint8_t>(jsec_level) ));
@@ -493,7 +493,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityLevelImpl(JNIEnv *env, job
jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return number( device->getConnSecurityLevel() );
@@ -505,7 +505,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getConnSecurityLevelImpl(JNIEnv *env, jobjec
jboolean Java_jau_direct_1bt_DBTDevice_setConnIOCapabilityImpl(JNIEnv *env, jobject obj, jbyte jio_cap) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return device->setConnIOCapability( getSMPIOCapability( static_cast<uint8_t>(jio_cap) ));
@@ -517,7 +517,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_setConnIOCapabilityImpl(JNIEnv *env, jobj
jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return device->setConnSecurity( getBTSecurityLevel( static_cast<uint8_t>(jsec_level) ),
@@ -530,7 +530,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityImpl(JNIEnv *env, jobject
jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return number( device->getConnIOCapability() );
@@ -542,7 +542,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getConnIOCapabilityImpl(JNIEnv *env, jobject
jbyte Java_jau_direct_1bt_DBTDevice_getPairingModeImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return number( device->getPairingMode() );
@@ -554,7 +554,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getPairingModeImpl(JNIEnv *env, jobject obj)
jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return static_cast<uint8_t>( device->getPairingState() );
@@ -566,7 +566,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj
jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject obj, jint jpasskey) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
// const std::string passkey = nullptr != jpasskey ? from_jstring_to_string(env, jpasskey) : std::string();
@@ -579,7 +579,7 @@ jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject o
jbyte Java_jau_direct_1bt_DBTDevice_setPairingNumericComparisonImpl(JNIEnv *env, jobject obj, jboolean jequal) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return number( device->setPairingNumericComparison( JNI_TRUE == jequal ? true : false ) );
@@ -593,32 +593,32 @@ jbyte Java_jau_direct_1bt_DBTDevice_setPairingNumericComparisonImpl(JNIEnv *env,
// getter
//
-static const std::string _serviceClazzCtorArgs("(JLdirect_bt/tinyb/DBTDevice;ZLjava/lang/String;SS)V");
+static const std::string _serviceClazzCtorArgs("(JLjau/direct_bt/DBTDevice;ZLjava/lang/String;SS)V");
jobject Java_jau_direct_1bt_DBTDevice_getServicesImpl(JNIEnv *env, jobject obj) {
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- jau::darray<GATTServiceRef> services = device->getGATTServices(); // implicit GATT connect and discovery if required incl GenericAccess retrieval
+ jau::darray<BTGattServiceRef> services = device->getGattServices(); // implicit GATT connect and discovery if required incl GenericAccess retrieval
if( services.size() > 0 ) {
- std::shared_ptr<GattGenericAccessSvc> ga = device->getGATTGenericAccess();
+ std::shared_ptr<GattGenericAccessSvc> ga = device->getGattGenericAccess();
if( nullptr != ga ) {
env->SetShortField(obj, getField(env, obj, "appearance", "S"), static_cast<jshort>(ga->appearance));
java_exception_check_and_throw(env, E_FILE_LINE);
- DBG_PRINT("DBTDevice.getServices(): GenericAccess: %s", ga->toString().c_str());
+ DBG_PRINT("BTDevice.getServices(): GenericAccess: %s", ga->toString().c_str());
}
} else {
return nullptr;
}
- // DBTGattService(final long nativeInstance, final DBTDevice device, final boolean isPrimary,
+ // BTGattService(final long nativeInstance, final BTDevice device, final boolean isPrimary,
// final String type_uuid, final short handleStart, final short handleEnd)
- std::function<jobject(JNIEnv*, jclass, jmethodID, GATTService*)> ctor_service =
- [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, GATTService *service)->jobject {
+ std::function<jobject(JNIEnv*, jclass, jmethodID, BTGattService*)> ctor_service =
+ [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, BTGattService *service)->jobject {
// prepare adapter ctor
- std::shared_ptr<DBTDevice> _device = service->getDeviceChecked();
+ std::shared_ptr<BTDevice> _device = service->getDeviceChecked();
JavaGlobalObj::check(_device->getJavaObject(), E_FILE_LINE);
jobject jdevice = JavaGlobalObj::GetObject(_device->getJavaObject());
const jboolean isPrimary = service->isPrimary;
@@ -637,7 +637,7 @@ jobject Java_jau_direct_1bt_DBTDevice_getServicesImpl(JNIEnv *env, jobject obj)
env_->DeleteLocalRef(jservice);
return JavaGlobalObj::GetObject(jServiceRef);
};
- return convert_vector_sharedptr_to_jarraylist<jau::darray<GATTServiceRef>, GATTService>(
+ return convert_vector_sharedptr_to_jarraylist<jau::darray<BTGattServiceRef>, BTGattService>(
env, services, _serviceClazzCtorArgs.c_str(), ctor_service);
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -648,7 +648,7 @@ jobject Java_jau_direct_1bt_DBTDevice_getServicesImpl(JNIEnv *env, jobject obj)
jboolean Java_jau_direct_1bt_DBTDevice_pingGATTImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return device->pingGATT() ? JNI_TRUE : JNI_FALSE;
@@ -661,7 +661,7 @@ jboolean Java_jau_direct_1bt_DBTDevice_pingGATTImpl(JNIEnv *env, jobject obj)
jstring Java_jau_direct_1bt_DBTDevice_getIcon(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return nullptr; // FIXME
} catch(...) {
@@ -673,7 +673,7 @@ jstring Java_jau_direct_1bt_DBTDevice_getIcon(JNIEnv *env, jobject obj)
void Java_jau_direct_1bt_DBTDevice_setTrustedImpl(JNIEnv *env, jobject obj, jboolean value)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
(void)value;
// FIXME
@@ -685,7 +685,7 @@ void Java_jau_direct_1bt_DBTDevice_setTrustedImpl(JNIEnv *env, jobject obj, jboo
void Java_jau_direct_1bt_DBTDevice_setBlockedImpl(JNIEnv *env, jobject obj, jboolean value)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
(void)value;
// FIXME
@@ -697,7 +697,7 @@ void Java_jau_direct_1bt_DBTDevice_setBlockedImpl(JNIEnv *env, jobject obj, jboo
jboolean JNICALL Java_jau_direct_1bt_DBTDevice_getLegacyPairing(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return JNI_FALSE; // FIXME
} catch(...) {
@@ -709,7 +709,7 @@ jboolean JNICALL Java_jau_direct_1bt_DBTDevice_getLegacyPairing(JNIEnv *env, job
jshort Java_jau_direct_1bt_DBTDevice_getRSSI(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return (jshort) device->getRSSI();
} catch(...) {
@@ -722,7 +722,7 @@ jshort Java_jau_direct_1bt_DBTDevice_getRSSI(JNIEnv *env, jobject obj)
jobjectArray Java_jau_direct_1bt_DBTDevice_getUUIDs(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return nullptr; // FIXME
} catch(...) {
@@ -734,7 +734,7 @@ jobjectArray Java_jau_direct_1bt_DBTDevice_getUUIDs(JNIEnv *env, jobject obj)
jstring Java_jau_direct_1bt_DBTDevice_getModalias(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return nullptr; // FIXME
} catch(...) {
@@ -746,7 +746,7 @@ jstring Java_jau_direct_1bt_DBTDevice_getModalias(JNIEnv *env, jobject obj)
jobject Java_jau_direct_1bt_DBTDevice_getManufacturerData(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
std::shared_ptr<ManufactureSpecificData> mdata = device->getManufactureSpecificData();
@@ -783,7 +783,7 @@ jobject Java_jau_direct_1bt_DBTDevice_getManufacturerData(JNIEnv *env, jobject o
jshort Java_jau_direct_1bt_DBTDevice_getTxPower(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
return (jshort) device->getTxPower();
} catch(...) {
@@ -834,7 +834,7 @@ typedef std::shared_ptr<BooleanDeviceCBContext> BooleanDeviceCBContextRef;
// Blocked
//
-static void disableBlockedNotifications(JNIEnv *env, jobject obj, DBTManager &mgmt)
+static void disableBlockedNotifications(JNIEnv *env, jobject obj, BTManager &mgmt)
{
InvocationFunc<bool, const MgmtEvent&> * funcptr =
getObjectRef<InvocationFunc<bool, const MgmtEvent&>>(env, obj, "blockedNotificationRef");
@@ -854,9 +854,9 @@ static void disableBlockedNotifications(JNIEnv *env, jobject obj, DBTManager &mg
void Java_jau_direct_1bt_DBTDevice_disableBlockedNotificationsImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- DBTManager & mgmt = device->getAdapter().getManager();
+ BTManager & mgmt = device->getAdapter().getManager();
disableBlockedNotifications(env, obj, mgmt);
} catch(...) {
@@ -866,10 +866,10 @@ void Java_jau_direct_1bt_DBTDevice_disableBlockedNotificationsImpl(JNIEnv *env,
void Java_jau_direct_1bt_DBTDevice_enableBlockedNotificationsImpl(JNIEnv *env, jobject obj, jobject javaCallback)
{
try {
- DBTDevice *device= getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device= getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- DBTAdapter & adapter = device->getAdapter();
- DBTManager & mgmt = adapter.getManager();
+ BTAdapter & adapter = device->getAdapter();
+ BTManager & mgmt = adapter.getManager();
disableBlockedNotifications(env, obj, mgmt);
@@ -924,7 +924,7 @@ void Java_jau_direct_1bt_DBTDevice_enableBlockedNotificationsImpl(JNIEnv *env, j
// Paired
//
-static void disablePairedNotifications(JNIEnv *env, jobject obj, DBTManager &mgmt)
+static void disablePairedNotifications(JNIEnv *env, jobject obj, BTManager &mgmt)
{
InvocationFunc<bool, const MgmtEvent&> * funcptr =
getObjectRef<InvocationFunc<bool, const MgmtEvent&>>(env, obj, "pairedNotificationRef");
@@ -941,9 +941,9 @@ static void disablePairedNotifications(JNIEnv *env, jobject obj, DBTManager &mgm
void Java_jau_direct_1bt_DBTDevice_disablePairedNotificationsImpl(JNIEnv *env, jobject obj)
{
try {
- DBTDevice *device = getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- DBTManager & mgmt = device->getAdapter().getManager();
+ BTManager & mgmt = device->getAdapter().getManager();
disablePairedNotifications(env, obj, mgmt);
} catch(...) {
@@ -953,10 +953,10 @@ void Java_jau_direct_1bt_DBTDevice_disablePairedNotificationsImpl(JNIEnv *env, j
void Java_jau_direct_1bt_DBTDevice_enablePairedNotificationsImpl(JNIEnv *env, jobject obj, jobject javaCallback)
{
try {
- DBTDevice *device= getJavaUplinkObject<DBTDevice>(env, obj);
+ BTDevice *device= getJavaUplinkObject<BTDevice>(env, obj);
JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
- DBTAdapter & adapter = device->getAdapter();
- DBTManager & mgmt = adapter.getManager();
+ BTAdapter & adapter = device->getAdapter();
+ BTManager & mgmt = adapter.getManager();
disablePairedNotifications(env, obj, mgmt);
diff --git a/java/jni/direct_bt/DBTGattCharacteristic.cxx b/java/jni/direct_bt/DBTGattChar.cxx
index 381c2e27..1695009b 100644
--- a/java/jni/direct_bt/DBTGattCharacteristic.cxx
+++ b/java/jni/direct_bt/DBTGattChar.cxx
@@ -23,22 +23,22 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "jau_direct_bt_DBTGattCharacteristic.h"
+#include "jau_direct_bt_DBTGattChar.h"
#include <jau/debug.hpp>
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTDevice.hpp"
-#include "direct_bt/DBTAdapter.hpp"
+#include "direct_bt/BTDevice.hpp"
+#include "direct_bt/BTAdapter.hpp"
using namespace direct_bt;
using namespace jau;
-jstring Java_jau_direct_1bt_DBTGattCharacteristic_toStringImpl(JNIEnv *env, jobject obj) {
+jstring Java_jau_direct_1bt_DBTGattChar_toStringImpl(JNIEnv *env, jobject obj) {
try {
- GATTCharacteristic *nativePtr = getJavaUplinkObject<GATTCharacteristic>(env, obj);
+ BTGattChar *nativePtr = getJavaUplinkObject<BTGattChar>(env, obj);
JavaGlobalObj::check(nativePtr->getJavaObject(), E_FILE_LINE);
return from_string_to_jstring(env, nativePtr->toString());
} catch(...) {
@@ -47,36 +47,36 @@ jstring Java_jau_direct_1bt_DBTGattCharacteristic_toStringImpl(JNIEnv *env, jobj
return nullptr;
}
-void Java_jau_direct_1bt_DBTGattCharacteristic_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) {
+void Java_jau_direct_1bt_DBTGattChar_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) {
(void)obj;
try {
- GATTCharacteristic *characteristic = castInstance<GATTCharacteristic>(nativeInstance);
+ BTGattChar *characteristic = castInstance<BTGattChar>(nativeInstance);
(void)characteristic;
- // No delete: Service instance owned by GATTService -> DBTDevice
+ // No delete: Service instance owned by BTGattService -> BTDevice
} catch(...) {
rethrow_and_raise_java_exception(env);
}
}
-static const std::string _descriptorClazzCtorArgs("(JLdirect_bt/tinyb/DBTGattCharacteristic;Ljava/lang/String;S[B)V");
+static const std::string _descriptorClazzCtorArgs("(JLjau/direct_bt/DBTGattChar;Ljava/lang/String;S[B)V");
-jobject Java_jau_direct_1bt_DBTGattCharacteristic_getDescriptorsImpl(JNIEnv *env, jobject obj) {
+jobject Java_jau_direct_1bt_DBTGattChar_getDescriptorsImpl(JNIEnv *env, jobject obj) {
try {
- GATTCharacteristic *characteristic = getJavaUplinkObject<GATTCharacteristic>(env, obj);
+ BTGattChar *characteristic = getJavaUplinkObject<BTGattChar>(env, obj);
JavaGlobalObj::check(characteristic->getJavaObject(), E_FILE_LINE);
- jau::darray<GATTDescriptorRef> & descriptorList = characteristic->descriptorList;
+ jau::darray<BTGattDescRef> & descriptorList = characteristic->descriptorList;
- // DBTGattDescriptor(final long nativeInstance, final DBTGattCharacteristic characteristic,
+ // BTGattDesc(final long nativeInstance, final BTGattChar characteristic,
// final String type_uuid, final short handle, final byte[] value)
- // DBTGattDescriptor(final long nativeInstance, final DBTGattCharacteristic characteristic,
+ // BTGattDesc(final long nativeInstance, final BTGattChar characteristic,
// final String type_uuid, final short handle, final byte[] value)
- std::function<jobject(JNIEnv*, jclass, jmethodID, GATTDescriptor *)> ctor_desc =
- [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, GATTDescriptor *descriptor)->jobject {
+ std::function<jobject(JNIEnv*, jclass, jmethodID, BTGattDesc *)> ctor_desc =
+ [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, BTGattDesc *descriptor)->jobject {
// prepare adapter ctor
- std::shared_ptr<GATTCharacteristic> _characteristic = descriptor->getCharacteristicChecked();
+ std::shared_ptr<BTGattChar> _characteristic = descriptor->getGattCharChecked();
JavaGlobalObj::check(_characteristic->getJavaObject(), E_FILE_LINE);
jobject jcharacteristic = JavaGlobalObj::GetObject(_characteristic->getJavaObject());
@@ -101,7 +101,7 @@ jobject Java_jau_direct_1bt_DBTGattCharacteristic_getDescriptorsImpl(JNIEnv *env
env_->DeleteLocalRef(jdesc);
return JavaGlobalObj::GetObject(jDescRef);
};
- return convert_vector_sharedptr_to_jarraylist<jau::darray<GATTDescriptorRef>, GATTDescriptor>(
+ return convert_vector_sharedptr_to_jarraylist<jau::darray<BTGattDescRef>, BTGattDesc>(
env, descriptorList, _descriptorClazzCtorArgs.c_str(), ctor_desc);
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -109,12 +109,12 @@ jobject Java_jau_direct_1bt_DBTGattCharacteristic_getDescriptorsImpl(JNIEnv *env
return nullptr;
}
-jbyteArray Java_jau_direct_1bt_DBTGattCharacteristic_readValueImpl(JNIEnv *env, jobject obj) {
+jbyteArray Java_jau_direct_1bt_DBTGattChar_readValueImpl(JNIEnv *env, jobject obj) {
try {
- GATTCharacteristic *characteristic = getJavaUplinkObject<GATTCharacteristic>(env, obj);
+ BTGattChar *characteristic = getJavaUplinkObject<BTGattChar>(env, obj);
JavaGlobalObj::check(characteristic->getJavaObject(), E_FILE_LINE);
- POctets res(GATTHandler::number(GATTHandler::Defaults::MAX_ATT_MTU), 0);
+ POctets res(BTGattHandler::number(BTGattHandler::Defaults::MAX_ATT_MTU), 0);
if( !characteristic->readValue(res) ) {
ERR_PRINT("Characteristic readValue failed: %s", characteristic->toString().c_str());
return env->NewByteArray((jsize)0);
@@ -132,7 +132,7 @@ jbyteArray Java_jau_direct_1bt_DBTGattCharacteristic_readValueImpl(JNIEnv *env,
return nullptr;
}
-jboolean Java_jau_direct_1bt_DBTGattCharacteristic_writeValueImpl(JNIEnv *env, jobject obj, jbyteArray jval, jboolean withResponse) {
+jboolean Java_jau_direct_1bt_DBTGattChar_writeValueImpl(JNIEnv *env, jobject obj, jbyteArray jval, jboolean withResponse) {
try {
if( nullptr == jval ) {
throw IllegalArgumentException("byte array null", E_FILE_LINE);
@@ -141,7 +141,7 @@ jboolean Java_jau_direct_1bt_DBTGattCharacteristic_writeValueImpl(JNIEnv *env, j
if( 0 == value_size ) {
return JNI_TRUE;
}
- GATTCharacteristic *characteristic = getJavaUplinkObject<GATTCharacteristic>(env, obj);
+ BTGattChar *characteristic = getJavaUplinkObject<BTGattChar>(env, obj);
JavaGlobalObj::check(characteristic->getJavaObject(), E_FILE_LINE);
JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
@@ -168,10 +168,10 @@ jboolean Java_jau_direct_1bt_DBTGattCharacteristic_writeValueImpl(JNIEnv *env, j
return JNI_FALSE;
}
-jboolean Java_jau_direct_1bt_DBTGattCharacteristic_configNotificationIndicationImpl(JNIEnv *env, jobject obj,
+jboolean Java_jau_direct_1bt_DBTGattChar_configNotificationIndicationImpl(JNIEnv *env, jobject obj,
jboolean enableNotification, jboolean enableIndication, jbooleanArray jEnabledState) {
try {
- GATTCharacteristic *characteristic = getJavaUplinkObjectUnchecked<GATTCharacteristic>(env, obj);
+ BTGattChar *characteristic = getJavaUplinkObjectUnchecked<BTGattChar>(env, obj);
if( nullptr == characteristic ) {
if( !enableNotification && !enableIndication ) {
// OK to have native characteristic being shutdown @ disable
@@ -197,7 +197,7 @@ jboolean Java_jau_direct_1bt_DBTGattCharacteristic_configNotificationIndicationI
bool cccdEnableResult[2];
bool res = characteristic->configNotificationIndication(enableNotification, enableIndication, cccdEnableResult);
- DBG_PRINT("DBTGattCharacteristic::configNotificationIndication Config Notification(%d), Indication(%d): Result %d",
+ DBG_PRINT("BTGattChar::configNotificationIndication Config Notification(%d), Indication(%d): Result %d",
cccdEnableResult[0], cccdEnableResult[1], res);
state_ptr[0] = cccdEnableResult[0];
state_ptr[1] = cccdEnableResult[1];
diff --git a/java/jni/direct_bt/DBTGattDescriptor.cxx b/java/jni/direct_bt/DBTGattDesc.cxx
index a14f1611..97b0d3a5 100644
--- a/java/jni/direct_bt/DBTGattDescriptor.cxx
+++ b/java/jni/direct_bt/DBTGattDesc.cxx
@@ -23,7 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "jau_direct_bt_DBTGattDescriptor.h"
+#include "jau_direct_bt_DBTGattDesc.h"
// #define VERBOSE_ON 1
#include <jau/debug.hpp>
@@ -31,26 +31,26 @@
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTDevice.hpp"
-#include "direct_bt/DBTAdapter.hpp"
+#include "direct_bt/BTDevice.hpp"
+#include "direct_bt/BTAdapter.hpp"
using namespace direct_bt;
using namespace jau;
-void Java_jau_direct_1bt_DBTGattDescriptor_deleteImpl(JNIEnv *env, jobject obj) {
+void Java_jau_direct_1bt_DBTGattDesc_deleteImpl(JNIEnv *env, jobject obj) {
try {
- GATTDescriptor *descriptor = getJavaUplinkObject<GATTDescriptor>(env, obj);
+ BTGattDesc *descriptor = getJavaUplinkObject<BTGattDesc>(env, obj);
(void)descriptor;
- // No delete: Service instance owned by GATTService -> DBTDevice
+ // No delete: Service instance owned by GATTService -> BTDevice
} catch(...) {
rethrow_and_raise_java_exception(env);
}
}
-jstring Java_jau_direct_1bt_DBTGattDescriptor_toStringImpl(JNIEnv *env, jobject obj) {
+jstring Java_jau_direct_1bt_DBTGattDesc_toStringImpl(JNIEnv *env, jobject obj) {
(void)obj;
try {
- GATTDescriptor *descriptor = getJavaUplinkObject<GATTDescriptor>(env, obj);
+ BTGattDesc *descriptor = getJavaUplinkObject<BTGattDesc>(env, obj);
JavaGlobalObj::check(descriptor->getJavaObject(), E_FILE_LINE);
return from_string_to_jstring(env, descriptor->toString());
} catch(...) {
@@ -59,9 +59,9 @@ jstring Java_jau_direct_1bt_DBTGattDescriptor_toStringImpl(JNIEnv *env, jobject
return nullptr;
}
-jbyteArray Java_jau_direct_1bt_DBTGattDescriptor_readValueImpl(JNIEnv *env, jobject obj) {
+jbyteArray Java_jau_direct_1bt_DBTGattDesc_readValueImpl(JNIEnv *env, jobject obj) {
try {
- GATTDescriptor *descriptor = getJavaUplinkObject<GATTDescriptor>(env, obj);
+ BTGattDesc *descriptor = getJavaUplinkObject<BTGattDesc>(env, obj);
JavaGlobalObj::check(descriptor->getJavaObject(), E_FILE_LINE);
if( !descriptor->readValue() ) {
@@ -80,7 +80,7 @@ jbyteArray Java_jau_direct_1bt_DBTGattDescriptor_readValueImpl(JNIEnv *env, jobj
return nullptr;
}
-jboolean Java_jau_direct_1bt_DBTGattDescriptor_writeValueImpl(JNIEnv *env, jobject obj, jbyteArray jval) {
+jboolean Java_jau_direct_1bt_DBTGattDesc_writeValueImpl(JNIEnv *env, jobject obj, jbyteArray jval) {
try {
if( nullptr == jval ) {
throw IllegalArgumentException("byte array null", E_FILE_LINE);
@@ -89,7 +89,7 @@ jboolean Java_jau_direct_1bt_DBTGattDescriptor_writeValueImpl(JNIEnv *env, jobje
if( 0 == value_size ) {
return JNI_TRUE;
}
- GATTDescriptor *descriptor = getJavaUplinkObject<GATTDescriptor>(env, obj);
+ BTGattDesc *descriptor = getJavaUplinkObject<BTGattDesc>(env, obj);
JavaGlobalObj::check(descriptor->getJavaObject(), E_FILE_LINE);
JNICriticalArray<uint8_t, jbyteArray> criticalArray(env); // RAII - release
diff --git a/java/jni/direct_bt/DBTGattService.cxx b/java/jni/direct_bt/DBTGattService.cxx
index b367c445..085ef1a1 100644
--- a/java/jni/direct_bt/DBTGattService.cxx
+++ b/java/jni/direct_bt/DBTGattService.cxx
@@ -31,15 +31,15 @@
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTDevice.hpp"
-#include "direct_bt/DBTAdapter.hpp"
+#include "direct_bt/BTDevice.hpp"
+#include "direct_bt/BTAdapter.hpp"
using namespace direct_bt;
using namespace jau;
jstring Java_jau_direct_1bt_DBTGattService_toStringImpl(JNIEnv *env, jobject obj) {
try {
- GATTService *nativePtr = getJavaUplinkObject<GATTService>(env, obj);
+ BTGattService *nativePtr = getJavaUplinkObject<BTGattService>(env, obj);
JavaGlobalObj::check(nativePtr->getJavaObject(), E_FILE_LINE);
return from_string_to_jstring(env, nativePtr->toString());
} catch(...) {
@@ -52,37 +52,37 @@ jstring Java_jau_direct_1bt_DBTGattService_toStringImpl(JNIEnv *env, jobject obj
void Java_jau_direct_1bt_DBTGattService_deleteImpl(JNIEnv *env, jobject obj, jlong nativeInstance) {
(void)obj;
try {
- GATTService *service = castInstance<GATTService>(nativeInstance);
+ BTGattService *service = castInstance<BTGattService>(nativeInstance);
(void)service;
- // No delete: Service instance owned by DBTDevice
+ // No delete: Service instance owned by BTDevice
} catch(...) {
rethrow_and_raise_java_exception(env);
}
}
-static const std::string _characteristicClazzCtorArgs("(JLdirect_bt/tinyb/DBTGattService;S[Ljava/lang/String;ZZLjava/lang/String;SI)V");
+static const std::string _characteristicClazzCtorArgs("(JLjau/direct_bt/DBTGattService;S[Ljava/lang/String;ZZLjava/lang/String;SI)V");
-jobject Java_jau_direct_1bt_DBTGattService_getCharacteristicsImpl(JNIEnv *env, jobject obj) {
+jobject Java_jau_direct_1bt_DBTGattService_getCharsImpl(JNIEnv *env, jobject obj) {
try {
- GATTService *service = getJavaUplinkObject<GATTService>(env, obj);
+ BTGattService *service = getJavaUplinkObject<BTGattService>(env, obj);
JavaGlobalObj::check(service->getJavaObject(), E_FILE_LINE);
- jau::darray<std::shared_ptr<GATTCharacteristic>> & characteristics = service->characteristicList;
+ jau::darray<std::shared_ptr<BTGattChar>> & characteristics = service->characteristicList;
- // DBTGattCharacteristic(final long nativeInstance, final DBTGattService service,
+ // BTGattChar(final long nativeInstance, final BTGattService service,
// final short handle, final String[] properties,
// final boolean hasNotify, final boolean hasIndicate,
// final String value_type_uuid, final short value_handle,
// final int clientCharacteristicsConfigIndex)
- std::function<jobject(JNIEnv*, jclass, jmethodID, GATTCharacteristic *)> ctor_char =
- [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, GATTCharacteristic *characteristic)->jobject {
+ std::function<jobject(JNIEnv*, jclass, jmethodID, BTGattChar *)> ctor_char =
+ [](JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, BTGattChar *characteristic)->jobject {
// prepare adapter ctor
- std::shared_ptr<GATTService> _service = characteristic->getServiceChecked();
+ std::shared_ptr<BTGattService> _service = characteristic->getServiceChecked();
JavaGlobalObj::check(_service->getJavaObject(), E_FILE_LINE);
jobject jservice = JavaGlobalObj::GetObject(_service->getJavaObject());
- jau::darray<std::unique_ptr<std::string>> props = GATTCharacteristic::getPropertiesStringList(characteristic->properties);
+ jau::darray<std::unique_ptr<std::string>> props = BTGattChar::getPropertiesStringList(characteristic->properties);
size_t props_size = props.size();
jobjectArray jproperties;
@@ -99,8 +99,8 @@ jobject Java_jau_direct_1bt_DBTGattService_getCharacteristicsImpl(JNIEnv *env, j
}
java_exception_check_and_throw(env_, E_FILE_LINE);
- const bool hasNotify = characteristic->hasProperties(GATTCharacteristic::PropertyBitVal::Notify);
- const bool hasIndicate = characteristic->hasProperties(GATTCharacteristic::PropertyBitVal::Indicate);
+ const bool hasNotify = characteristic->hasProperties(BTGattChar::PropertyBitVal::Notify);
+ const bool hasIndicate = characteristic->hasProperties(BTGattChar::PropertyBitVal::Indicate);
const jstring uuid = from_string_to_jstring(env_,
directBTJNISettings.getUnifyUUID128Bit() ? characteristic->value_type->toUUID128String() :
@@ -109,7 +109,7 @@ jobject Java_jau_direct_1bt_DBTGattService_getCharacteristicsImpl(JNIEnv *env, j
jobject jcharVal = env_->NewObject(clazz, clazz_ctor, (jlong)characteristic, jservice,
characteristic->handle, jproperties, hasNotify, hasIndicate,
- uuid, characteristic->value_handle, characteristic->clientCharacteristicsConfigIndex);
+ uuid, characteristic->value_handle, characteristic->clientCharConfigIndex);
java_exception_check_and_throw(env_, E_FILE_LINE);
JNIGlobalRef::check(jcharVal, E_FILE_LINE);
std::shared_ptr<JavaAnon> jCharRef = characteristic->getJavaObject(); // GlobalRef
@@ -118,7 +118,7 @@ jobject Java_jau_direct_1bt_DBTGattService_getCharacteristicsImpl(JNIEnv *env, j
env_->DeleteLocalRef(jcharVal);
return JavaGlobalObj::GetObject(jCharRef);
};
- return convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<GATTCharacteristic>>, GATTCharacteristic>(
+ return convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<BTGattChar>>, BTGattChar>(
env, characteristics, _characteristicClazzCtorArgs.c_str(), ctor_char);
} catch(...) {
rethrow_and_raise_java_exception(env);
diff --git a/java/jni/direct_bt/DBTManager.cxx b/java/jni/direct_bt/DBTManager.cxx
index eb3e8a3e..24665b97 100644
--- a/java/jni/direct_bt/DBTManager.cxx
+++ b/java/jni/direct_bt/DBTManager.cxx
@@ -31,9 +31,9 @@
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTDevice.hpp"
-#include "direct_bt/DBTAdapter.hpp"
-#include "direct_bt/DBTManager.hpp"
+#include "direct_bt/BTDevice.hpp"
+#include "direct_bt/BTAdapter.hpp"
+#include "direct_bt/BTManager.hpp"
using namespace direct_bt;
using namespace jau;
@@ -66,7 +66,7 @@ struct BooleanMgmtCBContext {
};
typedef std::shared_ptr<BooleanMgmtCBContext> BooleanMgmtCBContextRef;
-static void _addMgmtCBOnce(JNIEnv *env, DBTManager & mgmt, JNIGlobalRef jmgmtRef, MgmtEvent::Opcode opc,
+static void _addMgmtCBOnce(JNIEnv *env, BTManager & mgmt, JNIGlobalRef jmgmtRef, MgmtEvent::Opcode opc,
const std::string &jmethodName, const std::string &jmethodArgs)
{
try {
@@ -93,12 +93,12 @@ static void _addMgmtCBOnce(JNIEnv *env, DBTManager & mgmt, JNIGlobalRef jmgmtRef
jclass mgmtClazz = jau::search_class(env, jmgmtRef.getObject());
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == mgmtClazz ) {
- throw jau::InternalError("DBTManager not found", E_FILE_LINE);
+ throw jau::InternalError("BTManager not found", E_FILE_LINE);
}
jmethodID mid = jau::search_method(env, mgmtClazz, jmethodName.c_str(), jmethodArgs.c_str(), false);
jau::java_exception_check_and_throw(env, E_FILE_LINE);
if( nullptr == mid ) {
- throw jau::InternalError("DBTManager has no "+jmethodName+"."+jmethodArgs+" method, for "+mgmt.toString(), E_FILE_LINE);
+ throw jau::InternalError("BTManager has no "+jmethodName+"."+jmethodArgs+" method, for "+mgmt.toString(), E_FILE_LINE);
}
// move BooleanDeviceCBContextRef into CaptureInvocationFunc and operator== includes javaCallback comparison
@@ -114,8 +114,8 @@ void Java_jau_direct_1bt_DBTManager_initImpl(JNIEnv *env, jobject obj, jboolean
directBTJNISettings.setUnifyUUID128Bit(unifyUUID128Bit);
try {
BTMode btMode = static_cast<BTMode>(jbtMode);
- DBTManager *manager = &DBTManager::get(btMode); // special: static singleton
- setInstance<DBTManager>(env, obj, manager);
+ BTManager *manager = &BTManager::get(btMode); // special: static singleton
+ setInstance<BTManager>(env, obj, manager);
java_exception_check_and_throw(env, E_FILE_LINE);
manager->setJavaObject( std::shared_ptr<JavaAnon>( new JavaGlobalObj(obj, nullptr) ) );
JavaGlobalObj::check(manager->getJavaObject(), E_FILE_LINE);
@@ -134,7 +134,7 @@ void Java_jau_direct_1bt_DBTManager_deleteImpl(JNIEnv *env, jobject obj, jlong n
{
(void)obj;
try {
- DBTManager *manager = castInstance<DBTManager>(nativeInstance); // special: static singleton
+ BTManager *manager = castInstance<BTManager>(nativeInstance); // special: static singleton
manager->close();
manager->setJavaObject();
(void) manager;
@@ -144,7 +144,7 @@ void Java_jau_direct_1bt_DBTManager_deleteImpl(JNIEnv *env, jobject obj, jlong n
}
static const std::string _adapterClazzCtorArgs("(J[BLjava/lang/String;I)V");
-static jobject _createJavaAdapter(JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, DBTAdapter* adapter) {
+static jobject _createJavaAdapter(JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, BTAdapter* adapter) {
// prepare adapter ctor
const EUI48 addr = adapter->getAddress();
jbyteArray jaddr = env_->NewByteArray(sizeof(addr));
@@ -168,11 +168,11 @@ static jobject _createJavaAdapter(JNIEnv *env_, jclass clazz, jmethodID clazz_ct
jobject Java_jau_direct_1bt_DBTManager_getAdapterListImpl(JNIEnv *env, jobject obj)
{
try {
- DBTManager *manager = getInstance<DBTManager>(env, obj);
+ BTManager *manager = getInstance<BTManager>(env, obj);
DBG_PRINT("Java_jau_direct_1bt_DBTManager_getAdapterListImpl: Manager %s", manager->toString().c_str());
- jau::darray<std::shared_ptr<DBTAdapter>> adapters = manager->getAdapters();
- return convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<DBTAdapter>>, DBTAdapter>(
+ jau::darray<std::shared_ptr<BTAdapter>> adapters = manager->getAdapters();
+ return convert_vector_sharedptr_to_jarraylist<jau::darray<std::shared_ptr<BTAdapter>>, BTAdapter>(
env, adapters, _adapterClazzCtorArgs.c_str(), _createJavaAdapter);
} catch(...) {
rethrow_and_raise_java_exception(env);
@@ -183,16 +183,16 @@ jobject Java_jau_direct_1bt_DBTManager_getAdapterListImpl(JNIEnv *env, jobject o
jobject Java_jau_direct_1bt_DBTManager_getAdapterImpl(JNIEnv *env, jobject obj, jint dev_id)
{
try {
- DBTManager *manager = getInstance<DBTManager>(env, obj);
+ BTManager *manager = getInstance<BTManager>(env, obj);
- std::shared_ptr<DBTAdapter> adapter = manager->getAdapter(dev_id);
+ std::shared_ptr<BTAdapter> adapter = manager->getAdapter(dev_id);
if( nullptr == adapter ) {
- ERR_PRINT("DBTManager::getAdapterImpl: Adapter dev_id %d: Not found", dev_id);
+ ERR_PRINT("BTManager::getAdapterImpl: Adapter dev_id %d: Not found", dev_id);
return nullptr;
}
- DBG_PRINT("DBTManager::getAdapterImpl: Adapter dev_id %d: %s", dev_id, adapter->toString().c_str());
+ DBG_PRINT("BTManager::getAdapterImpl: Adapter dev_id %d: %s", dev_id, adapter->toString().c_str());
- return jau::convert_instance_to_jobject<DBTAdapter>(env, adapter.get(), _adapterClazzCtorArgs.c_str(), _createJavaAdapter);
+ return jau::convert_instance_to_jobject<BTAdapter>(env, adapter.get(), _adapterClazzCtorArgs.c_str(), _createJavaAdapter);
} catch(...) {
rethrow_and_raise_java_exception(env);
}
diff --git a/java/jni/direct_bt/DBTNativeDownlink.cxx b/java/jni/direct_bt/DBTNativeDownlink.cxx
index d912aaa3..88e0124a 100644
--- a/java/jni/direct_bt/DBTNativeDownlink.cxx
+++ b/java/jni/direct_bt/DBTNativeDownlink.cxx
@@ -30,7 +30,7 @@
#include "helper_base.hpp"
#include "helper_dbt.hpp"
-#include "direct_bt/DBTTypes.hpp"
+#include "direct_bt/BTTypes1.hpp"
using namespace direct_bt;
using namespace jau;
diff --git a/java/jni/direct_bt/DBTObject.cxx b/java/jni/direct_bt/DBTObject.cxx
index f41e2028..e6908c11 100644
--- a/java/jni/direct_bt/DBTObject.cxx
+++ b/java/jni/direct_bt/DBTObject.cxx
@@ -27,7 +27,7 @@
#include "helper_base.hpp"
-#include "direct_bt/DBTTypes.hpp"
+#include "direct_bt/BTTypes1.hpp"
using namespace direct_bt;
diff --git a/java/jni/helper_base.cxx b/java/jni/helper_base.cxx
index ceac1c78..a995718d 100644
--- a/java/jni/helper_base.cxx
+++ b/java/jni/helper_base.cxx
@@ -46,7 +46,7 @@ jobject get_bluetooth_type(JNIEnv *env, const char *field_name)
return result;
}
-void raise_java_exception(JNIEnv *env, const direct_bt::BluetoothException &e, const char* file, int line) {
+void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line) {
jau::print_native_caught_exception_fwd2java(e, file, line);
env->ThrowNew(env->FindClass("org/tinyb/BluetoothException"), e.what());
}
@@ -78,7 +78,7 @@ void rethrow_and_raise_java_exception_impl(JNIEnv *env, const char* file, int li
jau::raise_java_exception(env, e, file, line);
} catch (const jau::IndexOutOfBoundsException &e) {
jau::raise_java_exception(env, e, file, line);
- } catch (const direct_bt::BluetoothException &e) {
+ } catch (const direct_bt::BTException &e) {
raise_java_exception(env, e, file, line);
} catch (const tinyb::BluetoothException &e) {
raise_java_exception(env, e, file, line);
diff --git a/java/jni/helper_base.hpp b/java/jni/helper_base.hpp
index 7af77e2f..05293108 100644
--- a/java/jni/helper_base.hpp
+++ b/java/jni/helper_base.hpp
@@ -36,12 +36,12 @@
#include <jau/jni/helper_jni.hpp>
-#include "direct_bt/BTTypes.hpp"
+#include "direct_bt/BTTypes0.hpp"
#include "tinyb/BluetoothException.hpp"
jobject get_bluetooth_type(JNIEnv *env, const char *field_name);
-void raise_java_exception(JNIEnv *env, const direct_bt::BluetoothException &e, const char* file, int line);
+void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line);
void raise_java_exception(JNIEnv *env, const tinyb::BluetoothException &e, const char* file, int line);
/**
diff --git a/java/jni/tinyb/CMakeLists.txt b/java/jni/tinyb/CMakeLists.txt
index c54dd090..6ae9b25c 100644
--- a/java/jni/tinyb/CMakeLists.txt
+++ b/java/jni/tinyb/CMakeLists.txt
@@ -25,8 +25,8 @@ set (tinyb_JNI_SRCS
${PROJECT_SOURCE_DIR}/jaulib/java_jni/jni/helper_jni.cxx
${PROJECT_SOURCE_DIR}/jaulib/src/basic_types.cpp
${PROJECT_SOURCE_DIR}/java/jni/helper_base.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/BluetoothFactory.cxx
- ${PROJECT_SOURCE_DIR}/java/jni/BluetoothUtils.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/BTFactory.cxx
+ ${PROJECT_SOURCE_DIR}/java/jni/BTUtils.cxx
${PROJECT_SOURCE_DIR}/java/jni/tinyb/helper_tinyb.cxx
${PROJECT_SOURCE_DIR}/java/jni/tinyb/DBusAdapter.cxx
${PROJECT_SOURCE_DIR}/java/jni/tinyb/DBusDevice.cxx
diff --git a/java/jni/tinyb/DBusGattService.cxx b/java/jni/tinyb/DBusGattService.cxx
index 99284e39..f621df2d 100644
--- a/java/jni/tinyb/DBusGattService.cxx
+++ b/java/jni/tinyb/DBusGattService.cxx
@@ -103,7 +103,7 @@ jboolean Java_tinyb_dbus_DBusGattService_getPrimary(JNIEnv *env, jobject obj)
return JNI_FALSE;
}
-jobject Java_tinyb_dbus_DBusGattService_getCharacteristics(JNIEnv *env, jobject obj)
+jobject Java_tinyb_dbus_DBusGattService_getChars(JNIEnv *env, jobject obj)
{
try {
BluetoothGattService *obj_gatt_serv = getInstance<BluetoothGattService>(env, obj);
diff --git a/java/org/direct_bt/AdapterSettings.java b/java/org/direct_bt/AdapterSettings.java
index 52a090d4..8bf0ea2d 100644
--- a/java/org/direct_bt/AdapterSettings.java
+++ b/java/org/direct_bt/AdapterSettings.java
@@ -25,7 +25,7 @@
package org.direct_bt;
/**
- * Bit mask of '{@link BluetoothAdapter} setting' data fields,
+ * Bit mask of '{@link BTAdapter} setting' data fields,
* indicating a set of related data.
*
* @since 2.0.0
@@ -33,7 +33,7 @@ package org.direct_bt;
public class AdapterSettings {
/**
- * Bits representing '{@link BluetoothAdapter} setting' data fields.
+ * Bits representing '{@link BTAdapter} setting' data fields.
*
* @since 2.0.0
*/
diff --git a/java/org/direct_bt/AdapterStatusListener.java b/java/org/direct_bt/AdapterStatusListener.java
index 7e3b1634..68377957 100644
--- a/java/org/direct_bt/AdapterStatusListener.java
+++ b/java/org/direct_bt/AdapterStatusListener.java
@@ -26,20 +26,20 @@
package org.direct_bt;
/**
- * {@link BluetoothAdapter} status listener for {@link BluetoothDevice} discovery events: Added, updated and removed;
- * as well as for certain {@link BluetoothAdapter} events.
+ * {@link BTAdapter} status listener for {@link BTDevice} discovery events: Added, updated and removed;
+ * as well as for certain {@link BTAdapter} events.
* <p>
* User implementations shall return as early as possible to avoid blocking the event-handler thread,
- * if not specified within the methods otherwise (see {@link #deviceReady(BluetoothDevice, long)}).<br>
+ * if not specified within the methods otherwise (see {@link #deviceReady(BTDevice, long)}).<br>
* Especially complex mutable operations on DBTDevice or DBTAdapter should be issued off-thread!
* </p>
* <p>
- * A listener instance may be attached to a {@link BluetoothAdapter} via
- * {@link BluetoothAdapter#addStatusListener(AdapterStatusListener, BluetoothDevice)}.
+ * A listener instance may be attached to a {@link BTAdapter} via
+ * {@link BTAdapter#addStatusListener(AdapterStatusListener, BTDevice)}.
* </p>
* <p>
* One {@link AdapterStatusListener} instance can only be attached to a listener receiver once at a time,
- * i.e. you cannot attach the same instance more than once to a {@link BluetoothAdapter}.
+ * i.e. you cannot attach the same instance more than once to a {@link BTAdapter}.
* <br>
* To attach multiple listener, one instance per attachment must be created.
* <br>
@@ -67,75 +67,75 @@ public abstract class AdapterStatusListener {
}
/**
- * {@link BluetoothAdapter} setting(s) changed.
+ * {@link BTAdapter} setting(s) changed.
* @param adapter the adapter which settings have changed.
* @param oldmask the previous settings mask. {@link AdapterSettings#isEmpty()} indicates the initial setting notification,
- * see {@link BluetoothAdapter#addStatusListener(AdapterStatusListener, BluetoothDevice) addStatusListener(..)}.
+ * see {@link BTAdapter#addStatusListener(AdapterStatusListener, BTDevice) addStatusListener(..)}.
* @param newmask the new settings mask
* @param changedmask the changes settings mask. {@link AdapterSettings#isEmpty()} indicates the initial setting notification,
- * see {@link BluetoothAdapter#addStatusListener(AdapterStatusListener, BluetoothDevice) addStatusListener(..)}.
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
+ * see {@link BTAdapter#addStatusListener(AdapterStatusListener, BTDevice) addStatusListener(..)}.
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
*/
- public void adapterSettingsChanged(final BluetoothAdapter adapter,
+ public void adapterSettingsChanged(final BTAdapter adapter,
final AdapterSettings oldmask, final AdapterSettings newmask,
final AdapterSettings changedmask, final long timestamp) { }
/**
- * {@link BluetoothAdapter}'s discovery state has changed, i.e. enabled or disabled.
+ * {@link BTAdapter}'s discovery state has changed, i.e. enabled or disabled.
* @param adapter the adapter which discovering state has changed.
* @param currentMeta the current meta {@link ScanType}
* @param changedType denotes the changed {@link ScanType}
* @param changedEnabled denotes whether the changed {@link ScanType} has been enabled or disabled
* @param keepAlive if {@code true}, the denoted changed {@link ScanType} will be re-enabled if disabled by the underlying Bluetooth implementation.
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
*/
- public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { }
+ public void discoveringChanged(final BTAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { }
/**
- * A {@link BluetoothDevice} has been newly discovered.
+ * A {@link BTDevice} has been newly discovered.
* <p>
* The boolean return value informs the adapter whether the device shall be made persistent for connection {@code true},
* or that it can be discarded {@code false}.<br>
- * If no registered {@link AdapterStatusListener#deviceFound(BluetoothDevice, long) deviceFound(..)} implementation returns {@code true},
+ * If no registered {@link AdapterStatusListener#deviceFound(BTDevice, long) deviceFound(..)} implementation returns {@code true},
* the device instance will be removed from all internal lists and can no longer being used.<br>
- * If any registered {@link AdapterStatusListener#deviceFound(BluetoothDevice, long) deviceFound(..)} implementation returns {@code true},
- * the device will be made persistent, is ready to connect and {@link BluetoothDevice#remove() remove} shall be called after usage.
+ * If any registered {@link AdapterStatusListener#deviceFound(BTDevice, long) deviceFound(..)} implementation returns {@code true},
+ * the device will be made persistent, is ready to connect and {@link BTDevice#remove() remove} shall be called after usage.
* </p>
* @param device the found device
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
- * @return true if the device shall be made persistent and {@link BluetoothDevice#remove() remove} issued later. Otherwise false to remove device right away.
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
+ * @return true if the device shall be made persistent and {@link BTDevice#remove() remove} issued later. Otherwise false to remove device right away.
*/
- public boolean deviceFound(final BluetoothDevice device, final long timestamp) { return false; }
+ public boolean deviceFound(final BTDevice device, final long timestamp) { return false; }
/**
- * An already discovered {@link BluetoothDevice} has been updated.
+ * An already discovered {@link BTDevice} has been updated.
* @param device the updated device
* @param updateMask the update mask of changed data
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
*/
- public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) { }
+ public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) { }
/**
- * {@link BluetoothDevice} got connected.
+ * {@link BTDevice} got connected.
* @param device the device which has been connected, holding the new connection handle.
* @param handle the new connection handle, which has been assigned to the device already
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
*/
- public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) { }
+ public void deviceConnected(final BTDevice device, final short handle, final long timestamp) { }
/**
- * An already connected {@link BluetoothDevice}'s {@link SMPPairingState} has changed.
+ * An already connected {@link BTDevice}'s {@link SMPPairingState} has changed.
* @param device the device which {@link PairingMode} has been changed.
* @param state the current {@link SMPPairingState} of the connected device, see DBTDevice::getCurrentPairingState()
* @param mode the current {@link PairingMode} of the connected device, see DBTDevice::getCurrentPairingMode()
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
- * @see BluetoothDevice#setPairingPasskey(int)
- * @see BluetoothDevice#setPairingNumericComparison(boolean)
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
+ * @see BTDevice#setPairingPasskey(int)
+ * @see BTDevice#setPairingNumericComparison(boolean)
*/
- public void devicePairingState(final BluetoothDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {}
+ public void devicePairingState(final BTDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {}
/**
- * {@link BluetoothDevice} is ready for user (GATT) processing, i.e. already connected, optionally paired and ATT MTU size negotiated via connected GATT.
+ * {@link BTDevice} is ready for user (GATT) processing, i.e. already connected, optionally paired and ATT MTU size negotiated via connected GATT.
* <p>
* Method is being called from a dedicated native thread, hence restrictions on method duration and complex mutable operations don't apply here.
* </p>
@@ -143,14 +143,14 @@ public abstract class AdapterStatusListener {
* @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds().
* @see {@link SMPPairingState#COMPLETED}
*/
- public void deviceReady(final BluetoothDevice device, final long timestamp) {}
+ public void deviceReady(final BTDevice device, final long timestamp) {}
/**
- * {@link BluetoothDevice} got disconnected.
+ * {@link BTDevice} got disconnected.
* @param device the device which has been disconnected with zeroed connection handle.
* @param reason the {@link HCIStatusCode} reason for disconnection
* @param handle the disconnected connection handle, which has been unassigned from the device already
- * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}.
+ * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}.
*/
- public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) { }
+ public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) { }
};
diff --git a/java/org/direct_bt/BluetoothAdapter.java b/java/org/direct_bt/BTAdapter.java
index 65558731..77a00f8c 100644
--- a/java/org/direct_bt/BluetoothAdapter.java
+++ b/java/org/direct_bt/BTAdapter.java
@@ -35,15 +35,15 @@ import java.util.UUID;
* Provides access to Bluetooth adapters. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/adapter-api.txt
*/
-public interface BluetoothAdapter extends BluetoothObject
+public interface BTAdapter extends BTObject
{
@Override
- public BluetoothAdapter clone();
+ public BTAdapter clone();
/**
- * Returns the used singleton {@link BluetoothManager} instance, used to create this adapter.
+ * Returns the used singleton {@link BTManager} instance, used to create this adapter.
*/
- public BluetoothManager getManager();
+ public BTManager getManager();
/** Find a BluetoothDevice. If parameters name and address are not null,
* the returned object will have to match them.
@@ -58,7 +58,7 @@ public interface BluetoothAdapter extends BluetoothObject
* @return An object matching the name and address or null if not found before
* timeout expires.
*/
- public BluetoothDevice find(String name, BDAddressAndType addressAndType, long timeoutMS);
+ public BTDevice find(String name, BDAddressAndType addressAndType, long timeoutMS);
/** Find a BluetoothDevice. If parameters name and address are not null,
* the returned object will have to match them.
@@ -70,7 +70,7 @@ public interface BluetoothAdapter extends BluetoothObject
* waiting for
* @return An object matching the name and address.
*/
- public BluetoothDevice find(String name, BDAddressAndType addressAndType);
+ public BTDevice find(String name, BDAddressAndType addressAndType);
/* Bluetooth specific API */
@@ -145,7 +145,7 @@ public interface BluetoothAdapter extends BluetoothObject
* @deprecated since 2.0.0, use {@link #startDiscovery(boolean)}.
*/
@Deprecated
- public boolean startDiscovery() throws BluetoothException;
+ public boolean startDiscovery() throws BTException;
/**
* Turns on device discovery if it is disabled.
@@ -168,12 +168,12 @@ public interface BluetoothAdapter extends BluetoothObject
* and {@link #stopDiscovery()} is the recommended workflow
* for a reliable discovery process.
* @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state
- * @throws BluetoothException
+ * @throws BTException
* @since 2.0.0
* @implNote {@code keepAlive} not implemented in tinyb.dbus
* @see #getDiscovering()
*/
- public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException;
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException;
/**
* Turns off device discovery if it is enabled.
@@ -181,23 +181,23 @@ public interface BluetoothAdapter extends BluetoothObject
* @apiNote return {@link HCIStatusCode} since 2.0.0
* @since 2.0.0
*/
- public HCIStatusCode stopDiscovery() throws BluetoothException;
+ public HCIStatusCode stopDiscovery() throws BTException;
/** Returns a list of discovered BluetoothDevices from this adapter.
* @return A list of discovered BluetoothDevices on this adapter,
* NULL if an error occurred
*/
- public List<BluetoothDevice> getDiscoveredDevices();
+ public List<BTDevice> getDiscoveredDevices();
/**
* Remove all the discovered devices found on this adapter.
*
* @return The number of removed discovered devices on this adapter
- * @throws BluetoothException
+ * @throws BTException
* @since 2.2.0
* @implNote Changed from 'removeDiscoveredDevices()' for clarity since version 2.2.0
*/
- public int removeDiscoveredDevices() throws BluetoothException;
+ public int removeDiscoveredDevices() throws BTException;
/**
* Discards matching discovered devices.
@@ -304,7 +304,7 @@ public interface BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the powered
* property.
*/
- public void enablePoweredNotifications(BluetoothNotification<Boolean> callback);
+ public void enablePoweredNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the powered property and unregisters the callback
@@ -346,7 +346,7 @@ public interface BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the discoverable
* property.
*/
- public void enableDiscoverableNotifications(BluetoothNotification<Boolean> callback);
+ public void enableDiscoverableNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the discoverable property and unregisters the callback
* object passed through the corresponding enable method.
@@ -397,7 +397,7 @@ public interface BluetoothAdapter extends BluetoothObject
* <li>{@code random} - Random address</li>
* </ul>
*/
- public BluetoothDevice connectDevice(BDAddressAndType addressAndType);
+ public BTDevice connectDevice(BDAddressAndType addressAndType);
/** Returns the pairable state the adapter.
* @return The pairable state of the adapter.
@@ -411,7 +411,7 @@ public interface BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the pairable
* property.
*/
- public void enablePairableNotifications(BluetoothNotification<Boolean> callback);
+ public void enablePairableNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the pairable property and unregisters the callback
@@ -469,18 +469,18 @@ public interface BluetoothAdapter extends BluetoothObject
* Add the given {@link AdapterStatusListener} to the list if not already present.
* <p>
* The newly added {@link AdapterStatusListener} will receive an initial
- * {@link AdapterStatusListener#adapterSettingsChanged(BluetoothAdapter, AdapterSettings, AdapterSettings, AdapterSettings, long) adapterSettingsChanged}
+ * {@link AdapterStatusListener#adapterSettingsChanged(BTAdapter, AdapterSettings, AdapterSettings, AdapterSettings, long) adapterSettingsChanged}
* event, passing an {@link AdapterSettings empty oldMask and changedMask}, as well as {@link AdapterSettings current newMask}. <br>
* This allows the receiver to be aware of this adapter's current settings.
* </p>
* @param listener A {@link AdapterStatusListener} instance
- * @param deviceMatch Optional {@link BluetoothDevice} to be matched before calling any
+ * @param deviceMatch Optional {@link BTDevice} to be matched before calling any
* {@link AdapterStatusListener} {@code device*} methods. Pass {@code null} for no filtering.
* @return true if the given listener is not element of the list and has been newly added, otherwise false.
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
*/
- public boolean addStatusListener(final AdapterStatusListener listener, final BluetoothDevice deviceMatch);
+ public boolean addStatusListener(final AdapterStatusListener listener, final BTDevice deviceMatch);
/**
* Remove the given {@link AdapterStatusListener} from the list.
@@ -506,7 +506,7 @@ public interface BluetoothAdapter extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the discovering
* property.
*/
- public void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback);
+ public void enableDiscoveringNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the discovering property and unregisters the discovering
diff --git a/java/org/direct_bt/BluetoothCallback.java b/java/org/direct_bt/BTCallback.java
index a179c812..86b3f542 100644
--- a/java/org/direct_bt/BluetoothCallback.java
+++ b/java/org/direct_bt/BTCallback.java
@@ -26,7 +26,7 @@ package org.direct_bt;
import tinyb.dbus.DBusObject;
-public abstract class BluetoothCallback implements Runnable
+public abstract class BTCallback implements Runnable
{
protected DBusObject bObj;
diff --git a/java/org/direct_bt/BluetoothDevice.java b/java/org/direct_bt/BTDevice.java
index d80e2d64..4a92cf57 100644
--- a/java/org/direct_bt/BluetoothDevice.java
+++ b/java/org/direct_bt/BTDevice.java
@@ -35,10 +35,10 @@ import java.util.Map;
* Provides access to Bluetooth adapters. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/device-api.txt
*/
-public interface BluetoothDevice extends BluetoothObject
+public interface BTDevice extends BTObject
{
@Override
- public BluetoothDevice clone();
+ public BTDevice clone();
/** Find a BluetoothGattService. If parameter UUID is not null,
* the returned object will have to match it.
@@ -51,7 +51,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- BluetoothGattService find(String UUID, long timeoutMS);
+ BTGattService find(String UUID, long timeoutMS);
/** Find a BluetoothGattService. If parameter UUID is not null,
* the returned object will have to match it.
@@ -62,7 +62,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- BluetoothGattService find(String UUID);
+ BTGattService find(String UUID);
/* Bluetooth method calls: */
@@ -78,7 +78,7 @@ public interface BluetoothDevice extends BluetoothObject
* </p>
* <p>
* The device will be removed from the managing adapter's connected devices
- * when {@link AdapterStatusListener#deviceDisconnected(BluetoothDevice, HCIStatusCode, long)} has been received.
+ * when {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)} has been received.
* </p>
* <p>
* An open GATT connection will also be closed.<br>
@@ -92,7 +92,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
* @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i>
*/
- HCIStatusCode disconnect() throws BluetoothException;
+ HCIStatusCode disconnect() throws BTException;
/**
* <b>direct_bt.tinyb</b>: Establish a default HCI connection to this device, using certain default parameter.
@@ -107,8 +107,8 @@ public interface BluetoothDevice extends BluetoothObject
* </p>
* <p>
* The actual new connection handle will be delivered asynchronous and
- * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BluetoothDevice, long)},
- * or if failed via {@link AdapterStatusListener#deviceDisconnected(BluetoothDevice, HCIStatusCode, long)}.
+ * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BTDevice, long)},
+ * or if failed via {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)}.
* </p>
* <p>
* The device is tracked by the managing adapter.
@@ -121,7 +121,7 @@ public interface BluetoothDevice extends BluetoothObject
* @see #connectLE(short, short, short, short, short, short)
* @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i>
*/
- HCIStatusCode connect() throws BluetoothException;
+ HCIStatusCode connect() throws BTException;
/**
* Establish a HCI BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM connection to this device.
@@ -134,8 +134,8 @@ public interface BluetoothDevice extends BluetoothObject
* </p>
* <p>
* The actual new connection handle will be delivered asynchronous and
- * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BluetoothDevice, long)},
- * or if failed via {@link AdapterStatusListener#deviceDisconnected(BluetoothDevice, HCIStatusCode, long)}.
+ * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BTDevice, long)},
+ * or if failed via {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)}.
* </p>
* <p>
* The device is tracked by the managing adapter.
@@ -158,7 +158,7 @@ public interface BluetoothDevice extends BluetoothObject
* @param conn_latency slave latency in units of connection events, default value 0; Value range [0 .. 0x01F3].
* @param supervision_timeout in units of 10ms, default value >= 10 x conn_interval_max, we use 500 ms minimum; Value range [0xA-0x0C80] for [100ms - 32s].
* @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
- * @see BluetoothUtils#getHCIConnSupervisorTimeout(int, int, int, int)
+ * @see BTUtils#getHCIConnSupervisorTimeout(int, int, int, int)
* @see #connect()
* @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i>
* @implNote not implemented in <b>tinyb.dbus</b>
@@ -172,13 +172,13 @@ public interface BluetoothDevice extends BluetoothObject
* @param arg_UUID The UUID of the profile to be connected
* @return TRUE if the profile connected successfully
*/
- boolean connectProfile(String arg_UUID) throws BluetoothException;
+ boolean connectProfile(String arg_UUID) throws BTException;
/** Disconnects a specific profile available on the device, given by UUID
* @param arg_UUID The UUID of the profile to be disconnected
* @return TRUE if the profile disconnected successfully
*/
- boolean disconnectProfile(String arg_UUID) throws BluetoothException;
+ boolean disconnectProfile(String arg_UUID) throws BTException;
/**
* Returns the available {@link SMPKeyMask.KeyType} {@link SMPKeyMask} for the responder (LL slave) or initiator (LL master).
@@ -194,7 +194,7 @@ public interface BluetoothDevice extends BluetoothObject
* @param responder true will return the responder's LTK info (remote device, LL slave), otherwise the initiator's (the LL master).
* @return the resulting key. {@link SMPLongTermKeyInfo#enc_size} will be zero if invalid.
* @see {@link SMPPairingState#COMPLETED}
- * @see {@link AdapterStatusListener#deviceReady(BluetoothDevice, long)}
+ * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)}
* @since 2.2.0
* @implNote not implemented in tinyb.dbus
*/
@@ -217,7 +217,7 @@ public interface BluetoothDevice extends BluetoothObject
* @param responder true will return the responder's LTK info (remote device, LL slave), otherwise the initiator's (the LL master).
* @return the resulting key
* @see {@link SMPPairingState#COMPLETED}
- * @see {@link AdapterStatusListener#deviceReady(BluetoothDevice, long)}
+ * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)}
* @since 2.2.0
* @implNote not implemented in tinyb.dbus
*/
@@ -232,7 +232,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return TRUE if the device connected and paired
* @implNote not implemented in direct_bt.tinyb
*/
- boolean pair() throws BluetoothException;
+ boolean pair() throws BTException;
/**
* Unpairs this device from the adapter while staying connected.
@@ -390,7 +390,7 @@ public interface BluetoothDevice extends BluetoothObject
* Method sets the given passkey entry, see {@link PairingMode#PASSKEY_ENTRY_ini}.
* <p>
* Call this method if the device shall be securely paired with {@link PairingMode#PASSKEY_ENTRY_ini},
- * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) devicePairingState}
+ * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
* in state {@link SMPPairingState#PASSKEY_EXPECTED}.
* </p>
*
@@ -400,7 +400,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
* @see PairingMode
* @see SMPPairingState
- * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long)
+ * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
* @see #setPairingPasskey(int)
* @see #setPairingNumericComparison(boolean)
* @see #getPairingMode()
@@ -414,7 +414,7 @@ public interface BluetoothDevice extends BluetoothObject
* Method sets the numeric comparison result, see {@link PairingMode#NUMERIC_COMPARE_ini}.
* <p>
* Call this method if the device shall be securely paired with {@link PairingMode#NUMERIC_COMPARE_ini},
- * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) devicePairingState}
+ * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
* in state {@link SMPPairingState#NUMERIC_COMPARE_EXPECTED}.
* </p>
*
@@ -424,7 +424,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection.
* @see PairingMode
* @see SMPPairingState
- * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long)
+ * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
* @see #setPairingPasskey(int)
* @see #setPairingNumericComparison(boolean)
* @see #getPairingMode()
@@ -442,7 +442,7 @@ public interface BluetoothDevice extends BluetoothObject
* <p>
* If the Pairing Feature Exchange is completed, i.e. {@link SMPPairingState#FEATURE_EXCHANGE_COMPLETED}
* as notified by
- * {@link AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) devicePairingState}
+ * {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState}
* the current mode reflects the currently used {@link PairingMode}.
* </p>
* <p>
@@ -451,7 +451,7 @@ public interface BluetoothDevice extends BluetoothObject
* @return current PairingMode.
* @see PairingMode
* @see SMPPairingState
- * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long)
+ * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
* @see #setPairingPasskey(int)
* @see #setPairingNumericComparison(boolean)
* @see #getPairingMode()
@@ -468,7 +468,7 @@ public interface BluetoothDevice extends BluetoothObject
* </p>
* @see PairingMode
* @see SMPPairingState
- * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long)
+ * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long)
* @see #setPairingPasskey(int)
* @see #setPairingNumericComparison(boolean)
* @see #getPairingMode()
@@ -504,20 +504,20 @@ public interface BluetoothDevice extends BluetoothObject
* but never issue remove() after disconnect() if the device is in use.
* </p>
* @return TRUE if the device has been removed
- * @throws BluetoothException
+ * @throws BTException
*/
- boolean remove() throws BluetoothException;
+ boolean remove() throws BTException;
/** Cancels an initiated pairing operation
* @return TRUE if the paring is cancelled successfully
*/
- boolean cancelPairing() throws BluetoothException;
+ boolean cancelPairing() throws BTException;
/** Returns a list of BluetoothGattServices available on this device.
* @return A list of BluetoothGattServices available on this device,
* NULL if an error occurred
*/
- List<BluetoothGattService> getServices();
+ List<BTGattService> getServices();
/**
* Issues a GATT ping to the device, validating whether it is still reachable.
@@ -541,7 +541,7 @@ public interface BluetoothDevice extends BluetoothObject
* Returns the timestamp in monotonic milliseconds when this device instance has been created,
* either via its initial discovery or its initial direct connection.
*
- * @see BluetoothUtils#currentTimeMillis()
+ * @see BTUtils#currentTimeMillis()
* @since 2.0.0
*/
long getCreationTimestamp();
@@ -550,7 +550,7 @@ public interface BluetoothDevice extends BluetoothObject
* Returns the timestamp in monotonic milliseconds when this device instance has
* discovered or connected directly the last time.
*
- * @see BluetoothUtils#currentTimeMillis()
+ * @see BTUtils#currentTimeMillis()
* @since 2.0.0
* @implNote not implemented in tinyb.dbus, returns {@link #getCreationTimestamp()}
*/
@@ -560,7 +560,7 @@ public interface BluetoothDevice extends BluetoothObject
* Returns the timestamp in monotonic milliseconds when this device instance underlying data
* has been updated the last time.
*
- * @see BluetoothUtils#currentTimeMillis()
+ * @see BTUtils#currentTimeMillis()
* @since 2.0.0
* @implNote not implemented in tinyb.dbus, returns {@link #getCreationTimestamp()}
*/
@@ -623,7 +623,7 @@ public interface BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the paired
* property.
*/
- void enablePairedNotifications(BluetoothNotification<Boolean> callback);
+ void enablePairedNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the paired property and unregisters the callback
@@ -643,7 +643,7 @@ public interface BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the trusted
* property.
*/
- void enableTrustedNotifications(BluetoothNotification<Boolean> callback);
+ void enableTrustedNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the trusted property and unregisters the callback
@@ -667,7 +667,7 @@ public interface BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the blocked
* property.
*/
- void enableBlockedNotifications(BluetoothNotification<Boolean> callback);
+ void enableBlockedNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the blocked property and unregisters the callback
@@ -696,7 +696,7 @@ public interface BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the RSSI
* property.
*/
- void enableRSSINotifications(BluetoothNotification<Short> callback);
+ void enableRSSINotifications(BTNotification<Short> callback);
/**
* Disables notifications of the RSSI property and unregisters the callback
@@ -723,7 +723,7 @@ public interface BluetoothDevice extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the connected
* property.
*/
- void enableConnectedNotifications(BluetoothNotification<Boolean> callback);
+ void enableConnectedNotifications(BTNotification<Boolean> callback);
/**
* Disables notifications of the connected property and unregisters the callback
@@ -745,7 +745,7 @@ public interface BluetoothDevice extends BluetoothObject
* connected.
* @return The adapter.
*/
- BluetoothAdapter getAdapter();
+ BTAdapter getAdapter();
/** Returns a map containing manufacturer specific advertisement data.
* An entry has a uint16_t key and an array of bytes.
@@ -761,7 +761,7 @@ public interface BluetoothDevice extends BluetoothObject
* property.
*/
void enableManufacturerDataNotifications(
- BluetoothNotification<Map<Short, byte[]>> callback);
+ BTNotification<Map<Short, byte[]>> callback);
/**
* Disables notifications of the manufacturer data property and unregisters the callback
@@ -783,7 +783,7 @@ public interface BluetoothDevice extends BluetoothObject
* property.
*/
void enableServiceDataNotifications(
- BluetoothNotification<Map<String, byte[]>> callback);
+ BTNotification<Map<String, byte[]>> callback);
/**
* Disables notifications of the service data property and unregisters the callback
@@ -809,7 +809,7 @@ public interface BluetoothDevice extends BluetoothObject
* property.
*/
void enableServicesResolvedNotifications(
- BluetoothNotification<Boolean> callback);
+ BTNotification<Boolean> callback);
/**
* Disables notifications of the services resolved property and unregisters the callback
@@ -818,40 +818,40 @@ public interface BluetoothDevice extends BluetoothObject
void disableServicesResolvedNotifications();
/**
- * Add the given {@link GATTCharacteristicListener} to the listener list if not already present.
+ * Add the given {@link BTGattCharListener} to the listener list if not already present.
* <p>
* To enable the actual BLE notification and/or indication, one needs to call
- * {@link BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[])}
- * or {@link BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[])}.
+ * {@link BTGattChar#configNotificationIndication(boolean, boolean, boolean[])}
+ * or {@link BTGattChar#enableNotificationOrIndication(boolean[])}.
* </p>
- * @param listener A {@link GATTCharacteristicListener} instance, listening to all {@link BluetoothGattCharacteristic} events of this device
+ * @param listener A {@link BTGattCharListener} instance, listening to all {@link BTGattChar} events of this device
* @return true if the given listener is not element of the list and has been newly added, otherwise false.
- * @throws IllegalStateException if the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected
- * @throws IllegalStateException if the given {@link GATTCharacteristicListener} is already in use, i.e. added.
- * @see BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[])
- * @see BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[])
+ * @throws IllegalStateException if the {@link BTDevice}'s GATTHandler is null, i.e. not connected
+ * @throws IllegalStateException if the given {@link BTGattCharListener} is already in use, i.e. added.
+ * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[])
+ * @see BTGattChar#enableNotificationOrIndication(boolean[])
* @since 2.0.0
* @implNote not implemented in <b>tinyb.dbus</b>
*/
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener)
+ public boolean addCharListener(final BTGattCharListener listener)
throws IllegalStateException;
/**
- * Remove the given {@link GATTCharacteristicListener} from the listener list.
+ * Remove the given {@link BTGattCharListener} from the listener list.
* <p>
- * If the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected, {@code false} is being returned.
+ * If the {@link BTDevice}'s GATTHandler is null, i.e. not connected, {@code false} is being returned.
* </p>
- * @param listener A {@link GATTCharacteristicListener} instance
+ * @param listener A {@link BTGattCharListener} instance
* @return true if the given listener is an element of the list and has been removed, otherwise false.
* @since 2.0.0
* @implNote not implemented in <b>tinyb.dbus</b>
*/
- public boolean removeCharacteristicListener(final GATTCharacteristicListener l);
+ public boolean removeCharListener(final BTGattCharListener l);
/**
- * Remove all {@link GATTCharacteristicListener} from the list, which are associated to the given {@link BluetoothGattCharacteristic}.
+ * Remove all {@link BTGattCharListener} from the list, which are associated to the given {@link BTGattChar}.
* <p>
- * Implementation tests all listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic()}
+ * Implementation tests all listener's {@link BTGattCharListener#getAssociatedChar()}
* to match with the given associated characteristic.
* </p>
* @param associatedCharacteristic the match criteria to remove any GATTCharacteristicListener from the list
@@ -859,13 +859,13 @@ public interface BluetoothDevice extends BluetoothObject
* @since 2.0.0
* @implNote not implemented in <b>tinyb.dbus</b>
*/
- public int removeAllAssociatedCharacteristicListener(final BluetoothGattCharacteristic associatedCharacteristic);
+ public int removeAllAssociatedCharListener(final BTGattChar associatedCharacteristic);
/**
- * Remove all {@link GATTCharacteristicListener} from the list.
+ * Remove all {@link BTGattCharListener} from the list.
* @return number of removed listener.
* @since 2.0.0
* @implNote not implemented in <b>tinyb.dbus</b>
*/
- public int removeAllCharacteristicListener();
+ public int removeAllCharListener();
}
diff --git a/java/org/direct_bt/BluetoothEvent.java b/java/org/direct_bt/BTEvent.java
index 8ccce79b..12cf5f9e 100644
--- a/java/org/direct_bt/BluetoothEvent.java
+++ b/java/org/direct_bt/BTEvent.java
@@ -28,9 +28,9 @@
package org.direct_bt;
-public interface BluetoothEvent
+public interface BTEvent
{
- public BluetoothType getType();
+ public BTType getType();
public String getName();
public String getIdentifier();
public boolean executeCallback();
diff --git a/java/org/direct_bt/BluetoothException.java b/java/org/direct_bt/BTException.java
index d89eb154..b3ef62dd 100644
--- a/java/org/direct_bt/BluetoothException.java
+++ b/java/org/direct_bt/BTException.java
@@ -29,8 +29,8 @@
package org.direct_bt;
@SuppressWarnings("serial")
-public class BluetoothException extends RuntimeException {
- protected BluetoothException(final String msg) {
+public class BTException extends RuntimeException {
+ protected BTException(final String msg) {
super(msg);
}
}
diff --git a/java/org/direct_bt/BluetoothFactory.java b/java/org/direct_bt/BTFactory.java
index 66db7917..cee2aa7f 100644
--- a/java/org/direct_bt/BluetoothFactory.java
+++ b/java/org/direct_bt/BTFactory.java
@@ -41,17 +41,17 @@ import java.util.jar.Attributes;
import java.util.jar.Manifest;
/**
- * One stop {@link BluetoothManager} API entry point.
+ * One stop {@link BTManager} API entry point.
* <p>
* Further provides access to certain property settings,
* see {@link #DEBUG}, {@link #VERBOSE}, {@link #DIRECTBT_CHARACTERISTIC_VALUE_CACHE_NOTIFICATION_COMPAT}.
* </p>
*/
-public class BluetoothFactory {
+public class BTFactory {
/**
- * Identifier names, allowing {@link BluetoothFactory#getBluetoothManager(ImplementationIdentifier)}
- * to initialize the required native libraries and to instantiate the root {@link BluetoothManager} instance.
+ * Identifier names, allowing {@link BTFactory#getBluetoothManager(ImplementationIdentifier)}
+ * to initialize the required native libraries and to instantiate the root {@link BTManager} instance.
* <p>
* The implementation class must provide the static factory method
* <pre>
@@ -61,7 +61,7 @@ public class BluetoothFactory {
*/
public static class ImplementationIdentifier {
/**
- * Fully qualified class name for the {@link BluetoothManager} implementation
+ * Fully qualified class name for the {@link BTManager} implementation
* <p>
* The implementation class must provide the static factory method
* <pre>
@@ -120,7 +120,7 @@ public class BluetoothFactory {
* This value is exposed for convenience, user implementations are welcome.
* </p>
*/
- public static final ImplementationIdentifier DirectBTImplementationID = new ImplementationIdentifier("direct_bt.tinyb.DBTManager", "direct_bt", "javadirect_bt");
+ public static final ImplementationIdentifier DirectBTImplementationID = new ImplementationIdentifier("jau.direct_bt.DBTManager", "direct_bt", "javadirect_bt");
private static final List<ImplementationIdentifier> implIDs = new ArrayList<ImplementationIdentifier>();
@@ -206,10 +206,10 @@ public class BluetoothFactory {
try {
final Throwable[] t = { null };
- if( !PlatformToolkit.loadLibrary(id.ImplementationNativeLibraryBasename, BluetoothFactory.class.getClassLoader(), t) ) {
+ if( !PlatformToolkit.loadLibrary(id.ImplementationNativeLibraryBasename, BTFactory.class.getClassLoader(), t) ) {
throw new RuntimeException("Couldn't load native library with basename <"+id.ImplementationNativeLibraryBasename+">", t[0]);
}
- if( !PlatformToolkit.loadLibrary(id.JavaNativeLibraryBasename, BluetoothFactory.class.getClassLoader(), t) ) {
+ if( !PlatformToolkit.loadLibrary(id.JavaNativeLibraryBasename, BTFactory.class.getClassLoader(), t) ) {
throw new RuntimeException("Couldn't load native library with basename <"+id.JavaNativeLibraryBasename+">", t[0]);
}
} catch (final Throwable e) {
@@ -247,7 +247,7 @@ public class BluetoothFactory {
}
try {
- final Manifest manifest = getManifest(BluetoothFactory.class.getClassLoader(), new String[] { "org.tinyb" } );
+ final Manifest manifest = getManifest(BTFactory.class.getClassLoader(), new String[] { "org.tinyb" } );
final Attributes mfAttributes = null != manifest ? manifest.getMainAttributes() : null;
// major.minor must match!
@@ -301,12 +301,12 @@ public class BluetoothFactory {
}
}
- private static synchronized BluetoothManager getBluetoothManager(final Class<?> factoryImplClass)
- throws BluetoothException, NoSuchMethodException, SecurityException,
+ private static synchronized BTManager getBluetoothManager(final Class<?> factoryImplClass)
+ throws BTException, NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException
{
final Method m = factoryImplClass.getMethod("getManager");
- return (BluetoothManager)m.invoke(null);
+ return (BTManager)m.invoke(null);
}
/**
@@ -328,7 +328,7 @@ public class BluetoothFactory {
/**
* Returns the matching {@link ImplementationIdentifier} from the internal list or {@code null} if not found.
- * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BluetoothManager} implementation
+ * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BTManager} implementation
*/
public static synchronized ImplementationIdentifier getImplementationIdentifier(final String fqBluetoothManagerImplementationClassName) {
for(final ImplementationIdentifier id : implIDs) {
@@ -349,8 +349,8 @@ public class BluetoothFactory {
* The chosen implementation can't be changed within a running implementation, an exception is thrown if tried.
* </p>
*
- * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BluetoothManager} implementation
- * @throws BluetoothException
+ * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BTManager} implementation
+ * @throws BTException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws IllegalAccessException
@@ -360,8 +360,8 @@ public class BluetoothFactory {
* @see {@link #DBusFactoryImplClassName}
* @see {@link #DirectBTFactoryImplClassName}
*/
- public static synchronized BluetoothManager getBluetoothManager(final String fqBluetoothManagerImplementationClassName)
- throws BluetoothException, NoSuchMethodException, SecurityException,
+ public static synchronized BTManager getBluetoothManager(final String fqBluetoothManagerImplementationClassName)
+ throws BTException, NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException
{
final ImplementationIdentifier id = getImplementationIdentifier(fqBluetoothManagerImplementationClassName);
@@ -381,7 +381,7 @@ public class BluetoothFactory {
* The chosen implementation can't be changed within a running implementation, an exception is thrown if tried.
* </p>
* @param id the specific {@link ImplementationIdentifier}
- * @throws BluetoothException
+ * @throws BTException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws IllegalAccessException
@@ -391,8 +391,8 @@ public class BluetoothFactory {
* @see {@link #DBusFactoryImplClassName}
* @see {@link #DirectBTFactoryImplClassName}
*/
- public static synchronized BluetoothManager getBluetoothManager(final ImplementationIdentifier id)
- throws BluetoothException, NoSuchMethodException, SecurityException,
+ public static synchronized BTManager getBluetoothManager(final ImplementationIdentifier id)
+ throws BTException, NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException
{
registerImplementationIdentifier(id);
@@ -409,7 +409,7 @@ public class BluetoothFactory {
* <p>
* The chosen implementation can't be changed within a running implementation, an exception is thrown if tried.
* </p>
- * @throws BluetoothException
+ * @throws BTException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws IllegalAccessException
@@ -417,8 +417,8 @@ public class BluetoothFactory {
* @throws InvocationTargetException
* @throws ClassNotFoundException
*/
- public static synchronized BluetoothManager getDBusBluetoothManager()
- throws BluetoothException, NoSuchMethodException, SecurityException,
+ public static synchronized BTManager getDBusBluetoothManager()
+ throws BTException, NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException
{
return getBluetoothManager(DBusImplementationID);
@@ -432,7 +432,7 @@ public class BluetoothFactory {
* <p>
* The chosen implementation can't be changed within a running implementation, an exception is thrown if tried.
* </p>
- * @throws BluetoothException
+ * @throws BTException
* @throws NoSuchMethodException
* @throws SecurityException
* @throws IllegalAccessException
@@ -440,8 +440,8 @@ public class BluetoothFactory {
* @throws InvocationTargetException
* @throws ClassNotFoundException
*/
- public static synchronized BluetoothManager getDirectBTBluetoothManager()
- throws BluetoothException, NoSuchMethodException, SecurityException,
+ public static synchronized BTManager getDirectBTBluetoothManager()
+ throws BTException, NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException
{
return getBluetoothManager(DirectBTImplementationID);
diff --git a/java/org/direct_bt/BluetoothGattCharacteristic.java b/java/org/direct_bt/BTGattChar.java
index 580e30a3..8e7330dc 100644
--- a/java/org/direct_bt/BluetoothGattCharacteristic.java
+++ b/java/org/direct_bt/BTGattChar.java
@@ -34,10 +34,10 @@ import java.util.List;
* Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
*/
-public interface BluetoothGattCharacteristic extends BluetoothObject
+public interface BTGattChar extends BTObject
{
@Override
- public BluetoothGattCharacteristic clone();
+ public BTGattChar clone();
/** Find a BluetoothGattDescriptor. If parameter UUID is not null,
* the returned object will have to match it.
@@ -50,7 +50,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattDescriptor find(final String UUID, final long timeoutMS);
+ public BTGattDesc find(final String UUID, final long timeoutMS);
/** Find a BluetoothGattDescriptor. If parameter UUID is not null,
* the returned object will have to match it.
@@ -61,14 +61,14 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattDescriptor find(final String UUID);
+ public BTGattDesc find(final String UUID);
/* D-Bus method calls: */
/** Reads the value of this characteristic.
* @return A std::vector<unsgined char> containing the value of this characteristic.
*/
- public byte[] readValue() throws BluetoothException;
+ public byte[] readValue() throws BTException;
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration
@@ -93,7 +93,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed.
* Otherwise returns true.
* @throws IllegalStateException if notification or indication is set to be enabled
- * and the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected
+ * and the {@link BTDevice}'s GATTHandler is null, i.e. not connected
* @see #enableNotificationOrIndication(boolean[])
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
@@ -119,7 +119,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed.
* Otherwise returns true.
* @throws IllegalStateException if notification or indication is set to be enabled
- * and the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected
+ * and the {@link BTDevice}'s GATTHandler is null, i.e. not connected
* @see #configNotificationIndication(boolean, boolean, boolean[])
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
@@ -128,26 +128,26 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
throws IllegalStateException;
/**
- * Add the given {@link GATTCharacteristicListener} to the listener list if not already present.
+ * Add the given {@link BTGattCharListener} to the listener list if not already present.
* <p>
* Occurring notifications and indications, if enabled via {@link #configNotificationIndication(boolean, boolean, boolean[])}
* or {@link #enableNotificationOrIndication(boolean[])},
* will call the respective GATTCharacteristicListener callback method.
* </p>
- * @param listener A {@link GATTCharacteristicListener} instance, listening to this {@link BluetoothGattCharacteristic}'s events
+ * @param listener A {@link BTGattCharListener} instance, listening to this {@link BTGattChar}'s events
* @return true if the given listener is not element of the list and has been newly added, otherwise false.
* @throws IllegalStateException if the DBTDevice's GATTHandler is null, i.e. not connected
- * @throws IllegalStateException if the given {@link GATTCharacteristicListener} is already in use, i.e. added.
+ * @throws IllegalStateException if the given {@link BTGattCharListener} is already in use, i.e. added.
* @see #enableNotificationOrIndication(boolean[])
* @see #configNotificationIndication(boolean, boolean, boolean[])
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
*/
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener)
+ public boolean addCharacteristicListener(final BTGattCharListener listener)
throws IllegalStateException;
/**
- * Add the given {@link GATTCharacteristicListener} to the listener list if not already present
+ * Add the given {@link BTGattCharListener} to the listener list if not already present
* and if enabling the notification <i>or</i> indication for this characteristic at BLE level was successful.<br>
* Notification and/or indication configuration is only performed per characteristic if changed.
* <p>
@@ -156,33 +156,33 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* Implementation uses {@link #enableNotificationOrIndication(boolean[])} to enable one.
* </p>
* <p>
- * Occurring notifications and indications will call the respective {@link GATTCharacteristicListener}
+ * Occurring notifications and indications will call the respective {@link BTGattCharListener}
* callback method.
* </p>
- * @param listener A {@link GATTCharacteristicListener} instance, listening to this {@link BluetoothGattCharacteristic}'s events
+ * @param listener A {@link BTGattCharListener} instance, listening to this {@link BTGattChar}'s events
* @param enabledState array of size 2, holding the resulting enabled state for notification and indication
* using {@link #enableNotificationOrIndication(boolean[])}
* @return true if enabling the notification and/or indication was successful
* and if the given listener is not element of the list and has been newly added, otherwise false.
- * @throws IllegalStateException if the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected
- * @throws IllegalStateException if the given {@link GATTCharacteristicListener} is already in use, i.e. added.
+ * @throws IllegalStateException if the {@link BTDevice}'s GATTHandler is null, i.e. not connected
+ * @throws IllegalStateException if the given {@link BTGattCharListener} is already in use, i.e. added.
* @see #enableNotificationOrIndication(boolean[])
* @see #configNotificationIndication(boolean, boolean, boolean[])
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
*/
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener, final boolean enabledState[/*2*/])
+ public boolean addCharacteristicListener(final BTGattCharListener listener, final boolean enabledState[/*2*/])
throws IllegalStateException;
/**
* Disables the notification and/or indication for this characteristic at BLE level
* if {@code disableIndicationNotification == true}
- * and removes the given {@link GATTCharacteristicListener} from the listener list.
+ * and removes the given {@link BTGattCharListener} from the listener list.
* <p>
* If the DBTDevice's GATTHandler is null, i.e. not connected, {@code false} is being returned.
* </p>
*
- * @param listener A {@link GATTCharacteristicListener} instance
+ * @param listener A {@link BTGattCharListener} instance
* @param disableIndicationNotification if true, disables the notification and/or indication for this characteristic
* using {@link #configNotificationIndication(boolean, boolean, boolean[])}
* @return true if the given listener is an element of the list and has been removed, otherwise false.
@@ -190,15 +190,15 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
*/
- public boolean removeCharacteristicListener(final GATTCharacteristicListener l, final boolean disableIndicationNotification);
+ public boolean removeCharacteristicListener(final BTGattCharListener l, final boolean disableIndicationNotification);
/**
* Disables the notification and/or indication for this characteristic BLE level
* if {@code disableIndicationNotification == true}
- * and removes all {@link GATTCharacteristicListener} from the listener list,
+ * and removes all {@link BTGattCharListener} from the listener list,
* which are associated with this characteristic instance.
* <p>
- * Implementation tests all listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic()}
+ * Implementation tests all listener's {@link BTGattCharListener#getAssociatedChar()}
* to match with this characteristic instance.
* </p>
* <p>
@@ -209,7 +209,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* using {@link #configNotificationIndication(boolean, boolean, boolean[])}
* @return number of removed listener.
* @see #configNotificationIndication(boolean, boolean, boolean[])
- * @see BluetoothDevice#removeAllAssociatedCharacteristicListener(BluetoothGattCharacteristic)
+ * @see BTDevice#removeAllAssociatedCharacteristicListener(BTGattChar)
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
*/
@@ -225,7 +225,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the value
* property.
*/
- public void enableValueNotifications(BluetoothNotification<byte[]> callback);
+ public void enableValueNotifications(BTNotification<byte[]> callback);
/**
* Disables notifications of the value and unregisters the callback object
@@ -249,7 +249,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* @implNote {@code withResponse} parameter has been added since 2.0.0
* @implNote tinyb.dbus does not support {@code withResponse = true}
*/
- public boolean writeValue(byte[] argValue, boolean withResponse) throws BluetoothException;
+ public boolean writeValue(byte[] argValue, boolean withResponse) throws BTException;
/* D-Bus property accessors: */
@@ -261,7 +261,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
/** Returns the service to which this characteristic belongs to.
* @return The service.
*/
- public BluetoothGattService getService();
+ public BTGattService getService();
/** Returns the cached value of this characteristic, if any.
* @return The cached value of this characteristic.
@@ -293,5 +293,5 @@ public interface BluetoothGattCharacteristic extends BluetoothObject
* @return A list of BluetoothGattDescriptors exposed by this characteristic
* NULL if an error occurred
*/
- public List<BluetoothGattDescriptor> getDescriptors();
+ public List<BTGattDesc> getDescriptors();
}
diff --git a/java/org/direct_bt/GATTCharacteristicListener.java b/java/org/direct_bt/BTGattCharListener.java
index fad76d51..f95e0166 100644
--- a/java/org/direct_bt/GATTCharacteristicListener.java
+++ b/java/org/direct_bt/BTGattCharListener.java
@@ -28,25 +28,25 @@ package org.direct_bt;
import java.lang.ref.WeakReference;
/**
- * {@link BluetoothGattCharacteristic} event listener for notification and indication events.
+ * {@link BTGattChar} event listener for notification and indication events.
* <p>
- * A listener instance may be attached to a {@link BluetoothGattCharacteristic} via
- * {@link BluetoothGattCharacteristic#addCharacteristicListener(GATTCharacteristicListener)} to listen to its events.
+ * A listener instance may be attached to a {@link BTGattChar} via
+ * {@link BTGattChar#addCharacteristicListener(BTGattCharListener)} to listen to its events.
* </p>
* <p>
- * A listener instance may be attached to a {@link BluetoothDevice} via
- * {@link BluetoothDevice#addCharacteristicListener(GATTCharacteristicListener, BluetoothGattCharacteristic)}
+ * A listener instance may be attached to a {@link BTDevice} via
+ * {@link BTDevice#addCharacteristicListener(BTGattCharListener, BTGattChar)}
* to listen to all events of the device or the matching filtered events.
* </p>
* <p>
- * One {@link GATTCharacteristicListener} instance can only be attached to a listener receiver once at a time,
- * i.e. you cannot attach the same instance more than once to a {@link BluetoothDevice}
- * or {@link BluetoothGattCharacteristic}.
+ * One {@link BTGattCharListener} instance can only be attached to a listener receiver once at a time,
+ * i.e. you cannot attach the same instance more than once to a {@link BTDevice}
+ * or {@link BTGattChar}.
* <br>
* To attach multiple listener, one instance per attachment must be created.
* <br>
* This restriction is due to implementation semantics of strictly associating
- * one Java {@link GATTCharacteristicListener} instance to one C++ {@code GATTCharacteristicListener} instance.
+ * one Java {@link BTGattCharListener} instance to one C++ {@code GATTCharacteristicListener} instance.
* The latter will be added to the native list of listeners.
* This class's {@code nativeInstance} field links the Java instance to mentioned C++ listener.
* <br>
@@ -54,61 +54,61 @@ import java.lang.ref.WeakReference;
* this restriction is more esoteric.
* </p>
*/
-public abstract class GATTCharacteristicListener {
+public abstract class BTGattCharListener {
@SuppressWarnings("unused")
private long nativeInstance;
- private final WeakReference<BluetoothGattCharacteristic> associatedCharacteristic;
+ private final WeakReference<BTGattChar> associatedChar;
/**
- * Returns the weakly associated {@link BluetoothGattCharacteristic} to this listener instance.
+ * Returns the weakly associated {@link BTGattChar} to this listener instance.
* <p>
* Returns {@code null} if no association has been made
- * or if the associated {@link BluetoothGattCharacteristic} has been garbage collected.
+ * or if the associated {@link BTGattChar} has been garbage collected.
* </p>
*/
- public final BluetoothGattCharacteristic getAssociatedCharacteristic() {
- return null != associatedCharacteristic ? associatedCharacteristic.get() : null;
+ public final BTGattChar getAssociatedChar() {
+ return null != associatedChar ? associatedChar.get() : null;
}
/**
- * @param associatedCharacteristic weakly associates this listener instance to one {@link BluetoothGattCharacteristic},
+ * @param associatedCharacteristic weakly associates this listener instance to one {@link BTGattChar},
* may be {@code null} for no association.
- * @see #getAssociatedCharacteristic()
+ * @see #getAssociatedChar()
*/
- public GATTCharacteristicListener(final BluetoothGattCharacteristic associatedCharacteristic) {
+ public BTGattCharListener(final BTGattChar associatedCharacteristic) {
if( null != associatedCharacteristic ) {
- this.associatedCharacteristic = new WeakReference<BluetoothGattCharacteristic>(associatedCharacteristic);
+ this.associatedChar = new WeakReference<BTGattChar>(associatedCharacteristic);
} else {
- this.associatedCharacteristic = null;
+ this.associatedChar = null;
}
}
/**
* Called from native BLE stack, initiated by a received notification associated
- * with the given {@link BluetoothGattCharacteristic}.
- * @param charDecl {@link BluetoothGattCharacteristic} related to this notification
+ * with the given {@link BTGattChar}.
+ * @param charDecl {@link BTGattChar} related to this notification
* @param value the notification value
- * @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#currentTimeMillis()}
+ * @param timestamp the indication monotonic timestamp, see {@link BTUtils#currentTimeMillis()}
*/
- public void notificationReceived(final BluetoothGattCharacteristic charDecl,
+ public void notificationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp) {
}
/**
* Called from native BLE stack, initiated by a received indication associated
- * with the given {@link BluetoothGattCharacteristic}.
- * @param charDecl {@link BluetoothGattCharacteristic} related to this indication
+ * with the given {@link BTGattChar}.
+ * @param charDecl {@link BTGattChar} related to this indication
* @param value the indication value
- * @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#currentTimeMillis()}
+ * @param timestamp the indication monotonic timestamp, see {@link BTUtils#currentTimeMillis()}
* @param confirmationSent if true, the native stack has sent the confirmation, otherwise user is required to do so.
*/
- public void indicationReceived(final BluetoothGattCharacteristic charDecl,
+ public void indicationReceived(final BTGattChar charDecl,
final byte[] value, final long timestamp,
final boolean confirmationSent) {
}
public String toString() {
- final BluetoothGattCharacteristic c = getAssociatedCharacteristic();
+ final BTGattChar c = getAssociatedChar();
final String cs = null != c ? c.toString() : "null";
return "GATTCharacteristicListener[associated "+cs+"]";
}
diff --git a/java/org/direct_bt/BluetoothGattDescriptor.java b/java/org/direct_bt/BTGattDesc.java
index b09f58c0..68db424a 100644
--- a/java/org/direct_bt/BluetoothGattDescriptor.java
+++ b/java/org/direct_bt/BTGattDesc.java
@@ -32,10 +32,10 @@ package org.direct_bt;
* Provides access to Bluetooth GATT descriptor. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
*/
-public interface BluetoothGattDescriptor extends BluetoothObject
+public interface BTGattDesc extends BTObject
{
@Override
- public BluetoothGattDescriptor clone();
+ public BTGattDesc clone();
/* D-Bus method calls: */
@@ -49,7 +49,7 @@ public interface BluetoothGattDescriptor extends BluetoothObject
* to be written packed in a GBytes struct
* @return TRUE if value was written succesfully
*/
- public boolean writeValue(byte[] argValue) throws BluetoothException;
+ public boolean writeValue(byte[] argValue) throws BTException;
/**
* Enables notifications for the value and calls run function of the BluetoothNotification
@@ -58,7 +58,7 @@ public interface BluetoothGattDescriptor extends BluetoothObject
* when a notification is issued. The run function will deliver the new value of the value
* property.
*/
- public void enableValueNotifications(BluetoothNotification<byte[]> callback);
+ public void enableValueNotifications(BTNotification<byte[]> callback);
/**
* Disables notifications of the value and unregisters the callback object
* passed through the corresponding enable method.
@@ -75,7 +75,7 @@ public interface BluetoothGattDescriptor extends BluetoothObject
/** Returns the characteristic to which this descriptor belongs to.
* @return The characteristic.
*/
- public BluetoothGattCharacteristic getCharacteristic();
+ public BTGattChar getCharacteristic();
/** Returns the cached value of this descriptor, if any.
* @return The cached value of this descriptor.
diff --git a/java/org/direct_bt/BluetoothGattService.java b/java/org/direct_bt/BTGattService.java
index 35d4fe9c..898fd959 100644
--- a/java/org/direct_bt/BluetoothGattService.java
+++ b/java/org/direct_bt/BTGattService.java
@@ -35,10 +35,10 @@ import java.util.List;
* Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API
* available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
*/
-public interface BluetoothGattService extends BluetoothObject
+public interface BTGattService extends BTObject
{
@Override
- public BluetoothGattService clone();
+ public BTGattService clone();
/** Find a BluetoothGattCharacteristic. If parameter UUID is not null,
* the returned object will have to match it.
@@ -51,7 +51,7 @@ public interface BluetoothGattService extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattCharacteristic find(String UUID, long timeoutMS);
+ public BTGattChar find(String UUID, long timeoutMS);
/** Find a BluetoothGattCharacteristic. If parameter UUID is not null,
* the returned object will have to match it.
@@ -62,7 +62,7 @@ public interface BluetoothGattService extends BluetoothObject
* @return An object matching the UUID or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothGattCharacteristic find(String UUID);
+ public BTGattChar find(String UUID);
/* D-Bus property accessors: */
@@ -74,45 +74,45 @@ public interface BluetoothGattService extends BluetoothObject
/** Returns the device to which this service belongs to.
* @return The device.
*/
- public BluetoothDevice getDevice();
+ public BTDevice getDevice();
/** Returns true if this service is a primary service, false if secondary.
* @return true if this service is a primary service, false if secondary.
*/
public boolean getPrimary();
- /** Returns a list of BluetoothGattCharacteristics this service exposes.
- * @return A list of BluetoothGattCharacteristics exposed by this service
+ /** Returns a list of BTGattChar this service exposes.
+ * @return A list of BTGattChar exposed by this service
*/
- public List<BluetoothGattCharacteristic> getCharacteristics();
+ public List<BTGattChar> getChars();
/**
- * Adds the given {@link GATTCharacteristicListener} to the {@link BluetoothDevice}
- * and {@link BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[])} for all {@link BluetoothGattCharacteristic} instances.
- * @param listener {@link GATTCharacteristicListener} to add to the {@link BluetoothDevice}.
- * It is important to have hte listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic() associated characteristic} == null,
+ * Adds the given {@link BTGattCharListener} to the {@link BTDevice}
+ * and {@link BTGattChar#enableNotificationOrIndication(boolean[])} for all {@link BTGattChar} instances.
+ * @param listener {@link BTGattCharListener} to add to the {@link BTDevice}.
+ * It is important to have hte listener's {@link BTGattCharListener#getAssociatedChar() associated characteristic} == null,
* otherwise the listener can't be used for all characteristics.
* @return true if successful, otherwise false
- * @throws IllegalArgumentException if listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic() associated characteristic}
+ * @throws IllegalArgumentException if listener's {@link BTGattCharListener#getAssociatedChar() associated characteristic}
* is not null.
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
- * @see BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[])
- * @see BluetoothDevice#addCharacteristicListener(GATTCharacteristicListener, BluetoothGattCharacteristic)
+ * @see BTGattChar#enableNotificationOrIndication(boolean[])
+ * @see BTDevice#addCharacteristicListener(BTGattCharListener, BTGattChar)
*/
- public static boolean addCharacteristicListenerToAll(final BluetoothDevice device, final List<BluetoothGattService> services,
- final GATTCharacteristicListener listener) {
+ public static boolean addCharListenerToAll(final BTDevice device, final List<BTGattService> services,
+ final BTGattCharListener listener) {
if( null == listener ) {
throw new IllegalArgumentException("listener argument null");
}
- if( null != listener.getAssociatedCharacteristic() ) {
+ if( null != listener.getAssociatedChar() ) {
throw new IllegalArgumentException("listener's associated characteristic is not null");
}
- final boolean res = device.addCharacteristicListener(listener);
- for(final Iterator<BluetoothGattService> is = services.iterator(); is.hasNext(); ) {
- final BluetoothGattService s = is.next();
- final List<BluetoothGattCharacteristic> characteristics = s.getCharacteristics();
- for(final Iterator<BluetoothGattCharacteristic> ic = characteristics.iterator(); ic.hasNext(); ) {
+ final boolean res = device.addCharListener(listener);
+ for(final Iterator<BTGattService> is = services.iterator(); is.hasNext(); ) {
+ final BTGattService s = is.next();
+ final List<BTGattChar> characteristics = s.getChars();
+ for(final Iterator<BTGattChar> ic = characteristics.iterator(); ic.hasNext(); ) {
ic.next().enableNotificationOrIndication(new boolean[2]);
}
}
@@ -120,42 +120,42 @@ public interface BluetoothGattService extends BluetoothObject
}
/**
- * Removes the given {@link GATTCharacteristicListener} from the {@link BluetoothDevice}.
- * @param listener {@link GATTCharacteristicListener} to remove from the {@link BluetoothDevice}.
+ * Removes the given {@link BTGattCharListener} from the {@link BTDevice}.
+ * @param listener {@link BTGattCharListener} to remove from the {@link BTDevice}.
* @return true if successful, otherwise false
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
- * @see BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[])
- * @see BluetoothDevice#removeCharacteristicListener(GATTCharacteristicListener)
+ * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[])
+ * @see BTDevice#removeCharacteristicListener(BTGattCharListener)
*/
- public static boolean removeCharacteristicListenerFromAll(final BluetoothDevice device, final List<BluetoothGattService> services,
- final GATTCharacteristicListener listener) {
- for(final Iterator<BluetoothGattService> is = services.iterator(); is.hasNext(); ) {
- final BluetoothGattService s = is.next();
- final List<BluetoothGattCharacteristic> characteristics = s.getCharacteristics();
- for(final Iterator<BluetoothGattCharacteristic> ic = characteristics.iterator(); ic.hasNext(); ) {
+ public static boolean removeCharListenerFromAll(final BTDevice device, final List<BTGattService> services,
+ final BTGattCharListener listener) {
+ for(final Iterator<BTGattService> is = services.iterator(); is.hasNext(); ) {
+ final BTGattService s = is.next();
+ final List<BTGattChar> characteristics = s.getChars();
+ for(final Iterator<BTGattChar> ic = characteristics.iterator(); ic.hasNext(); ) {
ic.next().configNotificationIndication(false /* enableNotification */, false /* enableIndication */, new boolean[2]);
}
}
- return device.removeCharacteristicListener(listener);
+ return device.removeCharListener(listener);
}
/**
- * Removes all {@link GATTCharacteristicListener} from the {@link BluetoothDevice}.
- * @return count of removed {@link GATTCharacteristicListener}
+ * Removes all {@link BTGattCharListener} from the {@link BTDevice}.
+ * @return count of removed {@link BTGattCharListener}
* @since 2.0.0
* @implNote not implemented in tinyb.dbus
- * @see BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[])
- * @see BluetoothDevice#removeAllCharacteristicListener()
+ * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[])
+ * @see BTDevice#removeAllCharacteristicListener()
*/
- public static int removeAllCharacteristicListener(final BluetoothDevice device, final List<BluetoothGattService> services) {
- for(final Iterator<BluetoothGattService> is = services.iterator(); is.hasNext(); ) {
- final BluetoothGattService s = is.next();
- final List<BluetoothGattCharacteristic> characteristics = s.getCharacteristics();
- for(final Iterator<BluetoothGattCharacteristic> ic = characteristics.iterator(); ic.hasNext(); ) {
+ public static int removeAllCharListener(final BTDevice device, final List<BTGattService> services) {
+ for(final Iterator<BTGattService> is = services.iterator(); is.hasNext(); ) {
+ final BTGattService s = is.next();
+ final List<BTGattChar> characteristics = s.getChars();
+ for(final Iterator<BTGattChar> ic = characteristics.iterator(); ic.hasNext(); ) {
ic.next().configNotificationIndication(false /* enableNotification */, false /* enableIndication */, new boolean[2]);
}
}
- return device.removeAllCharacteristicListener();
+ return device.removeAllCharListener();
}
}
diff --git a/java/org/direct_bt/BluetoothManager.java b/java/org/direct_bt/BTManager.java
index 2c80a7e6..c770d6cf 100644
--- a/java/org/direct_bt/BluetoothManager.java
+++ b/java/org/direct_bt/BTManager.java
@@ -30,7 +30,7 @@ package org.direct_bt;
import java.util.List;
-public interface BluetoothManager
+public interface BTManager
{
/**
* Interface allowing to retrieve certain settings
@@ -52,15 +52,15 @@ public interface BluetoothManager
boolean isTinyB();
/**
- * Returns whether {@link BluetoothGattCharacteristic} API: {@link BluetoothGattCharacteristic#getValue() value cache} and
- * {@link BluetoothGattCharacteristic#enableValueNotifications(BluetoothNotification) value notification}
+ * Returns whether {@link BTGattChar} API: {@link BTGattChar#getValue() value cache} and
+ * {@link BTGattChar#enableValueNotifications(BluetoothNotification) value notification}
* is supported.
* <p>
* This is enabled using {@link #isTinyB() TinyB}, but disabled by default using {@link #isDirectBT() Direct-BT}.
* </p>
* <p>
* If using {@link #isDirectBT() Direct-BT}, user are encouraged to
- * {@link BluetoothGattCharacteristic#addCharacteristicListener(GATTCharacteristicListener, boolean[]) utilize GATTCharacteristicListener}
+ * {@link BTGattChar#addCharacteristicListener(GATTCharacteristicListener, boolean[]) utilize GATTCharacteristicListener}
* to handle value notifications when they occur w/o caching.
* </p>
* <p>
@@ -77,8 +77,8 @@ public interface BluetoothManager
/**
- * Event listener to receive change events regarding the system's {@link BluetoothAdapter} set,
- * e.g. a removed or added {@link BluetoothAdapter} due to user interaction or 'cold reset'.
+ * Event listener to receive change events regarding the system's {@link BTAdapter} set,
+ * e.g. a removed or added {@link BTAdapter} due to user interaction or 'cold reset'.
* <p>
* When a new callback is added, all available adapter's will be reported as added,
* this allows a fully event driven workflow.
@@ -89,25 +89,25 @@ public interface BluetoothManager
* </p>
* @since 2.0.0
* @implNote Not implemented on tinyb.dbus
- * @see BluetoothManager#addChangedAdapterSetListener(ChangedAdapterSetListener)
- * @see BluetoothManager#removeChangedAdapterSetListener(ChangedAdapterSetListener)
+ * @see BTManager#addChangedAdapterSetListener(ChangedAdapterSetListener)
+ * @see BTManager#removeChangedAdapterSetListener(ChangedAdapterSetListener)
*/
public static interface ChangedAdapterSetListener {
/**
- * {@link BluetoothAdapter} was added to the system.
- * @param adapter the newly added {@link BluetoothAdapter} to the system
+ * {@link BTAdapter} was added to the system.
+ * @param adapter the newly added {@link BTAdapter} to the system
*/
- void adapterAdded(final BluetoothAdapter adapter);
+ void adapterAdded(final BTAdapter adapter);
/**
- * {@link BluetoothAdapter} was removed from the system.
+ * {@link BTAdapter} was removed from the system.
* <p>
- * {@link BluetoothAdapter#close()} is being called by the native manager after issuing all
- * {@link #adapterRemoved(BluetoothAdapter)} calls.
+ * {@link BTAdapter#close()} is being called by the native manager after issuing all
+ * {@link #adapterRemoved(BTAdapter)} calls.
* </p>
- * @param adapter the removed {@link BluetoothAdapter} from the system
+ * @param adapter the removed {@link BTAdapter} from the system
*/
- void adapterRemoved(final BluetoothAdapter adapter);
+ void adapterRemoved(final BTAdapter adapter);
}
/**
@@ -134,7 +134,7 @@ public interface BluetoothManager
* @return An object matching the name, identifier, parent or null if not found before
* timeout expires or event is canceled.
*/
- public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent, long timeoutMS);
+ public BTObject find(BTType type, String name, String identifier, BTObject parent, long timeoutMS);
/** Find a BluetoothObject of a type matching type. If parameters name,
@@ -153,7 +153,7 @@ public interface BluetoothManager
* waiting for
* @return An object matching the name, identifier and parent.
*/
- public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent);
+ public BTObject find(BTType type, String name, String identifier, BTObject parent);
/** Find a BluetoothObject of type T. If parameters name, identifier and
* parent are not null, the returned object will have to match them.
@@ -171,7 +171,7 @@ public interface BluetoothManager
* @return An object matching the name, identifier, parent or null if not found before
* timeout expires or event is canceled.
*/
- public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent, long timeoutMS);
+ public <T extends BTObject> T find(String name, String identifier, BTObject parent, long timeoutMS);
/** Find a BluetoothObject of type T. If parameters name, identifier and
* parent are not null, the returned object will have to match them.
@@ -186,7 +186,7 @@ public interface BluetoothManager
* waiting for
* @return An object matching the name, identifier and parent.
*/
- public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent);
+ public <T extends BTObject> T find(String name, String identifier, BTObject parent);
/** Return a BluetoothObject of a type matching type. If parameters name,
* identifier and parent are not null, the returned object will have to
@@ -202,8 +202,8 @@ public interface BluetoothManager
* waiting for
* @return An object matching the name, identifier, parent or null if not found.
*/
- public BluetoothObject getObject(BluetoothType type, String name,
- String identifier, BluetoothObject parent);
+ public BTObject getObject(BTType type, String name,
+ String identifier, BTObject parent);
/** Return a List of BluetoothObject of a type matching type. If parameters name,
* identifier and parent are not null, the returned object will have to
@@ -219,13 +219,13 @@ public interface BluetoothManager
* waiting for
* @return A vector of object matching the name, identifier, parent.
*/
- public List<BluetoothObject> getObjects(BluetoothType type, String name,
- String identifier, BluetoothObject parent);
+ public List<BTObject> getObjects(BTType type, String name,
+ String identifier, BTObject parent);
/** Returns a list of BluetoothAdapters available in the system
* @return A list of BluetoothAdapters available in the system
*/
- public List<BluetoothAdapter> getAdapters();
+ public List<BTAdapter> getAdapters();
/**
* Returns the BluetoothAdapter matching the given dev_id or null if not found.
@@ -237,29 +237,29 @@ public interface BluetoothManager
* @since 2.0.0
* @implNote Not implemented on tinyb.dbus
*/
- public BluetoothAdapter getAdapter(final int dev_id);
+ public BTAdapter getAdapter(final int dev_id);
/** Returns a list of discovered BluetoothDevices
* @return A list of discovered BluetoothDevices
*/
- public List<BluetoothDevice> getDevices();
+ public List<BTDevice> getDevices();
/** Returns a list of available BluetoothGattServices
* @return A list of available BluetoothGattServices
*/
- public List<BluetoothGattService> getServices();
+ public List<BTGattService> getServices();
/**
* Sets a default adapter to use for discovery.
* @return TRUE if the device was set
* @implNote not implemented for direct_bt.tinyb
*/
- public boolean setDefaultAdapter(BluetoothAdapter adapter);
+ public boolean setDefaultAdapter(BTAdapter adapter);
/**
* Gets the default adapter to use for discovery.
* <p>
- * <i>direct_bt.tinyb</i>: The default adapter is either the first {@link BluetoothAdapter#isPowered() powered} {@link BluetoothAdapter},
+ * <i>direct_bt.tinyb</i>: The default adapter is either the first {@link BTAdapter#isPowered() powered} {@link BTAdapter},
* or function returns nullptr if none is enabled.
* </p>
* <p>
@@ -267,14 +267,14 @@ public interface BluetoothManager
* </p>
* @return the used default adapter
*/
- public BluetoothAdapter getDefaultAdapter();
+ public BTAdapter getDefaultAdapter();
/** Turns on device discovery on the default adapter if it is disabled.
* @return TRUE if discovery was successfully enabled
* @deprecated since 2.0.0, use {@link #startDiscovery(boolean)}.
*/
@Deprecated
- public boolean startDiscovery() throws BluetoothException;
+ public boolean startDiscovery() throws BTException;
/**
* Turns on device discovery on the default adapter if it is disabled.
@@ -284,11 +284,11 @@ public interface BluetoothManager
* and {@link #stopDiscovery()} is the recommended workflow
* for a reliable discovery process.
* @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state
- * @throws BluetoothException
+ * @throws BTException
* @since 2.0.0
* @implNote {@code keepAlive} not implemented in tinyb.dbus
*/
- public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException;
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException;
/**
* Turns off device discovery on the default adapter if it is enabled.
@@ -296,12 +296,12 @@ public interface BluetoothManager
* @apiNote return {@link HCIStatusCode} since 2.0.0
* @since 2.0.0
*/
- public HCIStatusCode stopDiscovery() throws BluetoothException;
+ public HCIStatusCode stopDiscovery() throws BTException;
/** Returns if the discovers is running or not.
* @return TRUE if discovery is running
*/
- public boolean getDiscovering() throws BluetoothException;
+ public boolean getDiscovering() throws BTException;
/**
* Add the given {@link ChangedAdapterSetListener} to this manager.
diff --git a/java/org/direct_bt/BluetoothNotification.java b/java/org/direct_bt/BTNotification.java
index 01e145bb..961008f7 100644
--- a/java/org/direct_bt/BluetoothNotification.java
+++ b/java/org/direct_bt/BTNotification.java
@@ -30,6 +30,6 @@ package org.direct_bt;
* to the enable*Notifications function. When a notification of that type is received,
* the run function of the class will be called.
*/
-public interface BluetoothNotification<T> {
+public interface BTNotification<T> {
public void run(T value);
}
diff --git a/java/org/direct_bt/BluetoothObject.java b/java/org/direct_bt/BTObject.java
index df90df4a..05821e48 100644
--- a/java/org/direct_bt/BluetoothObject.java
+++ b/java/org/direct_bt/BTObject.java
@@ -27,17 +27,17 @@
*/
package org.direct_bt;
-public interface BluetoothObject extends Cloneable, AutoCloseable
+public interface BTObject extends Cloneable, AutoCloseable
{
/** Returns the BluetoothType of this object
* @return The BluetoothType of this object
*/
- public BluetoothType getBluetoothType();
+ public BTType getBluetoothType();
/** Returns a clone of the BluetoothObject
* @return A clone of the BluetoothObject
*/
- public BluetoothObject clone();
+ public BTObject clone();
@Override
public boolean equals(Object obj);
diff --git a/java/org/direct_bt/BluetoothType.java b/java/org/direct_bt/BTType.java
index ef62d803..07817897 100644
--- a/java/org/direct_bt/BluetoothType.java
+++ b/java/org/direct_bt/BTType.java
@@ -24,7 +24,7 @@
package org.direct_bt;
-public enum BluetoothType
+public enum BTType
{
NONE, ADAPTER, DEVICE,
GATT_SERVICE, GATT_CHARACTERISTIC,
diff --git a/java/org/direct_bt/BluetoothUtils.java b/java/org/direct_bt/BTUtils.java
index 99ded5a9..e2266856 100644
--- a/java/org/direct_bt/BluetoothUtils.java
+++ b/java/org/direct_bt/BTUtils.java
@@ -24,7 +24,7 @@
*/
package org.direct_bt;
-public class BluetoothUtils {
+public class BTUtils {
private static long t0;
static {
t0 = startupTimeMillisImpl();
@@ -62,8 +62,8 @@ public class BluetoothUtils {
* @param min_result_ms the minimum resulting supervisor timeout, defaults to 500ms.
* If above formula results in a smaller value, min_result_ms/10 will be returned.
* @param multiplier recommendation is 6, we use 10 as default for safety.
- * @return the resulting supervising timeout in 1/10 [ms], suitable for the {@link BluetoothDevice#connectLE(short, short, short, short, short, short)}.
- * @see BluetoothDevice#connectLE(short, short, short, short, short, short)
+ * @return the resulting supervising timeout in 1/10 [ms], suitable for the {@link BTDevice#connectLE(short, short, short, short, short, short)}.
+ * @see BTDevice#connectLE(short, short, short, short, short, short)
*/
public static int getHCIConnSupervisorTimeout(final int conn_latency, final int conn_interval_max_ms,
final int min_result_ms, final int multiplier) {
diff --git a/java/org/direct_bt/EUI48.java b/java/org/direct_bt/EUI48.java
index 1d9c2618..2d4b2756 100644
--- a/java/org/direct_bt/EUI48.java
+++ b/java/org/direct_bt/EUI48.java
@@ -241,7 +241,7 @@ public class EUI48 {
public final String toString() {
final StringBuilder sb = new StringBuilder(17);
for(int i=byte_size-1; 0 <= i; i--) {
- BluetoothUtils.byteHexString(sb, b[i], false /* lowerCase */);
+ BTUtils.byteHexString(sb, b[i], false /* lowerCase */);
if( 0 < i ) {
sb.append(":");
}
diff --git a/java/org/direct_bt/ObjectArgCallback.java b/java/org/direct_bt/ObjectArgCallback.java
index a2f22f48..36430f8a 100644
--- a/java/org/direct_bt/ObjectArgCallback.java
+++ b/java/org/direct_bt/ObjectArgCallback.java
@@ -26,7 +26,7 @@ package org.direct_bt;
import tinyb.dbus.DBusObject;
-public class ObjectArgCallback extends BluetoothCallback
+public class ObjectArgCallback extends BTCallback
{
@SuppressWarnings("unused")
private final Object callbackArg;
diff --git a/java/org/direct_bt/ObjectArrayArgCallback.java b/java/org/direct_bt/ObjectArrayArgCallback.java
index 59d2d72e..8fb196b4 100644
--- a/java/org/direct_bt/ObjectArrayArgCallback.java
+++ b/java/org/direct_bt/ObjectArrayArgCallback.java
@@ -26,7 +26,7 @@ package org.direct_bt;
import tinyb.dbus.DBusObject;
-public class ObjectArrayArgCallback extends BluetoothCallback
+public class ObjectArrayArgCallback extends BTCallback
{
@SuppressWarnings("unused")
private final Object[] callbackArg;
diff --git a/java/org/direct_bt/PlatformToolkit.java b/java/org/direct_bt/PlatformToolkit.java
index decee20c..480200e3 100644
--- a/java/org/direct_bt/PlatformToolkit.java
+++ b/java/org/direct_bt/PlatformToolkit.java
@@ -279,7 +279,7 @@ final class PlatformToolkit {
final String _os_arch2 = getArchName(CPU_TYPE, ABI_TYPE, LITTLE_ENDIAN);
os_arch = null != _os_arch2 ? _os_arch2 : _os_arch1;
os_and_arch = os_name+"-"+os_arch;
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println("PlatformToolkit: os_name "+os_name+", os_arch ("+_os_arch1+" -> "+_os_arch2+" ->) "+os_arch+" (final), "+
"CPU_TYPE "+CPU_TYPE+", ABI_TYPE "+ABI_TYPE+", LITTLE_ENDIAN "+LITTLE_ENDIAN);
}
@@ -458,7 +458,7 @@ final class PlatformToolkit {
// f.getCanonicalPath() also resolved '.', '..' and symbolic links in contrast to f.getAbsolutePath()
return f.getCanonicalPath();
} catch (final Throwable t) {
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println("getAbsolutePath("+path+") failed: "+t.getMessage());
}
return null;
@@ -471,7 +471,7 @@ final class PlatformToolkit {
final String abspath = getCanonicalPath(fullpath);
if( null != abspath ) {
final boolean isDup = paths.contains(abspath);
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println(" "+abspath+" (addPath "+msg+", dropped duplicate "+isDup+")");
}
if( !isDup ) {
@@ -542,12 +542,12 @@ final class PlatformToolkit {
* @return {@code true} if successful, otherwise {@code false}.
*/
static boolean loadLibrary(final String libBaseName, final ClassLoader cl, final Throwable[] t) {
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println();
System.err.println("PlatformToolkit.loadLibrary: libBaseName "+libBaseName+":");
}
final List<String> possiblePaths = enumerateLibraryPaths(libBaseName, true /* searchSystemPath */, false /* searchSystemPathFirst */, cl);
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println();
}
@@ -556,12 +556,12 @@ final class PlatformToolkit {
final String path = iter.next();
try {
System.load(path);
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println(" "+path+" success");
}
return true;
} catch (final Throwable t0) {
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println(" "+path+" failed: "+t0.getMessage());
}
t[0] = t0;
@@ -571,12 +571,12 @@ final class PlatformToolkit {
// Fall back to loadLibrary
try {
System.loadLibrary(libBaseName);
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println(" "+libBaseName+" success");
}
return true;
} catch (final Throwable t0) {
- if( BluetoothFactory.DEBUG ) {
+ if( BTFactory.DEBUG ) {
System.err.println(" "+libBaseName+" failed: "+t0.getMessage());
}
t[0] = t0;
diff --git a/java/org/direct_bt/SMPLongTermKeyInfo.java b/java/org/direct_bt/SMPLongTermKeyInfo.java
index ce3e3254..7db7455e 100644
--- a/java/org/direct_bt/SMPLongTermKeyInfo.java
+++ b/java/org/direct_bt/SMPLongTermKeyInfo.java
@@ -208,9 +208,9 @@ public class SMPLongTermKeyInfo {
@Override
public String toString() { // hex-fmt aligned with btmon
return "LTK[props "+properties.toString()+", enc_size "+enc_size+
- ", ediv "+BluetoothUtils.bytesHexString(ediv, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+
- ", rand "+BluetoothUtils.bytesHexString(rand, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+
- ", ltk "+BluetoothUtils.bytesHexString(ltk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+
+ ", ediv "+BTUtils.bytesHexString(ediv, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+
+ ", rand "+BTUtils.bytesHexString(rand, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+
+ ", ltk "+BTUtils.bytesHexString(ltk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+
"]";
}
diff --git a/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java b/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java
index c517741f..89e8428c 100644
--- a/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java
+++ b/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java
@@ -180,7 +180,7 @@ public class SMPSignatureResolvingKeyInfo {
@Override
public String toString() { // hex-fmt aligned with btmon
return "LTK[props "+properties.toString()+
- ", csrk "+BluetoothUtils.bytesHexString(csrk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+
+ ", csrk "+BTUtils.bytesHexString(csrk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+
"]";
}
diff --git a/java/tinyb/dbus/DBusAdapter.java b/java/tinyb/dbus/DBusAdapter.java
index 11a81af4..bf44ebd3 100644
--- a/java/tinyb/dbus/DBusAdapter.java
+++ b/java/tinyb/dbus/DBusAdapter.java
@@ -36,36 +36,36 @@ import java.util.UUID;
import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
import org.direct_bt.EUI48;
import org.direct_bt.HCIStatusCode;
import org.direct_bt.HCIWhitelistConnectType;
import org.direct_bt.ScanType;
import org.direct_bt.TransportType;
-public class DBusAdapter extends DBusObject implements BluetoothAdapter
+public class DBusAdapter extends DBusObject implements BTAdapter
{
@Override
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
@Override
- public native BluetoothAdapter clone();
+ public native BTAdapter clone();
- static BluetoothType class_type() { return BluetoothType.ADAPTER; }
+ static BTType class_type() { return BTType.ADAPTER; }
@Override
- public BluetoothDevice find(final String name, final BDAddressAndType addressAndType, final long timeoutMS) {
- final BluetoothManager manager = DBusManager.getManager();
- return (BluetoothDevice) manager.find(BluetoothType.DEVICE, name, addressAndType.address.toString(), this, timeoutMS);
+ public BTDevice find(final String name, final BDAddressAndType addressAndType, final long timeoutMS) {
+ final BTManager manager = DBusManager.getManager();
+ return (BTDevice) manager.find(BTType.DEVICE, name, addressAndType.address.toString(), this, timeoutMS);
}
@Override
- public BluetoothDevice find(final String name, final BDAddressAndType addressAndType) {
+ public BTDevice find(final String name, final BDAddressAndType addressAndType) {
return find(name, addressAndType, 0);
}
@@ -103,30 +103,30 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
}
@Override
- public final BluetoothManager getManager() { return DBusManager.getManager(); }
+ public final BTManager getManager() { return DBusManager.getManager(); }
/* D-Bus method calls: */
@Override
@Deprecated
- public native boolean startDiscovery() throws BluetoothException;
+ public native boolean startDiscovery() throws BTException;
@Override
- public synchronized HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException {
+ public synchronized HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException {
return startDiscovery() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE; // FIXME keepAlive
}
@Override
- public HCIStatusCode stopDiscovery() throws BluetoothException {
+ public HCIStatusCode stopDiscovery() throws BTException {
return stopDiscoveryImpl() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE;
}
- private native boolean stopDiscoveryImpl() throws BluetoothException;
+ private native boolean stopDiscoveryImpl() throws BTException;
@Override
- public native List<BluetoothDevice> getDiscoveredDevices();
+ public native List<BTDevice> getDiscoveredDevices();
@Override
- public native int removeDiscoveredDevices() throws BluetoothException;
+ public native int removeDiscoveredDevices() throws BTException;
@Override
public boolean removeDiscoveredDevice(final BDAddressAndType addressAndType) {
@@ -160,7 +160,7 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native boolean getPoweredState();
@Override
- public native void enablePoweredNotifications(BluetoothNotification<Boolean> callback);
+ public native void enablePoweredNotifications(BTNotification<Boolean> callback);
@Override
public native void disablePoweredNotifications();
@@ -175,7 +175,7 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native boolean getDiscoverable();
@Override
- public native void enableDiscoverableNotifications(BluetoothNotification<Boolean> callback);
+ public native void enableDiscoverableNotifications(BTNotification<Boolean> callback);
@Override
public native void disableDiscoverableNotifications();
@@ -190,16 +190,16 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native boolean setDiscoverableTimout(long value);
@Override
- public BluetoothDevice connectDevice(final BDAddressAndType addressAndType) {
+ public BTDevice connectDevice(final BDAddressAndType addressAndType) {
return connectDeviceImpl(addressAndType.address.toString(), addressAndType.type.toDbusString());
}
- private native BluetoothDevice connectDeviceImpl(String address, String addressType);
+ private native BTDevice connectDeviceImpl(String address, String addressType);
@Override
public native boolean getPairable();
@Override
- public native void enablePairableNotifications(BluetoothNotification<Boolean> callback);
+ public native void enablePairableNotifications(BTNotification<Boolean> callback);
@Override
public native void disablePairableNotifications();
@@ -221,7 +221,7 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
public native boolean getDiscovering();
@Override
- public boolean addStatusListener(final AdapterStatusListener l, final BluetoothDevice deviceMatch) {
+ public boolean addStatusListener(final AdapterStatusListener l, final BTDevice deviceMatch) {
return false; // FIXME
}
@@ -236,7 +236,7 @@ public class DBusAdapter extends DBusObject implements BluetoothAdapter
}
@Override
- public native void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback);
+ public native void enableDiscoveringNotifications(BTNotification<Boolean> callback);
@Override
public native void disableDiscoveringNotifications();
diff --git a/java/tinyb/dbus/DBusBluetoothException.java b/java/tinyb/dbus/DBusBluetoothException.java
index 03e0233f..b2630dfd 100644
--- a/java/tinyb/dbus/DBusBluetoothException.java
+++ b/java/tinyb/dbus/DBusBluetoothException.java
@@ -28,10 +28,10 @@
package tinyb.dbus;
-import org.direct_bt.BluetoothException;
+import org.direct_bt.BTException;
@SuppressWarnings("serial")
-public class DBusBluetoothException extends BluetoothException {
+public class DBusBluetoothException extends BTException {
DBusBluetoothException(final String msg) {
super(msg);
}
diff --git a/java/tinyb/dbus/DBusDevice.java b/java/tinyb/dbus/DBusDevice.java
index f0f445d8..902efec0 100644
--- a/java/tinyb/dbus/DBusDevice.java
+++ b/java/tinyb/dbus/DBusDevice.java
@@ -33,18 +33,17 @@ import java.util.Map;
import org.direct_bt.BDAddressAndType;
import org.direct_bt.BDAddressType;
-import org.direct_bt.BLERandomAddressType;
import org.direct_bt.BTSecurityLevel;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
-import org.direct_bt.BluetoothUtils;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
+import org.direct_bt.BTUtils;
import org.direct_bt.EUI48;
-import org.direct_bt.GATTCharacteristicListener;
+import org.direct_bt.BTGattCharListener;
import org.direct_bt.HCIStatusCode;
import org.direct_bt.PairingMode;
import org.direct_bt.SMPIOCapability;
@@ -53,7 +52,7 @@ import org.direct_bt.SMPLongTermKeyInfo;
import org.direct_bt.SMPPairingState;
import org.direct_bt.SMPSignatureResolvingKeyInfo;
-public class DBusDevice extends DBusObject implements BluetoothDevice
+public class DBusDevice extends DBusObject implements BTDevice
{
@Override
public final long getCreationTimestamp() { return ts_creation; }
@@ -65,38 +64,38 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public final long getLastUpdateTimestamp() { return ts_creation; } // FIXME
@Override
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
@Override
public native DBusDevice clone();
- static BluetoothType class_type() { return BluetoothType.DEVICE; }
+ static BTType class_type() { return BTType.DEVICE; }
@Override
- public BluetoothGattService find(final String UUID, final long timeoutMS) {
- final BluetoothManager manager = DBusManager.getManager();
- return (BluetoothGattService) manager.find(BluetoothType.GATT_SERVICE,
+ public BTGattService find(final String UUID, final long timeoutMS) {
+ final BTManager manager = DBusManager.getManager();
+ return (BTGattService) manager.find(BTType.GATT_SERVICE,
null, UUID, this, timeoutMS);
}
@Override
- public BluetoothGattService find(final String UUID) {
+ public BTGattService find(final String UUID) {
return find(UUID, 0);
}
/* D-Bus method calls: */
@Override
- public final HCIStatusCode disconnect() throws BluetoothException {
+ public final HCIStatusCode disconnect() throws BTException {
return disconnectImpl() ? HCIStatusCode.SUCCESS : HCIStatusCode.UNSPECIFIED_ERROR ;
}
- private native boolean disconnectImpl() throws BluetoothException;
+ private native boolean disconnectImpl() throws BTException;
@Override
- public final HCIStatusCode connect() throws BluetoothException {
+ public final HCIStatusCode connect() throws BTException {
return connectImpl() ? HCIStatusCode.SUCCESS : HCIStatusCode.UNSPECIFIED_ERROR ;
}
- private native boolean connectImpl() throws BluetoothException;
+ private native boolean connectImpl() throws BTException;
@Override
public HCIStatusCode connectLE(final short interval, final short window,
@@ -106,10 +105,10 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
}
@Override
- public native boolean connectProfile(String arg_UUID) throws BluetoothException;
+ public native boolean connectProfile(String arg_UUID) throws BTException;
@Override
- public native boolean disconnectProfile(String arg_UUID) throws BluetoothException;
+ public native boolean disconnectProfile(String arg_UUID) throws BTException;
@Override
public final SMPKeyMask getAvailableSMPKeys(final boolean responder) { return new SMPKeyMask(); }
@@ -124,7 +123,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public final SMPSignatureResolvingKeyInfo getSignatureResolvingKeyInfo(final boolean responder) { return new SMPSignatureResolvingKeyInfo(); } // FIXME
@Override
- public native boolean pair() throws BluetoothException;
+ public native boolean pair() throws BTException;
@Override
public final HCIStatusCode unpair() { return HCIStatusCode.NOT_SUPPORTED; } // FIXME
@@ -160,13 +159,13 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public SMPPairingState getPairingState() { return SMPPairingState.NONE; }
@Override
- public native boolean remove() throws BluetoothException;
+ public native boolean remove() throws BTException;
@Override
- public native boolean cancelPairing() throws BluetoothException;
+ public native boolean cancelPairing() throws BTException;
@Override
- public native List<BluetoothGattService> getServices();
+ public native List<BTGattService> getServices();
@Override
public boolean pingGATT() { return true; } // FIXME
@@ -201,7 +200,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native boolean getPaired();
@Override
- public native void enablePairedNotifications(BluetoothNotification<Boolean> callback);
+ public native void enablePairedNotifications(BTNotification<Boolean> callback);
@Override
public native void disablePairedNotifications();
@@ -210,7 +209,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native boolean getTrusted();
@Override
- public native void enableTrustedNotifications(BluetoothNotification<Boolean> callback);
+ public native void enableTrustedNotifications(BTNotification<Boolean> callback);
@Override
public native void disableTrustedNotifications();
@@ -222,7 +221,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native boolean getBlocked();
@Override
- public native void enableBlockedNotifications(BluetoothNotification<Boolean> callback);
+ public native void enableBlockedNotifications(BTNotification<Boolean> callback);
@Override
public native void disableBlockedNotifications();
@@ -237,7 +236,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native short getRSSI();
@Override
- public native void enableRSSINotifications(BluetoothNotification<Short> callback);
+ public native void enableRSSINotifications(BTNotification<Short> callback);
@Override
public native void disableRSSINotifications();
@@ -249,7 +248,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public final short getConnectionHandle() { return 0; /* FIXME */ }
@Override
- public native void enableConnectedNotifications(BluetoothNotification<Boolean> callback);
+ public native void enableConnectedNotifications(BTNotification<Boolean> callback);
@Override
public native void disableConnectedNotifications();
@@ -267,7 +266,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native Map<Short, byte[]> getManufacturerData();
@Override
- public native void enableManufacturerDataNotifications(BluetoothNotification<Map<Short, byte[]> > callback);
+ public native void enableManufacturerDataNotifications(BTNotification<Map<Short, byte[]> > callback);
@Override
public native void disableManufacturerDataNotifications();
@@ -277,7 +276,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native Map<String, byte[]> getServiceData();
@Override
- public native void enableServiceDataNotifications(BluetoothNotification<Map<String, byte[]> > callback);
+ public native void enableServiceDataNotifications(BTNotification<Map<String, byte[]> > callback);
@Override
public native void disableServiceDataNotifications();
@@ -289,28 +288,28 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
public native boolean getServicesResolved ();
@Override
- public native void enableServicesResolvedNotifications(BluetoothNotification<Boolean> callback);
+ public native void enableServicesResolvedNotifications(BTNotification<Boolean> callback);
@Override
public native void disableServicesResolvedNotifications();
@Override
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener) {
+ public boolean addCharListener(final BTGattCharListener listener) {
return false; // FIXME
}
@Override
- public boolean removeCharacteristicListener(final GATTCharacteristicListener l) {
+ public boolean removeCharListener(final BTGattCharListener l) {
return false; // FIXME
}
@Override
- public int removeAllAssociatedCharacteristicListener(final BluetoothGattCharacteristic associatedCharacteristic) {
+ public int removeAllAssociatedCharListener(final BTGattChar associatedCharacteristic) {
return 0; // FIXME
}
@Override
- public int removeAllCharacteristicListener() {
+ public int removeAllCharListener() {
return 0; // FIXME
}
@@ -319,7 +318,7 @@ public class DBusDevice extends DBusObject implements BluetoothDevice
private DBusDevice(final long instance)
{
super(instance);
- ts_creation = BluetoothUtils.currentTimeMillis();
+ ts_creation = BTUtils.currentTimeMillis();
}
final long ts_creation;
diff --git a/java/tinyb/dbus/DBusEvent.java b/java/tinyb/dbus/DBusEvent.java
index dc9b8d0c..ddc080bc 100644
--- a/java/tinyb/dbus/DBusEvent.java
+++ b/java/tinyb/dbus/DBusEvent.java
@@ -24,16 +24,16 @@
package tinyb.dbus;
-import org.direct_bt.BluetoothCallback;
-import org.direct_bt.BluetoothEvent;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTCallback;
+import org.direct_bt.BTEvent;
+import org.direct_bt.BTType;
-public class DBusEvent implements BluetoothEvent
+public class DBusEvent implements BTEvent
{
private long nativeInstance;
@Override
- public native BluetoothType getType();
+ public native BTType getType();
@Override
public native String getName();
@Override
@@ -43,12 +43,12 @@ public class DBusEvent implements BluetoothEvent
@Override
public native boolean hasCallback();
- private native void init(BluetoothType type, String name, String identifier,
- DBusObject parent, BluetoothCallback cb, Object data);
+ private native void init(BTType type, String name, String identifier,
+ DBusObject parent, BTCallback cb, Object data);
private native void delete();
- public DBusEvent(final BluetoothType type, final String name, final String identifier,
- final DBusObject parent, final BluetoothCallback cb, final Object data)
+ public DBusEvent(final BTType type, final String name, final String identifier,
+ final DBusObject parent, final BTCallback cb, final Object data)
{
init(type, name, identifier, parent, cb, data);
}
diff --git a/java/tinyb/dbus/DBusGattCharacteristic.java b/java/tinyb/dbus/DBusGattCharacteristic.java
index 702ac886..01d67e15 100644
--- a/java/tinyb/dbus/DBusGattCharacteristic.java
+++ b/java/tinyb/dbus/DBusGattCharacteristic.java
@@ -30,55 +30,55 @@ package tinyb.dbus;
import java.util.List;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
-import org.direct_bt.GATTCharacteristicListener;
-
-public class DBusGattCharacteristic extends DBusObject implements BluetoothGattCharacteristic
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
+import org.direct_bt.BTGattCharListener;
+
+public class DBusGattCharacteristic extends DBusObject implements BTGattChar
{
@Override
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
@Override
public native DBusGattCharacteristic clone();
- static BluetoothType class_type() { return BluetoothType.GATT_CHARACTERISTIC; }
+ static BTType class_type() { return BTType.GATT_CHARACTERISTIC; }
@Override
- public BluetoothGattDescriptor find(final String UUID, final long timeoutMS) {
- final BluetoothManager manager = DBusManager.getManager();
- return (BluetoothGattDescriptor) manager.find(BluetoothType.GATT_DESCRIPTOR,
+ public BTGattDesc find(final String UUID, final long timeoutMS) {
+ final BTManager manager = DBusManager.getManager();
+ return (BTGattDesc) manager.find(BTType.GATT_DESCRIPTOR,
null, UUID, this, timeoutMS);
}
@Override
- public BluetoothGattDescriptor find(final String UUID) {
+ public BTGattDesc find(final String UUID) {
return find(UUID, 0);
}
/* D-Bus method calls: */
@Override
- public native byte[] readValue() throws BluetoothException;
+ public native byte[] readValue() throws BTException;
@Override
- public native void enableValueNotifications(BluetoothNotification<byte[]> callback);
+ public native void enableValueNotifications(BTNotification<byte[]> callback);
@Override
public native void disableValueNotifications();
@Override
- public boolean writeValue(final byte[] argValue, final boolean withResponse) throws BluetoothException {
+ public boolean writeValue(final byte[] argValue, final boolean withResponse) throws BTException {
if( withResponse ) {
throw new DBusBluetoothException("writeValue with response not yet supported");
}
return writeValueImpl(argValue);
}
- private native boolean writeValueImpl(byte[] argValue) throws BluetoothException;
+ private native boolean writeValueImpl(byte[] argValue) throws BTException;
/* D-Bus property accessors: */
@@ -86,7 +86,7 @@ public class DBusGattCharacteristic extends DBusObject implements BluetoothGattC
public native String getUUID();
@Override
- public native BluetoothGattService getService();
+ public native BTGattService getService();
@Override
public native byte[] getValue();
@@ -98,7 +98,7 @@ public class DBusGattCharacteristic extends DBusObject implements BluetoothGattC
public native String[] getFlags();
@Override
- public native List<BluetoothGattDescriptor> getDescriptors();
+ public native List<BTGattDesc> getDescriptors();
private native void init(DBusGattCharacteristic obj);
@@ -110,7 +110,7 @@ public class DBusGattCharacteristic extends DBusObject implements BluetoothGattC
}
@Override
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener) {
+ public boolean addCharacteristicListener(final BTGattCharListener listener) {
return false; // FIXME
}
@Override
@@ -126,13 +126,13 @@ public class DBusGattCharacteristic extends DBusObject implements BluetoothGattC
return false; // FIXME
}
@Override
- public boolean addCharacteristicListener(final GATTCharacteristicListener listener, final boolean[] enabledState)
+ public boolean addCharacteristicListener(final BTGattCharListener listener, final boolean[] enabledState)
throws IllegalStateException
{
return false; // FIXME
}
@Override
- public boolean removeCharacteristicListener(final GATTCharacteristicListener l, final boolean disableIndicationNotification) {
+ public boolean removeCharacteristicListener(final BTGattCharListener l, final boolean disableIndicationNotification) {
return false; // FIXME
}
@Override
diff --git a/java/tinyb/dbus/DBusGattDescriptor.java b/java/tinyb/dbus/DBusGattDescriptor.java
index 03d25cd8..f1741dba 100644
--- a/java/tinyb/dbus/DBusGattDescriptor.java
+++ b/java/tinyb/dbus/DBusGattDescriptor.java
@@ -28,19 +28,19 @@
package tinyb.dbus;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattDescriptor;
-import org.direct_bt.BluetoothNotification;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattDesc;
+import org.direct_bt.BTNotification;
+import org.direct_bt.BTType;
-public class DBusGattDescriptor extends DBusObject implements BluetoothGattDescriptor
+public class DBusGattDescriptor extends DBusObject implements BTGattDesc
{
@Override
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
@Override
- public native BluetoothGattDescriptor clone();
+ public native BTGattDesc clone();
- static BluetoothType class_type() { return BluetoothType.GATT_DESCRIPTOR; }
+ static BTType class_type() { return BTType.GATT_DESCRIPTOR; }
/* D-Bus method calls: */
@@ -48,10 +48,10 @@ public class DBusGattDescriptor extends DBusObject implements BluetoothGattDescr
public native byte[] readValue();
@Override
- public native boolean writeValue(byte[] argValue) throws BluetoothException;
+ public native boolean writeValue(byte[] argValue) throws BTException;
@Override
- public native void enableValueNotifications(BluetoothNotification<byte[]> callback);
+ public native void enableValueNotifications(BTNotification<byte[]> callback);
@Override
public native void disableValueNotifications();
diff --git a/java/tinyb/dbus/DBusGattService.java b/java/tinyb/dbus/DBusGattService.java
index d1c157d8..feb24e65 100644
--- a/java/tinyb/dbus/DBusGattService.java
+++ b/java/tinyb/dbus/DBusGattService.java
@@ -30,30 +30,30 @@ package tinyb.dbus;
import java.util.List;
-import org.direct_bt.BluetoothGattCharacteristic;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTGattChar;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTType;
-public class DBusGattService extends DBusObject implements BluetoothGattService
+public class DBusGattService extends DBusObject implements BTGattService
{
@Override
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
@Override
- public native BluetoothGattService clone();
+ public native BTGattService clone();
- static BluetoothType class_type() { return BluetoothType.GATT_SERVICE; }
+ static BTType class_type() { return BTType.GATT_SERVICE; }
@Override
- public BluetoothGattCharacteristic find(final String UUID, final long timeoutMS) {
- final BluetoothManager manager = DBusManager.getManager();
- return (DBusGattCharacteristic) manager.find(BluetoothType.GATT_CHARACTERISTIC,
+ public BTGattChar find(final String UUID, final long timeoutMS) {
+ final BTManager manager = DBusManager.getManager();
+ return (DBusGattCharacteristic) manager.find(BTType.GATT_CHARACTERISTIC,
null, UUID, this, timeoutMS);
}
@Override
- public BluetoothGattCharacteristic find(final String UUID) {
+ public BTGattChar find(final String UUID) {
return find(UUID, 0);
}
@@ -69,7 +69,7 @@ public class DBusGattService extends DBusObject implements BluetoothGattService
public native boolean getPrimary();
@Override
- public native List<BluetoothGattCharacteristic> getCharacteristics();
+ public native List<BTGattChar> getChars();
private native void delete();
diff --git a/java/tinyb/dbus/DBusManager.java b/java/tinyb/dbus/DBusManager.java
index a32cf875..faade7a1 100644
--- a/java/tinyb/dbus/DBusManager.java
+++ b/java/tinyb/dbus/DBusManager.java
@@ -30,26 +30,26 @@ package tinyb.dbus;
import java.util.List;
-import org.direct_bt.BluetoothAdapter;
-import org.direct_bt.BluetoothDevice;
-import org.direct_bt.BluetoothException;
-import org.direct_bt.BluetoothGattService;
-import org.direct_bt.BluetoothManager;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTAdapter;
+import org.direct_bt.BTDevice;
+import org.direct_bt.BTException;
+import org.direct_bt.BTGattService;
+import org.direct_bt.BTManager;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
import org.direct_bt.HCIStatusCode;
-import org.direct_bt.BluetoothManager.ChangedAdapterSetListener;
+import org.direct_bt.BTManager.ChangedAdapterSetListener;
-public class DBusManager implements BluetoothManager
+public class DBusManager implements BTManager
{
private long nativeInstance;
private final Settings settings;
private native static String getNativeAPIVersion();
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
- private native DBusObject find(int type, String name, String identifier, BluetoothObject parent, long milliseconds);
+ private native DBusObject find(int type, String name, String identifier, BTObject parent, long milliseconds);
@Override
public final Settings getSettings() {
@@ -57,77 +57,77 @@ public class DBusManager implements BluetoothManager
}
@Override
- public DBusObject find(final BluetoothType type, final String name, final String identifier, final BluetoothObject parent, final long timeoutMS) {
+ public DBusObject find(final BTType type, final String name, final String identifier, final BTObject parent, final long timeoutMS) {
return find(type.ordinal(), name, identifier, parent, timeoutMS);
}
@Override
- public DBusObject find(final BluetoothType type, final String name, final String identifier, final BluetoothObject parent) {
+ public DBusObject find(final BTType type, final String name, final String identifier, final BTObject parent) {
return find(type, name, identifier, parent, 0);
}
@SuppressWarnings("unchecked")
@Override
- public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent, final long timeoutMS) {
+ public <T extends BTObject> T find(final String name, final String identifier, final BTObject parent, final long timeoutMS) {
return (T) find(DBusObject.class_type().ordinal(), name, identifier, parent, timeoutMS);
}
@SuppressWarnings("unchecked")
@Override
- public <T extends BluetoothObject> T find(final String name, final String identifier, final BluetoothObject parent) {
+ public <T extends BTObject> T find(final String name, final String identifier, final BTObject parent) {
return (T) find(name, identifier, parent, 0);
}
@Override
- public BluetoothObject getObject(final BluetoothType type, final String name,
- final String identifier, final BluetoothObject parent) {
+ public BTObject getObject(final BTType type, final String name,
+ final String identifier, final BTObject parent) {
return getObject(type.ordinal(), name, identifier, parent);
}
- private native BluetoothObject getObject(int type, String name, String identifier, BluetoothObject parent);
+ private native BTObject getObject(int type, String name, String identifier, BTObject parent);
@Override
- public List<BluetoothObject> getObjects(final BluetoothType type, final String name,
- final String identifier, final BluetoothObject parent) {
+ public List<BTObject> getObjects(final BTType type, final String name,
+ final String identifier, final BTObject parent) {
return getObjects(type.ordinal(), name, identifier, parent);
}
- private native List<BluetoothObject> getObjects(int type, String name, String identifier, BluetoothObject parent);
+ private native List<BTObject> getObjects(int type, String name, String identifier, BTObject parent);
@Override
- public native List<BluetoothAdapter> getAdapters();
+ public native List<BTAdapter> getAdapters();
@Override
- public BluetoothAdapter getAdapter(final int dev_id) { return null; } // FIXME
+ public BTAdapter getAdapter(final int dev_id) { return null; } // FIXME
@Override
- public native List<BluetoothDevice> getDevices();
+ public native List<BTDevice> getDevices();
@Override
- public native List<BluetoothGattService> getServices();
+ public native List<BTGattService> getServices();
@Override
- public native boolean setDefaultAdapter(BluetoothAdapter adapter);
+ public native boolean setDefaultAdapter(BTAdapter adapter);
@Override
- public native BluetoothAdapter getDefaultAdapter();
+ public native BTAdapter getDefaultAdapter();
@Override
- public native boolean startDiscovery() throws BluetoothException;
+ public native boolean startDiscovery() throws BTException;
@Override
- public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException {
+ public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException {
return startDiscovery() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE; // FIXME keepAlive
}
@Override
- public HCIStatusCode stopDiscovery() throws BluetoothException {
+ public HCIStatusCode stopDiscovery() throws BTException {
return stopDiscoveryImpl() ? HCIStatusCode.SUCCESS : HCIStatusCode.INTERNAL_FAILURE;
}
- private native boolean stopDiscoveryImpl() throws BluetoothException;
+ private native boolean stopDiscoveryImpl() throws BTException;
@Override
- public native boolean getDiscovering() throws BluetoothException;
+ public native boolean getDiscovering() throws BTException;
- private native void init() throws BluetoothException;
+ private native void init() throws BTException;
private native void delete();
private DBusManager()
{
@@ -156,7 +156,7 @@ public class DBusManager implements BluetoothManager
/** Returns an instance of BluetoothManager, to be used instead of constructor.
* @return An initialized BluetoothManager instance.
*/
- public static synchronized BluetoothManager getManager() throws RuntimeException, BluetoothException {
+ public static synchronized BTManager getManager() throws RuntimeException, BTException {
return LazySingletonHolder.singleton;
}
/** Initialize-On-Demand Holder Class, similar to C++11's "Magic Statics". */
diff --git a/java/tinyb/dbus/DBusObject.java b/java/tinyb/dbus/DBusObject.java
index 7cb873a8..f28ba858 100644
--- a/java/tinyb/dbus/DBusObject.java
+++ b/java/tinyb/dbus/DBusObject.java
@@ -28,26 +28,26 @@
package tinyb.dbus;
-import org.direct_bt.BluetoothFactory;
-import org.direct_bt.BluetoothObject;
-import org.direct_bt.BluetoothType;
+import org.direct_bt.BTFactory;
+import org.direct_bt.BTObject;
+import org.direct_bt.BTType;
-public class DBusObject implements BluetoothObject
+public class DBusObject implements BTObject
{
protected long nativeInstance;
private boolean isValid;
static {
- BluetoothFactory.checkInitialized();
+ BTFactory.checkInitialized();
}
- static BluetoothType class_type() { return BluetoothType.NONE; }
+ static BTType class_type() { return BTType.NONE; }
@Override
- public native BluetoothType getBluetoothType();
+ public native BTType getBluetoothType();
@Override
- public native BluetoothObject clone();
+ public native BTObject clone();
private native void delete();
private native boolean operatorEqual(DBusObject obj);
diff --git a/scripts/run-java-scanner00.sh b/scripts/run-java-scanner00.sh
index dbfdb94f..dfdf434e 100644
--- a/scripts/run-java-scanner00.sh
+++ b/scripts/run-java-scanner00.sh
@@ -5,7 +5,7 @@
# ../scripts/run-java-scanner00.sh -wait -mac C0:26:DA:01:DA:B1 2>&1 | tee ~/scanner-h01-java00.log
#
-if [ ! -e lib/java/tinyb2.jar -o ! -e bin/java/ScannerTinyB00.jar -o ! -e lib/libdirect_bt.so ] ; then
+if [ ! -e lib/java/direct_bt.jar -o ! -e bin/java/ScannerTinyB00.jar -o ! -e lib/libdirect_bt.so ] ; then
echo run from dist directory
exit 1
fi
@@ -20,4 +20,4 @@ echo COMMANDLINE $0 $*
echo direct_bt_debug $direct_bt_debug
echo direct_bt_verbose $direct_bt_verbose
-java -cp lib/java/tinyb2.jar:bin/java/ScannerTinyB00.jar -Djava.library.path=`pwd`/lib ScannerTinyB00 $*
+java -cp lib/java/direct_bt.jar:bin/java/ScannerTinyB00.jar -Djava.library.path=`pwd`/lib ScannerTinyB00 $*
diff --git a/scripts/run-java-scanner01.sh b/scripts/run-java-scanner01.sh
index 8b8cb872..10cae6b6 100644
--- a/scripts/run-java-scanner01.sh
+++ b/scripts/run-java-scanner01.sh
@@ -4,12 +4,12 @@
#
# ../scripts/run-java-scanner01.sh -wait -mac C0:26:DA:01:DA:B1 -mode 0 2>&1 | tee ~/scanner-h01-java01.log
#
-# gdb --args /usr/bin/java -Djava.library.path=`pwd`/lib -cp lib/java/tinyb2.jar:bin/java/ScannerTinyB01.jar ScannerTinyB01 -mac C0:26:DA:01:DA:B1 -mode 0
+# gdb --args /usr/bin/java -Djava.library.path=`pwd`/lib -cp lib/java/direct_bt.jar:bin/java/ScannerTinyB01.jar ScannerTinyB01 -mac C0:26:DA:01:DA:B1 -mode 0
# > break crash_handler
# > handle SIGSEGV nostop noprint pass
#
-if [ ! -e lib/java/tinyb2.jar -o ! -e bin/java/ScannerTinyB01.jar -o ! -e lib/libdirect_bt.so ] ; then
+if [ ! -e lib/java/direct_bt.jar -o ! -e bin/java/ScannerTinyB01.jar -o ! -e lib/libdirect_bt.so ] ; then
echo run from dist directory
exit 1
fi
@@ -24,4 +24,4 @@ echo COMMANDLINE $0 $*
echo direct_bt_debug $direct_bt_debug
echo direct_bt_verbose $direct_bt_verbose
-java -cp lib/java/tinyb2.jar:bin/java/ScannerTinyB01.jar -Djava.library.path=`pwd`/lib ScannerTinyB01 $*
+java -cp lib/java/direct_bt.jar:bin/java/ScannerTinyB01.jar -Djava.library.path=`pwd`/lib ScannerTinyB01 $*
diff --git a/scripts/run-java-scanner02.sh b/scripts/run-java-scanner02.sh
index 427063ff..e52adc1e 100644
--- a/scripts/run-java-scanner02.sh
+++ b/scripts/run-java-scanner02.sh
@@ -4,12 +4,12 @@
#
# ../scripts/run-java-scanner02.sh -wait -mac C0:26:DA:01:DA:B1 -mode 0 2>&1 | tee ~/scanner-h01-java02.log
#
-# gdb --args /usr/bin/java -Djava.library.path=`pwd`/lib -cp lib/java/tinyb2.jar:bin/java/ScannerTinyB02.jar ScannerTinyB02 -mac C0:26:DA:01:DA:B1 -mode 0
+# gdb --args /usr/bin/java -Djava.library.path=`pwd`/lib -cp lib/java/direct_bt.jar:bin/java/ScannerTinyB02.jar ScannerTinyB02 -mac C0:26:DA:01:DA:B1 -mode 0
# > break crash_handler
# > handle SIGSEGV nostop noprint pass
#
-if [ ! -e lib/java/tinyb2.jar -o ! -e bin/java/ScannerTinyB02.jar -o ! -e lib/libdirect_bt.so ] ; then
+if [ ! -e lib/java/direct_bt.jar -o ! -e bin/java/ScannerTinyB02.jar -o ! -e lib/libdirect_bt.so ] ; then
echo run from dist directory
exit 1
fi
@@ -24,4 +24,4 @@ echo COMMANDLINE $0 $*
echo direct_bt_debug $direct_bt_debug
echo direct_bt_verbose $direct_bt_verbose
-java -cp lib/java/tinyb2.jar:bin/java/ScannerTinyB02.jar -Djava.library.path=`pwd`/lib ScannerTinyB02 $*
+java -cp lib/java/direct_bt.jar:bin/java/ScannerTinyB02.jar -Djava.library.path=`pwd`/lib ScannerTinyB02 $*
diff --git a/scripts/run-java-scanner10.sh b/scripts/run-java-scanner10.sh
index 002dbf4c..cb231de4 100755
--- a/scripts/run-java-scanner10.sh
+++ b/scripts/run-java-scanner10.sh
@@ -31,7 +31,7 @@ sdir=`dirname $(readlink -f $0)`
rootdir=`dirname $sdir`
bname=`basename $0 .sh`
-if [ ! -e lib/java/tinyb2.jar -o ! -e bin/java/DBTScanner10.jar -o ! -e lib/libdirect_bt.so ] ; then
+if [ ! -e lib/java/direct_bt.jar -o ! -e bin/java/DBTScanner10.jar -o ! -e lib/libdirect_bt.so ] ; then
echo run from dist directory
exit 1
fi
@@ -58,8 +58,8 @@ ulimit -c unlimited
export LANG=en_US.UTF-8
export LC_MEASUREMENT=en_US.UTF-8
-# JAVA_CMD="java -Xcheck:jni"
-JAVA_CMD="java"
+JAVA_CMD="java -Xcheck:jni -verbose:jni"
+# JAVA_CMD="java"
# VALGRIND="valgrind --tool=memcheck --leak-check=full --show-reachable=yes --error-limit=no --default-suppressions=yes --suppressions=$sdir/valgrind.supp --gen-suppressions=all -s --log-file=$valgrindlogfile"
# VALGRIND="valgrind --tool=helgrind --track-lockorders=yes --ignore-thread-creation=yes --default-suppressions=yes --suppressions=$sdir/valgrind.supp --gen-suppressions=all -s --log-file=$valgrindlogfile"
@@ -77,11 +77,12 @@ runit() {
echo direct_bt_debug $direct_bt_debug
echo direct_bt_verbose $direct_bt_verbose
- # $VALGRIND $JAVA_CMD -cp lib/java/tinyb2.jar:bin/java/DBTScanner10.jar -Djava.library.path=`pwd`/lib DBTScanner10 $*
+ echo $VALGRIND $JAVA_CMD -cp lib/java/direct_bt.jar:bin/java/DBTScanner10.jar -Djava.library.path=`pwd`/lib DBTScanner10 $*
+ # $VALGRIND $JAVA_CMD -cp lib/java/direct_bt.jar:bin/java/DBTScanner10.jar -Djava.library.path=`pwd`/lib DBTScanner10 $*
sudo /sbin/capsh --caps="cap_net_raw,cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" \
--keep=1 --user=$username --addamb=cap_net_raw,cap_net_admin+eip \
- -- -c "ulimit -c unlimited; $VALGRIND $JAVA_CMD -cp lib/java/tinyb2.jar:bin/java/DBTScanner10.jar -Djava.library.path=`pwd`/lib DBTScanner10 $*"
+ -- -c "ulimit -c unlimited; $VALGRIND $JAVA_CMD -cp lib/java/direct_bt.jar:bin/java/DBTScanner10.jar -Djava.library.path=`pwd`/lib DBTScanner10 $*"
}
diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/BTAdapter.cpp
index 2edbb4bc..2cf9bc03 100644
--- a/src/direct_bt/DBTAdapter.cpp
+++ b/src/direct_bt/BTAdapter.cpp
@@ -23,6 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTAdapter.hpp>
+#include <BTManager.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -39,8 +41,6 @@
#include "HCIIoctl.hpp"
#include "HCIComm.hpp"
-#include "DBTAdapter.hpp"
-#include "DBTManager.hpp"
extern "C" {
#include <inttypes.h>
@@ -50,10 +50,10 @@ extern "C" {
using namespace direct_bt;
-std::shared_ptr<DBTDevice> DBTAdapter::findDevice(device_list_t & devices, const EUI48 & address, const BDAddressType addressType) noexcept {
+std::shared_ptr<BTDevice> BTAdapter::findDevice(device_list_t & devices, const EUI48 & address, const BDAddressType addressType) noexcept {
const jau::nsize_t size = devices.size();
for (jau::nsize_t i = 0; i < size; ++i) {
- std::shared_ptr<DBTDevice> & e = devices[i];
+ std::shared_ptr<BTDevice> & e = devices[i];
if ( nullptr != e && address == e->getAddressAndType().address && addressType == e->getAddressAndType().type) {
return e;
}
@@ -61,10 +61,10 @@ std::shared_ptr<DBTDevice> DBTAdapter::findDevice(device_list_t & devices, const
return nullptr;
}
-std::shared_ptr<DBTDevice> DBTAdapter::findDevice(device_list_t & devices, DBTDevice const & device) noexcept {
+std::shared_ptr<BTDevice> BTAdapter::findDevice(device_list_t & devices, BTDevice const & device) noexcept {
const jau::nsize_t size = devices.size();
for (jau::nsize_t i = 0; i < size; ++i) {
- std::shared_ptr<DBTDevice> & e = devices[i];
+ std::shared_ptr<BTDevice> & e = devices[i];
if ( nullptr != e && device == *e ) {
return e;
}
@@ -72,7 +72,7 @@ std::shared_ptr<DBTDevice> DBTAdapter::findDevice(device_list_t & devices, DBTDe
return nullptr;
}
-bool DBTAdapter::addConnectedDevice(const std::shared_ptr<DBTDevice> & device) noexcept {
+bool BTAdapter::addConnectedDevice(const std::shared_ptr<BTDevice> & device) noexcept {
const std::lock_guard<std::mutex> lock(mtx_connectedDevices); // RAII-style acquire and relinquish via destructor
if( nullptr != findDevice(connectedDevices, *device) ) {
return false;
@@ -81,7 +81,7 @@ bool DBTAdapter::addConnectedDevice(const std::shared_ptr<DBTDevice> & device) n
return true;
}
-bool DBTAdapter::removeConnectedDevice(const DBTDevice & device) noexcept {
+bool BTAdapter::removeConnectedDevice(const BTDevice & device) noexcept {
const std::lock_guard<std::mutex> lock(mtx_connectedDevices); // RAII-style acquire and relinquish via destructor
auto end = connectedDevices.end();
for (auto it = connectedDevices.begin(); it != end; ++it) {
@@ -93,7 +93,7 @@ bool DBTAdapter::removeConnectedDevice(const DBTDevice & device) noexcept {
return false;
}
-int DBTAdapter::disconnectAllDevices(const HCIStatusCode reason) noexcept {
+int BTAdapter::disconnectAllDevices(const HCIStatusCode reason) noexcept {
device_list_t devices;
{
const std::lock_guard<std::mutex> lock(mtx_connectedDevices); // RAII-style acquire and relinquish via destructor
@@ -109,7 +109,7 @@ int DBTAdapter::disconnectAllDevices(const HCIStatusCode reason) noexcept {
return count;
}
-std::shared_ptr<DBTDevice> DBTAdapter::findConnectedDevice (const EUI48 & address, const BDAddressType & addressType) noexcept {
+std::shared_ptr<BTDevice> BTAdapter::findConnectedDevice (const EUI48 & address, const BDAddressType & addressType) noexcept {
const std::lock_guard<std::mutex> lock(mtx_connectedDevices); // RAII-style acquire and relinquish via destructor
return findDevice(connectedDevices, address, addressType);
}
@@ -118,7 +118,7 @@ std::shared_ptr<DBTDevice> DBTAdapter::findConnectedDevice (const EUI48 & addres
// *************************************************
// *************************************************
-bool DBTAdapter::validateDevInfo() noexcept {
+bool BTAdapter::validateDevInfo() noexcept {
bool ok = false;
currentMetaScanType = ScanType::NONE;
keep_le_scan_alive = false;
@@ -156,16 +156,16 @@ bool DBTAdapter::validateDevInfo() noexcept {
WORDY_PRINT("DBTAdapter::validateDevInfo: Adapter[%d]: Not POWERED: %s", dev_id, adapterInfo.toString().c_str());
}
ok = true;
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DISCOVERING, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceDiscoveringMgmt)) && ok;
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::NEW_SETTINGS, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvNewSettingsMgmt)) && ok;
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::LOCAL_NAME_CHANGED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvLocalNameChangedMgmt)) && ok;
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::PIN_CODE_REQUEST, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvPinCodeRequestMgmt));
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::USER_CONFIRM_REQUEST, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvUserConfirmRequestMgmt));
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::USER_PASSKEY_REQUEST, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvUserPasskeyRequestMgmt));
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::AUTH_FAILED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvAuthFailedMgmt));
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_UNPAIRED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceUnpairedMgmt));
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::PAIR_DEVICE_COMPLETE, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvPairDeviceCompleteMgmt));
- ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::NEW_LONG_TERM_KEY, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvNewLongTermKeyMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DISCOVERING, jau::bindMemberFunc(this, &BTAdapter::mgmtEvDeviceDiscoveringMgmt)) && ok;
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::NEW_SETTINGS, jau::bindMemberFunc(this, &BTAdapter::mgmtEvNewSettingsMgmt)) && ok;
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::LOCAL_NAME_CHANGED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvLocalNameChangedMgmt)) && ok;
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::PIN_CODE_REQUEST, jau::bindMemberFunc(this, &BTAdapter::mgmtEvPinCodeRequestMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::USER_CONFIRM_REQUEST, jau::bindMemberFunc(this, &BTAdapter::mgmtEvUserConfirmRequestMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::USER_PASSKEY_REQUEST, jau::bindMemberFunc(this, &BTAdapter::mgmtEvUserPasskeyRequestMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::AUTH_FAILED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvAuthFailedMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_UNPAIRED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvDeviceUnpairedMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::PAIR_DEVICE_COMPLETE, jau::bindMemberFunc(this, &BTAdapter::mgmtEvPairDeviceCompleteMgmt));
+ ok = mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::NEW_LONG_TERM_KEY, jau::bindMemberFunc(this, &BTAdapter::mgmtEvNewLongTermKeyMgmt));
if( !ok ) {
ERR_PRINT("Could not add all required MgmtEventCallbacks to DBTManager: %s", toString().c_str());
@@ -173,23 +173,23 @@ bool DBTAdapter::validateDevInfo() noexcept {
}
#if 0
- mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_DISCONNECTED, bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceDisconnectedMgmt));
+ mgmt.addMgmtEventCallback(dev_id, MgmtEvent::Opcode::DEVICE_DISCONNECTED, bindMemberFunc(this, &BTAdapter::mgmtEvDeviceDisconnectedMgmt));
#endif
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DISCOVERING, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceDiscoveringHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DEVICE_CONNECTED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceConnectedHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::CONNECT_FAILED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvConnectFailedHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DEVICE_DISCONNECTED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceDisconnectedHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DEVICE_FOUND, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvDeviceFoundHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::HCI_LE_REMOTE_USR_FEATURES, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvHCILERemoteUserFeaturesHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::HCI_ENC_CHANGED, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvHCIEncryptionChangedHCI)) && ok;
- ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::HCI_ENC_KEY_REFRESH_COMPLETE, jau::bindMemberFunc(this, &DBTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DISCOVERING, jau::bindMemberFunc(this, &BTAdapter::mgmtEvDeviceDiscoveringHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DEVICE_CONNECTED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvDeviceConnectedHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::CONNECT_FAILED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvConnectFailedHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DEVICE_DISCONNECTED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvDeviceDisconnectedHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::DEVICE_FOUND, jau::bindMemberFunc(this, &BTAdapter::mgmtEvDeviceFoundHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::HCI_LE_REMOTE_USR_FEATURES, jau::bindMemberFunc(this, &BTAdapter::mgmtEvHCILERemoteUserFeaturesHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::HCI_ENC_CHANGED, jau::bindMemberFunc(this, &BTAdapter::mgmtEvHCIEncryptionChangedHCI)) && ok;
+ ok = hci.addMgmtEventCallback(MgmtEvent::Opcode::HCI_ENC_KEY_REFRESH_COMPLETE, jau::bindMemberFunc(this, &BTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI)) && ok;
if( !ok ) {
ERR_PRINT("Could not add all required MgmtEventCallbacks to HCIHandler: %s of %s", hci.toString().c_str(), toString().c_str());
return false; // dtor local HCIHandler w/ closing
}
- hci.addSMPMsgCallback(jau::bindMemberFunc(this, &DBTAdapter::hciSMPMsgCallback));
+ hci.addSMPMsgCallback(jau::bindMemberFunc(this, &BTAdapter::hciSMPMsgCallback));
return true;
@@ -197,7 +197,7 @@ errout0:
return false;
}
-DBTAdapter::DBTAdapter(const DBTAdapter::ctor_cookie& cc, DBTManager& mgmt_, const AdapterInfo& adapterInfo_) noexcept
+BTAdapter::BTAdapter(const BTAdapter::ctor_cookie& cc, BTManager& mgmt_, const AdapterInfo& adapterInfo_) noexcept
: debug_event(jau::environment::getBooleanProperty("direct_bt.debug.adapter.event", false)),
debug_lock(jau::environment::getBooleanProperty("direct_bt.debug.adapter.lock", false)),
mgmt( mgmt_ ),
@@ -209,7 +209,7 @@ DBTAdapter::DBTAdapter(const DBTAdapter::ctor_cookie& cc, DBTManager& mgmt_, con
valid = validateDevInfo();
}
-DBTAdapter::~DBTAdapter() noexcept {
+BTAdapter::~BTAdapter() noexcept {
if( !isValid() ) {
DBG_PRINT("DBTAdapter::dtor: dev_id %d, invalid, %p", dev_id, this);
mgmt.removeAdapter(this); // remove this instance from manager
@@ -223,7 +223,7 @@ DBTAdapter::~DBTAdapter() noexcept {
DBG_PRINT("DBTAdapter::dtor: XXX");
}
-void DBTAdapter::close() noexcept {
+void BTAdapter::close() noexcept {
if( !isValid() ) {
// Native user app could have destroyed this instance already from
DBG_PRINT("DBTAdapter::close: dev_id %d, invalid, %p", dev_id, this);
@@ -261,7 +261,7 @@ void DBTAdapter::close() noexcept {
DBG_PRINT("DBTAdapter::close: XXX");
}
-void DBTAdapter::poweredOff() noexcept {
+void BTAdapter::poweredOff() noexcept {
if( !isValid() ) {
DBG_PRINT("DBTAdapter::poweredOff: dev_id %d, invalid, %p", dev_id, this);
return;
@@ -286,7 +286,7 @@ void DBTAdapter::poweredOff() noexcept {
DBG_PRINT("DBTAdapter::poweredOff: XXX");
}
-void DBTAdapter::printSharedPtrListOfDevices() noexcept {
+void BTAdapter::printSharedPtrListOfDevices() noexcept {
{
const std::lock_guard<std::mutex> lock0(mtx_sharedDevices);
jau::printSharedPtrList("SharedDevices", sharedDevices);
@@ -301,26 +301,26 @@ void DBTAdapter::printSharedPtrListOfDevices() noexcept {
}
}
-std::shared_ptr<NameAndShortName> DBTAdapter::setLocalName(const std::string &name, const std::string &short_name) noexcept {
+std::shared_ptr<NameAndShortName> BTAdapter::setLocalName(const std::string &name, const std::string &short_name) noexcept {
return mgmt.setLocalName(dev_id, name, short_name);
}
-bool DBTAdapter::setDiscoverable(bool value) noexcept {
+bool BTAdapter::setDiscoverable(bool value) noexcept {
AdapterSetting current_settings { AdapterSetting::NONE } ;
return MgmtStatus::SUCCESS == mgmt.setDiscoverable(dev_id, value ? 0x01 : 0x00, 10 /* timeout seconds */, current_settings);
}
-bool DBTAdapter::setBondable(bool value) noexcept {
+bool BTAdapter::setBondable(bool value) noexcept {
AdapterSetting current_settings { AdapterSetting::NONE } ;
return mgmt.setMode(dev_id, MgmtCommand::Opcode::SET_BONDABLE, value ? 1 : 0, current_settings);
}
-bool DBTAdapter::setPowered(bool value) noexcept {
+bool BTAdapter::setPowered(bool value) noexcept {
AdapterSetting current_settings { AdapterSetting::NONE } ;
return mgmt.setMode(dev_id, MgmtCommand::Opcode::SET_POWERED, value ? 1 : 0, current_settings);
}
-bool DBTAdapter::lockConnect(const DBTDevice & device, const bool wait, const SMPIOCapability io_cap) noexcept {
+bool BTAdapter::lockConnect(const BTDevice & device, const bool wait, const SMPIOCapability io_cap) noexcept {
std::unique_lock<std::mutex> lock(mtx_single_conn_device); // RAII-style acquire and relinquish via destructor
const uint32_t timeout_ms = 10000; // FIXME: Configurable?
@@ -384,7 +384,7 @@ bool DBTAdapter::lockConnect(const DBTDevice & device, const bool wait, const SM
}
}
-bool DBTAdapter::unlockConnect(const DBTDevice & device) noexcept {
+bool BTAdapter::unlockConnect(const BTDevice & device) noexcept {
std::unique_lock<std::mutex> lock(mtx_single_conn_device); // RAII-style acquire and relinquish via destructor
if( nullptr != single_conn_device_ptr && device == *single_conn_device_ptr ) {
@@ -415,7 +415,7 @@ bool DBTAdapter::unlockConnect(const DBTDevice & device) noexcept {
}
}
-bool DBTAdapter::unlockConnectAny() noexcept {
+bool BTAdapter::unlockConnectAny() noexcept {
std::unique_lock<std::mutex> lock(mtx_single_conn_device); // RAII-style acquire and relinquish via destructor
if( nullptr != single_conn_device_ptr ) {
@@ -442,7 +442,7 @@ bool DBTAdapter::unlockConnectAny() noexcept {
}
}
-HCIStatusCode DBTAdapter::reset() noexcept {
+HCIStatusCode BTAdapter::reset() noexcept {
if( !isValid() ) {
ERR_PRINT("DBTAdapter::reset(): Adapter invalid: %s, %s", aptrHexString(this).c_str(), toString().c_str());
return HCIStatusCode::UNSPECIFIED_ERROR;
@@ -471,11 +471,11 @@ HCIStatusCode DBTAdapter::reset() noexcept {
#endif
}
-bool DBTAdapter::isDeviceWhitelisted(const BDAddressAndType & addressAndType) noexcept {
+bool BTAdapter::isDeviceWhitelisted(const BDAddressAndType & addressAndType) noexcept {
return mgmt.isDeviceWhitelisted(dev_id, addressAndType);
}
-bool DBTAdapter::addDeviceToWhitelist(const BDAddressAndType & addressAndType, const HCIWhitelistConnectType ctype,
+bool BTAdapter::addDeviceToWhitelist(const BDAddressAndType & addressAndType, const HCIWhitelistConnectType ctype,
const uint16_t conn_interval_min, const uint16_t conn_interval_max,
const uint16_t conn_latency, const uint16_t timeout) {
if( !isPowered() ) {
@@ -494,14 +494,14 @@ bool DBTAdapter::addDeviceToWhitelist(const BDAddressAndType & addressAndType, c
return mgmt.addDeviceToWhitelist(dev_id, addressAndType, ctype);
}
-bool DBTAdapter::removeDeviceFromWhitelist(const BDAddressAndType & addressAndType) {
+bool BTAdapter::removeDeviceFromWhitelist(const BDAddressAndType & addressAndType) {
return mgmt.removeDeviceFromWhitelist(dev_id, addressAndType);
}
static jau::cow_darray<std::shared_ptr<AdapterStatusListener>>::equal_comparator _adapterStatusListenerRefEqComparator =
[](const std::shared_ptr<AdapterStatusListener> &a, const std::shared_ptr<AdapterStatusListener> &b) -> bool { return *a == *b; };
-bool DBTAdapter::addStatusListener(std::shared_ptr<AdapterStatusListener> l) {
+bool BTAdapter::addStatusListener(std::shared_ptr<AdapterStatusListener> l) {
if( nullptr == l ) {
throw jau::IllegalArgumentException("DBTAdapterStatusListener ref is null", E_FILE_LINE);
}
@@ -512,7 +512,7 @@ bool DBTAdapter::addStatusListener(std::shared_ptr<AdapterStatusListener> l) {
return true;
}
-bool DBTAdapter::removeStatusListener(std::shared_ptr<AdapterStatusListener> l) {
+bool BTAdapter::removeStatusListener(std::shared_ptr<AdapterStatusListener> l) {
if( nullptr == l ) {
throw jau::IllegalArgumentException("DBTAdapterStatusListener ref is null", E_FILE_LINE);
}
@@ -520,7 +520,7 @@ bool DBTAdapter::removeStatusListener(std::shared_ptr<AdapterStatusListener> l)
return count > 0;
}
-bool DBTAdapter::removeStatusListener(const AdapterStatusListener * l) {
+bool BTAdapter::removeStatusListener(const AdapterStatusListener * l) {
if( nullptr == l ) {
throw jau::IllegalArgumentException("DBTAdapterStatusListener ref is null", E_FILE_LINE);
}
@@ -539,13 +539,13 @@ bool DBTAdapter::removeStatusListener(const AdapterStatusListener * l) {
return false;
}
-int DBTAdapter::removeAllStatusListener() {
+int BTAdapter::removeAllStatusListener() {
int count = statusListenerList.size();
statusListenerList.clear();
return count;
}
-void DBTAdapter::checkDiscoveryState() noexcept {
+void BTAdapter::checkDiscoveryState() noexcept {
const ScanType currentNativeScanType = hci.getCurrentScanType();
// Check LE scan state
if( keep_le_scan_alive == false ) {
@@ -569,7 +569,7 @@ void DBTAdapter::checkDiscoveryState() noexcept {
}
}
-HCIStatusCode DBTAdapter::startDiscovery(const bool keepAlive, const HCILEOwnAddressType own_mac_type,
+HCIStatusCode BTAdapter::startDiscovery(const bool keepAlive, const HCILEOwnAddressType own_mac_type,
const uint16_t le_scan_interval, const uint16_t le_scan_window)
{
// FIXME: Respect DBTAdapter::btMode, i.e. BTMode::BREDR, BTMode::LE or BTMode::DUAL to setup BREDR, LE or DUAL scanning!
@@ -619,7 +619,7 @@ HCIStatusCode DBTAdapter::startDiscovery(const bool keepAlive, const HCILEOwnAdd
return status;
}
-void DBTAdapter::startDiscoveryBackground() noexcept {
+void BTAdapter::startDiscoveryBackground() noexcept {
// FIXME: Respect DBTAdapter::btMode, i.e. BTMode::BREDR, BTMode::LE or BTMode::DUAL to setup BREDR, LE or DUAL scanning!
if( !isPowered() ) {
WARN_PRINT("DBTAdapter::startDiscoveryBackground: Adapter not powered: %s", toString().c_str());
@@ -636,7 +636,7 @@ void DBTAdapter::startDiscoveryBackground() noexcept {
}
}
-HCIStatusCode DBTAdapter::stopDiscovery() noexcept {
+HCIStatusCode BTAdapter::stopDiscovery() noexcept {
// We allow !isEnabled, to utilize method for adjusting discovery state and notifying listeners
// FIXME: Respect DBTAdapter::btMode, i.e. BTMode::BREDR, BTMode::LE or BTMode::DUAL to stop BREDR, LE or DUAL scanning!
const std::lock_guard<std::mutex> lock(mtx_discovery); // RAII-style acquire and relinquish via destructor
@@ -719,12 +719,12 @@ exit:
// *************************************************
-std::shared_ptr<DBTDevice> DBTAdapter::findDiscoveredDevice (const EUI48 & address, const BDAddressType addressType) noexcept {
+std::shared_ptr<BTDevice> BTAdapter::findDiscoveredDevice (const EUI48 & address, const BDAddressType addressType) noexcept {
const std::lock_guard<std::mutex> lock(mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
return findDevice(discoveredDevices, address, addressType);
}
-bool DBTAdapter::addDiscoveredDevice(std::shared_ptr<DBTDevice> const &device) noexcept {
+bool BTAdapter::addDiscoveredDevice(std::shared_ptr<BTDevice> const &device) noexcept {
const std::lock_guard<std::mutex> lock(mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
if( nullptr != findDevice(discoveredDevices, *device) ) {
// already discovered
@@ -734,7 +734,7 @@ bool DBTAdapter::addDiscoveredDevice(std::shared_ptr<DBTDevice> const &device) n
return true;
}
-bool DBTAdapter::removeDiscoveredDevice(const BDAddressAndType & addressAndType) noexcept {
+bool BTAdapter::removeDiscoveredDevice(const BDAddressAndType & addressAndType) noexcept {
const std::lock_guard<std::mutex> lock(mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
for (auto it = discoveredDevices.begin(); it != discoveredDevices.end(); ) {
if ( nullptr != *it && addressAndType == (*it)->addressAndType ) {
@@ -748,20 +748,20 @@ bool DBTAdapter::removeDiscoveredDevice(const BDAddressAndType & addressAndType)
}
-int DBTAdapter::removeDiscoveredDevices() noexcept {
+int BTAdapter::removeDiscoveredDevices() noexcept {
const std::lock_guard<std::mutex> lock(mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
int res = discoveredDevices.size();
discoveredDevices.clear();
return res;
}
-jau::darray<std::shared_ptr<DBTDevice>> DBTAdapter::getDiscoveredDevices() const noexcept {
- const std::lock_guard<std::mutex> lock(const_cast<DBTAdapter*>(this)->mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
+jau::darray<std::shared_ptr<BTDevice>> BTAdapter::getDiscoveredDevices() const noexcept {
+ const std::lock_guard<std::mutex> lock(const_cast<BTAdapter*>(this)->mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
device_list_t res = discoveredDevices;
return res;
}
-bool DBTAdapter::addSharedDevice(std::shared_ptr<DBTDevice> const &device) noexcept {
+bool BTAdapter::addSharedDevice(std::shared_ptr<BTDevice> const &device) noexcept {
const std::lock_guard<std::mutex> lock(mtx_sharedDevices); // RAII-style acquire and relinquish via destructor
if( nullptr != findDevice(sharedDevices, *device) ) {
// already shared
@@ -771,12 +771,12 @@ bool DBTAdapter::addSharedDevice(std::shared_ptr<DBTDevice> const &device) noexc
return true;
}
-std::shared_ptr<DBTDevice> DBTAdapter::getSharedDevice(const DBTDevice & device) noexcept {
+std::shared_ptr<BTDevice> BTAdapter::getSharedDevice(const BTDevice & device) noexcept {
const std::lock_guard<std::mutex> lock(mtx_sharedDevices); // RAII-style acquire and relinquish via destructor
return findDevice(sharedDevices, device);
}
-void DBTAdapter::removeSharedDevice(const DBTDevice & device) noexcept {
+void BTAdapter::removeSharedDevice(const BTDevice & device) noexcept {
const std::lock_guard<std::mutex> lock(mtx_sharedDevices); // RAII-style acquire and relinquish via destructor
for (auto it = sharedDevices.begin(); it != sharedDevices.end(); ) {
if ( nullptr != *it && device == **it ) {
@@ -788,12 +788,12 @@ void DBTAdapter::removeSharedDevice(const DBTDevice & device) noexcept {
}
}
-std::shared_ptr<DBTDevice> DBTAdapter::findSharedDevice (const EUI48 & address, const BDAddressType addressType) noexcept {
+std::shared_ptr<BTDevice> BTAdapter::findSharedDevice (const EUI48 & address, const BDAddressType addressType) noexcept {
const std::lock_guard<std::mutex> lock(mtx_sharedDevices); // RAII-style acquire and relinquish via destructor
return findDevice(sharedDevices, address, addressType);
}
-void DBTAdapter::removeDevice(DBTDevice & device) noexcept {
+void BTAdapter::removeDevice(BTDevice & device) noexcept {
WORDY_PRINT("DBTAdapter::removeDevice: Start %s", toString(false).c_str());
const HCIStatusCode status = device.disconnect(HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION);
WORDY_PRINT("DBTAdapter::removeDevice: disconnect %s, %s", getHCIStatusCodeString(status).c_str(), toString(false).c_str());
@@ -804,7 +804,7 @@ void DBTAdapter::removeDevice(DBTDevice & device) noexcept {
removeSharedDevice(device);
}
-std::string DBTAdapter::toString(bool includeDiscoveredDevices) const noexcept {
+std::string BTAdapter::toString(bool includeDiscoveredDevices) const noexcept {
std::string out("Adapter[BTMode "+getBTModeString(btMode)+", "+getAddressString()+", '"+getName()+"', id "+std::to_string(dev_id)+
", curSettings"+getAdapterSettingMaskString(adapterInfo.getCurrentSettingMask())+
", scanType[native "+getScanTypeString(hci.getCurrentScanType())+", meta "+getScanTypeString(currentMetaScanType)+"]"
@@ -814,7 +814,7 @@ std::string DBTAdapter::toString(bool includeDiscoveredDevices) const noexcept {
if( includeDiscoveredDevices && devices.size() > 0 ) {
out.append("\n");
for(auto it = devices.begin(); it != devices.end(); it++) {
- std::shared_ptr<DBTDevice> p = *it;
+ std::shared_ptr<BTDevice> p = *it;
if( nullptr != p ) {
out.append(" ").append(p->toString()).append("\n");
}
@@ -825,7 +825,7 @@ std::string DBTAdapter::toString(bool includeDiscoveredDevices) const noexcept {
// *************************************************
-void DBTAdapter::sendAdapterSettingsChanged(const AdapterSetting old_settings_, const AdapterSetting current_settings, AdapterSetting changes,
+void BTAdapter::sendAdapterSettingsChanged(const AdapterSetting old_settings_, const AdapterSetting current_settings, AdapterSetting changes,
const uint64_t timestampMS) noexcept
{
int i=0;
@@ -841,7 +841,7 @@ void DBTAdapter::sendAdapterSettingsChanged(const AdapterSetting old_settings_,
});
}
-void DBTAdapter::sendAdapterSettingsInitial(AdapterStatusListener & asl, const uint64_t timestampMS) noexcept
+void BTAdapter::sendAdapterSettingsInitial(AdapterStatusListener & asl, const uint64_t timestampMS) noexcept
{
const AdapterSetting current_settings = adapterInfo.getCurrentSettingMask();
COND_PRINT(debug_event, "DBTAdapter::sendAdapterSettingsInitial: NONE -> %s, changes NONE: %s",
@@ -854,7 +854,7 @@ void DBTAdapter::sendAdapterSettingsInitial(AdapterStatusListener & asl, const u
}
}
-void DBTAdapter::sendDeviceUpdated(std::string cause, std::shared_ptr<DBTDevice> device, uint64_t timestamp, EIRDataType updateMask) noexcept {
+void BTAdapter::sendDeviceUpdated(std::string cause, std::shared_ptr<BTDevice> device, uint64_t timestamp, EIRDataType updateMask) noexcept {
int i=0;
jau::for_each_fidelity(statusListenerList, [&](std::shared_ptr<AdapterStatusListener> &l) {
try {
@@ -872,15 +872,15 @@ void DBTAdapter::sendDeviceUpdated(std::string cause, std::shared_ptr<DBTDevice>
// *************************************************
-bool DBTAdapter::mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept {
return mgmtEvDeviceDiscoveringAny(e, true /* hciSourced */ );
}
-bool DBTAdapter::mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceDiscoveringMgmt(const MgmtEvent& e) noexcept {
return mgmtEvDeviceDiscoveringAny(e, false /* hciSourced */ );
}
-bool DBTAdapter::mgmtEvDeviceDiscoveringAny(const MgmtEvent& e, const bool hciSourced) noexcept {
+bool BTAdapter::mgmtEvDeviceDiscoveringAny(const MgmtEvent& e, const bool hciSourced) noexcept {
const std::string srctkn = hciSourced ? "hci" : "mgmt";
const MgmtEvtDiscovering &event = *static_cast<const MgmtEvtDiscovering *>(&e);
const ScanType eventScanType = event.getScanType();
@@ -940,13 +940,13 @@ bool DBTAdapter::mgmtEvDeviceDiscoveringAny(const MgmtEvent& e, const bool hciSo
});
if( !hasScanType(currentNativeScanType, ScanType::LE) && keep_le_scan_alive ) {
- std::thread bg(&DBTAdapter::startDiscoveryBackground, this); // @suppress("Invalid arguments")
+ std::thread bg(&BTAdapter::startDiscoveryBackground, this); // @suppress("Invalid arguments")
bg.detach();
}
return true;
}
-bool DBTAdapter::mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept {
COND_PRINT(debug_event, "DBTAdapter:mgmt:NewSettings: %s", e.toString().c_str());
const MgmtEvtNewSettings &event = *static_cast<const MgmtEvtNewSettings *>(&e);
const AdapterSetting new_settings = adapterInfo.setCurrentSettingMask(event.getSettings()); // probably done by mgmt callback already
@@ -981,14 +981,14 @@ bool DBTAdapter::mgmtEvNewSettingsMgmt(const MgmtEvent& e) noexcept {
if( justPoweredOff ) {
// Adapter has been powered off, close connections and cleanup off-thread.
- std::thread bg(&DBTAdapter::poweredOff, this); // @suppress("Invalid arguments")
+ std::thread bg(&BTAdapter::poweredOff, this); // @suppress("Invalid arguments")
bg.detach();
}
return true;
}
-bool DBTAdapter::mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept {
COND_PRINT(debug_event, "DBTAdapter:mgmt:LocalNameChanged: %s", e.toString().c_str());
const MgmtEvtLocalNameChanged &event = *static_cast<const MgmtEvtLocalNameChanged *>(&e);
std::string old_name = localName.getName();
@@ -1009,7 +1009,7 @@ bool DBTAdapter::mgmtEvLocalNameChangedMgmt(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept {
COND_PRINT(debug_event, "DBTAdapter:hci:DeviceConnected(dev_id %d): %s", dev_id, e.toString().c_str());
const MgmtEvtDeviceConnected &event = *static_cast<const MgmtEvtDeviceConnected *>(&e);
EInfoReport ad_report;
@@ -1021,7 +1021,7 @@ bool DBTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept {
ad_report.read_data(event.getData(), event.getDataSize());
}
int new_connect = 0;
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr == device ) {
device = findDiscoveredDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
@@ -1038,7 +1038,7 @@ bool DBTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept {
}
if( nullptr == device ) {
// a whitelist auto-connect w/o previous discovery
- device = DBTDevice::make_shared(*this, ad_report);
+ device = BTDevice::make_shared(*this, ad_report);
addDiscoveredDevice(device);
addSharedDevice(device);
new_connect = 3;
@@ -1087,11 +1087,11 @@ bool DBTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept {
COND_PRINT(debug_event, "DBTAdapter::EventHCI:ConnectFailed: %s", e.toString().c_str());
const MgmtEvtDeviceConnectFailed &event = *static_cast<const MgmtEvtDeviceConnectFailed *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
const uint16_t handle = device->getConnectionHandle();
COND_PRINT(debug_event, "DBTAdapter::EventHCI:ConnectFailed(dev_id %d): %s, handle %s -> zero,\n -> %s",
@@ -1123,10 +1123,10 @@ bool DBTAdapter::mgmtEvConnectFailedHCI(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept {
const MgmtEvtHCIEncryptionChanged &event = *static_cast<const MgmtEvtHCIEncryptionChanged *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
// BT Core Spec v5.2: Vol 4, Part E HCI: 7.7.8 HCIEventType::ENCRYPT_CHANGE
const HCIStatusCode evtStatus = event.getHCIStatus();
@@ -1139,10 +1139,10 @@ bool DBTAdapter::mgmtEvHCIEncryptionChangedHCI(const MgmtEvent& e) noexcept {
}
return true;
}
-bool DBTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) noexcept {
const MgmtEvtHCIEncryptionKeyRefreshComplete &event = *static_cast<const MgmtEvtHCIEncryptionKeyRefreshComplete *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
// BT Core Spec v5.2: Vol 4, Part E HCI: 7.7.39 HCIEventType::ENCRYPT_KEY_REFRESH_COMPLETE
const HCIStatusCode evtStatus = event.getHCIStatus();
@@ -1157,10 +1157,10 @@ bool DBTAdapter::mgmtEvHCIEncryptionKeyRefreshCompleteHCI(const MgmtEvent& e) no
return true;
}
-bool DBTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept {
const MgmtEvtHCILERemoteUserFeatures &event = *static_cast<const MgmtEvtHCILERemoteUserFeatures *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
COND_PRINT(debug_event, "DBTAdapter::EventHCI:LERemoteUserFeatures(dev_id %d): %s, %s",
dev_id, event.toString().c_str(), device->toString().c_str());
@@ -1174,10 +1174,10 @@ bool DBTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept {
const MgmtEvtDeviceDisconnected &event = *static_cast<const MgmtEvtDeviceDisconnected *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
if( device->getConnectionHandle() != event.getHCIHandle() ) {
WORDY_PRINT("DBTAdapter::EventHCI:DeviceDisconnected(dev_id %d): ConnHandle mismatch %s\n -> %s",
@@ -1213,17 +1213,17 @@ bool DBTAdapter::mgmtEvDeviceDisconnectedHCI(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvDeviceDisconnectedMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceDisconnectedMgmt(const MgmtEvent& e) noexcept {
COND_PRINT(debug_event, "DBTAdapter:mgmt:DeviceDisconnected: %s", e.toString().c_str());
const MgmtEvtDeviceDisconnected &event = *static_cast<const MgmtEvtDeviceDisconnected *>(&e);
(void)event;
return true;
}
-bool DBTAdapter::mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtPairDeviceComplete &event = *static_cast<const MgmtEvtPairDeviceComplete *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr != device ) {
const HCIStatusCode evtStatus = getHCIStatusCode( event.getStatus() );
const bool ok = HCIStatusCode::ALREADY_PAIRED == evtStatus;
@@ -1236,10 +1236,10 @@ bool DBTAdapter::mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtNewLongTermKey& event = *static_cast<const MgmtEvtNewLongTermKey *>(&e);
const MgmtLongTermKeyInfo& ltk_info = event.getLongTermKey();
- std::shared_ptr<DBTDevice> device = findConnectedDevice(ltk_info.address, ltk_info.address_type);
+ std::shared_ptr<BTDevice> device = findConnectedDevice(ltk_info.address, ltk_info.address_type);
if( nullptr != device ) {
const bool ok = ltk_info.enc_size > 0 && ltk_info.key_type != MgmtLTKType::NONE;
if( ok ) {
@@ -1255,7 +1255,7 @@ bool DBTAdapter::mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept {
COND_PRINT(debug_event, "DBTAdapter:hci:DeviceFound(dev_id %d): %s", dev_id, e.toString().c_str());
const MgmtEvtDeviceFound &deviceFoundEvent = *static_cast<const MgmtEvtDeviceFound *>(&e);
@@ -1272,7 +1272,7 @@ bool DBTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept {
eir->read_data(deviceFoundEvent.getData(), deviceFoundEvent.getDataSize());
} // else: Sourced from HCIHandler via LE_ADVERTISING_REPORT (default!)
- std::shared_ptr<DBTDevice> dev = findDiscoveredDevice(eir->getAddress(), eir->getAddressType());
+ std::shared_ptr<BTDevice> dev = findDiscoveredDevice(eir->getAddress(), eir->getAddressType());
if( nullptr != dev ) {
//
// drop existing device
@@ -1327,7 +1327,7 @@ bool DBTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept {
//
// new device
//
- dev = DBTDevice::make_shared(*this, *eir);
+ dev = BTDevice::make_shared(*this, *eir);
addDiscoveredDevice(dev);
addSharedDevice(dev);
COND_PRINT(debug_event, "DBTAdapter:hci:DeviceFound: Use new %s, %s",
@@ -1355,20 +1355,20 @@ bool DBTAdapter::mgmtEvDeviceFoundHCI(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::mgmtEvDeviceUnpairedMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvDeviceUnpairedMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtDeviceUnpaired &event = *static_cast<const MgmtEvtDeviceUnpaired *>(&e);
DBG_PRINT("DBTAdapter:mgmt:DeviceUnpaired: %s", event.toString().c_str());
return true;
}
-bool DBTAdapter::mgmtEvPinCodeRequestMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvPinCodeRequestMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtPinCodeRequest &event = *static_cast<const MgmtEvtPinCodeRequest *>(&e);
DBG_PRINT("DBTAdapter:mgmt:PinCodeRequest: %s", event.toString().c_str());
return true;
}
-bool DBTAdapter::mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtAuthFailed &event = *static_cast<const MgmtEvtAuthFailed *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr == device ) {
WORDY_PRINT("DBTAdapter:hci:SMP: dev_id %d: Device not tracked: address[%s, %s], %s",
dev_id, event.getAddress().toString().c_str(), getBDAddressTypeString(event.getAddressType()).c_str(),
@@ -1379,10 +1379,10 @@ bool DBTAdapter::mgmtEvAuthFailedMgmt(const MgmtEvent& e) noexcept {
device->updatePairingState(device, e, evtStatus, SMPPairingState::FAILED);
return true;
}
-bool DBTAdapter::mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtUserConfirmRequest &event = *static_cast<const MgmtEvtUserConfirmRequest *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr == device ) {
WORDY_PRINT("DBTAdapter:hci:SMP: dev_id %d: Device not tracked: address[%s, %s], %s",
dev_id, event.getAddress().toString().c_str(), getBDAddressTypeString(event.getAddressType()).c_str(),
@@ -1393,10 +1393,10 @@ bool DBTAdapter::mgmtEvUserConfirmRequestMgmt(const MgmtEvent& e) noexcept {
device->updatePairingState(device, e, HCIStatusCode::SUCCESS, SMPPairingState::NUMERIC_COMPARE_EXPECTED);
return true;
}
-bool DBTAdapter::mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept {
+bool BTAdapter::mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept {
const MgmtEvtUserPasskeyRequest &event = *static_cast<const MgmtEvtUserPasskeyRequest *>(&e);
- std::shared_ptr<DBTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
+ std::shared_ptr<BTDevice> device = findConnectedDevice(event.getAddress(), event.getAddressType());
if( nullptr == device ) {
WORDY_PRINT("DBTAdapter:hci:SMP: dev_id %d: Device not tracked: address[%s, %s], %s",
dev_id, event.getAddress().toString().c_str(), getBDAddressTypeString(event.getAddressType()).c_str(),
@@ -1407,9 +1407,9 @@ bool DBTAdapter::mgmtEvUserPasskeyRequestMgmt(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTAdapter::hciSMPMsgCallback(const BDAddressAndType & addressAndType,
+bool BTAdapter::hciSMPMsgCallback(const BDAddressAndType & addressAndType,
const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept {
- std::shared_ptr<DBTDevice> device = findConnectedDevice(addressAndType.address, addressAndType.type);
+ std::shared_ptr<BTDevice> device = findConnectedDevice(addressAndType.address, addressAndType.type);
if( nullptr == device ) {
WORDY_PRINT("DBTAdapter:hci:SMP: dev_id %d: Device not tracked: address%s: %s, %s",
dev_id, addressAndType.toString().c_str(),
@@ -1428,7 +1428,7 @@ bool DBTAdapter::hciSMPMsgCallback(const BDAddressAndType & addressAndType,
return true;
}
-void DBTAdapter::sendDevicePairingState(std::shared_ptr<DBTDevice> device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept
+void BTAdapter::sendDevicePairingState(std::shared_ptr<BTDevice> device, const SMPPairingState state, const PairingMode mode, uint64_t timestamp) noexcept
{
int i=0;
jau::for_each_fidelity(statusListenerList, [&](std::shared_ptr<AdapterStatusListener> &l) {
@@ -1445,7 +1445,7 @@ void DBTAdapter::sendDevicePairingState(std::shared_ptr<DBTDevice> device, const
});
}
-void DBTAdapter::sendDeviceReady(std::shared_ptr<DBTDevice> device, uint64_t timestamp) noexcept {
+void BTAdapter::sendDeviceReady(std::shared_ptr<BTDevice> device, uint64_t timestamp) noexcept {
int i=0;
jau::for_each_fidelity(statusListenerList, [&](std::shared_ptr<AdapterStatusListener> &l) {
try {
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 38824bac..561a95a6 100644
--- a/src/direct_bt/DBTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -23,6 +23,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTAdapter.hpp>
+#include <BTDevice.hpp>
+#include <BTManager.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -37,13 +40,10 @@
#include "HCIComm.hpp"
-#include "DBTDevice.hpp"
-#include "DBTAdapter.hpp"
-#include "DBTManager.hpp"
using namespace direct_bt;
-DBTDevice::DBTDevice(const ctor_cookie& cc, DBTAdapter & a, EInfoReport const & r)
+BTDevice::BTDevice(const ctor_cookie& cc, BTAdapter & a, EInfoReport const & r)
: adapter(a),
l2cap_att(adapter.getAddress(), L2CAP_PSM_UNDEF, L2CAP_CID_ATT),
ts_creation(r.getTimestamp()),
@@ -78,18 +78,18 @@ DBTDevice::DBTDevice(const ctor_cookie& cc, DBTAdapter & a, EInfoReport const &
}
}
-DBTDevice::~DBTDevice() noexcept {
+BTDevice::~BTDevice() noexcept {
DBG_PRINT("DBTDevice::dtor: ... %p %s", this, addressAndType.toString().c_str());
advServices.clear();
advMSD = nullptr;
DBG_PRINT("DBTDevice::dtor: XXX %p %s", this, addressAndType.toString().c_str());
}
-std::shared_ptr<DBTDevice> DBTDevice::getSharedInstance() const noexcept {
+std::shared_ptr<BTDevice> BTDevice::getSharedInstance() const noexcept {
return adapter.getSharedDevice(*this);
}
-bool DBTDevice::addAdvService(std::shared_ptr<uuid_t> const &uuid) noexcept
+bool BTDevice::addAdvService(std::shared_ptr<uuid_t> const &uuid) noexcept
{
if( 0 > findAdvService(uuid) ) {
advServices.push_back(uuid);
@@ -97,7 +97,7 @@ bool DBTDevice::addAdvService(std::shared_ptr<uuid_t> const &uuid) noexcept
}
return false;
}
-bool DBTDevice::addAdvServices(jau::darray<std::shared_ptr<uuid_t>> const & services) noexcept
+bool BTDevice::addAdvServices(jau::darray<std::shared_ptr<uuid_t>> const & services) noexcept
{
bool res = false;
for(size_t j=0; j<services.size(); j++) {
@@ -107,7 +107,7 @@ bool DBTDevice::addAdvServices(jau::darray<std::shared_ptr<uuid_t>> const & serv
return res;
}
-int DBTDevice::findAdvService(std::shared_ptr<uuid_t> const &uuid) const noexcept
+int BTDevice::findAdvService(std::shared_ptr<uuid_t> const &uuid) const noexcept
{
const size_t size = advServices.size();
for (size_t i = 0; i < size; i++) {
@@ -119,25 +119,25 @@ int DBTDevice::findAdvService(std::shared_ptr<uuid_t> const &uuid) const noexcep
return -1;
}
-std::string const DBTDevice::getName() const noexcept {
- const std::lock_guard<std::recursive_mutex> lock(const_cast<DBTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
+std::string const BTDevice::getName() const noexcept {
+ const std::lock_guard<std::recursive_mutex> lock(const_cast<BTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
return name;
}
-std::shared_ptr<ManufactureSpecificData> const DBTDevice::getManufactureSpecificData() const noexcept {
- const std::lock_guard<std::recursive_mutex> lock(const_cast<DBTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
+std::shared_ptr<ManufactureSpecificData> const BTDevice::getManufactureSpecificData() const noexcept {
+ const std::lock_guard<std::recursive_mutex> lock(const_cast<BTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
return advMSD;
}
-jau::darray<std::shared_ptr<uuid_t>> DBTDevice::getAdvertisedServices() const noexcept {
- const std::lock_guard<std::recursive_mutex> lock(const_cast<DBTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
+jau::darray<std::shared_ptr<uuid_t>> BTDevice::getAdvertisedServices() const noexcept {
+ const std::lock_guard<std::recursive_mutex> lock(const_cast<BTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
return advServices;
}
-std::string DBTDevice::toString(bool includeDiscoveredServices) const noexcept {
- const std::lock_guard<std::recursive_mutex> lock(const_cast<DBTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
+std::string BTDevice::toString(bool includeDiscoveredServices) const noexcept {
+ const std::lock_guard<std::recursive_mutex> lock(const_cast<BTDevice*>(this)->mtx_data); // RAII-style acquire and relinquish via destructor
const uint64_t t0 = jau::getCurrentMilliseconds();
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
std::string msdstr = nullptr != advMSD ? advMSD->toString() : "MSD[null]";
std::string out("Device["+addressAndType.toString()+", name['"+name+
"'], age[total "+std::to_string(t0-ts_creation)+", ldisc "+std::to_string(t0-ts_last_discovery)+", lup "+std::to_string(t0-ts_last_update)+
@@ -161,7 +161,7 @@ std::string DBTDevice::toString(bool includeDiscoveredServices) const noexcept {
return out;
}
-EIRDataType DBTDevice::update(EInfoReport const & data) noexcept {
+EIRDataType BTDevice::update(EInfoReport const & data) noexcept {
const std::lock_guard<std::recursive_mutex> lock(mtx_data); // RAII-style acquire and relinquish via destructor
EIRDataType res = EIRDataType::NONE;
@@ -220,7 +220,7 @@ EIRDataType DBTDevice::update(EInfoReport const & data) noexcept {
return res;
}
-EIRDataType DBTDevice::update(GattGenericAccessSvc const &data, const uint64_t timestamp) noexcept {
+EIRDataType BTDevice::update(GattGenericAccessSvc const &data, const uint64_t timestamp) noexcept {
const std::lock_guard<std::recursive_mutex> lock(mtx_data); // RAII-style acquire and relinquish via destructor
EIRDataType res = EIRDataType::NONE;
@@ -236,8 +236,8 @@ EIRDataType DBTDevice::update(GattGenericAccessSvc const &data, const uint64_t t
return res;
}
-std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo() noexcept {
- DBTManager & mgmt = adapter.getManager();
+std::shared_ptr<ConnectionInfo> BTDevice::getConnectionInfo() noexcept {
+ BTManager & mgmt = adapter.getManager();
std::shared_ptr<ConnectionInfo> connInfo = mgmt.getConnectionInfo(adapter.dev_id, addressAndType);
if( nullptr != connInfo ) {
EIRDataType updateMask = EIRDataType::NONE;
@@ -250,7 +250,7 @@ std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo() noexcept {
setEIRDataTypeSet(updateMask, EIRDataType::TX_POWER);
}
if( EIRDataType::NONE != updateMask ) {
- std::shared_ptr<DBTDevice> sharedInstance = getSharedInstance();
+ std::shared_ptr<BTDevice> sharedInstance = getSharedInstance();
if( nullptr == sharedInstance ) {
ERR_PRINT("DBTDevice::getConnectionInfo: Device unknown to adapter and not tracked: %s", toString(false).c_str());
} else {
@@ -261,7 +261,7 @@ std::shared_ptr<ConnectionInfo> DBTDevice::getConnectionInfo() noexcept {
return connInfo;
}
-HCIStatusCode DBTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_window,
+HCIStatusCode BTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_window,
uint16_t conn_interval_min, uint16_t conn_interval_max,
uint16_t conn_latency, uint16_t supervision_timeout)
{
@@ -354,7 +354,7 @@ HCIStatusCode DBTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_w
return status;
}
-HCIStatusCode DBTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch)
+HCIStatusCode BTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t clock_offset, const uint8_t role_switch)
{
const std::lock_guard<std::recursive_mutex> lock_conn(mtx_connect); // RAII-style acquire and relinquish via destructor
if( !adapter.isPowered() ) {
@@ -394,7 +394,7 @@ HCIStatusCode DBTDevice::connectBREDR(const uint16_t pkt_type, const uint16_t cl
return status;
}
-HCIStatusCode DBTDevice::connectDefault()
+HCIStatusCode BTDevice::connectDefault()
{
switch( addressAndType.type ) {
case BDAddressType::BDADDR_LE_PUBLIC:
@@ -409,7 +409,7 @@ HCIStatusCode DBTDevice::connectDefault()
}
}
-void DBTDevice::notifyConnected(std::shared_ptr<DBTDevice> sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept {
+void BTDevice::notifyConnected(std::shared_ptr<BTDevice> sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept {
// coming from connected callback, update state and spawn-off connectGATT in background if appropriate (LE)
jau::sc_atomic_critical sync(sync_pairing);
DBG_PRINT("DBTDevice::notifyConnected: handle %s -> %s, io %s -> %s, %s",
@@ -426,18 +426,18 @@ void DBTDevice::notifyConnected(std::shared_ptr<DBTDevice> sthis, const uint16_t
(void)sthis; // not used yet
}
-void DBTDevice::notifyLEFeatures(std::shared_ptr<DBTDevice> sthis, const LEFeatures features) noexcept {
+void BTDevice::notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const LEFeatures features) noexcept {
DBG_PRINT("DBTDevice::notifyLEFeatures: LE_Encryption %d, %s",
isLEFeaturesBitSet(features, LEFeatures::LE_Encryption), toString(false).c_str());
le_features = features;
if( addressAndType.isLEAddress() && !l2cap_att.isOpen() ) {
- std::thread bg(&DBTDevice::processL2CAPSetup, this, sthis); // @suppress("Invalid arguments")
+ std::thread bg(&BTDevice::processL2CAPSetup, this, sthis); // @suppress("Invalid arguments")
bg.detach();
}
}
-void DBTDevice::processL2CAPSetup(std::shared_ptr<DBTDevice> sthis) {
+void BTDevice::processL2CAPSetup(std::shared_ptr<BTDevice> sthis) {
bool callProcessDeviceReady = false;
if( addressAndType.isLEAddress() && !l2cap_att.isOpen() ) {
@@ -499,7 +499,7 @@ void DBTDevice::processL2CAPSetup(std::shared_ptr<DBTDevice> sthis) {
DBG_PRINT("DBTDevice::processL2CAPSetup: End %s", toString(false).c_str());
}
-void DBTDevice::processDeviceReady(std::shared_ptr<DBTDevice> sthis, const uint64_t timestamp) {
+void BTDevice::processDeviceReady(std::shared_ptr<BTDevice> sthis, const uint64_t timestamp) {
DBG_PRINT("DBTDevice::processDeviceReady: %s", toString(false).c_str());
PairingMode pmode;
{
@@ -533,7 +533,7 @@ void DBTDevice::processDeviceReady(std::shared_ptr<DBTDevice> sthis, const uint6
static const SMPKeyType _key_mask_legacy = SMPKeyType::ENC_KEY | SMPKeyType::ID_KEY | SMPKeyType::SIGN_KEY;
static const SMPKeyType _key_mask_sc = SMPKeyType::ID_KEY | SMPKeyType::SIGN_KEY | SMPKeyType::LINK_KEY;
-bool DBTDevice::checkPairingKeyDistributionComplete(const std::string& timestamp) const noexcept {
+bool BTDevice::checkPairingKeyDistributionComplete(const std::string& timestamp) const noexcept {
bool res = false;
if( SMPPairingState::KEY_DISTRIBUTION == pairing_data.state ) {
@@ -568,7 +568,7 @@ bool DBTDevice::checkPairingKeyDistributionComplete(const std::string& timestamp
return res;
}
-bool DBTDevice::updatePairingState(std::shared_ptr<DBTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept {
+bool BTDevice::updatePairingState(std::shared_ptr<BTDevice> sthis, const MgmtEvent& evt, const HCIStatusCode evtStatus, SMPPairingState claimed_state) noexcept {
const std::lock_guard<std::mutex> lock(mtx_pairing); // RAII-style acquire and relinquish via destructor
jau::sc_atomic_critical sync(sync_pairing);
@@ -679,7 +679,7 @@ bool DBTDevice::updatePairingState(std::shared_ptr<DBTDevice> sthis, const MgmtE
adapter.sendDevicePairingState(sthis, claimed_state, mode, evt.getTimestamp());
if( is_device_ready ) {
- std::thread dc(&DBTDevice::processDeviceReady, this, sthis, evt.getTimestamp()); // @suppress("Invalid arguments")
+ std::thread dc(&BTDevice::processDeviceReady, this, sthis, evt.getTimestamp()); // @suppress("Invalid arguments")
dc.detach();
}
DBG_PRINT("DBTDevice::updatePairingState.2: End Complete: state %s, %s",
@@ -693,7 +693,7 @@ bool DBTDevice::updatePairingState(std::shared_ptr<DBTDevice> sthis, const MgmtE
return false;
}
-void DBTDevice::hciSMPMsgCallback(std::shared_ptr<DBTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept {
+void BTDevice::hciSMPMsgCallback(std::shared_ptr<BTDevice> sthis, const SMPPDUMsg& msg, const HCIACLData::l2cap_frame& source) noexcept {
const std::lock_guard<std::mutex> lock(mtx_pairing); // RAII-style acquire and relinquish via destructor
jau::sc_atomic_critical sync(sync_pairing);
@@ -951,7 +951,7 @@ void DBTDevice::hciSMPMsgCallback(std::shared_ptr<DBTDevice> sthis, const SMPPDU
adapter.sendDevicePairingState(sthis, pstate, pmode, msg.getTimestamp());
if( is_device_ready ) {
- std::thread dc(&DBTDevice::processDeviceReady, this, sthis, msg.getTimestamp()); // @suppress("Invalid arguments")
+ std::thread dc(&BTDevice::processDeviceReady, this, sthis, msg.getTimestamp()); // @suppress("Invalid arguments")
dc.detach();
}
if( jau::environment::get().debug ) {
@@ -960,8 +960,8 @@ void DBTDevice::hciSMPMsgCallback(std::shared_ptr<DBTDevice> sthis, const SMPPDU
}
}
-SMPKeyType DBTDevice::getAvailableSMPKeys(const bool responder) const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+SMPKeyType BTDevice::getAvailableSMPKeys(const bool responder) const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
if( responder ) {
return pairing_data.keys_resp_has;
} else {
@@ -969,12 +969,12 @@ SMPKeyType DBTDevice::getAvailableSMPKeys(const bool responder) const noexcept {
}
}
-SMPLongTermKeyInfo DBTDevice::getLongTermKeyInfo(const bool responder) const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+SMPLongTermKeyInfo BTDevice::getLongTermKeyInfo(const bool responder) const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
return responder ? pairing_data.ltk_resp : pairing_data.ltk_init;
}
-HCIStatusCode DBTDevice::setLongTermKeyInfo(const SMPLongTermKeyInfo& ltk) noexcept {
+HCIStatusCode BTDevice::setLongTermKeyInfo(const SMPLongTermKeyInfo& ltk) noexcept {
if( isConnected ) {
ERR_PRINT("DBTDevice::setLongTermKeyInfo: Already connected: %s", toString(false).c_str());
return HCIStatusCode::CONNECTION_ALREADY_EXISTS;
@@ -987,17 +987,17 @@ HCIStatusCode DBTDevice::setLongTermKeyInfo(const SMPLongTermKeyInfo& ltk) noexc
} else {
pairing_data.ltk_init = ltk;
}
- DBTManager & mngr = adapter.getManager();
+ BTManager & mngr = adapter.getManager();
HCIStatusCode res = mngr.uploadLongTermKeyInfo(adapter.dev_id, addressAndType, ltk);
return res;
}
-SMPSignatureResolvingKeyInfo DBTDevice::getSignatureResolvingKeyInfo(const bool responder) const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+SMPSignatureResolvingKeyInfo BTDevice::getSignatureResolvingKeyInfo(const bool responder) const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
return responder ? pairing_data.csrk_resp : pairing_data.csrk_init;
}
-HCIStatusCode DBTDevice::pair(const SMPIOCapability io_cap) noexcept {
+HCIStatusCode BTDevice::pair(const SMPIOCapability io_cap) noexcept {
/**
* Experimental only.
* <pre>
@@ -1009,7 +1009,7 @@ HCIStatusCode DBTDevice::pair(const SMPIOCapability io_cap) noexcept {
DBG_PRINT("DBTDevice::pairDevice: io %s, invalid value.", getSMPIOCapabilityString(io_cap).c_str());
return HCIStatusCode::INVALID_PARAMS;
}
- DBTManager& mngr = adapter.getManager();
+ BTManager& mngr = adapter.getManager();
DBG_PRINT("DBTDevice::pairDevice: Start: io %s, %s", getSMPIOCapabilityString(io_cap).c_str(), toString(false).c_str());
mngr.uploadConnParam(adapter.dev_id, addressAndType);
@@ -1024,7 +1024,7 @@ HCIStatusCode DBTDevice::pair(const SMPIOCapability io_cap) noexcept {
return res ? HCIStatusCode::SUCCESS : HCIStatusCode::FAILED;
}
-bool DBTDevice::setConnSecurityLevel(const BTSecurityLevel sec_level) noexcept {
+bool BTDevice::setConnSecurityLevel(const BTSecurityLevel sec_level) noexcept {
if( BTSecurityLevel::UNSET == sec_level ) {
DBG_PRINT("DBTAdapter::setConnSecurityLevel: lvl %s, invalid value.", getBTSecurityLevelString(sec_level).c_str());
return false;
@@ -1045,12 +1045,12 @@ bool DBTDevice::setConnSecurityLevel(const BTSecurityLevel sec_level) noexcept {
return res;
}
-BTSecurityLevel DBTDevice::getConnSecurityLevel() const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+BTSecurityLevel BTDevice::getConnSecurityLevel() const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
return pairing_data.sec_level_conn;
}
-bool DBTDevice::setConnIOCapability(const SMPIOCapability io_cap) noexcept {
+bool BTDevice::setConnIOCapability(const SMPIOCapability io_cap) noexcept {
if( SMPIOCapability::UNSET == io_cap ) {
DBG_PRINT("DBTDevice::setConnIOCapability: io %s, invalid value.", getSMPIOCapabilityString(io_cap).c_str());
return false;
@@ -1072,12 +1072,12 @@ bool DBTDevice::setConnIOCapability(const SMPIOCapability io_cap) noexcept {
return res;
}
-SMPIOCapability DBTDevice::getConnIOCapability() const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+SMPIOCapability BTDevice::getConnIOCapability() const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
return pairing_data.ioCap_conn;
}
-bool DBTDevice::setConnSecurity(const BTSecurityLevel sec_level, const SMPIOCapability io_cap) noexcept {
+bool BTDevice::setConnSecurity(const BTSecurityLevel sec_level, const SMPIOCapability io_cap) noexcept {
if( BTSecurityLevel::UNSET == sec_level ) {
DBG_PRINT("DBTAdapter::setConnSecurity: lvl %s, invalid value.", getBTSecurityLevelString(sec_level).c_str());
return false;
@@ -1106,7 +1106,7 @@ bool DBTDevice::setConnSecurity(const BTSecurityLevel sec_level, const SMPIOCapa
return res;
}
-bool DBTDevice::setConnSecurityBest(const BTSecurityLevel sec_level, const SMPIOCapability io_cap) noexcept {
+bool BTDevice::setConnSecurityBest(const BTSecurityLevel sec_level, const SMPIOCapability io_cap) noexcept {
if( BTSecurityLevel::UNSET < sec_level && SMPIOCapability::UNSET != io_cap ) {
return setConnSecurity(sec_level, io_cap);
} else if( BTSecurityLevel::UNSET < sec_level ) {
@@ -1122,12 +1122,12 @@ bool DBTDevice::setConnSecurityBest(const BTSecurityLevel sec_level, const SMPIO
}
}
-HCIStatusCode DBTDevice::setPairingPasskey(const uint32_t passkey) noexcept {
+HCIStatusCode BTDevice::setPairingPasskey(const uint32_t passkey) noexcept {
const std::lock_guard<std::mutex> lock(mtx_pairing); // RAII-style acquire and relinquish via destructor
jau::sc_atomic_critical sync(sync_pairing);
if( SMPPairingState::PASSKEY_EXPECTED == pairing_data.state ) {
- DBTManager& mngr = adapter.getManager();
+ BTManager& mngr = adapter.getManager();
MgmtStatus res = mngr.userPasskeyReply(adapter.dev_id, addressAndType, passkey);
DBG_PRINT("DBTDevice:mgmt:SMP: PASSKEY '%d', state %s, result %s",
passkey, getSMPPairingStateString(pairing_data.state).c_str(), getMgmtStatusString(res).c_str());
@@ -1139,12 +1139,12 @@ HCIStatusCode DBTDevice::setPairingPasskey(const uint32_t passkey) noexcept {
}
}
-HCIStatusCode DBTDevice::setPairingPasskeyNegative() noexcept {
+HCIStatusCode BTDevice::setPairingPasskeyNegative() noexcept {
const std::lock_guard<std::mutex> lock(mtx_pairing); // RAII-style acquire and relinquish via destructor
jau::sc_atomic_critical sync(sync_pairing);
if( SMPPairingState::PASSKEY_EXPECTED == pairing_data.state ) {
- DBTManager& mngr = adapter.getManager();
+ BTManager& mngr = adapter.getManager();
MgmtStatus res = mngr.userPasskeyNegativeReply(adapter.dev_id, addressAndType);
DBG_PRINT("DBTDevice:mgmt:SMP: PASSKEY NEGATIVE, state %s, result %s",
getSMPPairingStateString(pairing_data.state).c_str(), getMgmtStatusString(res).c_str());
@@ -1156,12 +1156,12 @@ HCIStatusCode DBTDevice::setPairingPasskeyNegative() noexcept {
}
}
-HCIStatusCode DBTDevice::setPairingNumericComparison(const bool positive) noexcept {
+HCIStatusCode BTDevice::setPairingNumericComparison(const bool positive) noexcept {
const std::lock_guard<std::mutex> lock(mtx_pairing); // RAII-style acquire and relinquish via destructor
jau::sc_atomic_critical sync(sync_pairing);
if( SMPPairingState::NUMERIC_COMPARE_EXPECTED == pairing_data.state ) {
- DBTManager& mngr = adapter.getManager();
+ BTManager& mngr = adapter.getManager();
MgmtStatus res = mngr.userConfirmReply(adapter.dev_id, addressAndType, positive);
DBG_PRINT("DBTDevice:mgmt:SMP: CONFIRM '%d', state %s, result %s",
positive, getSMPPairingStateString(pairing_data.state).c_str(), getMgmtStatusString(res).c_str());
@@ -1173,17 +1173,17 @@ HCIStatusCode DBTDevice::setPairingNumericComparison(const bool positive) noexce
}
}
-PairingMode DBTDevice::getPairingMode() const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+PairingMode BTDevice::getPairingMode() const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
return pairing_data.mode;
}
-SMPPairingState DBTDevice::getPairingState() const noexcept {
- jau::sc_atomic_critical sync(const_cast<DBTDevice*>(this)->sync_pairing);
+SMPPairingState BTDevice::getPairingState() const noexcept {
+ jau::sc_atomic_critical sync(const_cast<BTDevice*>(this)->sync_pairing);
return pairing_data.state;
}
-void DBTDevice::clearSMPStates(const bool connected) noexcept {
+void BTDevice::clearSMPStates(const bool connected) noexcept {
const std::lock_guard<std::mutex> lock(mtx_pairing); // RAII-style acquire and relinquish via destructor
jau::sc_atomic_critical sync(sync_pairing);
@@ -1223,7 +1223,7 @@ void DBTDevice::clearSMPStates(const bool connected) noexcept {
pairing_data.csrk_init.clear();
}
-void DBTDevice::disconnectSMP(const int caller) noexcept {
+void BTDevice::disconnectSMP(const int caller) noexcept {
#if SMP_SUPPORTED_BY_OS
const std::lock_guard<std::recursive_mutex> lock_conn(mtx_smpHandler);
if( nullptr != smpHandler ) {
@@ -1239,7 +1239,7 @@ void DBTDevice::disconnectSMP(const int caller) noexcept {
#endif
}
-bool DBTDevice::connectSMP(std::shared_ptr<DBTDevice> sthis, const BTSecurityLevel sec_level) noexcept {
+bool BTDevice::connectSMP(std::shared_ptr<BTDevice> sthis, const BTSecurityLevel sec_level) noexcept {
#if SMP_SUPPORTED_BY_OS
if( !isConnected || !allowDisconnect) {
ERR_PRINT("DBTDevice::connectSMP(%u): Device not connected: %s", sec_level, toString(false).c_str());
@@ -1278,7 +1278,7 @@ bool DBTDevice::connectSMP(std::shared_ptr<DBTDevice> sthis, const BTSecurityLev
#endif
}
-void DBTDevice::disconnectGATT(const int caller) noexcept {
+void BTDevice::disconnectGATT(const int caller) noexcept {
const std::lock_guard<std::recursive_mutex> lock_conn(mtx_gattHandler);
if( nullptr != gattHandler ) {
DBG_PRINT("DBTDevice::disconnectGATT: start (has gattHandler, caller %d)", caller);
@@ -1290,7 +1290,7 @@ void DBTDevice::disconnectGATT(const int caller) noexcept {
DBG_PRINT("DBTDevice::disconnectGATT: end");
}
-bool DBTDevice::connectGATT(std::shared_ptr<DBTDevice> sthis) noexcept {
+bool BTDevice::connectGATT(std::shared_ptr<BTDevice> sthis) noexcept {
if( !isConnected || !allowDisconnect) {
ERR_PRINT("DBTDevice::connectGATT: Device not connected: %s", toString(false).c_str());
return false;
@@ -1308,7 +1308,7 @@ bool DBTDevice::connectGATT(std::shared_ptr<DBTDevice> sthis) noexcept {
gattHandler = nullptr;
}
- gattHandler = std::make_shared<GATTHandler>(sthis, l2cap_att);
+ gattHandler = std::make_shared<BTGattHandler>(sthis, l2cap_att);
if( !gattHandler->isConnected() ) {
ERR_PRINT2("DBTDevice::connectGATT: Connection failed");
gattHandler = nullptr;
@@ -1317,18 +1317,18 @@ bool DBTDevice::connectGATT(std::shared_ptr<DBTDevice> sthis) noexcept {
return true;
}
-std::shared_ptr<GATTHandler> DBTDevice::getGATTHandler() noexcept {
+std::shared_ptr<BTGattHandler> BTDevice::getGattHandler() noexcept {
const std::lock_guard<std::recursive_mutex> lock_conn(mtx_gattHandler);
return gattHandler;
}
-jau::darray<std::shared_ptr<GATTService>> DBTDevice::getGATTServices() noexcept {
- std::shared_ptr<GATTHandler> gh = getGATTHandler();
+jau::darray<std::shared_ptr<BTGattService>> BTDevice::getGattServices() noexcept {
+ std::shared_ptr<BTGattHandler> gh = getGattHandler();
if( nullptr == gh ) {
ERR_PRINT("DBTDevice::getGATTServices: GATTHandler nullptr");
- return jau::darray<std::shared_ptr<GATTService>>();
+ return jau::darray<std::shared_ptr<BTGattService>>();
}
- jau::darray<std::shared_ptr<GATTService>> gattServices = gh->getServices();
+ jau::darray<std::shared_ptr<BTGattService>> gattServices = gh->getServices();
if( gattServices.size() > 0 ) { // reuse previous discovery result
return gattServices;
}
@@ -1346,7 +1346,7 @@ jau::darray<std::shared_ptr<GATTService>> DBTDevice::getGATTServices() noexcept
DBG_PRINT("DBTDevice::getGATTServices: updated %s:\n %s\n -> %s",
getEIRDataMaskString(updateMask).c_str(), gattGenericAccess->toString().c_str(), toString(false).c_str());
if( EIRDataType::NONE != updateMask ) {
- std::shared_ptr<DBTDevice> sharedInstance = getSharedInstance();
+ std::shared_ptr<BTDevice> sharedInstance = getSharedInstance();
if( nullptr == sharedInstance ) {
ERR_PRINT("DBTDevice::getGATTServices: Device unknown to adapter and not tracked: %s", toString(false).c_str());
} else {
@@ -1360,11 +1360,11 @@ jau::darray<std::shared_ptr<GATTService>> DBTDevice::getGATTServices() noexcept
return gattServices;
}
-std::shared_ptr<GATTService> DBTDevice::findGATTService(std::shared_ptr<uuid_t> const &uuid) {
- const jau::darray<std::shared_ptr<GATTService>> & gattServices = getGATTServices(); // reference of the GATTHandler's list
+std::shared_ptr<BTGattService> BTDevice::findGattService(std::shared_ptr<uuid_t> const &uuid) {
+ const jau::darray<std::shared_ptr<BTGattService>> & gattServices = getGattServices(); // reference of the GATTHandler's list
const size_t size = gattServices.size();
for (size_t i = 0; i < size; i++) {
- const std::shared_ptr<GATTService> & e = gattServices[i];
+ const std::shared_ptr<BTGattService> & e = gattServices[i];
if ( nullptr != e && *uuid == *(e->type) ) {
return e;
}
@@ -1372,8 +1372,8 @@ std::shared_ptr<GATTService> DBTDevice::findGATTService(std::shared_ptr<uuid_t>
return nullptr;
}
-bool DBTDevice::pingGATT() noexcept {
- std::shared_ptr<GATTHandler> gh = getGATTHandler();
+bool BTDevice::pingGATT() noexcept {
+ std::shared_ptr<BTGattHandler> gh = getGattHandler();
if( nullptr == gh || !gh->isConnected() ) {
jau::INFO_PRINT("DBTDevice::pingGATT: GATTHandler not connected -> disconnected on %s", toString(false).c_str());
disconnect(HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION);
@@ -1387,8 +1387,8 @@ bool DBTDevice::pingGATT() noexcept {
return false;
}
-std::shared_ptr<GattGenericAccessSvc> DBTDevice::getGATTGenericAccess() {
- std::shared_ptr<GATTHandler> gh = getGATTHandler();
+std::shared_ptr<GattGenericAccessSvc> BTDevice::getGattGenericAccess() {
+ std::shared_ptr<BTGattHandler> gh = getGattHandler();
if( nullptr == gh ) {
ERR_PRINT("DBTDevice::getGATTGenericAccess: GATTHandler nullptr");
return nullptr;
@@ -1396,46 +1396,46 @@ std::shared_ptr<GattGenericAccessSvc> DBTDevice::getGATTGenericAccess() {
return gh->getGenericAccess();
}
-bool DBTDevice::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) {
- std::shared_ptr<GATTHandler> gatt = getGATTHandler();
+bool BTDevice::addCharListener(std::shared_ptr<BTGattCharListener> l) {
+ std::shared_ptr<BTGattHandler> gatt = getGattHandler();
if( nullptr == gatt ) {
throw jau::IllegalStateException("Device's GATTHandle not connected: "+
toString(false), E_FILE_LINE);
}
- return gatt->addCharacteristicListener(l);
+ return gatt->addCharListener(l);
}
-bool DBTDevice::removeCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) noexcept {
- std::shared_ptr<GATTHandler> gatt = getGATTHandler();
+bool BTDevice::removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept {
+ std::shared_ptr<BTGattHandler> gatt = getGattHandler();
if( nullptr == gatt ) {
// OK to have GATTHandler being shutdown @ disable
DBG_PRINT("Device's GATTHandle not connected: %s", toString(false).c_str());
return false;
}
- return gatt->removeCharacteristicListener(l);
+ return gatt->removeCharListener(l);
}
-int DBTDevice::removeAllAssociatedCharacteristicListener(std::shared_ptr<GATTCharacteristic> associatedCharacteristic) noexcept {
- std::shared_ptr<GATTHandler> gatt = getGATTHandler();
+int BTDevice::removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedCharacteristic) noexcept {
+ std::shared_ptr<BTGattHandler> gatt = getGattHandler();
if( nullptr == gatt ) {
// OK to have GATTHandler being shutdown @ disable
DBG_PRINT("Device's GATTHandle not connected: %s", toString(false).c_str());
return false;
}
- return gatt->removeAllAssociatedCharacteristicListener( associatedCharacteristic );
+ return gatt->removeAllAssociatedCharListener( associatedCharacteristic );
}
-int DBTDevice::removeAllCharacteristicListener() noexcept {
- std::shared_ptr<GATTHandler> gatt = getGATTHandler();
+int BTDevice::removeAllCharListener() noexcept {
+ std::shared_ptr<BTGattHandler> gatt = getGattHandler();
if( nullptr == gatt ) {
// OK to have GATTHandler being shutdown @ disable
DBG_PRINT("Device's GATTHandle not connected: %s", toString(false).c_str());
return 0;
}
- return gatt->removeAllCharacteristicListener();
+ return gatt->removeAllCharListener();
}
-void DBTDevice::notifyDisconnected() noexcept {
+void BTDevice::notifyDisconnected() noexcept {
// coming from disconnect callback, ensure cleaning up!
DBG_PRINT("DBTDevice::notifyDisconnected: handle %s -> zero, %s",
jau::uint16HexString(hciConnHandle).c_str(), toString(false).c_str());
@@ -1448,11 +1448,11 @@ void DBTDevice::notifyDisconnected() noexcept {
l2cap_att.close();
}
-void DBTDevice::sendMgmtEvDeviceDisconnected(std::unique_ptr<MgmtEvent> evt) noexcept {
+void BTDevice::sendMgmtEvDeviceDisconnected(std::unique_ptr<MgmtEvent> evt) noexcept {
adapter.mgmtEvDeviceDisconnectedHCI(*evt);
}
-HCIStatusCode DBTDevice::disconnect(const HCIStatusCode reason) noexcept {
+HCIStatusCode BTDevice::disconnect(const HCIStatusCode reason) noexcept {
// Avoid disconnect re-entry lock-free
bool expConn = true; // C++11, exp as value since C++20
if( !allowDisconnect.compare_exchange_strong(expConn, false) ) {
@@ -1510,7 +1510,7 @@ exit:
// or in case the hci->disconnect() itself fails,
// send the DISCONN_COMPLETE event directly.
// SEND_EVENT: Perform off-thread to avoid potential deadlock w/ application callbacks (similar when sent from HCIHandler's reader-thread)
- std::thread bg(&DBTDevice::sendMgmtEvDeviceDisconnected, this, // @suppress("Invalid arguments")
+ std::thread bg(&BTDevice::sendMgmtEvDeviceDisconnected, this, // @suppress("Invalid arguments")
std::make_unique<MgmtEvtDeviceDisconnected>(adapter.dev_id, addressAndType, reason, hciConnHandle.load()) );
bg.detach();
// adapter.mgmtEvDeviceDisconnectedHCI( std::unique_ptr<MgmtEvent>( new MgmtEvtDeviceDisconnected(adapter.dev_id, address, addressType, reason, hciConnHandle.load()) ) );
@@ -1523,7 +1523,7 @@ exit:
return res;
}
-HCIStatusCode DBTDevice::unpair() noexcept {
+HCIStatusCode BTDevice::unpair() noexcept {
#if USE_LINUX_BT_SECURITY
const MgmtStatus res = adapter.getManager().unpairDevice(adapter.dev_id, addressAndType, false /* disconnect */);
clearSMPStates(false /* connected */);
@@ -1535,7 +1535,7 @@ HCIStatusCode DBTDevice::unpair() noexcept {
#endif
}
-void DBTDevice::remove() noexcept {
+void BTDevice::remove() noexcept {
clearSMPStates(false /* connected */);
adapter.removeDevice(*this);
}
diff --git a/src/direct_bt/GATTCharacteristic.cpp b/src/direct_bt/BTGattChar.cpp
index 4e200204..85108210 100644
--- a/src/direct_bt/GATTCharacteristic.cpp
+++ b/src/direct_bt/BTGattChar.cpp
@@ -23,6 +23,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTDevice.hpp>
+#include <BTGattChar.hpp>
+#include <BTGattHandler.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -34,9 +37,6 @@
#include <jau/debug.hpp>
-#include "GATTCharacteristic.hpp"
-#include "GATTHandler.hpp"
-#include "DBTDevice.hpp"
using namespace direct_bt;
using namespace jau;
@@ -65,7 +65,7 @@ using namespace jau;
#define CASE_TO_STRING2(V,S) case V: return #S;
-std::string GATTCharacteristic::getPropertyString(const PropertyBitVal prop) noexcept {
+std::string BTGattChar::getPropertyString(const PropertyBitVal prop) noexcept {
switch(prop) {
CHAR_DECL_PROPS_ENUM(CASE_TO_STRING2)
default: ; // fall through intended
@@ -73,7 +73,7 @@ std::string GATTCharacteristic::getPropertyString(const PropertyBitVal prop) noe
return "Unknown property";
}
-std::string GATTCharacteristic::getPropertiesString(const PropertyBitVal properties) noexcept {
+std::string BTGattChar::getPropertiesString(const PropertyBitVal properties) noexcept {
const PropertyBitVal none = static_cast<PropertyBitVal>(0);
const uint8_t one = 1;
bool has_pre = false;
@@ -90,7 +90,7 @@ std::string GATTCharacteristic::getPropertiesString(const PropertyBitVal propert
return out;
}
-jau::darray<std::unique_ptr<std::string>> GATTCharacteristic::getPropertiesStringList(const PropertyBitVal properties) noexcept {
+jau::darray<std::unique_ptr<std::string>> BTGattChar::getPropertiesStringList(const PropertyBitVal properties) noexcept {
jau::darray<std::unique_ptr<std::string>> out;
const PropertyBitVal none = static_cast<PropertyBitVal>(0);
const uint8_t one = 1;
@@ -103,9 +103,9 @@ jau::darray<std::unique_ptr<std::string>> GATTCharacteristic::getPropertiesStrin
return out;
}
-std::string GATTCharacteristic::toString() const noexcept {
+std::string BTGattChar::toString() const noexcept {
uint16_t service_handle_end = 0xffff;
- GATTServiceRef serviceRef = getServiceUnchecked();
+ BTGattServiceRef serviceRef = getServiceUnchecked();
std::string service_uuid_str = "";
std::string service_name = "";
std::string char_name = "";
@@ -126,7 +126,7 @@ std::string GATTCharacteristic::toString() const noexcept {
char_name = ", "+GattCharacteristicTypeToString(static_cast<GattCharacteristicType>(uuid16));
}
for(size_t i=0; i<descriptorList.size(); i++) {
- const GATTDescriptorRef cd = descriptorList[i];
+ const BTGattDescRef cd = descriptorList[i];
desc_str += cd->toString() + ", ";
}
desc_str += " ]";
@@ -137,7 +137,7 @@ std::string GATTCharacteristic::toString() const noexcept {
service_name+", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"] ] ]";
}
-std::string GATTCharacteristic::toShortString() const noexcept {
+std::string BTGattChar::toShortString() const noexcept {
std::string char_name = "";
if( uuid_t::TypeSize::UUID16_SZ == value_type->getTypeSize() ) {
@@ -151,51 +151,51 @@ std::string GATTCharacteristic::toShortString() const noexcept {
", enabled[notify "+std::to_string(enabledNotifyState)+", indicate "+std::to_string(enabledIndicateState)+"] ] ]";
}
-std::shared_ptr<GATTService> GATTCharacteristic::getServiceChecked() const {
- std::shared_ptr<GATTService> ref = wbr_service.lock();
+std::shared_ptr<BTGattService> BTGattChar::getServiceChecked() const {
+ std::shared_ptr<BTGattService> ref = wbr_service.lock();
if( nullptr == ref ) {
throw IllegalStateException("GATTCharacteristic's service already destructed: "+toShortString(), E_FILE_LINE);
}
return ref;
}
-std::shared_ptr<GATTHandler> GATTCharacteristic::getGATTHandlerUnchecked() const noexcept {
- std::shared_ptr<GATTService> s = getServiceUnchecked();
+std::shared_ptr<BTGattHandler> BTGattChar::getGattHandlerUnchecked() const noexcept {
+ std::shared_ptr<BTGattService> s = getServiceUnchecked();
if( nullptr != s ) {
- return s->getGATTHandlerUnchecked();
+ return s->getGattHandlerUnchecked();
}
return nullptr;
}
-std::shared_ptr<GATTHandler> GATTCharacteristic::getGATTHandlerChecked() const {
- return getServiceChecked()->getGATTHandlerChecked();
+std::shared_ptr<BTGattHandler> BTGattChar::getGattHandlerChecked() const {
+ return getServiceChecked()->getGattHandlerChecked();
}
-std::shared_ptr<DBTDevice> GATTCharacteristic::getDeviceUnchecked() const noexcept {
- std::shared_ptr<GATTService> s = getServiceUnchecked();
+std::shared_ptr<BTDevice> BTGattChar::getDeviceUnchecked() const noexcept {
+ std::shared_ptr<BTGattService> s = getServiceUnchecked();
if( nullptr != s ) {
return s->getDeviceUnchecked();
}
return nullptr;
}
-std::shared_ptr<DBTDevice> GATTCharacteristic::getDeviceChecked() const {
+std::shared_ptr<BTDevice> BTGattChar::getDeviceChecked() const {
return getServiceChecked()->getDeviceChecked();
}
-bool GATTCharacteristic::configNotificationIndication(const bool enableNotification, const bool enableIndication, bool enabledState[2]) {
+bool BTGattChar::configNotificationIndication(const bool enableNotification, const bool enableIndication, bool enabledState[2]) {
enabledState[0] = false;
enabledState[1] = false;
- const bool hasEnableNotification = hasProperties(GATTCharacteristic::PropertyBitVal::Notify);
- const bool hasEnableIndication = hasProperties(GATTCharacteristic::PropertyBitVal::Indicate);
+ const bool hasEnableNotification = hasProperties(BTGattChar::PropertyBitVal::Notify);
+ const bool hasEnableIndication = hasProperties(BTGattChar::PropertyBitVal::Indicate);
if( !hasEnableNotification && !hasEnableIndication ) {
DBG_PRINT("Characteristic has neither Notify nor Indicate property present: %s", toString().c_str());
return false;
}
- std::shared_ptr<DBTDevice> device = getDeviceUnchecked();
- std::shared_ptr<GATTHandler> gatt = nullptr != device ? device->getGATTHandler() : nullptr;
+ std::shared_ptr<BTDevice> device = getDeviceUnchecked();
+ std::shared_ptr<BTGattHandler> gatt = nullptr != device ? device->getGattHandler() : nullptr;
if( nullptr == gatt ) {
if( !enableNotification && !enableIndication ) {
// OK to have GATTHandler being shutdown @ disable
@@ -219,7 +219,7 @@ bool GATTCharacteristic::configNotificationIndication(const bool enableNotificat
return true;
}
- GATTDescriptorRef cccd = this->getClientCharacteristicConfig();
+ BTGattDescRef cccd = this->getClientCharConfig();
if( nullptr == cccd ) {
DBG_PRINT("Characteristic has no ClientCharacteristicConfig descriptor: %s", toString().c_str());
return false;
@@ -238,9 +238,9 @@ bool GATTCharacteristic::configNotificationIndication(const bool enableNotificat
return res;
}
-bool GATTCharacteristic::enableNotificationOrIndication(bool enabledState[2]) {
- const bool hasEnableNotification = hasProperties(GATTCharacteristic::PropertyBitVal::Notify);
- const bool hasEnableIndication = hasProperties(GATTCharacteristic::PropertyBitVal::Indicate);
+bool BTGattChar::enableNotificationOrIndication(bool enabledState[2]) {
+ const bool hasEnableNotification = hasProperties(BTGattChar::PropertyBitVal::Notify);
+ const bool hasEnableIndication = hasProperties(BTGattChar::PropertyBitVal::Indicate);
const bool enableNotification = hasEnableNotification;
const bool enableIndication = !enableNotification && hasEnableIndication;
@@ -248,36 +248,36 @@ bool GATTCharacteristic::enableNotificationOrIndication(bool enabledState[2]) {
return configNotificationIndication(enableNotification, enableIndication, enabledState);
}
-bool GATTCharacteristic::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) {
- return getDeviceChecked()->addCharacteristicListener(l);
+bool BTGattChar::addCharListener(std::shared_ptr<BTGattCharListener> l) {
+ return getDeviceChecked()->addCharListener(l);
}
-bool GATTCharacteristic::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l, bool enabledState[2]) {
+bool BTGattChar::addCharListener(std::shared_ptr<BTGattCharListener> l, bool enabledState[2]) {
if( !enableNotificationOrIndication(enabledState) ) {
return false;
}
- return addCharacteristicListener(l);
+ return addCharListener(l);
}
-bool GATTCharacteristic::removeCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l, bool disableIndicationNotification) {
+bool BTGattChar::removeCharListener(std::shared_ptr<BTGattCharListener> l, bool disableIndicationNotification) {
if( disableIndicationNotification ) {
bool enabledState[2];
configNotificationIndication(false, false, enabledState);
}
- return getDeviceChecked()->removeCharacteristicListener(l);
+ return getDeviceChecked()->removeCharListener(l);
}
-int GATTCharacteristic::removeAllCharacteristicListener(bool disableIndicationNotification) {
+int BTGattChar::removeAllCharListener(bool disableIndicationNotification) {
if( disableIndicationNotification ) {
bool enabledState[2];
configNotificationIndication(false, false, enabledState);
}
- return getDeviceChecked()->removeAllCharacteristicListener();
+ return getDeviceChecked()->removeAllCharListener();
}
-bool GATTCharacteristic::readValue(POctets & res, int expectedLength) {
- std::shared_ptr<DBTDevice> device = getDeviceChecked();
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+bool BTGattChar::readValue(POctets & res, int expectedLength) {
+ std::shared_ptr<BTDevice> device = getDeviceChecked();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
throw IllegalStateException("Characteristic's device GATTHandle not connected: "+toShortString(), E_FILE_LINE);
}
@@ -286,9 +286,9 @@ bool GATTCharacteristic::readValue(POctets & res, int expectedLength) {
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value
*/
-bool GATTCharacteristic::writeValue(const TROOctets & value) {
- std::shared_ptr<DBTDevice> device = getDeviceChecked();
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+bool BTGattChar::writeValue(const TROOctets & value) {
+ std::shared_ptr<BTDevice> device = getDeviceChecked();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
throw IllegalStateException("Characteristic's device GATTHandle not connected: "+toShortString(), E_FILE_LINE);
}
@@ -298,9 +298,9 @@ bool GATTCharacteristic::writeValue(const TROOctets & value) {
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response
*/
-bool GATTCharacteristic::writeValueNoResp(const TROOctets & value) {
- std::shared_ptr<DBTDevice> device = getDeviceChecked();
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+bool BTGattChar::writeValueNoResp(const TROOctets & value) {
+ std::shared_ptr<BTDevice> device = getDeviceChecked();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
throw IllegalStateException("Characteristic's device GATTHandle not connected: "+toShortString(), E_FILE_LINE);
}
diff --git a/src/direct_bt/GATTDescriptor.cpp b/src/direct_bt/BTGattDesc.cpp
index 9e6e5135..31fd2764 100644
--- a/src/direct_bt/GATTDescriptor.cpp
+++ b/src/direct_bt/BTGattDesc.cpp
@@ -23,6 +23,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTDevice.hpp>
+#include <BTGattDesc.hpp>
+#include <BTGattHandler.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -34,55 +37,52 @@
#include <jau/debug.hpp>
-#include "GATTDescriptor.hpp"
-#include "GATTHandler.hpp"
-#include "DBTDevice.hpp"
using namespace direct_bt;
using namespace jau;
-const uuid16_t GATTDescriptor::TYPE_EXT_PROP(Type::CHARACTERISTIC_EXTENDED_PROPERTIES);
-const uuid16_t GATTDescriptor::TYPE_USER_DESC(Type::CHARACTERISTIC_USER_DESCRIPTION);
-const uuid16_t GATTDescriptor::TYPE_CCC_DESC(Type::CLIENT_CHARACTERISTIC_CONFIGURATION);
+const uuid16_t BTGattDesc::TYPE_EXT_PROP(Type::CHARACTERISTIC_EXTENDED_PROPERTIES);
+const uuid16_t BTGattDesc::TYPE_USER_DESC(Type::CHARACTERISTIC_USER_DESCRIPTION);
+const uuid16_t BTGattDesc::TYPE_CCC_DESC(Type::CLIENT_CHARACTERISTIC_CONFIGURATION);
-std::shared_ptr<GATTCharacteristic> GATTDescriptor::getCharacteristicChecked() const {
- std::shared_ptr<GATTCharacteristic> ref = wbr_characteristic.lock();
+std::shared_ptr<BTGattChar> BTGattDesc::getGattCharChecked() const {
+ std::shared_ptr<BTGattChar> ref = wbr_char.lock();
if( nullptr == ref ) {
throw IllegalStateException("GATTDescriptor's characteristic already destructed: "+toShortString(), E_FILE_LINE);
}
return ref;
}
-std::shared_ptr<GATTHandler> GATTDescriptor::getGATTHandlerChecked() const {
- return getCharacteristicChecked()->getGATTHandlerChecked();
+std::shared_ptr<BTGattHandler> BTGattDesc::getGattHandlerChecked() const {
+ return getGattCharChecked()->getGattHandlerChecked();
}
-std::shared_ptr<DBTDevice> GATTDescriptor::getDeviceChecked() const {
- return getCharacteristicChecked()->getDeviceChecked();
+std::shared_ptr<BTDevice> BTGattDesc::getDeviceChecked() const {
+ return getGattCharChecked()->getDeviceChecked();
}
-bool GATTDescriptor::readValue(int expectedLength) {
- std::shared_ptr<DBTDevice> device = getDeviceChecked();
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+bool BTGattDesc::readValue(int expectedLength) {
+ std::shared_ptr<BTDevice> device = getDeviceChecked();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
throw IllegalStateException("Descriptor's device GATTHandle not connected: "+toShortString(), E_FILE_LINE);
}
return gatt->readDescriptorValue(*this, expectedLength);
}
-bool GATTDescriptor::writeValue() {
- std::shared_ptr<DBTDevice> device = getDeviceChecked();
- std::shared_ptr<GATTHandler> gatt = device->getGATTHandler();
+bool BTGattDesc::writeValue() {
+ std::shared_ptr<BTDevice> device = getDeviceChecked();
+ std::shared_ptr<BTGattHandler> gatt = device->getGattHandler();
if( nullptr == gatt ) {
throw IllegalStateException("Descriptor's device GATTHandle not connected: "+toShortString(), E_FILE_LINE);
}
return gatt->writeDescriptorValue(*this);
}
-std::string GATTDescriptor::toString() const noexcept {
+std::string BTGattDesc::toString() const noexcept {
return "[type 0x"+type->toString()+", handle "+uint16HexString(handle)+", value["+value.toString()+"] ]";
}
-std::string GATTDescriptor::toShortString() const noexcept {
+std::string BTGattDesc::toShortString() const noexcept {
return "[handle "+uint16HexString(handle)+", value["+value.toString()+"] ]";
}
diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/BTGattHandler.cpp
index 9ffbad42..215ca165 100644
--- a/src/direct_bt/GATTHandler.cpp
+++ b/src/direct_bt/BTGattHandler.cpp
@@ -48,19 +48,19 @@ extern "C" {
#include <jau/basic_algos.hpp>
#include "L2CAPIoctl.hpp"
-#include "GATTNumbers.hpp"
+#include "GattNumbers.hpp"
-#include "GATTHandler.hpp"
+#include <BTGattHandler.hpp>
-#include "DBTDevice.hpp"
+#include <BTDevice.hpp>
-#include "DBTManager.hpp"
-#include "DBTAdapter.hpp"
-#include "DBTManager.hpp"
+#include <BTManager.hpp>
+#include <BTAdapter.hpp>
+#include <BTManager.hpp>
using namespace direct_bt;
-GATTEnv::GATTEnv() noexcept
+BTGattEnv::BTGattEnv() noexcept
: exploding( jau::environment::getExplodingProperties("direct_bt.gatt") ),
GATT_READ_COMMAND_REPLY_TIMEOUT( jau::environment::getInt32Property("direct_bt.gatt.cmd.read.timeout", 500, 250 /* min */, INT32_MAX /* max */) ),
GATT_WRITE_COMMAND_REPLY_TIMEOUT( jau::environment::getInt32Property("direct_bt.gatt.cmd.write.timeout", 500, 250 /* min */, INT32_MAX /* max */) ),
@@ -72,15 +72,15 @@ GATTEnv::GATTEnv() noexcept
#define CASE_TO_STRING(V) case V: return #V;
-std::shared_ptr<DBTDevice> GATTHandler::getDeviceChecked() const {
- std::shared_ptr<DBTDevice> ref = wbr_device.lock();
+std::shared_ptr<BTDevice> BTGattHandler::getDeviceChecked() const {
+ std::shared_ptr<BTDevice> ref = wbr_device.lock();
if( nullptr == ref ) {
throw jau::IllegalStateException("GATTHandler's device already destructed: "+deviceString, E_FILE_LINE);
}
return ref;
}
-bool GATTHandler::validateConnected() noexcept {
+bool BTGattHandler::validateConnected() noexcept {
bool l2capIsConnected = l2cap.isOpen();
bool l2capHasIOError = l2cap.hasIOError();
@@ -99,17 +99,17 @@ bool GATTHandler::validateConnected() noexcept {
return true;
}
-static jau::cow_darray<std::shared_ptr<GATTCharacteristicListener>>::equal_comparator _characteristicListenerRefEqComparator =
- [](const std::shared_ptr<GATTCharacteristicListener> &a, const std::shared_ptr<GATTCharacteristicListener> &b) -> bool { return *a == *b; };
+static jau::cow_darray<std::shared_ptr<BTGattCharListener>>::equal_comparator _characteristicListenerRefEqComparator =
+ [](const std::shared_ptr<BTGattCharListener> &a, const std::shared_ptr<BTGattCharListener> &b) -> bool { return *a == *b; };
-bool GATTHandler::addCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) {
+bool BTGattHandler::addCharListener(std::shared_ptr<BTGattCharListener> l) {
if( nullptr == l ) {
throw jau::IllegalArgumentException("GATTEventListener ref is null", E_FILE_LINE);
}
return characteristicListenerList.push_back_unique(l, _characteristicListenerRefEqComparator);
}
-bool GATTHandler::removeCharacteristicListener(std::shared_ptr<GATTCharacteristicListener> l) noexcept {
+bool BTGattHandler::removeCharListener(std::shared_ptr<BTGattCharListener> l) noexcept {
if( nullptr == l ) {
ERR_PRINT("Given GATTCharacteristicListener ref is null");
return false;
@@ -118,7 +118,7 @@ bool GATTHandler::removeCharacteristicListener(std::shared_ptr<GATTCharacteristi
return count > 0;
}
-bool GATTHandler::removeCharacteristicListener(const GATTCharacteristicListener * l) noexcept {
+bool BTGattHandler::removeCharListener(const BTGattCharListener * l) noexcept {
if( nullptr == l ) {
ERR_PRINT("Given GATTCharacteristicListener ref is null");
return false;
@@ -134,15 +134,15 @@ bool GATTHandler::removeCharacteristicListener(const GATTCharacteristicListener
return false;
}
-int GATTHandler::removeAllAssociatedCharacteristicListener(std::shared_ptr<GATTCharacteristic> associatedCharacteristic) noexcept {
+int BTGattHandler::removeAllAssociatedCharListener(std::shared_ptr<BTGattChar> associatedCharacteristic) noexcept {
if( nullptr == associatedCharacteristic ) {
ERR_PRINT("Given GATTCharacteristic ref is null");
return false;
}
- return removeAllAssociatedCharacteristicListener( associatedCharacteristic.get() );
+ return removeAllAssociatedCharListener( associatedCharacteristic.get() );
}
-int GATTHandler::removeAllAssociatedCharacteristicListener(const GATTCharacteristic * associatedCharacteristic) noexcept {
+int BTGattHandler::removeAllAssociatedCharListener(const BTGattChar * associatedCharacteristic) noexcept {
if( nullptr == associatedCharacteristic ) {
ERR_PRINT("Given GATTCharacteristic ref is null");
return false;
@@ -163,21 +163,21 @@ int GATTHandler::removeAllAssociatedCharacteristicListener(const GATTCharacteris
return count;
}
-int GATTHandler::removeAllCharacteristicListener() noexcept {
+int BTGattHandler::removeAllCharListener() noexcept {
int count = characteristicListenerList.size();
characteristicListenerList.clear();
return count;
}
-void GATTHandler::setSendIndicationConfirmation(const bool v) {
+void BTGattHandler::setSendIndicationConfirmation(const bool v) {
sendIndicationConfirmation = v;
}
-bool GATTHandler::getSendIndicationConfirmation() noexcept {
+bool BTGattHandler::getSendIndicationConfirmation() noexcept {
return sendIndicationConfirmation;
}
-void GATTHandler::l2capReaderThreadImpl() {
+void BTGattHandler::l2capReaderThreadImpl() {
{
const std::lock_guard<std::mutex> lock(mtx_l2capReaderLifecycle); // RAII-style acquire and relinquish via destructor
l2capReaderShallStop = false;
@@ -206,13 +206,13 @@ void GATTHandler::l2capReaderThreadImpl() {
if( AttPDUMsg::Opcode::HANDLE_VALUE_NTF == opc ) {
const AttHandleValueRcv * a = static_cast<const AttHandleValueRcv*>(attPDU.get());
COND_PRINT(env.DEBUG_DATA, "GATTHandler::reader: NTF: %s, listener %zd", a->toString().c_str(), characteristicListenerList.size());
- GATTCharacteristicRef decl = findCharacterisicsByValueHandle(a->getHandle());
+ BTGattCharRef decl = findCharacterisicsByValueHandle(a->getHandle());
const TOctetSlice& a_value_view = a->getValue();
const TROOctets data_view(a_value_view.get_ptr_nc(0), a_value_view.getSize()); // just a view, still owned by attPDU
// const std::shared_ptr<TROOctets> data( std::make_shared<POctets>(a->getValue()) );
const uint64_t timestamp = a->ts_creation;
int i=0;
- jau::for_each_fidelity(characteristicListenerList, [&](std::shared_ptr<GATTCharacteristicListener> &l) {
+ jau::for_each_fidelity(characteristicListenerList, [&](std::shared_ptr<BTGattCharListener> &l) {
try {
if( l->match(*decl) ) {
l->notificationReceived(decl, data_view, timestamp);
@@ -234,13 +234,13 @@ void GATTHandler::l2capReaderThreadImpl() {
send(cfm);
cfmSent = true;
}
- GATTCharacteristicRef decl = findCharacterisicsByValueHandle(a->getHandle());
+ BTGattCharRef decl = findCharacterisicsByValueHandle(a->getHandle());
const TOctetSlice& a_value_view = a->getValue();
const TROOctets data_view(a_value_view.get_ptr_nc(0), a_value_view.getSize()); // just a view, still owned by attPDU
// const std::shared_ptr<TROOctets> data( std::make_shared<POctets>(a->getValue()) );
const uint64_t timestamp = a->ts_creation;
int i=0;
- jau::for_each_fidelity(characteristicListenerList, [&](std::shared_ptr<GATTCharacteristicListener> &l) {
+ jau::for_each_fidelity(characteristicListenerList, [&](std::shared_ptr<BTGattCharListener> &l) {
try {
if( l->match(*decl) ) {
l->indicationReceived(decl, data_view, timestamp, cfmSent);
@@ -274,8 +274,8 @@ void GATTHandler::l2capReaderThreadImpl() {
disconnect(true /* disconnectDevice */, has_ioerror);
}
-GATTHandler::GATTHandler(const std::shared_ptr<DBTDevice> &device, L2CAPComm& l2cap_att) noexcept
-: env(GATTEnv::get()),
+BTGattHandler::BTGattHandler(const std::shared_ptr<BTDevice> &device, L2CAPComm& l2cap_att) noexcept
+: env(BTGattEnv::get()),
wbr_device(device),
l2cap(l2cap_att),
deviceString(device->getAddressAndType().toString()),
@@ -300,7 +300,7 @@ GATTHandler::GATTHandler(const std::shared_ptr<DBTDevice> &device, L2CAPComm& l2
{
std::unique_lock<std::mutex> lock(mtx_l2capReaderLifecycle); // RAII-style acquire and relinquish via destructor
- std::thread l2capReaderThread(&GATTHandler::l2capReaderThreadImpl, this); // @suppress("Invalid arguments")
+ std::thread l2capReaderThread(&BTGattHandler::l2capReaderThreadImpl, this); // @suppress("Invalid arguments")
l2capReaderThreadId = l2capReaderThread.native_handle();
// Avoid 'terminate called without an active exception'
// as l2capReaderThread may end due to I/O errors.
@@ -331,14 +331,14 @@ GATTHandler::GATTHandler(const std::shared_ptr<DBTDevice> &device, L2CAPComm& l2
}
}
-GATTHandler::~GATTHandler() noexcept {
+BTGattHandler::~BTGattHandler() noexcept {
disconnect(false /* disconnectDevice */, false /* ioErrorCause */);
characteristicListenerList.clear();
services.clear();
genericAccess = nullptr;
}
-bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCause) noexcept {
+bool BTGattHandler::disconnect(const bool disconnectDevice, const bool ioErrorCause) noexcept {
PERF3_TS_T0();
// Interrupt GATT's L2CAP::connect(..) and L2CAP::read(..), avoiding prolonged hang
// and pull all underlying l2cap read operations!
@@ -387,7 +387,7 @@ bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCaus
PERF3_TS_TD("GATTHandler::disconnect.2");
if( disconnectDevice ) {
- std::shared_ptr<DBTDevice> device = getDeviceUnchecked();
+ std::shared_ptr<BTDevice> device = getDeviceUnchecked();
if( nullptr != device ) {
// Cleanup device resources, proper connection state
// Intentionally giving the POWER_OFF reason for the device in case of ioErrorCause!
@@ -403,7 +403,7 @@ bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCaus
return true;
}
-void GATTHandler::send(const AttPDUMsg & msg) {
+void BTGattHandler::send(const AttPDUMsg & msg) {
if( !validateConnected() ) {
throw jau::IllegalStateException("GATTHandler::send: Invalid IO State: req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
}
@@ -418,19 +418,19 @@ void GATTHandler::send(const AttPDUMsg & msg) {
IRQ_PRINT("GATTHandler::send: l2cap write error -> disconnect: %s to %s", msg.toString().c_str(), deviceString.c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */); // state -> Disconnected
- throw BluetoothException("GATTHandler::send: l2cap write error: req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
+ throw BTException("GATTHandler::send: l2cap write error: req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
}
if( static_cast<size_t>(res) != msg.pdu.getSize() ) {
ERR_PRINT("GATTHandler::send: l2cap write count error, %zd != %zu: %s -> disconnect: %s",
res, msg.pdu.getSize(), msg.toString().c_str(), deviceString.c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */); // state -> Disconnected
- throw BluetoothException("GATTHandler::send: l2cap write count error, "+std::to_string(res)+" != "+std::to_string(res)
+ throw BTException("GATTHandler::send: l2cap write count error, "+std::to_string(res)+" != "+std::to_string(res)
+": "+msg.toString()+" -> disconnect: "+deviceString, E_FILE_LINE);
}
}
-std::unique_ptr<const AttPDUMsg> GATTHandler::sendWithReply(const AttPDUMsg & msg, const int timeout) {
+std::unique_ptr<const AttPDUMsg> BTGattHandler::sendWithReply(const AttPDUMsg & msg, const int timeout) {
send( msg );
// Ringbuffer read is thread safe
@@ -440,12 +440,12 @@ std::unique_ptr<const AttPDUMsg> GATTHandler::sendWithReply(const AttPDUMsg & ms
IRQ_PRINT("GATTHandler::sendWithReply: nullptr result (timeout %d): req %s to %s", timeout, msg.toString().c_str(), deviceString.c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */);
- throw BluetoothException("GATTHandler::sendWithReply: nullptr result (timeout "+std::to_string(timeout)+"): req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
+ throw BTException("GATTHandler::sendWithReply: nullptr result (timeout "+std::to_string(timeout)+"): req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
}
return res;
}
-uint16_t GATTHandler::exchangeMTUImpl(const uint16_t clientMaxMTU, const int32_t timeout) {
+uint16_t BTGattHandler::exchangeMTUImpl(const uint16_t clientMaxMTU, const int32_t timeout) {
/***
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.3.1 Exchange MTU (Server configuration)
*/
@@ -486,13 +486,13 @@ uint16_t GATTHandler::exchangeMTUImpl(const uint16_t clientMaxMTU, const int32_t
return mtu;
}
-GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle) noexcept {
+BTGattCharRef BTGattHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle) noexcept {
return findCharacterisicsByValueHandle(charValueHandle, services);
}
-GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle, jau::darray<GATTServiceRef> &services_) noexcept {
+BTGattCharRef BTGattHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle, jau::darray<BTGattServiceRef> &services_) noexcept {
for(auto it = services_.begin(); it != services_.end(); it++) {
- GATTCharacteristicRef decl = findCharacterisicsByValueHandle(charValueHandle, *it);
+ BTGattCharRef decl = findCharacterisicsByValueHandle(charValueHandle, *it);
if( nullptr != decl ) {
return decl;
}
@@ -500,9 +500,9 @@ GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_
return nullptr;
}
-GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle, GATTServiceRef service) noexcept {
+BTGattCharRef BTGattHandler::findCharacterisicsByValueHandle(const uint16_t charValueHandle, BTGattServiceRef service) noexcept {
for(auto it = service->characteristicList.begin(); it != service->characteristicList.end(); it++) {
- GATTCharacteristicRef decl = *it;
+ BTGattCharRef decl = *it;
if( charValueHandle == decl->value_handle ) {
return decl;
}
@@ -510,13 +510,13 @@ GATTCharacteristicRef GATTHandler::findCharacterisicsByValueHandle(const uint16_
return nullptr;
}
-jau::darray<GATTServiceRef> & GATTHandler::discoverCompletePrimaryServices(std::shared_ptr<GATTHandler> shared_this) {
+jau::darray<BTGattServiceRef> & BTGattHandler::discoverCompletePrimaryServices(std::shared_ptr<BTGattHandler> shared_this) {
const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor
if( !discoverPrimaryServices(shared_this, services) ) {
return services;
}
for(auto it = services.begin(); it != services.end(); it++) {
- GATTServiceRef primSrv = *it;
+ BTGattServiceRef primSrv = *it;
if( discoverCharacteristics(primSrv) ) {
discoverDescriptors(primSrv);
}
@@ -525,10 +525,10 @@ jau::darray<GATTServiceRef> & GATTHandler::discoverCompletePrimaryServices(std::
return services;
}
-bool GATTHandler::discoverPrimaryServices(std::shared_ptr<GATTHandler> shared_this, jau::darray<GATTServiceRef> & result) {
+bool BTGattHandler::discoverPrimaryServices(std::shared_ptr<BTGattHandler> shared_this, jau::darray<BTGattServiceRef> & result) {
{
// validate shared_this first!
- GATTHandler *given_this = shared_this.get();
+ BTGattHandler *given_this = shared_this.get();
if( given_this != this ) {
throw jau::IllegalArgumentException("Given shared GATTHandler reference "+
jau::aptrHexString(given_this)+" not matching this "+jau::aptrHexString(this), E_FILE_LINE);
@@ -562,7 +562,7 @@ bool GATTHandler::discoverPrimaryServices(std::shared_ptr<GATTHandler> shared_th
for(int i=0; i<count; i++) {
const int ePDUOffset = p->getElementPDUOffset(i);
const int esz = p->getElementTotalSize();
- result.push_back( GATTServiceRef( new GATTService( shared_this, true,
+ result.push_back( BTGattServiceRef( new BTGattService( shared_this, true,
p->pdu.get_uint16(ePDUOffset), // start-handle
p->pdu.get_uint16(ePDUOffset + 2), // end-handle
p->pdu.get_uuid( ePDUOffset + 2 + 2, uuid_t::toTypeSize(esz-2-2) ) // uuid
@@ -589,7 +589,7 @@ bool GATTHandler::discoverPrimaryServices(std::shared_ptr<GATTHandler> shared_th
return result.size() > 0;
}
-bool GATTHandler::discoverCharacteristics(GATTServiceRef & service) {
+bool BTGattHandler::discoverCharacteristics(BTGattServiceRef & service) {
/***
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.6.1 Discover All Characteristics of a Service
* <p>
@@ -624,11 +624,11 @@ bool GATTHandler::discoverCharacteristics(GATTServiceRef & service) {
// value: Characteristics Property, Characteristics Value Handle _and_ Characteristics UUID
const int ePDUOffset = p->getElementPDUOffset(e_iter);
const int esz = p->getElementTotalSize();
- service->characteristicList.push_back( GATTCharacteristicRef( new GATTCharacteristic(
+ service->characteristicList.push_back( BTGattCharRef( new BTGattChar(
service,
p->pdu.get_uint16(ePDUOffset), // Characteristics's Service Handle
p->getElementHandle(e_iter), // Characteristic Handle
- static_cast<GATTCharacteristic::PropertyBitVal>(p->pdu.get_uint8(ePDUOffset + 2)), // Characteristics Property
+ static_cast<BTGattChar::PropertyBitVal>(p->pdu.get_uint8(ePDUOffset + 2)), // Characteristics Property
p->pdu.get_uint16(ePDUOffset + 2 + 1), // Characteristics Value Handle
p->pdu.get_uuid(ePDUOffset + 2 + 1 + 2, uuid_t::toTypeSize(esz-2-1-2) ) ) ) ); // Characteristics Value Type UUID
COND_PRINT(env.DEBUG_DATA, "GATT C discovered[%d/%d]: char%s on %s", e_iter, e_count,
@@ -654,7 +654,7 @@ bool GATTHandler::discoverCharacteristics(GATTServiceRef & service) {
return service->characteristicList.size() > 0;
}
-bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
+bool BTGattHandler::discoverDescriptors(BTGattServiceRef & service) {
/***
* BT Core Spec v5.2: Vol 3, Part G GATT: 4.7.1 Discover All Characteristic Descriptors
* <p>
@@ -668,7 +668,7 @@ bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
bool done=false;
const int charCount = service->characteristicList.size();
for(int charIter=0; !done && charIter < charCount; charIter++ ) {
- GATTCharacteristicRef charDecl = service->characteristicList[charIter];
+ BTGattCharRef charDecl = service->characteristicList[charIter];
charDecl->clearDescriptors();
COND_PRINT(env.DEBUG_DATA, "GATT discoverDescriptors Characteristic[%d/%d]: %s on %s", charIter, charCount, charDecl->toString().c_str(), deviceString.c_str());
@@ -697,7 +697,7 @@ bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
const uint16_t cd_handle = p->getElementHandle(e_iter);
std::unique_ptr<const uuid_t> cd_uuid = p->getElementValue(e_iter);
- std::shared_ptr<GATTDescriptor> cd( std::make_shared<GATTDescriptor>(charDecl, std::move(cd_uuid), cd_handle) );
+ std::shared_ptr<BTGattDesc> cd( std::make_shared<BTGattDesc>(charDecl, std::move(cd_uuid), cd_handle) );
if( cd_handle <= charDecl->value_handle || cd_handle > cd_handle_end ) { // should never happen!
ERR_PRINT("GATT discoverDescriptors CD handle %s not in range ]%s..%s]: descr%s within char%s on %s",
jau::uint16HexString(cd_handle).c_str(),
@@ -713,8 +713,8 @@ bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
done = true;
break;
}
- if( cd->isClientCharacteristicConfiguration() ) {
- charDecl->clientCharacteristicsConfigIndex = charDecl->descriptorList.size();
+ if( cd->isClientCharConfig() ) {
+ charDecl->clientCharConfigIndex = charDecl->descriptorList.size();
}
charDecl->descriptorList.push_back(cd);
COND_PRINT(env.DEBUG_DATA, "GATT CD discovered[%d/%d]: %s", e_iter, e_count, cd->toString().c_str());
@@ -739,17 +739,17 @@ bool GATTHandler::discoverDescriptors(GATTServiceRef & service) {
return service->characteristicList.size() > 0;
}
-bool GATTHandler::readDescriptorValue(GATTDescriptor & desc, int expectedLength) {
+bool BTGattHandler::readDescriptorValue(BTGattDesc & desc, int expectedLength) {
COND_PRINT(env.DEBUG_DATA, "GATTHandler::readDescriptorValue expLen %d, desc %s", expectedLength, desc.toString().c_str());
const bool res = readValue(desc.handle, desc.value, expectedLength);
if( !res ) {
WORDY_PRINT("GATT readDescriptorValue error on desc%s within char%s from %s",
- desc.toString().c_str(), desc.getCharacteristicChecked()->toString().c_str(), deviceString.c_str());
+ desc.toString().c_str(), desc.getGattCharChecked()->toString().c_str(), deviceString.c_str());
}
return res;
}
-bool GATTHandler::readCharacteristicValue(const GATTCharacteristic & decl, POctets & resValue, int expectedLength) {
+bool BTGattHandler::readCharacteristicValue(const BTGattChar & decl, POctets & resValue, int expectedLength) {
COND_PRINT(env.DEBUG_DATA, "GATTHandler::readCharacteristicValue expLen %d, decl %s", expectedLength, decl.toString().c_str());
const bool res = readValue(decl.value_handle, resValue, expectedLength);
if( !res ) {
@@ -758,7 +758,7 @@ bool GATTHandler::readCharacteristicValue(const GATTCharacteristic & decl, POcte
return res;
}
-bool GATTHandler::readValue(const uint16_t handle, POctets & res, int expectedLength) {
+bool BTGattHandler::readValue(const uint16_t handle, POctets & res, int expectedLength) {
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.1 Read Characteristic Value */
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.8.3 Read Long Characteristic Value */
const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor
@@ -831,7 +831,7 @@ bool GATTHandler::readValue(const uint16_t handle, POctets & res, int expectedLe
return offset > 0;
}
-bool GATTHandler::writeDescriptorValue(const GATTDescriptor & cd) {
+bool BTGattHandler::writeDescriptorValue(const BTGattDesc & cd) {
/* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration */
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value */
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.11 Characteristic Value Indication */
@@ -840,12 +840,12 @@ bool GATTHandler::writeDescriptorValue(const GATTDescriptor & cd) {
const bool res = writeValue(cd.handle, cd.value, true);
if( !res ) {
WORDY_PRINT("GATT writeDescriptorValue error on desc%s within char%s from %s",
- cd.toString().c_str(), cd.getCharacteristicChecked()->toString().c_str(), deviceString.c_str());
+ cd.toString().c_str(), cd.getGattCharChecked()->toString().c_str(), deviceString.c_str());
}
return res;
}
-bool GATTHandler::writeCharacteristicValue(const GATTCharacteristic & c, const TROOctets & value) {
+bool BTGattHandler::writeCharacteristicValue(const BTGattChar & c, const TROOctets & value) {
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value */
COND_PRINT(env.DEBUG_DATA, "GATTHandler::writeCharacteristicValue desc %s, value %s", c.toString().c_str(), value.toString().c_str());
const bool res = writeValue(c.value_handle, value, true);
@@ -855,13 +855,13 @@ bool GATTHandler::writeCharacteristicValue(const GATTCharacteristic & c, const T
return res;
}
-bool GATTHandler::writeCharacteristicValueNoResp(const GATTCharacteristic & c, const TROOctets & value) {
+bool BTGattHandler::writeCharacteristicValueNoResp(const BTGattChar & c, const TROOctets & value) {
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.1 Write Characteristic Value Without Response */
COND_PRINT(env.DEBUG_DATA, "GATT writeCharacteristicValueNoResp decl %s, value %s", c.toString().c_str(), value.toString().c_str());
return writeValue(c.value_handle, value, false); // complete or exception
}
-bool GATTHandler::writeValue(const uint16_t handle, const TROOctets & value, const bool withResponse) {
+bool BTGattHandler::writeValue(const uint16_t handle, const TROOctets & value, const bool withResponse) {
/* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration */
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.9.3 Write Characteristic Value */
/* BT Core Spec v5.2: Vol 3, Part G GATT: 4.11 Characteristic Value Indication */
@@ -904,8 +904,8 @@ bool GATTHandler::writeValue(const uint16_t handle, const TROOctets & value, con
return res;
}
-bool GATTHandler::configNotificationIndication(GATTDescriptor & cccd, const bool enableNotification, const bool enableIndication) {
- if( !cccd.isClientCharacteristicConfiguration() ) {
+bool BTGattHandler::configNotificationIndication(BTGattDesc & cccd, const bool enableNotification, const bool enableIndication) {
+ if( !cccd.isClientCharConfig() ) {
throw jau::IllegalArgumentException("Not a ClientCharacteristicConfiguration: "+cccd.toString(), E_FILE_LINE);
}
/* BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration */
@@ -916,7 +916,7 @@ bool GATTHandler::configNotificationIndication(GATTDescriptor & cccd, const bool
cccd.value.put_uint16_nc(0, ccc_value);
try {
return writeDescriptorValue(cccd);
- } catch (BluetoothException & bte) {
+ } catch (BTException & bte) {
if( !enableNotification && !enableIndication ) {
// OK to have lost connection @ disable
WORDY_PRINT("GATTHandler::configNotificationIndication(disable) on %s caught exception: %s", deviceString.c_str(), bte.what());
@@ -947,7 +947,7 @@ static const uuid16_t _MANUFACTURER_NAME_STRING(GattCharacteristicType::MANUFACT
static const uuid16_t _REGULATORY_CERT_DATA_LIST(GattCharacteristicType::REGULATORY_CERT_DATA_LIST);
static const uuid16_t _PNP_ID(GattCharacteristicType::PNP_ID);
-std::shared_ptr<GattGenericAccessSvc> GATTHandler::getGenericAccess(jau::darray<GATTCharacteristicRef> & genericAccessCharDeclList) {
+std::shared_ptr<GattGenericAccessSvc> BTGattHandler::getGenericAccess(jau::darray<BTGattCharRef> & genericAccessCharDeclList) {
std::shared_ptr<GattGenericAccessSvc> res = nullptr;
POctets value(number(Defaults::MAX_ATT_MTU), 0);
std::string deviceName = "";
@@ -957,8 +957,8 @@ std::shared_ptr<GattGenericAccessSvc> GATTHandler::getGenericAccess(jau::darray<
const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor
for(size_t i=0; i<genericAccessCharDeclList.size(); i++) {
- const GATTCharacteristic & charDecl = *genericAccessCharDeclList.at(i);
- std::shared_ptr<GATTService> service = charDecl.getServiceUnchecked();
+ const BTGattChar & charDecl = *genericAccessCharDeclList.at(i);
+ std::shared_ptr<BTGattService> service = charDecl.getServiceUnchecked();
if( nullptr == service || _GENERIC_ACCESS != *(service->type) ) {
continue;
}
@@ -982,7 +982,7 @@ std::shared_ptr<GattGenericAccessSvc> GATTHandler::getGenericAccess(jau::darray<
return res;
}
-std::shared_ptr<GattGenericAccessSvc> GATTHandler::getGenericAccess(jau::darray<GATTServiceRef> & primServices) {
+std::shared_ptr<GattGenericAccessSvc> BTGattHandler::getGenericAccess(jau::darray<BTGattServiceRef> & primServices) {
std::shared_ptr<GattGenericAccessSvc> res = nullptr;
for(size_t i=0; i<primServices.size() && nullptr == res; i++) {
res = getGenericAccess(primServices.at(i)->characteristicList);
@@ -990,17 +990,17 @@ std::shared_ptr<GattGenericAccessSvc> GATTHandler::getGenericAccess(jau::darray<
return res;
}
-bool GATTHandler::ping() {
+bool BTGattHandler::ping() {
const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor
bool isOK = true;
for(size_t i=0; isOK && i<services.size(); i++) {
- jau::darray<GATTCharacteristicRef> & genericAccessCharDeclList = services.at(i)->characteristicList;
+ jau::darray<BTGattCharRef> & genericAccessCharDeclList = services.at(i)->characteristicList;
POctets value(32, 0);
for(size_t j=0; isOK && j<genericAccessCharDeclList.size(); j++) {
- const GATTCharacteristic & charDecl = *genericAccessCharDeclList.at(j);
- std::shared_ptr<GATTService> service = charDecl.getServiceUnchecked();
+ const BTGattChar & charDecl = *genericAccessCharDeclList.at(j);
+ std::shared_ptr<BTGattService> service = charDecl.getServiceUnchecked();
if( nullptr == service || _GENERIC_ACCESS != *(service->type) ) {
continue;
}
@@ -1022,7 +1022,7 @@ bool GATTHandler::ping() {
return false;
}
-std::shared_ptr<GattDeviceInformationSvc> GATTHandler::getDeviceInformation(jau::darray<GATTCharacteristicRef> & characteristicDeclList) {
+std::shared_ptr<GattDeviceInformationSvc> BTGattHandler::getDeviceInformation(jau::darray<BTGattCharRef> & characteristicDeclList) {
std::shared_ptr<GattDeviceInformationSvc> res = nullptr;
POctets value(number(Defaults::MAX_ATT_MTU), 0);
@@ -1040,8 +1040,8 @@ std::shared_ptr<GattDeviceInformationSvc> GATTHandler::getDeviceInformation(jau:
const std::lock_guard<std::recursive_mutex> lock(mtx_command); // RAII-style acquire and relinquish via destructor
for(size_t i=0; i<characteristicDeclList.size(); i++) {
- const GATTCharacteristic & charDecl = *characteristicDeclList.at(i);
- std::shared_ptr<GATTService> service = charDecl.getServiceUnchecked();
+ const BTGattChar & charDecl = *characteristicDeclList.at(i);
+ std::shared_ptr<BTGattService> service = charDecl.getServiceUnchecked();
if( nullptr == service || _DEVICE_INFORMATION != *(service->type) ) {
continue;
}
@@ -1092,7 +1092,7 @@ std::shared_ptr<GattDeviceInformationSvc> GATTHandler::getDeviceInformation(jau:
return res;
}
-std::shared_ptr<GattDeviceInformationSvc> GATTHandler::getDeviceInformation(jau::darray<GATTServiceRef> & primServices) {
+std::shared_ptr<GattDeviceInformationSvc> BTGattHandler::getDeviceInformation(jau::darray<BTGattServiceRef> & primServices) {
std::shared_ptr<GattDeviceInformationSvc> res = nullptr;
for(size_t i=0; i<primServices.size() && nullptr == res; i++) {
res = getDeviceInformation(primServices.at(i)->characteristicList);
diff --git a/src/direct_bt/GATTService.cpp b/src/direct_bt/BTGattService.cpp
index 70d537c2..e87bb3e2 100644
--- a/src/direct_bt/GATTService.cpp
+++ b/src/direct_bt/BTGattService.cpp
@@ -23,6 +23,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTDevice.hpp>
+#include <BTGattHandler.hpp>
+#include <BTGattService.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -34,35 +37,32 @@
#include <jau/debug.hpp>
-#include "DBTDevice.hpp"
-#include "GATTHandler.hpp"
-#include "GATTService.hpp"
-#include "GATTNumbers.hpp"
+#include "GattNumbers.hpp"
using namespace direct_bt;
using namespace jau;
-std::shared_ptr<GATTHandler> GATTService::getGATTHandlerChecked() const {
- std::shared_ptr<GATTHandler> ref = wbr_handler.lock();
+std::shared_ptr<BTGattHandler> BTGattService::getGattHandlerChecked() const {
+ std::shared_ptr<BTGattHandler> ref = wbr_handler.lock();
if( nullptr == ref ) {
throw IllegalStateException("GATTService's GATTHandler already destructed: "+toShortString(), E_FILE_LINE);
}
return ref;
}
-std::shared_ptr<DBTDevice> GATTService::getDeviceUnchecked() const noexcept {
- std::shared_ptr<GATTHandler> h = getGATTHandlerUnchecked();
+std::shared_ptr<BTDevice> BTGattService::getDeviceUnchecked() const noexcept {
+ std::shared_ptr<BTGattHandler> h = getGattHandlerUnchecked();
if( nullptr != h ) {
return h->getDeviceUnchecked();
}
return nullptr;
}
-std::shared_ptr<DBTDevice> GATTService::getDeviceChecked() const {
- return getGATTHandlerChecked()->getDeviceChecked();
+std::shared_ptr<BTDevice> BTGattService::getDeviceChecked() const {
+ return getGattHandlerChecked()->getDeviceChecked();
}
-std::string GATTService::toString() const noexcept {
+std::string BTGattService::toString() const noexcept {
std::string name = "";
if( uuid_t::TypeSize::UUID16_SZ == type->getTypeSize() ) {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(type.get()))->value;
@@ -72,7 +72,7 @@ std::string GATTService::toString() const noexcept {
name+", "+std::to_string(characteristicList.size())+" characteristics]";
}
-std::string GATTService::toShortString() const noexcept {
+std::string BTGattService::toShortString() const noexcept {
std::string name = "";
if( uuid_t::TypeSize::UUID16_SZ == type->getTypeSize() ) {
const uint16_t uuid16 = (static_cast<const uuid16_t*>(type.get()))->value;
diff --git a/src/direct_bt/DBTManager.cpp b/src/direct_bt/BTManager.cpp
index 70248d60..2e8be6d7 100644
--- a/src/direct_bt/DBTManager.cpp
+++ b/src/direct_bt/BTManager.cpp
@@ -23,6 +23,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTAdapter.hpp>
+#include <BTManager.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -40,12 +42,9 @@
#include "BTIoctl.hpp"
-#include "DBTManager.hpp"
#include "HCIIoctl.hpp"
#include "HCIComm.hpp"
-#include "DBTTypes.hpp"
-#include "DBTAdapter.hpp"
-
+#include "BTTypes1.hpp"
#include "SMPHandler.hpp"
extern "C" {
@@ -80,10 +79,10 @@ MgmtEnv::MgmtEnv() noexcept
{
}
-const pid_t DBTManager::pidSelf = getpid();
-std::mutex DBTManager::mtx_singleton;
+const pid_t BTManager::pidSelf = getpid();
+std::mutex BTManager::mtx_singleton;
-void DBTManager::mgmtReaderThreadImpl() noexcept {
+void BTManager::mgmtReaderThreadImpl() noexcept {
{
const std::lock_guard<std::mutex> lock(mtx_mgmtReaderLifecycle); // RAII-style acquire and relinquish via destructor
mgmtReaderShallStop = false;
@@ -125,11 +124,11 @@ void DBTManager::mgmtReaderThreadImpl() noexcept {
mgmtEventRing.putBlocking( std::move( event ) );
} else if( MgmtEvent::Opcode::INDEX_ADDED == opc ) {
COND_PRINT(env.DEBUG_EVENT, "DBTManager-IO RECV (ADD) %s", event->toString().c_str());
- std::thread adapterAddedThread(&DBTManager::processAdapterAdded, this, std::move( event) ); // @suppress("Invalid arguments")
+ std::thread adapterAddedThread(&BTManager::processAdapterAdded, this, std::move( event) ); // @suppress("Invalid arguments")
adapterAddedThread.detach();
} else if( MgmtEvent::Opcode::INDEX_REMOVED == opc ) {
COND_PRINT(env.DEBUG_EVENT, "DBTManager-IO RECV (REM) %s", event->toString().c_str());
- std::thread adapterRemovedThread(&DBTManager::processAdapterRemoved, this, std::move( event ) ); // @suppress("Invalid arguments")
+ std::thread adapterRemovedThread(&BTManager::processAdapterRemoved, this, std::move( event ) ); // @suppress("Invalid arguments")
adapterRemovedThread.detach();
} else {
// issue a callback
@@ -151,7 +150,7 @@ void DBTManager::mgmtReaderThreadImpl() noexcept {
}
-void DBTManager::sendMgmtEvent(const MgmtEvent& event) noexcept {
+void BTManager::sendMgmtEvent(const MgmtEvent& event) noexcept {
const uint16_t dev_id = event.getDevID();
MgmtAdapterEventCallbackList & mgmtEventCallbackList = mgmtAdapterEventCallbackLists[static_cast<uint16_t>(event.getOpcode())];
int invokeCount = 0;
@@ -174,11 +173,11 @@ void DBTManager::sendMgmtEvent(const MgmtEvent& event) noexcept {
}
static void mgmthandler_sigaction(int sig, siginfo_t *info, void *ucontext) noexcept {
- bool pidMatch = info->si_pid == DBTManager::pidSelf;
+ bool pidMatch = info->si_pid == BTManager::pidSelf;
WORDY_PRINT("DBTManager.sigaction: sig %d, info[code %d, errno %d, signo %d, pid %d, uid %d, fd %d], pid-self %d (match %d)",
sig, info->si_code, info->si_errno, info->si_signo,
info->si_pid, info->si_uid, info->si_fd,
- DBTManager::pidSelf, pidMatch);
+ BTManager::pidSelf, pidMatch);
(void)ucontext;
if( !pidMatch || SIGALRM != sig ) {
@@ -200,7 +199,7 @@ static void mgmthandler_sigaction(int sig, siginfo_t *info, void *ucontext) noex
#endif
}
-bool DBTManager::send(MgmtCommand &req) noexcept {
+bool BTManager::send(MgmtCommand &req) noexcept {
const std::lock_guard<std::recursive_mutex> lock(mtx_sendReply); // RAII-style acquire and relinquish via destructor
COND_PRINT(env.DEBUG_EVENT, "DBTManager-IO SENT %s", req.toString().c_str());
TROOctets & pdu = req.getPDU();
@@ -211,7 +210,7 @@ bool DBTManager::send(MgmtCommand &req) noexcept {
return true;
}
-std::unique_ptr<MgmtEvent> DBTManager::sendWithReply(MgmtCommand &req) noexcept {
+std::unique_ptr<MgmtEvent> BTManager::sendWithReply(MgmtCommand &req) noexcept {
const std::lock_guard<std::recursive_mutex> lock(mtx_sendReply); // RAII-style acquire and relinquish via destructor
if( !send(req) ) {
return nullptr;
@@ -240,7 +239,7 @@ std::unique_ptr<MgmtEvent> DBTManager::sendWithReply(MgmtCommand &req) noexcept
return nullptr;
}
-std::unique_ptr<AdapterInfo> DBTManager::initAdapter(const uint16_t dev_id, const BTMode btMode) noexcept {
+std::unique_ptr<AdapterInfo> BTManager::initAdapter(const uint16_t dev_id, const BTMode btMode) noexcept {
/**
* We weight on PairingMode::PASSKEY_ENTRY. FIXME: Have it configurable!
*
@@ -353,7 +352,7 @@ fail:
return adapterInfo;
}
-void DBTManager::shutdownAdapter(DBTAdapter& adapter) noexcept {
+void BTManager::shutdownAdapter(BTAdapter& adapter) noexcept {
DBG_PRINT("DBTManager::shutdownAdapter: %s", adapter.toString().c_str());
const uint16_t dev_id = adapter.dev_id;
adapter.close(); // also issues removeMgmtEventCallback(dev_id);
@@ -372,7 +371,7 @@ void DBTManager::shutdownAdapter(DBTAdapter& adapter) noexcept {
DBG_PRINT("DBTManager::shutdownAdapter: done: %s", adapter.toString().c_str());
}
-DBTManager::DBTManager(const BTMode _defaultBTMode) noexcept
+BTManager::BTManager(const BTMode _defaultBTMode) noexcept
: env(MgmtEnv::get()),
defaultBTMode(BTMode::NONE != _defaultBTMode ? _defaultBTMode : env.DEFAULT_BTMODE),
#if USE_LINUX_BT_SECURITY
@@ -385,7 +384,7 @@ DBTManager::DBTManager(const BTMode _defaultBTMode) noexcept
mgmtReaderThreadId(0), mgmtReaderRunning(false),
allowClose( comm.isOpen() )
{
- WORDY_PRINT("DBTManager.ctor: BTMode %s, pid %d", getBTModeString(defaultBTMode).c_str(), DBTManager::pidSelf);
+ WORDY_PRINT("DBTManager.ctor: BTMode %s, pid %d", getBTModeString(defaultBTMode).c_str(), BTManager::pidSelf);
if( !allowClose ) {
ERR_PRINT("DBTManager::open: Could not open mgmt control channel");
return;
@@ -404,7 +403,7 @@ DBTManager::DBTManager(const BTMode _defaultBTMode) noexcept
{
std::unique_lock<std::mutex> lock(mtx_mgmtReaderLifecycle); // RAII-style acquire and relinquish via destructor
- std::thread mgmtReaderThread(&DBTManager::mgmtReaderThreadImpl, this); // @suppress("Invalid arguments")
+ std::thread mgmtReaderThread(&BTManager::mgmtReaderThreadImpl, this); // @suppress("Invalid arguments")
mgmtReaderThreadId = mgmtReaderThread.native_handle();
// Avoid 'terminate called without an active exception'
// as hciReaderThreadImpl may end due to I/O errors.
@@ -486,7 +485,7 @@ next1:
const uint16_t dev_id = jau::get_uint16(data, 2+i*2, true /* littleEndian */);
std::unique_ptr<AdapterInfo> adapterInfo = initAdapter(dev_id, defaultBTMode);
if( nullptr != adapterInfo ) {
- std::shared_ptr<DBTAdapter> adapter = DBTAdapter::make_shared(*this, *adapterInfo);
+ std::shared_ptr<BTAdapter> adapter = BTAdapter::make_shared(*this, *adapterInfo);
adapters.push_back( adapter );
adapterIOCapability.push_back(defaultIOCapability);
DBG_PRINT("DBTManager::adapters %d/%d: dev_id %d: %s", i, num_adapter, dev_id, adapter->toString().c_str());
@@ -496,38 +495,38 @@ next1:
}
}
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_SETTINGS, jau::bindMemberFunc(this, &DBTManager::mgmtEvNewSettingsCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_SETTINGS, jau::bindMemberFunc(this, &BTManager::mgmtEvNewSettingsCB));
if( jau::environment::get().debug ) {
- addMgmtEventCallback(-1, MgmtEvent::Opcode::CONTROLLER_ERROR, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::CLASS_OF_DEV_CHANGED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_LINK_KEY, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_LONG_TERM_KEY, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_CONNECTED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_DISCONNECTED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::CONNECT_FAILED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::PIN_CODE_REQUEST, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::USER_CONFIRM_REQUEST, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::USER_PASSKEY_REQUEST, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::AUTH_FAILED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_FOUND, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DISCOVERING, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_BLOCKED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_UNBLOCKED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_UNPAIRED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::PASSKEY_NOTIFY, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_IRK, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_CSRK, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_WHITELIST_ADDED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_WHITELIST_REMOVED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_CONN_PARAM, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
-
- addMgmtEventCallback(-1, MgmtEvent::Opcode::LOCAL_OOB_DATA_UPDATED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
-
- addMgmtEventCallback(-1, MgmtEvent::Opcode::PAIR_DEVICE_COMPLETE, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::HCI_ENC_CHANGED, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::HCI_ENC_KEY_REFRESH_COMPLETE, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
- addMgmtEventCallback(-1, MgmtEvent::Opcode::HCI_LE_REMOTE_USR_FEATURES, jau::bindMemberFunc(this, &DBTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::CONTROLLER_ERROR, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::CLASS_OF_DEV_CHANGED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_LINK_KEY, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_LONG_TERM_KEY, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_CONNECTED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_DISCONNECTED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::CONNECT_FAILED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::PIN_CODE_REQUEST, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::USER_CONFIRM_REQUEST, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::USER_PASSKEY_REQUEST, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::AUTH_FAILED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_FOUND, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DISCOVERING, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_BLOCKED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_UNBLOCKED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_UNPAIRED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::PASSKEY_NOTIFY, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_IRK, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_CSRK, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_WHITELIST_ADDED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::DEVICE_WHITELIST_REMOVED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::NEW_CONN_PARAM, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::LOCAL_OOB_DATA_UPDATED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::PAIR_DEVICE_COMPLETE, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::HCI_ENC_CHANGED, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::HCI_ENC_KEY_REFRESH_COMPLETE, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
+ addMgmtEventCallback(-1, MgmtEvent::Opcode::HCI_LE_REMOTE_USR_FEATURES, jau::bindMemberFunc(this, &BTManager::mgmtEventAnyCB));
}
PERF_TS_TD("DBTManager::ctor.ok");
DBG_PRINT("DBTManager::ctor: OK");
@@ -540,7 +539,7 @@ fail:
return;
}
-void DBTManager::close() noexcept {
+void BTManager::close() noexcept {
// Avoid disconnect re-entry -> potential deadlock
bool expConn = true; // C++11, exp as value since C++20
if( !allowClose.compare_exchange_strong(expConn, false) ) {
@@ -562,7 +561,7 @@ void DBTManager::close() noexcept {
{
int i=0;
- jau::for_each_fidelity(adapters, [&](std::shared_ptr<DBTAdapter> & a) {
+ jau::for_each_fidelity(adapters, [&](std::shared_ptr<BTAdapter> & a) {
DBG_PRINT("DBTManager::close::shutdownAdapter: %d/%d processing: %s", i, adapters.size(), a->toString().c_str());
shutdownAdapter(*a);
++i;
@@ -616,7 +615,7 @@ void DBTManager::close() noexcept {
DBG_PRINT("DBTManager::close: End");
}
-std::shared_ptr<DBTAdapter> DBTManager::getDefaultAdapter() const noexcept {
+std::shared_ptr<BTAdapter> BTManager::getDefaultAdapter() const noexcept {
typename adapters_t::const_iterator it = adapters.cbegin();
for (; !it.is_end(); ++it) {
if( (*it)->isPowered() ) {
@@ -626,7 +625,7 @@ std::shared_ptr<DBTAdapter> DBTManager::getDefaultAdapter() const noexcept {
return nullptr;
}
-std::shared_ptr<DBTAdapter> DBTManager::getAdapter(const EUI48 &mac) const noexcept {
+std::shared_ptr<BTAdapter> BTManager::getAdapter(const EUI48 &mac) const noexcept {
typename adapters_t::const_iterator it = adapters.cbegin();
for (; !it.is_end(); ++it) {
if ( (*it)->adapterInfo.address == mac ) {
@@ -635,7 +634,7 @@ std::shared_ptr<DBTAdapter> DBTManager::getAdapter(const EUI48 &mac) const noexc
}
return nullptr;
}
-std::shared_ptr<DBTAdapter> DBTManager::getAdapter(const uint16_t dev_id) const noexcept {
+std::shared_ptr<BTAdapter> BTManager::getAdapter(const uint16_t dev_id) const noexcept {
typename adapters_t::const_iterator it = adapters.cbegin();
for (; !it.is_end(); ++it) {
if ( (*it)->dev_id == dev_id ) {
@@ -645,7 +644,7 @@ std::shared_ptr<DBTAdapter> DBTManager::getAdapter(const uint16_t dev_id) const
return nullptr;
}
-std::shared_ptr<DBTAdapter> DBTManager::addAdapter(const AdapterInfo& ai ) noexcept {
+std::shared_ptr<BTAdapter> BTManager::addAdapter(const AdapterInfo& ai ) noexcept {
typename adapters_t::iterator it = adapters.begin(); // lock mutex and copy_store
for (; !it.is_end(); ++it) {
if ( (*it)->dev_id == ai.dev_id ) {
@@ -654,7 +653,7 @@ std::shared_ptr<DBTAdapter> DBTManager::addAdapter(const AdapterInfo& ai ) noexc
}
if( it.is_end() ) {
// new entry
- std::shared_ptr<DBTAdapter> adapter = DBTAdapter::make_shared(*this, ai);
+ std::shared_ptr<BTAdapter> adapter = BTAdapter::make_shared(*this, ai);
it.push_back( adapter );
adapterIOCapability.push_back(defaultIOCapability);
DBG_PRINT("DBTManager::addAdapter: Adding new: %s", adapter->toString().c_str())
@@ -662,20 +661,20 @@ std::shared_ptr<DBTAdapter> DBTManager::addAdapter(const AdapterInfo& ai ) noexc
return adapter;
} else {
// already existing
- std::shared_ptr<DBTAdapter> adapter = *it;
+ std::shared_ptr<BTAdapter> adapter = *it;
WARN_PRINT("DBTManager::addAdapter: Already existing %s, overwriting %s", ai.toString().c_str(), adapter->toString().c_str())
adapter->adapterInfo = ai;
return adapter;
}
}
-std::shared_ptr<DBTAdapter> DBTManager::removeAdapter(const uint16_t dev_id) noexcept {
+std::shared_ptr<BTAdapter> BTManager::removeAdapter(const uint16_t dev_id) noexcept {
typename adapters_t::iterator it = adapters.begin(); // lock mutex and copy_store
for(; !it.is_end(); ++it ) {
- std::shared_ptr<DBTAdapter> & ai = *it;
+ std::shared_ptr<BTAdapter> & ai = *it;
if( ai->dev_id == dev_id ) {
adapterIOCapability.erase( adapterIOCapability.cbegin() + it.dist_begin() );
- std::shared_ptr<DBTAdapter> res = ai; // copy
+ std::shared_ptr<BTAdapter> res = ai; // copy
DBG_PRINT("DBTManager::removeAdapter: Remove: %s", res->toString().c_str())
it.erase();
it.write_back();
@@ -686,10 +685,10 @@ std::shared_ptr<DBTAdapter> DBTManager::removeAdapter(const uint16_t dev_id) noe
return nullptr;
}
-bool DBTManager::removeAdapter(DBTAdapter* adapter) noexcept {
+bool BTManager::removeAdapter(BTAdapter* adapter) noexcept {
typename adapters_t::iterator it = adapters.begin(); // lock mutex and copy_store
for(; !it.is_end(); ++it ) {
- std::shared_ptr<DBTAdapter> & ai = *it;
+ std::shared_ptr<BTAdapter> & ai = *it;
if( ai.get() == adapter ) {
adapterIOCapability.erase( adapterIOCapability.cbegin() + it.dist_begin() );
DBG_PRINT("DBTManager::removeAdapter: Remove: %p -> %s", adapter, ai->toString().c_str())
@@ -702,7 +701,7 @@ bool DBTManager::removeAdapter(DBTAdapter* adapter) noexcept {
return false;
}
-bool DBTManager::setIOCapability(const uint16_t dev_id, const SMPIOCapability io_cap, SMPIOCapability& pre_io_cap) noexcept {
+bool BTManager::setIOCapability(const uint16_t dev_id, const SMPIOCapability io_cap, SMPIOCapability& pre_io_cap) noexcept {
if( SMPIOCapability::UNSET != io_cap ) {
#if USE_LINUX_BT_SECURITY
typename adapters_t::const_iterator it = adapters.cbegin();
@@ -725,7 +724,7 @@ bool DBTManager::setIOCapability(const uint16_t dev_id, const SMPIOCapability io
return false;
}
-SMPIOCapability DBTManager::getIOCapability(const uint16_t dev_id) const noexcept {
+SMPIOCapability BTManager::getIOCapability(const uint16_t dev_id) const noexcept {
typename adapters_t::const_iterator it = adapters.cbegin();
for (; !it.is_end(); ++it) {
if( (*it)->dev_id == dev_id ) {
@@ -735,7 +734,7 @@ SMPIOCapability DBTManager::getIOCapability(const uint16_t dev_id) const noexcep
return SMPIOCapability::UNSET;
}
-bool DBTManager::setMode(const uint16_t dev_id, const MgmtCommand::Opcode opc, const uint8_t mode, AdapterSetting& current_settings) noexcept {
+bool BTManager::setMode(const uint16_t dev_id, const MgmtCommand::Opcode opc, const uint8_t mode, AdapterSetting& current_settings) noexcept {
MgmtUint8Cmd req(opc, dev_id, mode);
std::unique_ptr<MgmtEvent> reply = sendWithReply(req);
MgmtStatus res;
@@ -761,7 +760,7 @@ bool DBTManager::setMode(const uint16_t dev_id, const MgmtCommand::Opcode opc, c
return MgmtStatus::SUCCESS == res;
}
-MgmtStatus DBTManager::setDiscoverable(const uint16_t dev_id, const uint8_t state, const uint16_t timeout_sec, AdapterSetting& current_settings) noexcept {
+MgmtStatus BTManager::setDiscoverable(const uint16_t dev_id, const uint8_t state, const uint16_t timeout_sec, AdapterSetting& current_settings) noexcept {
MgmtSetDiscoverableCmd req(dev_id, state, timeout_sec);
std::unique_ptr<MgmtEvent> reply = sendWithReply(req);
MgmtStatus res;
@@ -786,11 +785,11 @@ MgmtStatus DBTManager::setDiscoverable(const uint16_t dev_id, const uint8_t stat
return res;
}
-ScanType DBTManager::startDiscovery(const uint16_t dev_id, const BTMode btMode) noexcept {
+ScanType BTManager::startDiscovery(const uint16_t dev_id, const BTMode btMode) noexcept {
return startDiscovery(dev_id, getScanType(btMode));
}
-ScanType DBTManager::startDiscovery(const uint16_t dev_id, const ScanType scanType) noexcept {
+ScanType BTManager::startDiscovery(const uint16_t dev_id, const ScanType scanType) noexcept {
MgmtUint8Cmd req(MgmtCommand::Opcode::START_DISCOVERY, dev_id, number(scanType));
std::unique_ptr<MgmtEvent> res = sendWithReply(req);
ScanType type = ScanType::NONE;
@@ -807,7 +806,7 @@ ScanType DBTManager::startDiscovery(const uint16_t dev_id, const ScanType scanTy
}
return type;
}
-bool DBTManager::stopDiscovery(const uint16_t dev_id, const ScanType type) noexcept {
+bool BTManager::stopDiscovery(const uint16_t dev_id, const ScanType type) noexcept {
MgmtUint8Cmd req(MgmtCommand::Opcode::STOP_DISCOVERY, dev_id, number(type));
std::unique_ptr<MgmtEvent> res = sendWithReply(req);
if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) {
@@ -817,7 +816,7 @@ bool DBTManager::stopDiscovery(const uint16_t dev_id, const ScanType type) noexc
return false;
}
-bool DBTManager::uploadConnParam(const uint16_t dev_id, const BDAddressAndType & addressAndType,
+bool BTManager::uploadConnParam(const uint16_t dev_id, const BDAddressAndType & addressAndType,
const uint16_t conn_min_interval, const uint16_t conn_max_interval,
const uint16_t conn_latency, const uint16_t supervision_timeout) noexcept {
MgmtConnParam connParam{ addressAndType.address, addressAndType.type, conn_min_interval, conn_max_interval, conn_latency, supervision_timeout };
@@ -830,7 +829,7 @@ bool DBTManager::uploadConnParam(const uint16_t dev_id, const BDAddressAndType &
return false;
}
-MgmtStatus DBTManager::uploadLinkKey(const uint16_t dev_id, const bool debug_keys, const MgmtLinkKeyInfo &key) noexcept {
+MgmtStatus BTManager::uploadLinkKey(const uint16_t dev_id, const bool debug_keys, const MgmtLinkKeyInfo &key) noexcept {
MgmtLoadLinkKeyCmd req(dev_id, debug_keys, key);
std::unique_ptr<MgmtEvent> res = sendWithReply(req);
if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) {
@@ -840,7 +839,7 @@ MgmtStatus DBTManager::uploadLinkKey(const uint16_t dev_id, const bool debug_key
return MgmtStatus::TIMEOUT;
}
-HCIStatusCode DBTManager::uploadLongTermKey(const uint16_t dev_id, const MgmtLongTermKeyInfo &key) noexcept {
+HCIStatusCode BTManager::uploadLongTermKey(const uint16_t dev_id, const MgmtLongTermKeyInfo &key) noexcept {
MgmtLoadLongTermKeyCmd req(dev_id, key);
HCIStatusCode res;
std::unique_ptr<MgmtEvent> reply = sendWithReply(req);
@@ -860,7 +859,7 @@ HCIStatusCode DBTManager::uploadLongTermKey(const uint16_t dev_id, const MgmtLon
return res;
}
-HCIStatusCode DBTManager::uploadLongTermKeyInfo(const uint16_t dev_id, const BDAddressAndType & addressAndType,
+HCIStatusCode BTManager::uploadLongTermKeyInfo(const uint16_t dev_id, const BDAddressAndType & addressAndType,
const SMPLongTermKeyInfo& ltk) noexcept {
const MgmtLTKType key_type = getMgmtLTKType(ltk.properties);
const bool responder = ( SMPLongTermKeyInfo::Property::RESPONDER & ltk.properties ) != SMPLongTermKeyInfo::Property::NONE;
@@ -884,7 +883,7 @@ HCIStatusCode DBTManager::uploadLongTermKeyInfo(const uint16_t dev_id, const BDA
return res;
}
-MgmtStatus DBTManager::userPasskeyReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const uint32_t passkey) noexcept {
+MgmtStatus BTManager::userPasskeyReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const uint32_t passkey) noexcept {
MgmtUserPasskeyReplyCmd cmd(dev_id, addressAndType, passkey);
std::unique_ptr<MgmtEvent> res = sendWithReply(cmd);
if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) {
@@ -895,7 +894,7 @@ MgmtStatus DBTManager::userPasskeyReply(const uint16_t dev_id, const BDAddressAn
return MgmtStatus::TIMEOUT;
}
-MgmtStatus DBTManager::userPasskeyNegativeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept {
+MgmtStatus BTManager::userPasskeyNegativeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept {
MgmtUserPasskeyNegativeReplyCmd cmd(dev_id, addressAndType);
std::unique_ptr<MgmtEvent> res = sendWithReply(cmd);
if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) {
@@ -906,7 +905,7 @@ MgmtStatus DBTManager::userPasskeyNegativeReply(const uint16_t dev_id, const BDA
return MgmtStatus::TIMEOUT;
}
-MgmtStatus DBTManager::userConfirmReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool positive) noexcept {
+MgmtStatus BTManager::userConfirmReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool positive) noexcept {
std::unique_ptr<MgmtEvent> res;
if( positive ) {
MgmtUserConfirmReplyCmd cmd(dev_id, addressAndType);
@@ -923,12 +922,12 @@ MgmtStatus DBTManager::userConfirmReply(const uint16_t dev_id, const BDAddressAn
return MgmtStatus::TIMEOUT;
}
-bool DBTManager::pairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPIOCapability iocap) noexcept {
+bool BTManager::pairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPIOCapability iocap) noexcept {
MgmtPairDeviceCmd cmd(dev_id, addressAndType, iocap);
return send(cmd);
}
-MgmtStatus DBTManager::unpairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool disconnect) noexcept {
+MgmtStatus BTManager::unpairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool disconnect) noexcept {
MgmtUnpairDeviceCmd cmd(dev_id, addressAndType, disconnect);
std::unique_ptr<MgmtEvent> res = sendWithReply(cmd);
@@ -940,7 +939,7 @@ MgmtStatus DBTManager::unpairDevice(const uint16_t dev_id, const BDAddressAndTyp
return MgmtStatus::TIMEOUT;
}
-bool DBTManager::isDeviceWhitelisted(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept {
+bool BTManager::isDeviceWhitelisted(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept {
auto it = whitelist.cbegin();
for( auto end = whitelist.cend(); it != end; ++it) {
std::shared_ptr<WhitelistElem> wle = *it;
@@ -951,7 +950,7 @@ bool DBTManager::isDeviceWhitelisted(const uint16_t dev_id, const BDAddressAndTy
return false;
}
-bool DBTManager::addDeviceToWhitelist(const uint16_t dev_id, const BDAddressAndType & addressAndType, const HCIWhitelistConnectType ctype) noexcept {
+bool BTManager::addDeviceToWhitelist(const uint16_t dev_id, const BDAddressAndType & addressAndType, const HCIWhitelistConnectType ctype) noexcept {
MgmtAddDeviceToWhitelistCmd req(dev_id, addressAndType, ctype);
// Check if already exist in our local whitelist first, reject if so ..
@@ -970,7 +969,7 @@ bool DBTManager::addDeviceToWhitelist(const uint16_t dev_id, const BDAddressAndT
return false;
}
-int DBTManager::removeAllDevicesFromWhitelist() noexcept {
+int BTManager::removeAllDevicesFromWhitelist() noexcept {
#if 0
jau::darray<std::shared_ptr<WhitelistElem>> whitelist_copy = whitelist;
int count = 0;
@@ -985,7 +984,7 @@ int DBTManager::removeAllDevicesFromWhitelist() noexcept {
int count = 0;
DBG_PRINT("DBTManager::removeAllDevicesFromWhitelist.B: Start %d elements", count);
whitelist.clear();
- jau::for_each_const(adapters, [&](const std::shared_ptr<DBTAdapter> & a) {
+ jau::for_each_const(adapters, [&](const std::shared_ptr<BTAdapter> & a) {
if( removeDeviceFromWhitelist(a->dev_id, BDAddressAndType::ANY_BREDR_DEVICE) ) { // flush whitelist!
++count;
}
@@ -997,7 +996,7 @@ int DBTManager::removeAllDevicesFromWhitelist() noexcept {
return count;
}
-bool DBTManager::removeDeviceFromWhitelist(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept {
+bool BTManager::removeDeviceFromWhitelist(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept {
// Remove from our local whitelist first
{
auto it = whitelist.cbegin();
@@ -1023,7 +1022,7 @@ bool DBTManager::removeDeviceFromWhitelist(const uint16_t dev_id, const BDAddres
return false;
}
-bool DBTManager::disconnect(const bool ioErrorCause,
+bool BTManager::disconnect(const bool ioErrorCause,
const uint16_t dev_id, const BDAddressAndType & addressAndType,
const HCIStatusCode reason) noexcept {
bool bres = false;
@@ -1050,7 +1049,7 @@ bool DBTManager::disconnect(const bool ioErrorCause,
return bres;
}
-std::shared_ptr<ConnectionInfo> DBTManager::getConnectionInfo(const uint16_t dev_id, const BDAddressAndType& addressAndType) noexcept {
+std::shared_ptr<ConnectionInfo> BTManager::getConnectionInfo(const uint16_t dev_id, const BDAddressAndType& addressAndType) noexcept {
MgmtGetConnectionInfoCmd req(dev_id, addressAndType);
std::unique_ptr<MgmtEvent> res = sendWithReply(req);
if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) {
@@ -1063,7 +1062,7 @@ std::shared_ptr<ConnectionInfo> DBTManager::getConnectionInfo(const uint16_t dev
return nullptr;
}
-std::shared_ptr<NameAndShortName> DBTManager::setLocalName(const uint16_t dev_id, const std::string & name, const std::string & short_name) noexcept {
+std::shared_ptr<NameAndShortName> BTManager::setLocalName(const uint16_t dev_id, const std::string & name, const std::string & short_name) noexcept {
MgmtSetLocalNameCmd req (static_cast<uint16_t>(dev_id), name, short_name);
std::unique_ptr<MgmtEvent> res = sendWithReply(req);
if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) {
@@ -1095,7 +1094,7 @@ static MgmtAdapterEventCallbackList::equal_comparator _mgmtAdapterEventCallbackE
static MgmtAdapterEventCallbackList::equal_comparator _mgmtAdapterEventCallbackEqComp_ID =
[](const MgmtAdapterEventCallback &a, const MgmtAdapterEventCallback &b) -> bool { return a.getDevID() == b.getDevID(); };
-bool DBTManager::addMgmtEventCallback(const int dev_id, const MgmtEvent::Opcode opc, const MgmtEventCallback &cb) noexcept {
+bool BTManager::addMgmtEventCallback(const int dev_id, const MgmtEvent::Opcode opc, const MgmtEventCallback &cb) noexcept {
if( !isValidMgmtEventCallbackListsIndex(opc) ) {
ERR_PRINT("Opcode %s >= %d", MgmtEvent::getOpcodeString(opc).c_str(), mgmtAdapterEventCallbackLists.size());
return false;
@@ -1104,7 +1103,7 @@ bool DBTManager::addMgmtEventCallback(const int dev_id, const MgmtEvent::Opcode
/* const bool added = */ l.push_back_unique(MgmtAdapterEventCallback(dev_id, opc, cb), _mgmtAdapterEventCallbackEqComp_ID_CB);
return true;
}
-int DBTManager::removeMgmtEventCallback(const MgmtEvent::Opcode opc, const MgmtEventCallback &cb) noexcept {
+int BTManager::removeMgmtEventCallback(const MgmtEvent::Opcode opc, const MgmtEventCallback &cb) noexcept {
if( !isValidMgmtEventCallbackListsIndex(opc) ) {
ERR_PRINT("Opcode %s >= %d", MgmtEvent::getOpcodeString(opc).c_str(), mgmtAdapterEventCallbackLists.size());
return 0;
@@ -1113,7 +1112,7 @@ int DBTManager::removeMgmtEventCallback(const MgmtEvent::Opcode opc, const MgmtE
return l.erase_matching( MgmtAdapterEventCallback( 0, MgmtEvent::Opcode::INVALID, cb ),
true /* all_matching */, _mgmtAdapterEventCallbackEqComp_CB);
}
-int DBTManager::removeMgmtEventCallback(const int dev_id) noexcept {
+int BTManager::removeMgmtEventCallback(const int dev_id) noexcept {
if( 0 > dev_id ) {
// skip dev_id -1 case, use clearAllMgmtEventCallbacks() here
return 0;
@@ -1126,27 +1125,27 @@ int DBTManager::removeMgmtEventCallback(const int dev_id) noexcept {
}
return count;
}
-void DBTManager::clearMgmtEventCallbacks(const MgmtEvent::Opcode opc) noexcept {
+void BTManager::clearMgmtEventCallbacks(const MgmtEvent::Opcode opc) noexcept {
if( !isValidMgmtEventCallbackListsIndex(opc) ) {
ERR_PRINT("Opcode %s >= %d", MgmtEvent::getOpcodeString(opc).c_str(), mgmtAdapterEventCallbackLists.size());
return;
}
mgmtAdapterEventCallbackLists[static_cast<uint16_t>(opc)].clear();
}
-void DBTManager::clearAllCallbacks() noexcept {
+void BTManager::clearAllCallbacks() noexcept {
for(size_t i=0; i<mgmtAdapterEventCallbackLists.size(); i++) {
mgmtAdapterEventCallbackLists[i].clear();
}
mgmtChangedAdapterSetCallbackList.clear();
}
-void DBTManager::processAdapterAdded(std::unique_ptr<MgmtEvent> e) noexcept {
+void BTManager::processAdapterAdded(std::unique_ptr<MgmtEvent> e) noexcept {
const uint16_t dev_id = e->getDevID();
std::unique_ptr<AdapterInfo> adapterInfo = initAdapter(dev_id, defaultBTMode);
if( nullptr != adapterInfo ) {
- std::shared_ptr<DBTAdapter> adapter = addAdapter( *adapterInfo );
+ std::shared_ptr<BTAdapter> adapter = addAdapter( *adapterInfo );
DBG_PRINT("DBTManager::Adapter[%d] Added: Start %s, added %d", dev_id, adapter->toString().c_str());
sendMgmtEvent(*e);
DBG_PRINT("DBTManager::Adapter[%d] Added: User_ %s", dev_id, adapter->toString().c_str());
@@ -1158,9 +1157,9 @@ void DBTManager::processAdapterAdded(std::unique_ptr<MgmtEvent> e) noexcept {
DBG_PRINT("DBTManager::Adapter[%d] Added: InitAI failed", dev_id);
}
}
-void DBTManager::processAdapterRemoved(std::unique_ptr<MgmtEvent> e) noexcept {
+void BTManager::processAdapterRemoved(std::unique_ptr<MgmtEvent> e) noexcept {
const uint16_t dev_id = e->getDevID();
- std::shared_ptr<DBTAdapter> ai = removeAdapter(dev_id);
+ std::shared_ptr<BTAdapter> ai = removeAdapter(dev_id);
if( nullptr != ai ) {
DBG_PRINT("DBTManager::Adapter[%d] Removed: Start: %s", dev_id, ai->toString().c_str());
sendMgmtEvent(*e);
@@ -1174,9 +1173,9 @@ void DBTManager::processAdapterRemoved(std::unique_ptr<MgmtEvent> e) noexcept {
DBG_PRINT("DBTManager::Adapter[%d] Removed: RemoveAI failed", dev_id);
}
}
-bool DBTManager::mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept {
+bool BTManager::mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept {
const MgmtEvtNewSettings &event = *static_cast<const MgmtEvtNewSettings *>(&e);
- std::shared_ptr<DBTAdapter> adapter = getAdapter(event.getDevID());
+ std::shared_ptr<BTAdapter> adapter = getAdapter(event.getDevID());
if( nullptr != adapter ) {
const AdapterSetting old_settings = adapter->adapterInfo.getCurrentSettingMask();
const AdapterSetting new_settings = adapter->adapterInfo.setCurrentSettingMask(event.getSettings());
@@ -1194,7 +1193,7 @@ bool DBTManager::mgmtEvNewSettingsCB(const MgmtEvent& e) noexcept {
return true;
}
-bool DBTManager::mgmtEventAnyCB(const MgmtEvent& e) noexcept {
+bool BTManager::mgmtEventAnyCB(const MgmtEvent& e) noexcept {
DBG_PRINT("DBTManager:mgmt:Any: %s", e.toString().c_str());
(void)e;
return true;
@@ -1208,25 +1207,25 @@ static ChangedAdapterSetCallbackList::equal_comparator _changedAdapterSetCallbac
[](const ChangedAdapterSetCallback& a, const ChangedAdapterSetCallback& b) -> bool { return a == b; };
-void DBTManager::addChangedAdapterSetCallback(const ChangedAdapterSetCallback & l) {
+void BTManager::addChangedAdapterSetCallback(const ChangedAdapterSetCallback & l) {
ChangedAdapterSetCallback* l_p = const_cast<ChangedAdapterSetCallback*>(&l);
mgmtChangedAdapterSetCallbackList.push_back(l);
- jau::for_each_fidelity(adapters, [&](std::shared_ptr<DBTAdapter>& ai) {
+ jau::for_each_fidelity(adapters, [&](std::shared_ptr<BTAdapter>& ai) {
l_p->invoke(true /* added */, ai);
});
}
-int DBTManager::removeChangedAdapterSetCallback(const ChangedAdapterSetCallback & l) {
+int BTManager::removeChangedAdapterSetCallback(const ChangedAdapterSetCallback & l) {
return mgmtChangedAdapterSetCallbackList.erase_matching(l, true /* all_matching */, _changedAdapterSetCallbackEqComp);
}
-void DBTManager::addChangedAdapterSetCallback(ChangedAdapterSetFunc f) {
+void BTManager::addChangedAdapterSetCallback(ChangedAdapterSetFunc f) {
addChangedAdapterSetCallback(
ChangedAdapterSetCallback(
- jau::bindPlainFunc<bool, bool, std::shared_ptr<DBTAdapter>&>(f)
+ jau::bindPlainFunc<bool, bool, std::shared_ptr<BTAdapter>&>(f)
) );
}
-int DBTManager::removeChangedAdapterSetCallback(ChangedAdapterSetFunc f) {
- ChangedAdapterSetCallback l( jau::bindPlainFunc<bool, bool, std::shared_ptr<DBTAdapter>&>(f) );
+int BTManager::removeChangedAdapterSetCallback(ChangedAdapterSetFunc f) {
+ ChangedAdapterSetCallback l( jau::bindPlainFunc<bool, bool, std::shared_ptr<BTAdapter>&>(f) );
return mgmtChangedAdapterSetCallbackList.erase_matching(l, true /* all_matching */, _changedAdapterSetCallbackEqComp);
}
diff --git a/src/direct_bt/BTTypes.cpp b/src/direct_bt/BTTypes0.cpp
index ad6b0695..44414ed7 100644
--- a/src/direct_bt/BTTypes.cpp
+++ b/src/direct_bt/BTTypes0.cpp
@@ -1,6 +1,6 @@
/*
* Author: Sven Gothel <[email protected]>
- * Copyright (c) 2020 Gothel Software e.K.
+ * Copyright (c) 2021 Gothel Software e.K.
* Copyright (c) 2020 ZAFENA AB
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -34,7 +34,7 @@
#include <jau/debug.hpp>
#include <jau/darray.hpp>
-#include "BTTypes.hpp"
+#include "BTTypes0.hpp"
using namespace direct_bt;
@@ -145,9 +145,95 @@ BLERandomAddressType EUI48::getBLERandomAddressType(const BDAddressType addressT
}
}
-std::string EUI48::toString() const {
+std::string EUI48Sub::toString() const noexcept {
+ // str_len = 2 * len + ( len - 1 )
+ // str_len = 3 * len - 1
+ // len = ( str_len + 1 ) / 3
std::string str;
- str.reserve(17);
+ str.reserve(3 * length - 1);
+
+ for(int i=length-1; 0 <= i; i--) {
+ jau::byteHexString(str, b[i], false /* lowerCase */);
+ if( 0 < i ) {
+ str.push_back(':');
+ }
+ }
+ return str;
+}
+
+EUI48Sub::EUI48Sub(const std::string str) {
+ const jau::nsize_t str_len = static_cast<jau::nsize_t>( str.length() );
+ length = 0;
+
+ if( 17 < str_len ) { // not exceeding byte_size
+ throw jau::IllegalArgumentException("EUI48 sub-string must be less or equal length 17 but "+std::to_string(str_len)+": "+str, E_FILE_LINE);
+ }
+ const char * str_ptr = str.c_str();
+ jau::nsize_t j=0;
+ uint8_t b_[6]; // intermediate result high -> low
+ while( j+1 < str_len /* && byte_count_ < byte_size */ ) { // min 2 chars left
+ if( ':' == str[j] ) {
+ ++j;
+ } else {
+ if ( sscanf(str_ptr+j, "%02hhx", &b_[length]) != 1 ) // b_: high->low
+ {
+ std::string msg("EUI48Sub sub-string not in format '01:02:03:0A:0B:0C' but '"+str+"', pos "+std::to_string(j)+", len "+std::to_string(str_len));
+ throw jau::IllegalArgumentException(msg, E_FILE_LINE);
+ }
+ j += 2;
+ ++length;
+ }
+ }
+ for(j=0; j<length; ++j) { // swap low->high
+ b[j] = b_[length-1-j];
+ }
+ // sscanf provided host data type, in which we store the values,
+ // hence no endian conversion
+}
+
+EUI48Sub::EUI48Sub(const uint8_t * b_, const jau::nsize_t len_) noexcept {
+ length = len_;
+ memcpy(b, b_, std::max<jau::nsize_t>(sizeof(b), len_));
+}
+
+jau::snsize_t EUI48::indexOf(const EUI48Sub& other) const noexcept {
+ if( 0 == other.length ) {
+ return 0;
+ }
+ const uint8_t first = other.b[0];
+ const jau::nsize_t outerEnd = 6 - other.length + 1; // exclusive
+
+ for (jau::nsize_t i = 0; i < outerEnd; i++) {
+ // find first char of other
+ while( b[i] != first ) {
+ if( ++i == outerEnd ) {
+ return -1;
+ }
+ }
+ if( i < outerEnd ) { // otherLen chars left to match?
+ // continue matching other chars
+ const jau::nsize_t innerEnd = i + other.length; // exclusive
+ jau::nsize_t j = i, k=0;
+ do {
+ if( ++j == innerEnd ) {
+ return i; // gotcha
+ }
+ } while( b[j] == other.b[++k] );
+ }
+ }
+ return -1;
+}
+
+bool EUI48::contains(const EUI48Sub& other) const noexcept {
+ return 0 <= indexOf(other);
+}
+
+std::string EUI48::toString() const noexcept {
+ // str_len = 2 * len + ( len - 1 )
+ // str_len = 3 * len - 1
+ // len = ( str_len + 1 ) / 3
+ std::string str;
+ str.reserve(17); // 6 * 2 + ( 6 - 1 )
for(int i=6-1; 0 <= i; i--) {
jau::byteHexString(str, b[i], false /* lowerCase */);
@@ -168,7 +254,7 @@ EUI48::EUI48(const std::string str) {
if ( sscanf(str.c_str(), "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
&b[5], &b[4], &b[3], &b[2], &b[1], &b[0]) != 6 )
{
- std::string msg("EUI48 string not in format '01:02:03:0A:0B:0C' but "+str);
+ std::string msg("EUI48 string not in format '01:02:03:0A:0B:0C' but '"+str+"'");
throw jau::IllegalArgumentException(msg, E_FILE_LINE);
}
@@ -176,8 +262,8 @@ EUI48::EUI48(const std::string str) {
// hence no endian conversion
}
-EUI48::EUI48(const uint8_t * _b) noexcept {
- memcpy(b, _b, sizeof(b));
+EUI48::EUI48(const uint8_t * b_) noexcept {
+ memcpy(b, b_, sizeof(b));
}
const EUI48 direct_bt::EUI48::ANY_DEVICE; // default ctor is zero bytes!
diff --git a/src/direct_bt/DBTTypes.cpp b/src/direct_bt/BTTypes1.cpp
index 8a8d4558..7db5617c 100644
--- a/src/direct_bt/DBTTypes.cpp
+++ b/src/direct_bt/BTTypes1.cpp
@@ -36,7 +36,7 @@
// #define VERBOSE_ON 1
#include <jau/debug.hpp>
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
extern "C" {
#include <inttypes.h>
diff --git a/src/direct_bt/CMakeLists.txt b/src/direct_bt/CMakeLists.txt
index 0325c058..89ff0588 100644
--- a/src/direct_bt/CMakeLists.txt
+++ b/src/direct_bt/CMakeLists.txt
@@ -16,25 +16,25 @@ set (direct_bt_LIB_SRCS
${PROJECT_SOURCE_DIR}/jaulib/src/debug.cpp
${PROJECT_SOURCE_DIR}/jaulib/src/basic_types.cpp
${PROJECT_SOURCE_DIR}/src/ieee11073/DataTypes.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/UUID.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/BTTypes.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/ATTPDUTypes.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTAdapter.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTDevice.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTGattDesc.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTGattChar.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTGattService.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTGattHandler.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTManager.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTTypes0.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/BTTypes1.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/GATTNumbers.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/HCIComm.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/HCITypes.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/HCIHandler.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/HCITypes.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/L2CAPComm.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/SMPTypes.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/MgmtTypes.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/DBTManager.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/DBTTypes.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/DBTAdapter.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/DBTDevice.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/ATTPDUTypes.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/GATTNumbers.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/GATTDescriptor.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/GATTCharacteristic.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/GATTService.cpp
- ${PROJECT_SOURCE_DIR}/src/direct_bt/GATTHandler.cpp
${PROJECT_SOURCE_DIR}/src/direct_bt/SMPHandler.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/SMPTypes.cpp
+ ${PROJECT_SOURCE_DIR}/src/direct_bt/UUID.cpp
# autogenerated files
${CMAKE_CURRENT_BINARY_DIR}/../version.c
)
diff --git a/src/direct_bt/GATTNumbers.cpp b/src/direct_bt/GATTNumbers.cpp
index 85696f2b..7816c2eb 100644
--- a/src/direct_bt/GATTNumbers.cpp
+++ b/src/direct_bt/GATTNumbers.cpp
@@ -34,7 +34,7 @@
#include <jau/darray.hpp>
#include <jau/debug.hpp>
-#include "GATTNumbers.hpp"
+#include "GattNumbers.hpp"
using namespace direct_bt;
diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp
index 2d500068..47dd325b 100644
--- a/src/direct_bt/HCIHandler.cpp
+++ b/src/direct_bt/HCIHandler.cpp
@@ -43,7 +43,7 @@
#include "HCIIoctl.hpp"
#include "HCIComm.hpp"
#include "HCIHandler.hpp"
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
extern "C" {
#include <inttypes.h>
diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp
index 08e08fe6..d56b8950 100644
--- a/src/direct_bt/L2CAPComm.cpp
+++ b/src/direct_bt/L2CAPComm.cpp
@@ -23,6 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <BTAdapter.hpp>
#include <cstring>
#include <string>
#include <memory>
@@ -41,7 +42,6 @@
#include "HCIComm.hpp"
#include "L2CAPComm.hpp"
-#include "DBTAdapter.hpp"
extern "C" {
#include <unistd.h>
@@ -126,7 +126,7 @@ L2CAPComm::L2CAPComm(const EUI48& adapterAddress_, const uint16_t psm_, const ui
*/
#define SET_BT_SECURITY_POST_CONNECT 1
-bool L2CAPComm::open(const DBTDevice& device, const BTSecurityLevel sec_level) {
+bool L2CAPComm::open(const BTDevice& device, const BTSecurityLevel sec_level) {
bool expOpen = false; // C++11, exp as value since C++20
if( !is_open.compare_exchange_strong(expOpen, true) ) {
diff --git a/src/direct_bt/MgmtTypes.cpp b/src/direct_bt/MgmtTypes.cpp
index dcd85839..564ef038 100644
--- a/src/direct_bt/MgmtTypes.cpp
+++ b/src/direct_bt/MgmtTypes.cpp
@@ -40,7 +40,7 @@
#include "MgmtTypes.hpp"
#include "HCIIoctl.hpp"
#include "HCIComm.hpp"
-#include "DBTTypes.hpp"
+#include "BTTypes1.hpp"
extern "C" {
#include <inttypes.h>
diff --git a/src/direct_bt/SMPHandler.cpp b/src/direct_bt/SMPHandler.cpp
index cc4e97ff..ae2898f6 100644
--- a/src/direct_bt/SMPHandler.cpp
+++ b/src/direct_bt/SMPHandler.cpp
@@ -52,8 +52,8 @@ extern "C" {
#include "SMPHandler.hpp"
-#include "DBTDevice.hpp"
-#include "DBTAdapter.hpp"
+#include <BTDevice.hpp>
+#include <BTAdapter.hpp>
using namespace direct_bt;
@@ -72,8 +72,8 @@ SMPEnv::SMPEnv() noexcept
bool SMPHandler::IS_SUPPORTED_BY_OS = false;
#endif
-std::shared_ptr<DBTDevice> SMPHandler::getDeviceChecked() const {
- std::shared_ptr<DBTDevice> ref = wbr_device.lock();
+std::shared_ptr<BTDevice> SMPHandler::getDeviceChecked() const {
+ std::shared_ptr<BTDevice> ref = wbr_device.lock();
if( nullptr == ref ) {
throw jau::IllegalStateException("SMPHandler's device already destructed: "+deviceString, E_FILE_LINE);
}
@@ -155,7 +155,7 @@ void SMPHandler::l2capReaderThreadImpl() {
disconnect(true /* disconnectDevice */, has_ioerror);
}
-SMPHandler::SMPHandler(const std::shared_ptr<DBTDevice> &device) noexcept
+SMPHandler::SMPHandler(const std::shared_ptr<BTDevice> &device) noexcept
: env(SMPEnv::get()),
wbr_device(device), deviceString(device->getAddressAndType().toString()), rbuffer(number(Defaults::SMP_MTU_BUFFER_SZ)),
l2cap(device->getAdapter().getAddress(), L2CAP_PSM_UNDEF, L2CAP_CID_SMP),
@@ -256,7 +256,7 @@ bool SMPHandler::disconnect(const bool disconnectDevice, const bool ioErrorCause
PERF3_TS_TD("SMPHandler::disconnect.2");
if( disconnectDevice ) {
- std::shared_ptr<DBTDevice> device = getDeviceUnchecked();
+ std::shared_ptr<BTDevice> device = getDeviceUnchecked();
if( nullptr != device ) {
// Cleanup device resources, proper connection state
// Intentionally giving the POWER_OFF reason for the device in case of ioErrorCause!
@@ -287,14 +287,14 @@ void SMPHandler::send(const SMPPDUMsg & msg) {
IRQ_PRINT("SMPHandler::send: l2cap write error -> disconnect: %s to %s", msg.toString().c_str(), deviceString.c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */); // state -> Disconnected
- throw BluetoothException("SMPHandler::send: l2cap write error: req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
+ throw BTException("SMPHandler::send: l2cap write error: req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
}
if( static_cast<size_t>(res) != msg.pdu.getSize() ) {
ERR_PRINT("SMPHandler::send: l2cap write count error, %zd != %zu: %s -> disconnect: %s",
res, msg.pdu.getSize(), msg.toString().c_str(), deviceString.c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */); // state -> Disconnected
- throw BluetoothException("SMPHandler::send: l2cap write count error, "+std::to_string(res)+" != "+std::to_string(res)
+ throw BTException("SMPHandler::send: l2cap write count error, "+std::to_string(res)+" != "+std::to_string(res)
+": "+msg.toString()+" -> disconnect: "+deviceString, E_FILE_LINE);
}
}
@@ -309,7 +309,7 @@ std::unique_ptr<const SMPPDUMsg> SMPHandler::sendWithReply(const SMPPDUMsg & msg
IRQ_PRINT("SMPHandler::sendWithReply: nullptr result (timeout %d): req %s to %s", timeout, msg.toString().c_str(), deviceString.c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */);
- throw BluetoothException("SMPHandler::sendWithReply: nullptr result (timeout "+std::to_string(timeout)+"): req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
+ throw BTException("SMPHandler::sendWithReply: nullptr result (timeout "+std::to_string(timeout)+"): req "+msg.toString()+" to "+deviceString, E_FILE_LINE);
}
return res;
}
diff --git a/test/direct_bt/test_attpdu01.cpp b/test/direct_bt/test_attpdu01.cpp
index 16ee20aa..955f98c2 100644
--- a/test/direct_bt/test_attpdu01.cpp
+++ b/test/direct_bt/test_attpdu01.cpp
@@ -10,7 +10,7 @@
#include <direct_bt/UUID.hpp>
// #include <direct_bt/BTAddress.hpp>
-// #include <direct_bt/DBTTypes.hpp>
+// #include <direct_bt/BTTypes1.hpp>
#include <direct_bt/ATTPDUTypes.hpp>
// #include <direct_bt/GATTHandler.hpp>
// #include <direct_bt/GATTIoctl.hpp>