summaryrefslogtreecommitdiffstats
path: root/src/direct_bt
Commit message (Collapse)AuthorAgeFilesLines
* Add jaulib jau::os::get_platform_info() (jau::os, jau::cpu) code and show ↵Sven Göthel2024-05-121-4/+7
| | | | info in test.
* jaulib: Bump and adopt to enum type name changes, added '_t'Sven Göthel2024-05-1210-53/+53
|
* Cleanup/Fix: C++20, clang-16 + clang-tidy-16, gcc 12.2, latest jaulib, ↵Sven Göthel2024-05-046-12/+13
| | | | passing all tests w/ gcc + clang + java17 build
* Bump jaulib and adopt to jaulib byte_util API change (commit ↵Sven Göthel2024-03-0210-69/+69
| | | | 147e17b0b41a123b2f4040cbd6df5b73b7e97164)
* Adopt to jaulib commit d658b6059d7e7513b60c5c67019b76c9cd3f809bSven Göthel2024-02-255-11/+11
|
* BTAdapter::mgmtEvDeviceFoundHCI: Only unpair() shared and non-discovered ↵Sven Gothel2023-11-241-1/+1
| | | | | | device if not pre-paired Avoid losing device pairing if performed via Direct-BT in case explicit startDiscovery() purged discovered devices.
* BTDevice::setSMPKeyBin: Align C++/Java code using setSMPKeyBin()Sven Gothel2023-11-241-3/+10
|
* BTDevice::pairing_data.is_pre_paired: Set on uploadKeys() post setup, ↵Sven Gothel2023-11-241-4/+8
| | | | aligned for all cases (C++ and Java, via setSMPKey() or manual)
* BTAdapter::startDiscovery: Use given DBGattServerRef in already discovering ↵Sven Gothel2023-11-231-0/+1
| | | | state
* BTAdapter: Add debug/verbose msg w/ printDeviceLists()Sven Gothel2023-11-231-6/+35
|
* LE Resolvable Address: BTDevice::hciSMPMsgCallback: Fix IRK responder ↵Sven Gothel2023-11-051-1/+1
| | | | properties: Use irk_resp (copy/paste bug) and SMPIdentityResolvingKey::Property::RESPONDER
* BTGattCmd: Response: Add DataCallback, add setting minimum response size, ↵Sven Gothel2023-10-281-10/+26
| | | | add sendOnly(..) to skip waiting for response
* BTGattHandler::BTGattHandler: Pick BTAdapter::getGATTServerData() also in ↵Sven Gothel2023-10-272-3/+18
| | | | | | | | | | | | | GATTRole::Client; BTAdapter::startDiscovery() add DBGattServerRef ref A GattServerHandler(DBGattServer) is also possible for LL master (GATT client) connections where the server inquires certain data points within the client's GATT. User can pass DBGattServer to BTAdapter::startDiscovery() to enable the GattServerHandler for such cause. Test case: Avalun's LabPad device - DBTLabPadClient01.java - dbt_labpadclient01.cpp
* BTGattHandler::GattServerHandler::replyReadByTypeReq: Add BT Core Spec v5.2: ↵Sven Gothel2023-10-271-10/+45
| | | | Vol 3, Part G GATT: 4.8.2 Read Using Characteristic UUID
* GATT Server Auth: Validate encryption and authentication requirements in ↵Sven Gothel2023-10-261-0/+44
| | | | | | | | | | | server mode The actual used security level shall match the required (user-set) level as follows - Don't care if request is < ENC_ONLY - If request == ENC_ONLY, actual must be >= ENC_ONLY - If request >= ENC_AUTH, actual must be >= ENC_AUTH Here we do ignore ENC_AUTH_FIPS, as not all devices/adapter support it yet.
* GATT Server Auth: BTDevice::processL2CAPSetup don't set sec_level w/ ↵Sven Gothel2023-10-261-4/+7
| | | | | | authentication in server mode; Read-out l2cap's actual sec_level when paired This state works w/ pairing against an Android phone using Random Private Address and authentication.
* GATT Server Auth: BTAdapter::smp_timeoutfunc shall not timeout in ↵Sven Gothel2023-10-261-0/+5
| | | | authentication mode
* GATT Server Auth: Cleanup sec_levl + io_cap validation and transition, ↵Sven Gothel2023-10-262-125/+211
| | | | | | | | | | | | | | | | | | | | | utilizing sec_level_server, io_cap_server in server mode In server mode, pre-set and validated sec_level_server, io_cap_server are handled as follows: (1) io_cap_server gets set in the manager before start advertising and actual when connected at mgmtEvDeviceConnectedHCI() the manager setting is propagated to the device via notifyConnected() (2) sec_level_server is also propagated to the device when connected at mgmtEvDeviceConnectedHCI() via notifyConnected(). It subsequently is set on the L2CAP at BTDevice::processL2CAPSetup() on the server l2cap connection. +++ Renamed 'ioCap'* -> 'io_cap'* for readability as we don't regularly use camel-case for fields here.
* BTAdapter::disconnectAllDevices(): Ensure disconnected device is actually ↵Sven Gothel2023-10-251-1/+4
| | | | | | | | removed even if disconnect failed (power-off case) Notable was a failed pairing attempt causing the adapter to reset (power cycle). The disconnect command was unable to succeed, hence survived in the connected list and subsequent startAdvertising faild.
* LE Resolvable Address: Handle identity- and resolvale-private-address (RPA), ↵Sven Gothel2023-10-254-44/+153
| | | | | | | | | | | | | | | | | | | using RPA/IRK crypto matcher for HCI events (passing RPA) HCIConnectionRef and BTDevice store both address pairs, naming the potential RPA as 'visibleAddressAndType'. BTAdapter's findDevice*() method seeks through all device's address first and if the potential RPA is not found queries each device whether it matches with its IRK (if existing). In case the latter is positive, the identity address has been found. Naturally, to have this work, the adapter (in server mode) needs to upload all keys to the host adapter to allow resolving as well as instantiating all devices per key-set. This concept has already been implemented, hence the IRK resolution change-set is not too dramatic. Trial unit tests passed.
* HCIHandler: Remove reset{->HCI}() from publicSven Gothel2023-10-251-24/+17
|
* HCI resolvable functions: HCIHandler: Only issue resolvable function if ↵Sven Gothel2023-10-251-14/+21
| | | | supported, fix DBG_PRINT, add missing declarations
* LE Resolvable Address: Support IRK: SMPIdentityResolvingKey (IRK w/ added ↵Sven Gothel2023-10-253-32/+149
| | | | id_address), SMPKeyBin storage and host upload, w/ clearing all IRKs on startup
* LE Resolvable Address: Add tinycrypt, supporting AES to match IRK w/ LE ↵Sven Gothel2023-10-254-12/+160
| | | | Random Address, made available in SMPIdentityResolvingKey and BTDevice
* HCI resolvable functions: HCIHandler shall only report DBG messages; ↵Sven Gothel2023-10-233-7/+21
| | | | BTAdapter clear resolvable list at 1st init, BTDevice del from resolvable list at disconnect
* GATT Server Auth: Expose PASSKEY_NOTIFY from BTManager -> BTDevice; App ↵Sven Gothel2023-10-233-0/+39
| | | | using AdapterStatusListener::devicePairingState() + SMPPairingState::PASSKEY_NOTIFY to display generated PassKey
* GATT Server Auth: MgmtEvent: Add PASSKEY_NOTIFY -> MgmtEvtPasskeyNotify mappingSven Gothel2023-10-232-1/+3
|
* HCIHandler: Add support for HCI resolvable functions: add, del, clear, ↵Sven Gothel2023-10-232-0/+113
| | | | | | | | | | | | | | | read.., set.. NOTE that the following seem not to be supported in Linux/BlueZ: - LE_READ_PEER_RESOLV_ADDR - LE_READ_LOCAL_RESOLV_ADDR The others are coded within BlueZ, but I received 0x01 UNKNOWN_COMMAND as a HCIStatusCode Used kernel for analysis: - bluetooth-next 2022-04-01 - 38a1944deda4d96ca04b9aaa51ee5ae879b61aa0
* HCIHandler: Reuse opcode from request and use to_string for error messagesSven Gothel2023-10-231-5/+5
|
* HCIHandler::receiveCommandComplete(..): Preserve returned CMD_STATUS error ↵Sven Gothel2023-10-231-0/+4
| | | | status
* Sync Java with C++ and tag API changes; All trial unit tests passedSven Gothel2023-10-221-4/+16
| | | | | | | | API Changes for v3.2.0: - BTAdapter: - setPrivacy(bool) added - initialize() w/o args or default args removed - initialize(final BTMode btMode, boolean powerOn) added
* Adapter Random Address (WIP): Add BTAdapter::setPrivacy() and intercepting ↵Sven Gothel2023-10-222-0/+73
| | | | | | | | | new-IRK FIXME: Passing a HCILEOwnAddressType other than PUBLIC for "LE set scan Param" after setPrivacy(true) via BTManager results in failure. TBD: Seems like the mngr API and HCI is not aligned or my adapter revolts.
* BTManager::initializeAdapter(): Disable Privacy and reorder modes BREDR -> ↵Sven Gothel2023-10-221-4/+9
| | | | LE for clarity
* BTManager::handleCurrentSettingsReply(): Added to unify setMode() and ↵Sven Gothel2023-10-221-27/+13
| | | | setDiscoverable() mode change replies
* BTAdapter/BTManager: Initialize BTAdapter w/ optional power-on, allowing ↵Sven Gothel2023-10-222-18/+13
| | | | subsequent power-off settings w/o toggling power again
* Adapter Random Address: Add visibleMACType = HCILEOwnAddressType::PUBLIC and ↵Sven Gothel2023-10-223-7/+5
| | | | use it for BTAdapter::startDiscovery() and BTDevice::connectLE()
* BTAdapter::smp_timeoutfunc: Clear smp_events after warning/ignore msg (OK); ↵Sven Gothel2023-10-202-1/+6
| | | | BTDevice::updatePairingState/hciSMPMsgCallback: Clear smp_events after pairing completion
* MgmtPinCodeReplyCmd: Use given pin_code size and add std::string variant, ↵Sven Gothel2023-10-202-1/+73
| | | | zero pin-code array first; Support PinCode throughout BTManager/BTDevice.
* Adopt to jaulib ringbuffer changes v1.0.1-8-g854a714Sven Gothel2023-01-014-4/+20
|
* C++20: MgmtTypes: Have name length enums as jau::nsize_t, aligning to same ↵Sven Gothel2022-12-311-1/+1
| | | | param types and enum types in algebraic expressions
* clang-tidy fixes part-3 / 4, adding Check `performance-*`Sven Gothel2022-11-2811-44/+44
| | | | | | | | | | | | | | See also jaulib commit 9160f9a4b74f5e5ae07f715025ea4d3aafdf6ab3 Details: - Using 'const T&' as method argument type where applicable, i.e. not when required to pass value off-thread. - Notable: Can also hold a default value! - Using `const T&` in range-loop where applicable - Drop std::move for trivial types - ...
* clang-tidy: cover modernize-pass-by-value, handle modernize-use-equals-deleteSven Gothel2022-11-272-12/+13
|
* clang-tidy fixes part-1Sven Gothel2022-11-2715-232/+275
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Details - Use 'size_type' instead of 'int', propagate same 'size_type' into 'darray' etc. - Use 'std::make_shared', 'std::make_unique' - Use range-based for loops - Remove redundant 'virtual', use 'override' in derived classes - Use 'nullptr' - Use default impl for dtor, ctor (incomplete) - Use copy and std::move (incomplete) - Explcitly catch std::bad_alloc in 'new' in 'noexcept' -> 'abort' - 'abort' was issued implicitly in noexcept methods - L2CAPServer, L2CAPClient, NopGattServerHandler, DBGattServerHandler, FwdGattServerHandler - Use local close_impl(), usable in virtual destructor - L2CAPClient::read, HCIComm::read - preset 'poll' result 'n', avoid garbage comparison - BTAdapter::enableListening - loop through addMgmtEventCallback() result - JNI code - explicit size_type is cast to jsize or jint w/o check - unchanged semantics
* BTAdapter.cpp: Workaround gcc 12.2.0-3 Debian 12 Bookworm 2022-10-17 false ↵Sven Gothel2022-10-171-1/+19
| | | | positive '-Werror=stringop-overflow=' using std::atomic_bool::load()
* Change all callback return type: dummy 'bool' -> 'void', now enabled by ↵Sven Gothel2022-09-162-65/+37
| | | | jau::function<void(A...)>
* Adopt to jau::function<R(A...)> from jau::FunctionDef<>Sven Gothel2022-09-166-78/+76
|
* BTAdapter/HCIHandler::toString(): Show dev_id as 1st element w/o explicitly ↵Sven Gothel2022-09-152-4/+3
| | | | naming it.
* HCIHandler::resetAdapter(): Add optional HCIHandler::PostShutdownFunc ↵Sven Gothel2022-09-152-22/+38
| | | | | | | argument, allowing BTAdapter::reset() to wait until all devices are disconnected before powering-up again Waiting for all disconnections within reset after shutdown phase determines the state of all devices before powering up.
* BTAdapter: Align hasDevicesPausingDiscovery() -> ↵Sven Gothel2022-09-151-6/+6
| | | | getDevicesPausingDiscoveryCount() w/ getConnectedDeviceCount(), both return nsize_t
* BTAdapter::poweredOff(): Always use disconnectAllDevices() for proper device ↵Sven Gothel2022-09-151-6/+1
| | | | | | | | | pull-down to clear all its states instead of just deleting all refs if !active BTAdapter::poweredOff()'s active argument shall only impact issuing stopDiscoveryImpl(). Without disconnectAllDevices(), non removed devices will have states uncleared, e.g. isConnected, certain SMP states etc.