summaryrefslogtreecommitdiffstats
path: root/examples
Commit message (Collapse)AuthorAgeFilesLines
* dbt_peripheral00/DBTPeripheral00: Fix using *Indicate handle where selectedSven Gothel2022-01-012-4/+4
|
* Examples: Use clear 'client_keys' and 'server_keys' for key client- and ↵Sven Gothel2022-01-017-18/+18
| | | | server-path.
* dbt_scanner10/DBTScanner10: Remove redundant ↵Sven Gothel2021-12-052-6/+0
| | | | adapter::removeDiscoveredDevices() before adapter::startDiscovery(..)
* DiscoveryPolicy: DBTScanner10.java align with dbt_scanner10.cpp, remove all ↵Sven Gothel2021-11-291-12/+0
| | | | stopDiscovery() calls.
* BTAdapter::pausing_discovery_devices: Use std::weak_ptr<BTDevice> list; Add ↵Sven Gothel2021-11-292-6/+15
| | | | | | | | | | | | | | | | BTAdapter::removeDevicePausingDiscovery() and getCurrentDiscoveryPolicy() Using a weak_ptr<BTDevice> list avoid stopping BTDevice destruction. BTAdapter::removeDevicePausingDiscovery() allows manual DiscoveryPolicy intervention point, allowing user to remove the ready device from the queue of pausing-discovery devices. Manual intervention might be desired, if using DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED, but allowing discovery at an earlier processing step from AdapterStatusListener::deviceReady(). +++ Further added removeDevicePausingDiscovery() call in BTAdapter::removeDevice() as a last resort.
* DiscoveryPolicy: Implement Discovery Policy, covering HCI host OS's implied ↵Sven Gothel2021-11-287-120/+53
| | | | | | | | | | | | | | | | | | | | | | discovery-off and detailed 'keep alive' options API change (earmark version 2.5.0): - AdapterStatusListener::discoveringChanged() - BTAdapter::startDiscovery() BTAdapter::startDiscovery() takes DiscoveryPolicy instead of bool keep_alive, allowing fine tuned discovery keep-alive policy and covering HCI host OS's implied discovery turn-off when connected (BlueZ/Linux). dbt_scanner10.cpp and DBTScanner10.java covery the new DiscoveryPolicy and user may pass its integer value via '-discoveryPolicy <0-4>'. These example were further adjusted as follows: - Removed WHITELIST variation of connection w/o discovery, cleaning up and simplifying example code - Remove manual start- and stopDiscovery() handling, ending up in a single startDiscovery() call @ init (and power-on).
* SMPKeyBin::createAndWrite(..): Drop 'overwrite' argument as we shall set ↵Sven Gothel2021-11-193-3/+3
| | | | | | | | overwrite = PairingMode::PRE_PAIRED != device.getPairingMode() Only PRE_PAIRED keys shall not be overwrite the existing file, as they don't need to be and hence can preserve their timestamp. However, another PairingMode indicates a new key and shall overwrite an existing file.
* BTAdapter::startDiscovery(..): Add 'bool filter_dup=true' as last parameter; ↵Sven Gothel2021-11-171-1/+3
| | | | Java: Same, but no default value possible (minor API change)
* dbt_peripheral00: Drop virtual on override; DBTPeripheral00: Drop overriding ↵Sven Gothel2021-11-152-4/+2
| | | | finalize() and call super.close() on close()
* peripheral00 example: Bring back 100ms sleep @ disconnected before restart ↵Sven Gothel2021-11-142-0/+4
| | | | | | advertising (FIXME) FIXME: Fast restart of advertising error: Analyze!
* Align DBTPeripheral00.java w/ dbt_peripheral00.cpp: initAdapter() w/ full ↵Sven Gothel2021-11-144-24/+81
| | | | | | | | | name and SC init, LE_PHYs and SMPKeyPath DBTPeripheral00 now also exposed - startup and reusing stored SMPKeyBin files in SMPKeyPath - prefer LE_PHYs::LE_2M, if available (BT5) - set use SC (default) or legacy (not SC) - SC = LE Secure Connection
* Complete DBGattServer Lifecycle: Add DBGatt* dtor on Java side; Remove ↵Sven Gothel2021-11-144-21/+95
| | | | BTAdapter held reference on disconnect, align ref holding in Java BTAdapter; Add explicit shutdown test
* DBGatt[Desc|Char|Service].java: Working proxy for DBGattServer/Peripheral on ↵Sven Gothel2021-11-131-7/+12
| | | | Java side.
* DBGatt[Desc|Char|Service]: Use mutable and const field accessors; Remove ↵Sven Gothel2021-11-131-11/+11
| | | | | | | | | | JavaUplink Use mutable and const field accessors, similar to upcoming Java 'proxy' classes. This shall help defining mutable and const reference data access. Revert adding JavaUplink to DBGatt[Desc|Char|Service] of commit 414c81b7214d895aba694ff444feca9cdc491bc5, as we do not link from native instance to Java.
* DBGatt[Desc|Char|Service]: Use shared_ptr references to support Java binding ↵Sven Gothel2021-11-131-42/+42
| | | | and hence derive from JavaUplink
* Use 'typedef std::shared_ptr<BTDevice> BTDeviceRef' to shorten code linesSven Gothel2021-11-132-30/+30
|
* Align early Direct-BT version output in main function and use fprintf_td() / ↵Sven Gothel2021-11-093-40/+39
| | | | BTUtils.*print*()
* DBTPeripheral: Port over 'MyGATTServerListener extends ↵Sven Gothel2021-11-091-11/+207
| | | | DBGattServer.Listener' from C++
* DBGatt[Char|Desc]::variable_length defaults to false; Add DBGattValue.java ↵Sven Gothel2021-11-092-27/+28
| | | | | | | covering semantics of C++ POctets + bool variable_length DBGattValue covers C++ POctets + bool variable_length, where POctets contains bytes, its size and capacity.
* DBTScanner10.java: Show utf8 value for notification/indication data (like ↵Sven Gothel2021-11-091-2/+4
| | | | dbt_scanner10)
* Slave Peripheral / Gatt Server: Map DBGattServer.hpp types ↵Sven Gothel2021-11-091-1/+109
| | | | | | | | | | DBGatt[Server|Service|Char|Desc] to Java ; BTAdapter.startAdvertising(..) Adds DBGattServer arg - Implementation is not yet functional, i.e. types are not yet mapped to native instance. - DBGattChar and DBGattDesc value currently just a 'byte[]' and lacks capacity: - Its capacity defines the maximum writable variable length - and its size defines the maximum writable fixed length.
* dbt_peripheral00.cpp: Add jau::uuid128_t DataServiceUUID; Cleanup DBGattChar ↵Sven Gothel2021-11-091-11/+12
| | | | ctor braces
* DBGattServer::Listener: Add connected() and mtuChanged(): Supporting using ↵Sven Gothel2021-11-081-29/+64
| | | | | | | | | 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 ..
* Add BTGattCmd (C++/Java): Conveniently maps a GATT command and optionally ↵Sven Gothel2021-11-082-2/+79
| | | | | | its asynchronous response to a synchronous atomic operation Examples, see dbt_scanner10 and DBTScanner10
* BTDevice.java: Align API functions to C++: getServices() -> ↵Sven Gothel2021-11-081-2/+2
| | | | getGattServices(); connect() -> connectDefault()
* Add example: dbt_readsmpkey.cpp: Read SMPKeyBin files and dump themSven Gothel2021-11-082-0/+71
|
* Add BTAdapter's Slave Peripheral SMP Key ManagementSven Gothel2021-10-292-24/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); +++
* Move SMPKeyBin 'apply' to BTDevice, splitting functionality: setting + ↵Sven Gothel2021-10-293-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Issue BTDevice::unpair() directly when device is discovered, disconnected ↵Sven Gothel2021-10-284-35/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* dbt_peripheral00: Peripheral in SC mode needs unpair(), i.e. erase all keys ..Sven Gothel2021-10-281-3/+5
|
* dbt_scanner10: PASSKEY_EXPECTED, NUMERIC_COMPARE_EXPECTED: Lookup ↵Sven Gothel2021-10-281-2/+2
| | | | BTSecurityRegistry by start-of name as well
* DBGattServer: Add convenience functions to zero values and reset ↵Sven Gothel2021-10-281-18/+2
| | | | ClientCharConfig
* dbt_peripheral00: initAdapter(): Fail on failed setupSven Gothel2021-10-281-0/+1
|
* dbt_peripheral: Fix initial setup: Move power-off settings post initialize ↵Sven Gothel2021-10-281-19/+25
| | | | (name + SC)
* Add DBGattServer::Listener::disconnect(..) for cleanup, example: Full ↵Sven Gothel2021-10-271-18/+54
| | | | cleanup incl. CCCD regs
* SMPKeyBin: Add helper to load all SMPKeyBin files from a directory, filter ↵Sven Gothel2021-10-271-2/+11
| | | | for one adapter and apply them all (peripheral pre-pairing)
* SMPKeyBin (Version 5, C++/Java): Add IRK and (set/get) and also set CSRKSven Gothel2021-10-271-1/+9
|
* Add 3 HCI Commands + 1 HCI MetaEvent to support SMP SC on slave peripheral ↵Sven Gothel2021-10-262-9/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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(..)
* DBGattServer / dbt_peripheral00: Use jau::make_darray(..) for proper ↵Sven Gothel2021-10-241-63/+78
| | | | | | | | | | | | | move-semantics; 1st fully functional Gatt-Server! Gatt-Server functionality provided by dbt_peripheral: - Service GENERIC_ACCESS - Service DEVICE_INFORMATION - Service Proprietary `d0ca6bf3-3d50-4760-98e5-fc5883e93712` - Characterictic DATA_STATIC: Read static data - Characterictic COMMAND: Write a command - Characterictic RESPONSE: Command response notify or indicate - Characterictic DATA_PULSE: Periodical data sent via notify or indicate
* dbt_peripheral02: MyGATTServerListener implements DATA PULSE notify/indicate ↵Sven Gothel2021-10-201-1/+85
| | | | and echo command response via notify/indicate
* dbt_scanner10: If KEEP_CONNECT: don't remove char-listener, have them work ↵Sven Gothel2021-10-201-1/+2
| | | | until disconnect
* dbt_scanner10: show utf8 string of notify/indicate if not TempSven Gothel2021-10-201-2/+8
|
* DBGattServer::Listener::clientCharConfigChanged() Use const qualifier; ↵Sven Gothel2021-10-191-4/+4
| | | | dbt_peripheral00: Add DBGattDesc::createClientCharConfig() to RESPONSE notify
* Add DBGattServer::Listener::clientCharConfigChanged(..)Sven Gothel2021-10-191-0/+6
|
* DBGattServer:: Add 'variable_length' Desc/Char attribute, add ↵Sven Gothel2021-10-191-9/+13
| | | | | | DBGattDesc::createClientCharConfig(), .. add Listener::write*Value(..) value_offset argument for long write requests
* Add DBGattServer::att_mtu, enabling custom max ATT_MTU size (also used for ↵Sven Gothel2021-10-161-0/+4
| | | | testing)
* Adding DBGattServer::Listener allowing server application to react on remote ↵Sven Gothel2021-10-161-1/+30
| | | | GATT action
* README.md: Mention Peripheral Example C++/Java; Sync bothSven Gothel2021-10-152-4/+9
| | | | The Java example is currently not yet working ...
* dbt_peripheral00: Restart advertising (and allowing new connections) after ↵Sven Gothel2021-10-151-2/+21
| | | | DISCONNECT
* dbt_peripheral00: Add proprietary service using all usual data, command and ↵Sven Gothel2021-10-141-32/+52
| | | | response components with user-description