aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* API doc AdapterStatusListener, GATTCharacteristicListener restriction: One ↵Sven Gothel2020-05-182-2/+27
| | | | | | instance can only be attached once. To attach multiple instances, you need to create one instance per attachment.
* sloccount: Adding java/jni and test codeSven Gothel2020-05-171-1/+5
|
* Working GATT Java Side; GATT Types made fully functional for user to avoid ↵Sven Gothel2020-05-1754-930/+3116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'technical' GATTHandler GATT Types made fully functional for user to avoid 'technical' GATTHandler (C++) > GATTService, GATTCharacteristic, GATTDescriptor -- Reside in their own respective files -- Added semantic methods (readValue(), ..) implemented using DBTDevice -> GATTHandler -- GATTDescriptor owns its value -- GATTHandler setSendIndicationConfirmation(..) defaults to true -- Allow user to cirvumvent using GATTHandler manually completely, device 1--*> services 1--*> characteristics 1--*> descriptor -- C++ GATT types aligned 1:1 to TinyB (Java) > Merged GATTIndicationListener + GATTNotificationListener -> GATTCharacteristicListener -- Simplifying usage, unifying notification and indication -- Now using a list of shared_ptr<GATTCharacteristicListener> allowing multiple actors instead of just a one shot entry. Similar to AdapterStatusListener, we utilize this also on the Java side to implement the TinyB notifications. See dbt_scanner00.cpp: Simplified high-level usage. See dbt_scanner01.cpp: Lower-level technical usage w/ GATTHandler. +++ > Simplified more names > Removed redundancy in listener callbacks, -- don't pass adapter when device is already given. device <*--1> adapter -- don't pass GATT handle explicitly when characteristic is passed > Comparison of all GATT types are done by their respective unique handle Attribute handles are unique for each device (server) (BT Core Spec v5.2: Vol 3, Part F Protocol..: 3.2.2 Attribute Handle) > GATTHandler: Own L2CAPComm instance directly, instead of shared_ptr. > JNIMem: Added JNICriticalArray class for RAII style release ++++ ++++ Working GATT Java Side > All toString() methods return the C++ toString() via JNI for better representation. > DBTDevice.java/JNI: Resolved the odd 'adapter' reference issue: -- Was not passing the jobject of DBTAdapter, but its shared container refeference ;-) > All GATT types receive their GATT handler for equal test and identity @ ctor > GATT read/write Value update the cached value as well as issue the notifyValue on change, including GATTCharacteristic notification/indication listener
* GATT Cleanup of method + field names; GATT discoverDescriptors: Use more ↵Sven Gothel2020-05-157-196/+213
| | | | | | | | | | | | | | | | | | | | reasonable and efficient traversal... GATT Cleanup of method + field names - the service and characteristic uuid's specify types, hence name field *type* being of value-type uuid_t. - use short and clear names like 'Characteristic' and simply 'Descriptor' for 'Characteristic Descriptor'. - etc etc GATT discoverDescriptors: Use more reasonable and efficient traversal through Charactecteristics - Previous we traversed through all handle of services for Descriptors, only to find the matching Charactecteristic to attach to. The latter was done via another loop through all Charactecteristic and hence even reduced performance by one magnitude. Further, not all handles reflect Descriptors ;-) - Simply iterate through all Charactecteristic and find their Descriptors within their value handle range as per BT spec. Also read the Descriptor value right away.
* GATT Service and Characteristic Java <-> JNI binding (incomplete, TODO ↵Sven Gothel2020-05-146-23/+170
| | | | Descriptor)
* C++ GATT: Cleanup and complete Descriptor <*-1> Characteristic <*-1> ServiceSven Gothel2020-05-145-315/+341
| | | | | | | | | | | | Cleanup GATT type names aligned to TinyB. Remove unused types. Complete relationship: Descriptor <*-1> Characteristic <*-1> Service, read all Descriptor with value instead of only ClientCharacteristicConfig. Prepate for GATT Descriptor: Extended properties etc, TODO: parse! Add JavaUplink, preparing for JNI.
* DBTDevice JNI: Add comment re delete and add javaObject checkSven Gothel2020-05-141-0/+2
|
* DBTManager(java/jni): get/setDefaultAdapter(..) java side implementation, ↵Sven Gothel2020-05-142-44/+11
| | | | remove JNI code
* jni helper: Unique rename for 'convert_vector*(..)' template functionsSven Gothel2020-05-1410-53/+19
|
* Fixing multiple Java/C++ Lifecycle Issues (DBTDevice, add ShutdownHook, ..)Sven Gothel2020-05-1214-32/+201
| | | | | | | | | | | | | | | | | | | | | | DBTDevice - don't native delete @ JNI deleteImpl, adapter holds share_ptr ownership - only create its java object 1st time @ deviceFound callback of JNI DBTAdapter DBTAdapter::mgmtEvDeviceFoundCB - in case of !discoveredDeviceList but sharedDeviceList, the device shall be updated first, then deviceFound callbacks issued, allowing listener to act and register, then deviceUpdate callbacks issued, allowing data update on existing actors DBTManager.java: - Add ShutdownHook calling custom hooks and shutdown() - shutdown() in depth shutdown: -- iterated through all adapter issueing adapter.close() -- Adapter.close() iterates through all discoveredDevices issuing close() DBTDevice.java: - adds adapter JNI proxy to removeStatusListener(..), same 'to be resolved' issue as with addStatusListener(..).
* Catching device loop exception - need to shutdown device while VM running!Sven Gothel2020-05-111-83/+87
| | | | | | | | | | | | | | | | | | ****** Loop 3 Caught: Inconsistent discovered device count: Native 3, callback 1 java.lang.InternalError: Inconsistent discovered device count: Native 3, callback 1 at direct_bt.tinyb.DBTAdapter.removeDevices(DBTAdapter.java:280) at direct_bt.tinyb.DBTAdapter.startDiscovery(DBTAdapter.java:249) at ScannerTinyB01.main(ScannerTinyB01.java:194) ... Exception thrown due to discoveredDevices differences of native / java side. We may resolve this issue or allow such case. However, we need to properly shutdown the native direct_bt before the VM exits - otherwise we won't be able handle the lost Java references. TODO: Add a java shutdown hook!
* HCISession::disconnected: Don't throw exception, intentionally called at ↵Sven Gothel2020-05-114-7/+10
| | | | closing w/o being connected
* Resolving flushed discovered devices and shared device reference usage.Sven Gothel2020-05-116-64/+203
| | | | | | | | | | | | | | | | | | | | | Commit 09cd1183b3599357b05c426e2b59e8df813304c5 describes existed issue in a multi device and hence multi-device-discovery environment. (The change has been reverted) This changed resolves the shared device reference usage, by having adapter maintaining a 'sharedDevices' list in parallel to the 'discoveredDevices'. Adapter will add a newly found and created device to both lists, shared- and discovered devices. Device may remove itself from the sharedDevices list via remove() and its destructor. Adapter will also look in sharedDevices in connected and found callback to determine if a device is known and re-adds it to the discovered devices list for consistency. (Note: discoveredDevices may be flushed via a new startDiscovery)
* Revert "Adapter::startDiscovery(): removeDevices() will not work as ↵Sven Gothel2020-05-112-0/+2
| | | | | | previously scanned devices may still be in use!" This reverts commit 09cd1183b3599357b05c426e2b59e8df813304c5.
* ScannerTinyB00/01: stopDiscovery() will not shut down everything using ↵Sven Gothel2020-05-112-4/+0
| | | | | | | | direct_bt, .. .. however, keeping discovery alive while GATT processing will [naturally] slow down performance. Therefor, discovery should be stopped before GATT processing if possible.
* Adapter::startDiscovery(): removeDevices() will not work as previously ↵Sven Gothel2020-05-112-2/+0
| | | | | | | | | | | | | | | scanned devices may still be in use! In an multi device environment, it is possible to have one device already scanned and 'in use' w/ GATT processing while we enter a new discovery for additional devices. We need to think about a smart method to kick out 'old devices' which are not in use and are no more available. This is curently only possible for: - end of device operation, manually remove from list - communication breakup, i.e. loss of [GATT] communication
* Shape GATTServiceDecl + GATTCharacterisicsDecl into TinyB API conform data ↵Sven Gothel2020-05-115-76/+74
| | | | | | | | | | | | | | | | | | | | relationship GATTServiceDecl: Add DBTDevice reference and 'isPrimary' GATTCharacterisicsDecl: Add GATTServiceDecl reference and remove now obsolete copies of service_uuid and service_handle_end. +++ GattHandler only have ctor w/ DBTDevice reference hence and pass the GATTServiceDeclRef by reference itself (efficiency). +++ TODO: Add the JNI code and complete the GATT Java binding to access native GATTServiceDecl + GATTCharacterisicsDecl mapping and also support the read/write functionality via GATTHandler.
* GATT: GATTPrimaryService -> GATTServiceDecl (-> GATTTypes.hpp) ; Add ↵Sven Gothel2020-05-115-72/+85
| | | | JavaUplink base to GATTCharacterisicsDecl + GATTServiceDecl
* Move general types out of MgmtTypes; Extract DBTDevice + DBTAdapter into ↵Sven Gothel2020-05-1118-783/+1014
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | their own header files; Added DirectBT.hpp Move general out of MgmtTypes - BTMode -> BTTypes.gpp - AdapterSetting -> DBTTypes.hpp - AdapterInfo -> DBTTypes.hpp - ConnectionInfo -> DBTTypes.hpp - NameAndShortName -> DBTTypes.hpp Consequently add 'to<Type>()' methods to the respective MgmtEvent types, allowing seamless constructing with validation. This data extraction is perfromed to isolate the Mgmt* type from the general API, as MgmtTypes and DBTManager are more implementation specific (-> BlueZ Linux Kernel). +++ Extract DBTDevice + DBTAdapter into their own header files. With the above move of general data types into DBTTypes.hpp, the extraction of the central DBTDevice + DBTAdapter types shall support clarity. +++ Added convenient DirectBT.hpp for user space applications.
* BasicAlgos: Rename 'InputIt' -> 'InputArray' for template type, indicating ↵Sven Gothel2020-05-101-4/+4
| | | | indexed array usage, not iterator
* Converging Java/JNI and C++ API to match tinyb interface requirements (step-2)Sven Gothel2020-05-1021-234/+1074
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - BasicTypes: Align exception names w/ Java. - BTTypes / EInfoReport: Add getDeviceIDModalias() - DBTManager: Add getConnectionInfo(..) and setLocalName(..) - OctetTypes: Fix put_octets(..), removed sizeof(). Adding put/get string methods +++ DBTTypes: - Fix Comments - DBTDevice: Add appearance, getConnectionInfo(), connectGATT(..) and disconnectGATT(). Last two GATT's ease association of GATTHandler w/ device for tinyb binding. - DBTDevice: Fix defaultConnect(): Differenciate le public/random - DBTDevice: New getConnectionInfo() - also may issue deviceUpdate callback on rssi/tx_power changes - DBTAdapter: Add missing DBTAdapterStatusListener list declaration of previous commit. - DBTAdapter: Add misc information access for tinyb binding. +++ Java - DBTAdapter: Adding more tinyb implementation code, sorting methods - ~90% complete - DBTDevice: Adding more tinyb implementation code, sorting methods - ~70% complete
* [Bluetooth]AdapterStatusListener: Renamed; Using a list instead of one-shot ↵Sven Gothel2020-05-1012-84/+410
| | | | | | | | | | | | | | | | | callback; Mutable callbacks for_each... [Bluetooth]AdapterStatusListener: - Renamed BluetoothAdapterStatusListener -> AdapterStatusListener - Using a list instead of one-shot callback: Allows utilizing information from multiple actors, which also allows a more efficient implementation of the tinyb interfaces. - Mutable callbacks for_each...: BasicAlgos.hpp adds for_each_idx_mtx(..) template algos, allowing to perform one UnaryFunction via indices and utilizing mutex lock for thread safety. This pattern reduces code complexity, as we need to use the visitor model for the listener multiple times. - Java: DBTDevice's AdapterStatusListener hook performs certain TinyB one-shot callbacks
* Eclipse settingsSven Gothel2020-05-042-34/+32
|
* JNI DBTAdapter: Enhance callback pattern (here DiscoveringNotifications); ↵Sven Gothel2020-05-041-129/+33
| | | | | | | | | | | | | | | | | | | | | | PoweredNotification has been dropped .. JNI DBTAdapter: Enhance callback pattern (here DiscoveringNotifications) - Use 1:1 native methods for java callback API w/o need for intermediate java code - get/set/clear the corresponding jlong InvocationFunc<..> callback field, holding the identity copy instance of used callback. We use 'funcDef.cloneFunction()' for this purpose - Use JNIGlobalRef's move-ctor to have it placed within CaptureInvocationFunc - Use JNIGlobalRed's operator== to have the actuall callback included in equality operation (callback identity) +++ PoweredNotification has been dropped .. - NEW_SETTINGS deduced callbacks are derived from BluetoothAdapterStatusListener callback
* helper_base: Add generic getField(..), getObjectRef<T>(..) and ↵Sven Gothel2020-05-042-29/+49
| | | | | | | | | setObjectRef<T>(..) Generic getField(..) allows convenient fetching of object fields. getObjectRef<T>(..) and setObjectRef<T>(..) allows get/set of jlong references of any user type pointer (reference).
* JNIGlobalRef: Add copy-ctor, move-ctor and equality operationsSven Gothel2020-05-042-3/+68
| | | | | | | | | | | | | | | | | | | | Goal is to utilize JNIGlobalRef as a first class shared jobject instance without the need to use std::shared_ptr<JNIGlobalRef>. +++ Efficiency and functionality: Add copy-ctor, move-ctor - Allow a JNIGlobalRef to be shared by creating copies with a 'NewGlobalRef(..)'. - Allow JNIGlobalRef to be moved by 'nulling' the source jobject +++ Functionality: Add equality operations - test inner jobject via 'IsSameObject(..)'
* FunctionDef: Enhance efficiency and create InvocationFunc<..>::clone() and ↵Sven Gothel2020-05-042-60/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | FunctionDef<..>::cloneFunction() ... Enhance efficiency - Equality: Check pointer first - CaptureInvocationFunc function spec uses 'I& data', by reference - CaptureInvocationFunc ctor supports 'I&& data' move-ctor and 'const I& data' copy-ctor w/ later copy (instead relying of in place) - Added FunctionDef ctor for naked InvocationFunc<..> for convenience - Added FunctionDef getFunction(), allowing user to 'see' the InvocationFunc<..> shared instance. +++ FunctionDef: Create InvocationFunc<..>::clone() and FunctionDef<..>::cloneFunction() ... - This allows user to reproduce an identical InvocationFunc<..> polymorph instance (copy-ctor) - Such instance can be used to reproduce an identical FunctionDef later on, here intended for a listener vector equality test for removal. Allowing not to use any intermediate data types.
* cppunit: fix ::print (global static)Sven Gothel2020-05-041-1/+1
|
* Extend BluetoothDeviceStatusListener -> BluetoothAdapterStatusListener; Enum ↵Sven Gothel2020-05-0418-411/+658
| | | | | | | | | | | | | | | | | | | | | | | | | | | bit field mask: Add AdapterSettings , fix EIRDataType -> EIRDataTypeSet Extend Java BluetoothDeviceStatusListener -> BluetoothAdapterStatusListener and C++ DBTDeviceStatusListener -> DBTAdapterStatusListener - BluetoothAdapterStatusListener shall be (ab)used for anything adapter event related, user may utilize it (optional) - Added callback method adapterSettingsChanged(..) in DBTAdapterStatusListener - An internal listener further produces more detailed callbacks, used on the Java side. +++ Java enum bit field mask: Add AdapterSettings , fix EIRDataType -> EIRDataTypeSet - In Java, we cannot have an indivudual enum instance (like in C++) ;-) - Hence 'enum EIRDataType' -> EIRDataTypeSet.DataType and having the 'bit mask' implemented in EIRDataTypeSet. - Adding similar AdapterSettings bit field, utilized in DBTAdapter's internal BluetoothAdapterStatusListener to produce fine grained callbacks.
* examples: remove warningsSven Gothel2020-05-031-1/+7
|
* JNI: DBTAdapter: Use new FunctionDef::CaptureInvocationFuncSven Gothel2020-05-031-6/+38
|
* FunctionDef: Add CaptureInvocationFunc supporting lambdas w/ an explicit ↵Sven Gothel2020-05-034-124/+306
| | | | | | | | | | | | | | | | | | | | capture instance Commit efa490bc3f55b1af072b5159d075afece018991f introduced StdInvocationFunc, which utilized std:function for capturing lambdas. Since it requires to pass a unique key for equality operation, it is rather a poor workaround for capturing lambdas. CaptureInvocationFunc allows one explicit capture data type to be stored, which will be implicitly passed to the custom function @ invoke. The bindCaptureFunc(..) allows to set dataIsIdentity=false (defaults to true), i.e. ignore the capturing data to be compared in the equality operation. CaptureInvocationFunc allows producing FunctionDef using lambdas on-the-fly, w/o specifying an explicit unique key and dropping the usage of a more complex std::function instance.
* add rebuild script .. convenient faster build, install and test after ↵Sven Gothel2020-05-031-0/+21
| | | | initial build
* DBTAdapter Java/JNI: Add enable/disable Powered|Discovering NotificationsSven Gothel2020-05-033-33/+194
| | | | | | | For now, we store the on-the-fly JNI callback lambda via bindStdFunc(..) and use the 'jobject obj' as the unique id for equality operation. Tested via ScannerTinyB01.
* MgmtAdapterEventCallback: Pass MgmtEventCallback by reference, avoiding one copySven Gothel2020-05-031-1/+1
|
* FunctionDef: Add StdInvocationFunc supporting std::function for capturing ↵Sven Gothel2020-05-032-0/+101
| | | | | | | | | | | | lambdas StdInvocationFunc wraps std::function, while using a given unique uint64_t identifier used for equality operations, as std::function doesn't support the very same. std::function support allows using capturing lambdas in C++11, which we require for on the fly callbacks. Since we haven't figured out yet how to properly wrap capturing lambdas otherwise via PlainInvocationFunc, StdInvocationFunc must do it until.
* DBTAdapter: Cleanup and sort fields, isOpen:=false on close.Sven Gothel2020-05-031-16/+21
|
* ClassFunction -> FunctionDef generalization, adding plain function ↵Sven Gothel2020-05-035-42/+124
| | | | | | | | | | | (non-class-member) support To support on-the-fly lambda non-member functions for callbacks, we need to bind to same non-member plain functions. Hence rename ClassFunction -> FunctionDef and add PlainInvocationFunc for this purpose. Tested via C++ unit test test_basictypes01.cpp
* cmake: COMPILE_FLAGS += -Werror (warnings -> error)Sven Gothel2020-05-032-2/+2
|
* Java: Utilize new EIRDataType in BluetoothDeviceStatusListener; ...Sven Gothel2020-05-038-42/+100
| | | | | | | | | | | | | | | | - Utilize new EIRDataType in BluetoothDeviceStatusListener - DBTAdapter: Add null checks for java callbacks - JNI: Adapt to EIRDataType on deviceUpdated. - DBTManager: Implement getAdapterListImpl(), supporting multiple adapter. JNI Implementation uses proper lambda for java-object ctor and fixed 'convert_vector_to_jobject'. - JNI: Fix 'convert_vector_to_jobject' using vector<unique_ptr<..>> as we cannot escape from a shared_ptr, i.e. no release() of ownership. - Working ScannerTinyB01 (discovery + connect using multiple adapter)
* DBTAdapter::mgmtEvDeviceConnectedCB considers a new connection; Misc ↵Sven Gothel2020-05-031-13/+30
| | | | | | | | | | | | | | | | | | decoration/cleanup mgmtEvDeviceConnectedCB considers a new connection, since the HCI le_connect may timeout on certain poorly supported BT USB adapter. However, we do receive a CONNECTED event, hence register it as a new connection, fetching the device reference from the discoveredDevices. Further update the device using the given EInfoReport and also call deviceUpdated on a present deviceStatusListener for updated information. +++ Throw InternalError if nullptr == session @ MgmtEvent adapter callbacks, indicating erroneous code.
* Ensure unique set of HCISession::connectedDevices and ↵Sven Gothel2020-05-033-2/+15
| | | | | | | | DBTAdapter::discoveredDevices HCISession::disconnected(..): Fix equality comparison: Compare content, not pointer ;-) HCISession::connectedDevices: Make it thread safe via recursive_mutex.
* TROOctets: Add equality operatorSven Gothel2020-05-031-0/+7
|
* DBTManager::close(): Clear adapterInfos (avoiding re-entry failure); Java ↵Sven Gothel2020-05-033-1/+7
| | | | | | | | deleteImpl(): Calls close(). DBTManager::close(): Clear adapterInfos (avoiding re-entry failure), make it functional. Java deleteImpl(): Calls close(), avoiding same on JVM shutdown.
* HCIComm: HCI_TO_SEND_REQ_POLL_MS 1s -> 3s timeoutSven Gothel2020-05-032-3/+3
|
* MgmtEventCallbackList -> MgmtAdapterEventCallbackList: Adding adapter dev_id ↵Sven Gothel2020-05-033-41/+119
| | | | | | | | | | | | | | | for MgmtEvent adapter filtering Registering a MgmtEventCallback for a specified adapter shall only deliver events circulating for same adapter. Intermediate MgmtAdapterEventCallback struct associated the adapter dev_id to the MgmtEventCallback, used to build the MgmtAdapterEventCallbackList. addMgmtEventCallback(..) passes the desired adapter dev_id, -1 to listen to all adapter events. Implementation only adds the callback if not yet present, i.e. key = dev_id + opcode + callback. New 'removeMgmtEventCallback(const int dev_id)' allows removal of all callbacks registered for specified dev_id, which helps reducing user code when deregistering.
* Element -> EIRDataType: Promote to top, add bit-ops and add Java equivalent; ↵Sven Gothel2020-05-037-112/+297
| | | | | | | | EInfoReport: Use EIRDataType for eir_data_mask DBTDevice::update(..) returns the 'EIRDataType updateMask'. DBTDeviceStatusListener::deviceUpdated(..): Add 'EIRDataType updateMask', allowing user to identify the updated data.
* ManufactureSpecificData: Add equality operator ; remove dead declarationSven Gothel2020-05-031-1/+6
|
* JNI helper_base: Robustness: Add java_exception_check_and_throw(..) and use ↵Sven Gothel2020-05-022-13/+19
| | | | InternalError for exceptions.
* DBTManager Java: Add getAdapterListImpl()Sven Gothel2020-05-026-50/+118
| | | | | getAdapterListImpl() JNI code utilizes new convert_vector_to_jobject(..) with given ctor function defined ad-hoc via lambda.