summaryrefslogtreecommitdiffstats
path: root/java/direct_bt
Commit message (Collapse)AuthorAgeFilesLines
* GATT Service and Characteristic Java <-> JNI binding (incomplete, TODO ↵Sven Gothel2020-05-143-17/+74
| | | | Descriptor)
* DBTManager(java/jni): get/setDefaultAdapter(..) java side implementation, ↵Sven Gothel2020-05-141-7/+11
| | | | remove JNI code
* Fixing multiple Java/C++ Lifecycle Issues (DBTDevice, add ShutdownHook, ..)Sven Gothel2020-05-123-3/+103
| | | | | | | | | | | | | | | | | | | | | | 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(..).
* Revert "Adapter::startDiscovery(): removeDevices() will not work as ↵Sven Gothel2020-05-111-0/+1
| | | | | | previously scanned devices may still be in use!" This reverts commit 09cd1183b3599357b05c426e2b59e8df813304c5.
* Adapter::startDiscovery(): removeDevices() will not work as previously ↵Sven Gothel2020-05-111-1/+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
* Move general types out of MgmtTypes; Extract DBTDevice + DBTAdapter into ↵Sven Gothel2020-05-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Converging Java/JNI and C++ API to match tinyb interface requirements (step-2)Sven Gothel2020-05-102-115/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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-102-27/+95
| | | | | | | | | | | | | | | | | 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
* Extend BluetoothDeviceStatusListener -> BluetoothAdapterStatusListener; Enum ↵Sven Gothel2020-05-041-61/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* DBTAdapter Java/JNI: Add enable/disable Powered|Discovering NotificationsSven Gothel2020-05-031-31/+44
| | | | | | | 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.
* DBTAdapter: Cleanup and sort fields, isOpen:=false on close.Sven Gothel2020-05-031-16/+21
|
* Java: Utilize new EIRDataType in BluetoothDeviceStatusListener; ...Sven Gothel2020-05-032-6/+11
| | | | | | | | | | | | | | | | - 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)
* DBTManager Java: Add getAdapterListImpl()Sven Gothel2020-05-022-23/+29
| | | | | getAdapterListImpl() JNI code utilizes new convert_vector_to_jobject(..) with given ctor function defined ad-hoc via lambda.
* DBTManager / DBTDeviceStatusListener: Refine events; java: Keep alive ↵Sven Gothel2020-04-261-156/+82
| | | | | | | | | | | | | | | | | | | | | | | | discovery; Remove discovery thread (1) DBTAdapter: Keep alive discovery DBTDeviceStatusListener (incl Java binding: - DBTDeviceDiscoveryListener -> DBTDeviceStatusListener to cover more functionality - Rename deviceAdded -> deviceFound, to match BlueZ event naming - Rename deviceRemoved -> deviceDisconnected - Add deviceConnected HCIComm/DBTAdapter: Use HCIAddressType where applicable for clarity MgmtEvent: Add timestamp MgmtEvent: Add MgmtEvtDeviceConnectFailed, MgmtEvtDeviceAdded, MgmtEvtDeviceRemoved, MgmtEvtDeviceUnpaired +++ DBTAdapter.java remove discovery thread (part 1) - Use events, no more discovery polling required - TODO: Same for native DBTAdapter.cpp!
* Refine: DBT API, HCISession/DBTAdapter lifecycle, API doc and C++ and ↵Sven Gothel2020-04-211-11/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++/JNI exception handling - HCISession: Handle multiple connections - DBTDevice holds le_conn_handle and provides the le_disconnect as well - HCISession maintains a vector of connected devices - HCISession/DBTAdapter: Cleanup shutdown and refine lifecycle - DBTDevice/DBTAdapter: Drop explicit HCISession argument, simply use the attached HCISession of DBTAdapter. - Refine API doc in general +++ - Device Java/JNI: Add a few more methods to test connect/disconnect. +++ Refine C++ and C++/JNI exception handling: - Use new java_exception_check_and_throw(..): Throw C++ exception on pending Java exception, retrieving toString() message. - Use new java_exception_check(..): Return immediately from JNI on pending Java exception. - Replace macro CATCH_EXCEPTION_AND_RAISE_JAVA(..) with new rethrow_and_raise_java_exception(..), re-trhowing exception and raising detailed Java exception.
* HCIComm thread safety, resolve deadlock; Renaming: MgmtHandler -> ↵Sven Gothel2020-04-201-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | DBTManager, revert DBTSession -> HCISession HCIComm thread safety With the java DBTAdapter, we have introduces multithreading access to the HCIComm instance: start/stop etc + discovery-thread. We have experienced a deadlock issuing stopDiscovery() while the discovery-thread is in progress. HCIComm and its dd is now locked using a recursive mutex, which is also being exposed to HCISession allowing DBTAdapter's discovery to use it as well. +++ Renaming: MgmtHandler -> DBTManager, revert DBTSession -> HCISession HCISession is not a major DBT (direct-bt) (java) instance and actually describing the HCI(Comm) session. DBTManager is a major DBT java instance, mapped. Hence also splitting MgmtComm.* -> MgmtTypes.* + DBTManager.*
* Direct-BT: Fix BluetoothFactory; Renaming using 'DBT' prefixSven Gothel2020-04-208-48/+42
| | | | | - Fix BluetoothFactory: Group implementation identification (class-name and lib-names) - Renaming using 'DBT' prefix, easing identification (java and HCITypes -> DBTTypes)
* Initial working Java binding for the direct_bt C++ moduleSven Gothel2020-04-209-0/+1356
Example ScannerTinyB01 demonstrates efficient scanning devices using the new BluetoothDeviceDiscoveryListener interface. The C++ HCIObject extends JavaUplink, which handles the java object references via 'std::shared_ptr<JavaAnonObj>', where JavaAnonObj relies on later polymorph specialization. JavaAnonObj gets derived in the java/jni of direct_bt, where the JNI header + libraries are available. +++ The java inplementing NativeDownlink implementations store the nativeInstance to the C++ instances as well as handle their java references within the native instances. The C++ JavaUplink and Java NativeDownlink interfaces are complete the cross referencing java <-> native. +++ Native libraries are now split into pairs: - tinyb + javatinyb - direct_bt + javadirect_bt TODO: BluetoothFactory must chose the proper bundle! +++ The Java Adapter received a BluetoothDeviceDiscoveryListener hook, matching C++ Adapter's HCIDeviceDiscoveryListener. Since the Java Adapter implements its own discovery thread, using the BluetoothDeviceDiscoveryListener is more efficient then polling over a list of Devices fetched. ++++ TODO: Align Java and C++ class names, foremost in the C++ direct_bt space. TODO: Bind the whole C++ GATT functionality More testing.