| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
L2CAPComm::open() BT_SECURITY deadlock
Re-enable auth-failure (try w/o security) from hciSMPMsgCallback()
Resolve L2CAPComm::open() BT_SECURITY deadlock
- set sec_level after connect() within L2CAPComm::open()
- see macro SET_BT_SECURITY_POST_CONNECT in L2CAPComm.cpp
- L2CAPComm::setBTSecurityLevel() ignores unchanged BT_SECURITY value.
Otherwise it fails on BTSecurityLevel::NONE, don't ask - don't know, even after BlueZ/Kernel review.
Working w/ DBTScanner10:
- Device w/o security: No special settings in commandline
- Device w/ Secure Connection SMP: Only set passkey in commandline
- Device w/ legacy encryption only (no auth): Set BTSecurityLevel::ENC_ONLY or SMPIOCapabilities::NO_INPUT_NO_OUTPUT or both.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
SMPIOCapability: Like force JUST_WORKS by BTSecurityLevel::ENC_ONLY or SMPIOCapability::NO_INPUT_NO_OUTPUT
To allow non-auth encryption mode, user _must_ set BTSecurityLevel, SMPIOCapability or both appropriately.
Otherwise BlueZ/Kernel will chose authenticated SMP negotiation.
- DBTDevice::setConnSecurityLevel(): Will adjust SMPIOCapability automatically, if not yet set
- DBTDevice::setConnIOCapability() and DBTDevice::setConnSecurity(): Perform plain setting
- DBTDevice::processL2CAPSetup(): Sets BTSecurityLevel appropriately either if no-auth SMPIOCapability::NO_INPUT_NO_OUTPUT is chosen,
or based on LE_Enc feature bit and/or SC capability.
Using new HCI ENCRYPT_CHANGE and ENCRYPT_KEY_REFRESH_COMPLETE, for non-auth BTSecurityLevel::ENC_ONLY
endpoint to set SMPPairingState::PROCESS_COMPLETED + PairingMode::JUST_WORKS.
Note: In the non-auth legacy mode, the SMP (ACL.SMP) is not being used.
....
|
|
|
|
| |
UUID output for more brief debug output
|
| |
|
|
|
|
| |
[set|get]SecurityLevel() using BTSecurityLevel, overriding auto-determined mode.
|
|
|
|
| |
force update (initiator role)
|
|
|
|
| |
PairingMode by forced state change (PASSKEY*, NUMERIC_COMPARE*, OOB*)
|
|
|
|
|
|
|
| |
*Device::setPairingPasskey(..) and setPairingNumericComparison(..) API doc (act upon state)
PairingState::NUMERIC_COMPARISON_EXPECTED -> NUMERIC_COMPARE_EXPECTED
and use PairingMode::PASSKEY_ENTRY_ini, PairingMode::NUMERIC_COMPARE_ini in API doc.
|
|
|
|
| |
executeOffThread(..) editing; SMPHandler: Avoid unused arguments
|
|
|
|
|
|
|
|
|
|
| |
L2CAPComm::setBTSecurityLevel() for DBTDevice::processL2CAPSetup()
sec_level > BT_SECURITY_LOW is now required to start security negotiation (not just > 0), matching BT_SECURITY API.
This change aligns the tentative SMPHandler and conditionally disabled code with current state.
SMPHandler::establishSecurity(..) needs to be implemented for non BlueZ platforms or when SMP is accessible under BlueZ.
|
|
|
|
| |
was successful! DBTDevice::processL2CAPSetup: Direct processDeviceReady() if !l2cap_Sec
|
| |
|
| |
|
|
|
|
| |
EOF, more lifecycle/reading-order aligned.
|
|
|
|
| |
w/o security directly from processL2CAPSetup()
|
|
|
|
|
|
|
|
|
| |
the now tracked 'responder requested security' SMP hint.
'const bool responderLikesEncryption = pairing_data.res_requested_sec || isLEFeaturesBitSet(le_features, LEFeatures::LE_Encryption)'
takes into account the responder device desire for security/encryption
as expressed via SMPPDUMsg::Opcode::SECURITY_REQUEST.
|
|
|
|
|
|
|
|
|
|
| |
spawn-off @ notifyLEFeatures, using LEFeatures::LE_Encryption
- Move set BT_SECURITY from DBTManager -> L2CAPComm.
Notable: setBTSecurityLevel(level) shall happen _after_ l2cap open and connect!
- Performing l2cap handling after LE_REMOTE_USER_FEATURES allows us to turn-off security completely,
if remote device does not support LE_Encryption.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
event; Wire HCI LE_REMOTE_USER_FEATURES -> DBTDevice; ..
- DBTAdapter/Device: updatePairingStateAndMode() -> updatePairingState(), simplifying locked access
- DBTDevice::notifyConnected: Set BT_SECURITY w/ a sec_level on l2cap_att socket
- hciSMPMsgCallback:
-- FAIL: reopen l2cap_att (remove security settings) and try without security/encryption
-- issue deviceReady(..) if appropriate
- Adapt dbt_scanner10 example to deviceReady(..)
- TODO:
-- AdapterStatusListener::deviceReady(..) forwarding to Java
-- Validate GATT operation on encryption
|
|
|
|
|
|
|
|
| |
re-establish l2cap channel on changed security/encryption
- DBTDevice
-- Aggregating L2CAPComm instance, open/close and passing to GATTHandler
-- add LEFeatures le_features field, incl notify update hook
|
|
|
|
| |
'getPairing[Mode|State]()'; Don't store passkey.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
DBTDevice incl deduction of SMPPairingState and PairingMode
- Added: AdapterStatusListener::devicePairingState(...): Notifying user about a changed PairingState
- HCIHandler's HCISMPMsgCallback: Pass HCIACLData::l2cap_frame, allowing final receiver (DBTDevice)
to learn about initiator/responder role.
- DBTAdapter
-- Added Mgmt SMP related callbacks
-- Added SMPMsgCallback from HCIHandler, to be forwarded to DBTDevice for actual SMPPairingState handling,
tracking state and SMPPDUMsg details.
- DBTDevice
-- Add API to set/get pairing passkey and numeric comparison
-- Expose current SMPPairingState
-- DBTDevice hciSMPMsgCallback(..): Track underlying PairingState details, received from HCIHandler -> DBTAdapter -> this,
and deduce PairingMode via getPairingMode(..) using both devices AuthReqs, IOCaps and OOBFlag.
|
|
|
|
| |
(access all) and forward to matching DBTDevice
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(SMP) incl. facility in HCIHandler (read and callbacks)
As noted in commit 6f3e08562f4f990b579ff2540d25dac06beea15a,
we can't connect directly to the L2CAP/SMP channel.
However, it is possible to access the SMP messages through the HCI layer,
grabing the ACL Data's L2CAP packets. The latter may expose an SMP (via CID).
This finally allows us to put our SMPPDUMsg to use
and hence provide a HCISMPSecurityReqCallback facility in HCIHandler.
|
|
|
|
| |
compilation/usage if false, removing costs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
supported)
On our current target platform Linux/BlueZ,
access to the existing SMP implementation via L2CAP (socket) is sadly prohibited.
Linux/BlueZ currently only allows L2CAP sockets for LE devices for the ATT protocol,
determined by L2CAP_CID_ATT.
Therefor we have to use Linux/BlueZ manager control channel's
API to access the SMP implementation.
However, the SMPHandler and used SMPPDUMsg types may be used on other platforms.
Hence implementation shall be completed for these later on.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
[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++)
|
|
|
|
|
|
| |
(DBTDevice) or stopDiscovery (DBTAdapter) commands
Note: stopDiscovery and disconnected events will be sent!
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
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"
|
| |
|
| |
|
|
|
|
| |
semantics (1st POWERED)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
notify[Connected|Disconnected]() callbacks or in GATTHandler lifecycle
GATTHandler lifecycle has its own minimal mutex, mtx_gattHandler, no more [ab]using mtx_connect.
To avoid 'lock order' issues and hence potential deadlocks:
- GATTHandler construction happens now via connectGATT() into notifyConnect off-thread for LE devices.
- GATTHandler disconnectGATT() happens at disconnect() upfront above the mtx_connect lock or at notifyDisconnect() the latest.
- notify[Connected|Disconnected]() callbacks don't hold mtx_connect,
as they only set atomic flags and notifyConnected() may issue connectGATT() off-thread (see above)
Have allowDisconnect before isConnected in notify[Connected|Disconnected](), as it is queried before.
Have disconnectGATT() be called last in notifyDisconnected(), as allowDisconnect and isConnected have precedent
and connectGATT() queries both to avoid ctor attempt if not connected or disconnecting.
getGATTService() and pingGATT() now just use getGATTHandler(), implemented merely as 'user methods',
either the GATTHandler was created at notifyConnected() and hence exists or not.
connectGATT(): Add noexcept as GATTHandler ctor is also noexcept; also don't throw an exception.
This renders connectGATT() suitable to be excecuted off-thread.
|
|
|
|
| |
normal event delivered via HCIHandler's reader thread
|
|
|
|
|
|
|
|
| |
code path is fully noexcept.
Note that the default dtor is noexcept by specification since C++11.
GATTService and childs were marked noexcept earlier.
|
|
|
|
|
|
|
| |
cleanup from the self-inflicted disconnect event lag due to huge supervisor timeout
Note that this patch won't compile, as 'noexcept' has been introduced,
which will be reflected in the followp commit (ensure instance 'take down' is on 'noexcept' code path).
|
|
|
|
| |
and erroneous missing data handle nicely (no crash)
|
|
|
|
|
|
|
|
|
|
|
|
| |
on HCIStatusCode error; decouple notifyDisconnect()
Have notifyDisconnect() cleanup itself, no abusing disconnect().
!isConnected is OK, b/c a disconnect event could have come before the user issuance.
Only send event on HCIStatusCode error, not on 'ioErrorCause' (WIP, testing - supervision timeout related).
After proving 'ioErrorCause' has no impact anymore, we shall drop it from method.
|
|
|
|
| |
used, moved up to DBTDevice::disconnect()
|
|
|
|
| |
event to caller (DBTDevice) to cover HCIHandler == nullptr (power-off)
|
|
|
|
| |
already dead (powered-off)
|
|
|
|
|
|
|
|
|
|
|
| |
PairingModes (C++, Java)
For now, DBTDevice has a NOP implementation, i.e. returning zero length vectors (or arrays in Java)
for supported and required PairingMode.
The pair(String passkey) simply returns HCIStatusCode::INTERNAL_FAILURE;
Intention is to validate the new API entry with our application.
|
|
|
|
|
|
|
| |
GATTHandler::discoverCompletePrimaryServices(..) avoiding abort
DBTDevice::getGATTServices() noexcept: API doc says, "returns an empty list if an error occurred".
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
skipped >= GATTService); GATTHandler owned by DBTDevice, always.
GATTService and childs might need access to their GATTHandler, not just DBTDevice.
This relationship always existed, but was skipped.
Also emphasize that GATTHandler is always owned by DBTDevice, hence has a weak back-reference to the same.
Fixed in ATTPDUTypes C++ Direct-BT API doc overview.
Further impact:
- GATTService has a weak back-reference to GATTHandler instead of DBTDevice,
DBTDevice reference will then be picked up from GATTHandler, the usual.
- GATTHandler::discoverPrimaryServices(..), discoverCompletePrimaryServices(..)
needs to receive GATTHandler's shared_ptr from owner and caller to build the back-reference in GATTService
|
|
|
|
|
|
| |
Validated all 'throw ' expressions within src/ java/jni/ test/ examples/.
We are not Java here - duh! :)
|
|
|
|
| |
'noexcept'
|