| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
proper MTU and connection tracking.
In case multiple connections will be supported, DBGattServer::Listener
is able to match the connected BTDevice to the callback event.
For now, dbt_peripheral00 only supports one connection while ignoring others ..
|
|
|
|
|
|
| |
its asynchronous response to a synchronous atomic operation
Examples, see dbt_scanner10 and DBTScanner10
|
|
|
|
| |
Less efficient, but might be desired by user
|
|
|
|
| |
BTDevice::connectLE(..) Use const params like in decl
|
|
|
|
| |
BTGattHandler): Store in [ms] = 10 * [ms/10]
|
|
|
|
|
|
|
|
|
|
| |
connection_supervising_timeout+50ms) per connection
Using a connection derived GATT timeout considers the actually used supervising timout from the current connection.
The latter determines the official determination of a connection loss,
hence we shall not claim this case earlier.
The additional 50ms is given to allow L2CAP timeout hit first.
|
|
|
|
| |
characteristic value handle - clarification; Add proper API doc.
|
|
|
|
| |
order
|
|
|
|
|
|
| |
sendWithReply() (cmd + reply events)
Note: sendNotification() does not require such sync, as it doesn't await a reply.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
in vanilla or FAIL SMPPairingState
In pre-pairing, it may occur that the slave adapter sends the SECURITY_REQUEST out,
but pre-pairing is still setup and working.
Hence ignore this request if SMPPairingState has progressed,
BT Spec agrees here (only once before pairing).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To have full SMP key persitency in peripheral slave mode,
BTAdapter requires fine grained control over
- Passing stored keys to BTDevice's PairingData (w/o uploading them)
- Uploading BTDevice's PairingData to the adapter
This required interaction in certain places,
only enabled if adapter is BTRole::Slave (peripheral):
- BTAdapter::mgmtEvDeviceConnectedHCI()
Only issue unpairDevice() if not pre-paired.
Unpairing is required for new pairing to avoid DHKey Check failures!
- BTAdapter::mgmtEvDeviceDisconnectedHCI()
- First unpairDevice() will be issued via notifyDisconnect()
- Set and upload stored keys for disconnected device (if existing),
preparing for next connect.
- BTAdapter::sendDevicePairingState()
- SMPPairingState::COMPLETED && not SMPPairingState::PRE_PAIRED: Store keys
- SMPPairingState::COMPLETED && SMPPairingState::PRE_PAIRED: Refresh keys to BTDevice (set), no upload!
- SMPPairingState::FAILED: Remove and delete keys
+++
BTAdapter::setSMPKeyPath(path) allows user to enable the persistent key storage
by setting its local filesystem path.
It will also read all key files (SMPKeyBin) and if valid and matching with the adapter,
uploads them for pre-pairing.
See dbt_peripheral00.cpp:
adapter->setSMPKeyPath(ADAPTER_KEY_PATH);
+++
|
|
|
|
| |
peripheral key management
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
uploading keys (required for peripheral BTAdapter key management)
SMPKeyBin has the key apply action revoked.
SMPKeyBin is reduced to store keys, address and security settings,
as well adding persistence (read/write to filesystem).
BTDevice::setSMPKeyBin(SMPKeyBin&) shall be used copy the key data over
and BTDevice::uploadKeys() to upload them to the adapter for pre-pairing.
See dbt_scanner10.cpp's use of convenient API (same efficiency as before)
device->uploadKeys(KEY_PATH, req_sec_level, true /* verbose_ */);
BTDevice::setSMPKeyBin(SMPKeyBin&) fully restored BTDevice's PairingData
- keys
- key caps
- user security level and IOCaps
+++
The reduced 'set<Name>Key(..)' methods only
- copy the key to BTDevice's PairingData
- set the KeyType bit for keys_<role>_[init|resp], fully restoring key caps
|
|
|
|
| |
filename; Add member getFilename(path) and remove(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
and connected as peripheral
This enforces a consistent and stable security workflow.
- when a BTRole::Slave BTDevice is discovered, see AdapterStatusListener::deviceFound().
- when a BTRole::Slave BTDevice is disconnected, see AdapterStatusListener::deviceDisconnected().
- when a BTRole::Master BTDevice gets connected, see AdapterStatusListener::deviceConnected().
+++
Especially when connected as peripheral without unpair in SC mode,
the peripheral fails the DHKey Check.
TODO: Provide a persistent pre-pairing mechanism via SMPKeyBin for peripheral mode.
+++
Note: Our existing example code to connect to a remote slave/peripheral,
already performed the unpair on deviceFound(..) and deviceDisconnected().
These calls have now being removed, as they are performed directly by Direct-BT.
The example code uploads pre-existing keys for pre-pairing when device is found,
if existing.
|
|
|
|
| |
BTDevice::unpair(): Add DBG_PRINT on failure; BTDevice::clearSMPStates() reduce to one DBG_PRINT
|
| |
|
|
|
|
| |
replies DBT_PRINT
|
| |
|
|
|
|
| |
cleanup incl. CCCD regs
|
|
|
|
|
|
| |
from BTRole::Slave (peripheral)
BlueZ/Kernel not reliably sending out HCI_LE_REMOTE_FEATURES
|
|
|
|
| |
for one adapter and apply them all (peripheral pre-pairing)
|
|
|
|
|
|
| |
pre-connection
FIXME: Pass keys to BTDevice instance after connection!
|
|
|
|
| |
> usedMTU
|
|
|
|
| |
address, just ignore (LTK is enough)
|
| |
|
|
|
|
|
|
|
|
| |
Give remote slave (peripheral, Gatt-Server) 'some time' (100ms)
to complete connection and listening to our Gatt-Client requests.
We give the Gatt-Server a slightly longer period
after newly paired encryption keys (150ms).
|
| |
|
|
|
|
|
|
|
|
|
| |
clearSMPStates() call from BTDevice::disconnect() is
- redundant
- may cause a deadlock due to mtx_pairing lock
Issued at ctor(), manual unpair() and notifyDisconnect()
notifyDisconnect() will be called at all times, even if disconnect() fails!
|
| |
|
| |
|
|
|
|
| |
Expose SMPIdentityResolvingKey (IRK) adding get/set methods; Add setSignatureResolvingKey();
|
|
|
|
|
|
|
|
|
| |
- BTDevice::notifyConnected(..): Don't issue clearSMPStates() to have valid content from manual settings.
Previous disconnect commands should have cleaned these.
- BTDevice::remove(): Don't issue clearSMPStates(), disconnect(..) will.
- BTDevice::disconnect(): Issue clearSMPStates()!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Semantics
Revise BTDevice::PairingData Handling
- BTDevice::PairingData
- Add SMPIdentityResolvingKey, replacing uint128_t
- Use 'BDAddressAndType id_address_init, id_address_resp'
- Add 'toString(const BDAddressAndType& addressAndType, const BTRole& role)'
for unified string representation
- Add 'encryption_enabled'
- checkPairingKeyDistributionComplete()
- bring back strict KEY checking (w/ IRK + SIGN)
- requires encryption_enabled
- drop printKeyDistributionStatus()
- BTDevice::updatePairingState()
- #if CONSIDER_HCI_CMD_FOR_SMP_STATE
- Never override SMP key induced data
- Only take HCI Encryption keys in SC mode
- In SC mode, LTK is for both, Server + Slave
- Add early (pre-pair) MgmtEvent::Opcode::HCI_LE_ENABLE_ENC
- Move checkPairingKeyDistributionComplete() and DBG_PRINT to end of switch/if branches,
cleaning up workflow.
- Reset claimed_state also if any key is invalid (fix)
- DBG_PRINT BTDevice::PairingData::toString()
- BTDevice::hciSMPMsgCallback()
- Move DBG_PRINT to end of switch/if branches, cleaning up workflow.
- DBG_PRINT BTDevice::PairingData::toString()
++++
Fix HCITypes/MgmtTypes Encryption Key Semantics,
i.e. HCILEEnableEncryptionCmd, HCILELTKReplyAckCmd and HCILELTKReqEvent (+ Mgmt mappings)
HCILEEnableEncryptionCmd:
- This command shall only be used when the local device’s role is BTRole::Master (initiator).
- Encryption key belongs to the remote device having role BTRole::Slave (responder).
- The encryption key matches the LTK from SMP messaging in SC mode only!
HCILELTKReplyAckCmd:
- This command shall only be used when the local device’s role is BTRole::Slave (responder).
- LTK belongs to the local device having role BTRole::Slave (responder).
- The LTK matches the LTK from SMP messaging in SC mode only!
HCILELTKReqEvent
- This event shall only be generated when the local device’s role is BTRole::Slave (responder, adapter in peripheral mode).
- Rand and Ediv belong to the local device having role BTRole::Slave (responder).
- Rand and Ediv matches the LTK from SMP messaging in SC mode only!
|
|
|
|
| |
code in BTDevice::updatePairingState)
|
|
|
|
| |
peripheral with legacy mode
|
| |
|
|
|
|
| |
getConnected())
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
site, incl. mapping to Mgmt event object
Situation: Linux Kernel 5.10.0-9-amd64, Debian 12
dbt_scanner10: Master, initiatior (DUAL)
dbt_peripheral00: Slave, peripheral (LE only)
LE Secure Connections enabled per default.
Issue: LTK via Mgmt event in ~50% of cases not send!
However, full information already passed via HCI commands/events.
Workaround: Listen to HCI commands as well and allow
related commands + events to complement SC status tracking.
+++
New HCI commands + events, incl. their Mgmt event mapping:
- HCIOpcode::LE_ENABLE_ENC -> HCILEEnableEncryptionCmd
- Mgmt HCI_LE_ENABLE_ENC -> MgmtEvtHCILEEnableEncryptionCmd
- HCIOpcode::LE_LTK_REPLY_ACK -> HCILELTKReplyAckCmd
- Mgmt HCI_LE_LTK_REPLY_ACK -> MgmtEvtHCILELTKReplyAckCmd
- HCIOpcode::LE_LTK_REPLY_REJ -> HCILELTKReplyRejCmd
- Mgmt HCI_LE_LTK_REPLY_REJ -> MgmtEvtHCILELTKReplyRejCmd
- HCIMetaEventType::LE_LTK_REQUEST -> HCILELTKReqEvent
- Mgmt: Opcode::HCI_LE_LTK_REQUEST -> MgmtEvtHCILELTKReq
- HCICommand::getSpecialized(..)
|
|
|
|
| |
LE_LTK_REPLY_ACK and LE_LTK_REPLY_REJ
|
|
|
|
| |
'msg_from_initiator' using local BTRole (adapter) and l2cap pbflag
|
|
|
|
| |
adapter
|
|
|
|
|
|
|
|
|
|
|
|
| |
handler with status code; ...
DBTDevice::notifyLEFeatures() is always reached even with LE_REMOTE_FEATURES status != SUCCESS,
in which case is will enforce `le_features = le_features | LE_Features::LE_Encryption`.
BTAdapter::mgmtEvDeviceConnectedHCI(): Drops special case device->notifyLEFeatures(),
which was injected for BTRole::Slave == getRole().
This is possible, since we pass LE_REMOTE_FEATURES with !SUCCESS status and
regain original workflow.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
self-connect dbt_scanner10 with dbt_peripheral00
It has been experienced that our Gatt-Server (slave device, tested with dbt_peripheral00 example)
misses receiving the `ATT Exchange MTU Request` after notified being connected.
In this case, the master client received the connection before the slave server
and sent out the `ATT Exchange MTU Request` before the slave server
even started listening.
For now, the master client waits 100ms before sending out the MTU exchange request,
giving the slave server ample time to be notified and setup the L2CAP listener.
However, this should be further analysed ...
|
|
|
|
|
|
|
|
|
|
|
|
| |
copy-ctor; Disable its compilation and preserve resources.
GATT_SERVICES .. etc were merely created as a proof of concept to compile a complex static structure
representing detailed GATT services with its characteristics etc.
Its usage has been fixed to avoid std::initialize_list and copy-ctor.
One can enable its compilation and linkage
by defining `DIRECTBT_BUILDIN_GATT_SERVICE_CHARACTERISTIC_SPEC`.
|
|
|
|
| |
L2CAPComm::RWExitCode::POLL_TIMEOUT
|
|
|
|
| |
warning issue
|
| |
|