| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
[DBT|Bluetooth]Manager, enabling fully event driven workflow w/ adapter add/remove
|
| |
|
| |
|
|
|
|
| |
set_store
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
INDEX_REMOVED Mgmt events
C++ DBTManager detects INDEX_ADDED and INDEX_REMOVED Mgmt events
@INDEX_ADDED reception in the event reader, a new processAdapterAdded() thread is spawned
initializing the adapter as usual and maintaining adding its AdapterInfo artifact.
Then all user INDEX_ADDED callbacks are called from this thread,
after the new AdapterInfo entry has been added.
@INDEX_REMOVED here the matching AdapterInfo entry is simply removed
DBTAdapter naturally also listens to INDEX_REMOVED,
simply closing its instance and hence rendering it isValid() = false.
+++
On close(), Java's DBTAdapter will remove itself
from the DBTManager's adapter list.
This removal will happen automatically,
if INDEX_REMOVED is received - see below.
On the Java side, DBTManager listens to:
@INDEX_REMOVED here the matching adapter instance is simply removed
@INDEX_ADDED and @NEW_SETTINGS(POWERED) checks whether the matching adapter instance
exists and creates a new one added to the adapters list if necessary.
@NEW_SETTINGS(POWERED) has been added here as well, since a user could
chose to close the adapter if POWERED off and hence removing itself
from the DBTManager adapter list.
Hence NEW_SETTINGS(POWERED) will add a new adapter instance, if none exists.
+++
Due to this new concurrent use-case of the adapter list,
the list is now a CopyOnWriteArrayList instance supporting lock-free fast reads.
Mutations of the list occur rarely, hopefully ;-).
On the C++, the AdapterInfo is a jau::cow_vector and the callbacks are
store in a jau::cow_vector as well (MgmtAdapterEventCallbackList).
Hence both share the same properties w/ the Java side: Fast lock-free reads.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
[DBT|Bluetooth]Adapter: C++ and Java: Redefine/add state queries:
- isValid(): true if this adapter references are valid and hasn't been DBTAdapter::close() 'ed
- isPowered(): true if DBTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is set
- isSuspended(): true if DBTAdapter::isValid(), HCIHandler::isOpen() and AdapterSetting::POWERED state is not set
- dev_id / getDevID(): Added definition, added method + implementation to Java
BluetoothAdapter: Java
- getPowered() -> getPoweredState() - to differentiate with isPowered()
BluetoothManager: Java
- getAdapter(dev_id) added
- setDefaultAdapter(..) implementation removed in DBTManager -> nonsense
- getDefaultAdapter(): DBT: Return 1st isPowered() adapter (redfinition, aligned with C++)
|
|
|
|
|
|
|
| |
shall update AdapterInfo state
DBTAdapter hence requires to cache the old AdapterInfo state to realize the changed bits
and for AdapterStatusListener forwarding.
|
| |
|
|
|
|
| |
adapterInfo-list, further drop index language for dev_id
|
|
|
|
| |
index requirement
|
|
|
|
| |
range int, including -1)
|
| |
|
|
|
|
|
|
| |
hasScanType(eventScanType, ScanType::LE)
Note: '-Wmaybe-uninitialized' didn't trigger this when building in DEBUG mode using g++ 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ScanType for the changedEnabled value; Expose meta ScanType.
The additional information in the callback is essential in a LE + BREDR environment.
User can also see the current meta ScanType.
ScanType is exposed to Java.
Java's BluetoothAdapter also adds 'ScanType getCurrentScanType()', exposing the last sent meta ScanType.
DBTAdapter.java stores the meta ScanType instead of a boolean flag, hence we can react on LE only scanning for example.
DBTAdapter can call all discovery callbacks for all ScanTypes now.
|
|
|
|
| |
current, const ScanType changeType, const bool changeEnable)'
|
|
|
|
|
|
| |
(DBTDevice) or stopDiscovery (DBTAdapter) commands
Note: stopDiscovery and disconnected events will be sent!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
differentiating further.
Discovery events will be sent directly instead off-thread.
This is now possible w/o deadlock risk as we utilize the lock-free jau::cow_vector.
Further, off-thread event sending can cause non sequentially consistence (SC)
as the new threads potentially can be executed later on.
This happened in some test cases where event-2 has been received before event-1.
HCIHandler
- add setCurrentScanType(), allowing outside events to update its state
- sendMgmtEvent() directly, see above
DBTAdapter
- small renamings for clarity
- more ScanType differentiating: LE, BREDR and DUAL
using 'hasScanType(ScanType current, ScanType test)'
- FIXME note on AdapterStatusListener::discoveringChanged():
Method shall include the enabled/disabled ScanType plus the current overall ScanType state.
For now, we only report LE discovery state.
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
currentMetaScanType post HCI completed command.
DBTAdapter:
- Drop local currentNativeScanType, use HCIHandler::getCurrentScanType()
- start/stop_discovery: Set currentMetaScanType post HCI command, as it already waited for completed.
- startDiscovery: Use own_mac_type, le_scan_interval and le_scan_window arguments (pass to HCIHandler command),
was silently dropped.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
avoiding HCIStatusCode::COMMAND_DISALLOWED
similar to mitigation of a pending disconnect causing HCIStatusCode::CONNECTION_ALREADY_EXISTS.
Further ...
Added le_start_scan, performing atomic le_set_scan_param and le_enable_scan.
le_enable_scan skips command if currentScanType == nextScanType,
i.e. avoiding a false failure HCIStatusCode::COMMAND_DISALLOWED on disable-scan when already disabled.
le_start_scan and le_set_scan_param pre-check hasScanType(currentScanType, ScanType::LE),
if LE is already enabled: warns and returns HCIStatusCode::COMMAND_DISALLOWED (spec).
+++
HCIHandler:
- mtx_connectionList is recursive_mutex again due to disconnect()
- Add currentScanType tracking and exposure
- Consolidate [process|receive]CommandComplete: [sendWith -> getNext]CmdCompleteReply
- isOpen(): Add allowClose test and use isOpen() instead of comm.isOpen()
- elaborate toString() content w/ currentScanType and ring elements
- Add toString() to all [ERR|WARN|DBG]_PRINT
Misc:
- HCIEnv: Add HCI_COMMAND_POLL_PERIOD 125ms for LE_Create_Connection or Create_Connection..
- HCICommandCompleteEvent: Remove now unused getReturnStatus(..)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Revises commit 1f6e924fe05ed45bfa4d0d901af2c4df6c1abab5
Use jau::nsize_t and jau::snsize_t where appropriate
- OctetTypes.hpp: TROOctets*
- ATTPDUTypes.hpp: AttPDUMsg*
- HCITypes.hpp: HCIPacket*
- HCIComm.hpp: HCIComm
- L2CAPComm.hpp: L2CAPComm
- MgmtTypes.hpp: MgmtCommand*, MgmtEvent*
- UUID.hpp: uuid_t
- DBTManager, GATTHandler, HCIHandler
- HCIComm.hpp: HCIComm
- BTTypes.hpp
- DBTTypes.hpp
|
|
|
|
| |
Revising commit 2e40a6fbb84ef21bb9551c653199964e55d7954b
|
| |
|
|
|
|
|
|
|
| |
Turns our there are too many to handle for now.
Trust that i.e. dev_id value range does not exceed expected range,
but even though - it would just end up in a failed call.
|
|
|
|
| |
avoid 2/2 (tinyb)
|
|
|
|
|
|
| |
avoid 1/2 (direct_bt)
Another shadow bug fixed: UUID string ctor in UUID.cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
timestamp is uint64_t
- AttPDUMsg
Use size_t where appropriate
- OctetTypes.hpp: TROOctets*
- ATTPDUTypes.hpp: AttPDUMsg*
- HCITypes.hpp: HCIPacket*
- HCIComm.hpp: HCIComm
- L2CAPComm.hpp: L2CAPComm
- MgmtTypes.hpp: MgmtCommand*, MgmtEvent*
- UUID.hpp: uuid_t
- DBTManager, GATTHandler, HCIHandler
- HCIComm.hpp: HCIComm
- BTTypes.hpp
- DBTTypes.hpp
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
top-level command mtx (just use mtx_sendReply)
Also use mtx_sendReply for close() and start-, stop- and resetAdapter().
Same strategy as for DBTManager.
Have to analyze GATTHandler, which is special due to having top-level commands
producing multiple send-reply communications.
|
|
|
|
| |
settings for all, avoiding confusion.
|
|
|
|
| |
Adapter not enabled/powered
|
|
|
|
| |
avoiding locks in callback iteration
|
|
|
|
| |
avoiding locks in callback iteration
|
|
|
|
|
|
| |
avoiding locks in callback iteration
Also use relaxed_atomic_bool for sendIndicationConfirmation.
|
|
|
|
| |
services.
|
|
|
|
|
|
|
|
| |
that is how it potentially has been deleted!
This fix also gives us the opportunity back to use a simple mutex for mtx_sharedDevices.
Also add dedicated close() for better leak testing.
|
|
|
|
|
|
| |
copy_store() on custom mutable operation
Also std::move(snapshot) back to cow_vector, as set_store is now a move operation.
|
| |
|
|
|
|
| |
device remove -> ~device -> remove from Java
|
|
|
|
| |
discovery): No recursion nor deadlock covering most small code blocks.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
*' with wrapper 'HCIStructCmdCompleteMetaEvtWrap<T>' ctor
Assume T is any 'hci_cmd_event_struct' template type.
We had
[1] HCIStructCmdCompleteMetaEvt<T> * ev_cc = (HCIStructCmdCompleteMetaEvt<T> *) orig_ptr;
now use simple (actual) wrapper (as was intended)
[2] HCIStructCmdCompleteMetaEvtWrap<T> ev_cc(*orig_ptr);
++++
[1] is a potential violation of virtual function pointer table,
as HCIStructCmdCompleteMetaEvt<T> might not have indentical heritage as
the type 'orig_ptr' points to.
The intention was to just access the orig_ptr data to deliver
certain aspects in regards to any 'hci_cmd_event_struct' -> a wrapper.
[2] Resolves the issue, using a temporary instance of the wrapper.
This inconsistency was found with 'UndefinedBehaviorSanitizer' UBSAN,
using GCC '-fsanitize=undefined' option.
|
|
|
|
|
|
| |
erroneously overriden by local variable!
Was detected with Full Warnings enabled!
|
| |
|
|
|
|
| |
Add missing 'jau::' namespace usage on bind* and *print*
|
| |
|
|
|
|
| |
jaucpp, namespace jau
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
caused sporadic CONNECTION_ALREADY_EXISTS connection failures
Since direct_bt's DBTDevice::disconnect() does not wait for DISCONN_COMPLETE,
so might a user application not wait.
A 'too fast' [le_]create_conn attempt while DISCONN_COMPLETE has not been received yet
from a pending disconnect call, leads to CONNECTION_ALREADY_EXISTS failure.
This change tracks the pending disconnect commands
and waits up to HCI_COMMAND_COMPLETE_REPLY_TIMEOUT (10s default)
for receiving the DISCONN_COMPLETE.
Resolved the sporadic issue testing with cpp and java scanner10,
e.g.: "../scripts/run-dbt_scanner10.sh -disconnect -count 10 -quiet -mac C0:26:DA:01:DA:B1"
|
| |
|
| |
|
|
|
|
| |
reset() and stopAdapter() (resetAdapter()).
|