| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
instance can only be attached once.
To attach multiple instances, you need to create one instance per attachment.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
'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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Descriptor)
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
remove JNI code
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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(..).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
****** 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!
|
|
|
|
| |
closing w/o being connected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
| |
previously scanned devices may still be in use!"
This reverts commit 09cd1183b3599357b05c426e2b59e8df813304c5.
|
|
|
|
|
|
|
|
| |
direct_bt, ..
.. however, keeping discovery alive while GATT processing will [naturally] slow down performance.
Therefor, discovery should be stopped before GATT processing if possible.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
JavaUplink base to GATTCharacterisicsDecl + GATTServiceDecl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
indexed array usage, not iterator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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<..>::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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
initial build
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
(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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
DBTAdapter::discoveredDevices
HCISession::disconnected(..): Fix equality comparison: Compare content, not pointer ;-)
HCISession::connectedDevices: Make it thread safe via recursive_mutex.
|
| |
|
|
|
|
|
|
|
|
| |
deleteImpl(): Calls close().
DBTManager::close(): Clear adapterInfos (avoiding re-entry failure), make it functional.
Java deleteImpl(): Calls close(), avoiding same on JVM shutdown.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
InternalError for exceptions.
|
|
|
|
|
| |
getAdapterListImpl() JNI code utilizes new convert_vector_to_jobject(..)
with given ctor function defined ad-hoc via lambda.
|