summaryrefslogtreecommitdiffstats
path: root/api
Commit message (Collapse)AuthorAgeFilesLines
* GATT/L2CAP Robustness: Have L2CAPHandler its own DBTEnvrionment (local ↵Sven Gothel2020-09-232-13/+65
| | | | | | | | | L2CAP_READER_POLL_TIMEOUT) and new L2CAP_RESTART_COUNT_ON_ERROR for testing L2CAPHandler's read/write will also issue verbose error-out messages in case the instance is still connected, i.e. not intentionally pulled by another thread. This is work in progress.
* Conclude POWERED state change across C++/Java; Newly added ↵Sven Gothel2020-09-232-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | AdapterStatusListener shall receive adapterSettingsChanged(..) for initial AdapterSettings Conclude POWERED state change across C++/Java - DBTAdapter.java must be notified to have isDiscovering and discoveredDevices cleared on !POWERED. It will additionally react to !POWERED state change, by clearing the mentioned states for robustness. - DBTAdapter.cpp's stopDiscovery() shall send MgmtEvtDiscovering (-> AdapterStatusListener.discoveryChanged(..)) itself in case of le_enable_scan != SUCCESS, otherwise - DBTAdapter.cpp's poweredOff(): -- Shall not clearAllMgmtEventCallbacks() on HCI before stopDiscovery() and disconnectAllDevices(), otherwise stopDiscovery events won't be received and forwarded to AdapterStatusListener. hci->close() will deal with it afterwards. It is up to the user (application) to react to POWERED (power on) state change, i.e. restart discovery! +++ Newly added AdapterStatusListener shall receive adapterSettingsChanged(..) for initial AdapterSettings. This is required to have e.g. the DBTAdapter.java instance be aware of its initial state, e.g. isPowered etc.
* LE Secure Connections: Initial API to support secure pairing with varying ↵Sven Gothel2020-09-222-1/+66
| | | | | | | | | | | 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.
* Doxygen: C++ package and private extraction creates too verbose ↵v2.1.26Sven Gothel2020-09-212-2/+19
| | | | | | | | documentation, leave it out for now. We may add a developer api doc later on. Also mention HCIHandler correctly in DBTAdapter and DBTDevice, where it is being used.
* README/API-Doc: Add details about Direct-BT and resolve markdown to html ↵Sven Gothel2020-09-211-7/+8
| | | | limitations of cgit's md2html
* DBTAdapter::mgmtEvNewSettingsMgmt: Update DBTAdapter::btMode from new ↵Sven Gothel2020-09-201-1/+2
| | | | setting (and expose in debug message)
* GATTHandler::sendWithReply(..): Either returns a valid reply or throws an ↵Sven Gothel2020-09-201-0/+36
| | | | | | exception, similar to send(..); Remove nullptr == reply in caller. Add appropriate detailed API doc for GATTHandler::send() and GATTHandler::sendWithReply().
* Handle abort() via dbt_debug's new ABORT(..), ensure a message is being send ↵Sven Gothel2020-09-202-3/+7
| | | | and process aborted; Use it.
* OctetTypes::freeData() regression: Zero sized POctets w/ nullptr are ↵Sven Gothel2020-09-201-17/+16
| | | | | | | | | supported now, see POctets::POctets() As commit ac2cf3d62bb405b2a25ad5f674925e11b08c6b5e explicitly allows zero POctets via its default ctor, freeData shall tolerate it, simply doing nothing. Renamed POctets::malloc(..) to POctets::allocData(..), to match freeData() method and hence pairing intention.
* GATT[Service,...] used a 'toSafeString()' due to unknown SIGSEGV at this ↵Sven Gothel2020-09-203-27/+3
| | | | | | | | | time, rename to toShortString() The SIGSEGV back then happened due to abusive non-weak backreference back to device, which already got destroyed at some point. Since this has been resolved, we rename the method to 'toShortString()' and remove the elaborated comment.
* HCIHandler: Earmark BT Spec details for LE Secure ConnectionsSven Gothel2020-09-201-0/+14
|
* C++ DBTManager / Java BluetoothFactory: Default operation is BTMode::LE (Was ↵Sven Gothel2020-09-201-2/+14
| | | | | | | | | | DUAL in Java) All global BTMode defaults to LE (only) - C++ DBTManager: Add MgmtEnv::DEFAULT_BTMODE, env-var 'direct_bt.mgmt.btmode' first, then try 'org.tinyb.btmode'. - DBTEnv:getProperty(name): Add COND_PRINT(debug,..) for no default value root method as well.
* POctets: Add default ctor POctets() with intentional zero sized data and use ↵Sven Gothel2020-09-193-18/+16
| | | | | | | | | | | | it where applicable As POctets with explicit given size==0 is now considered an illegal argument, avoiding wrongdoing or invalid data by accident, we offer the default ctor to initialize an intentional zero sized instance. This is used for GATTDescriptor ctor and ManufactureSpecificData ctor. The caller for the latter will explicitly check whether the EIR data has actual specific data left in its received EIR data chunk.
* Fix GATT* Object relationship incl weak back-reference (GATTHandler was ↵Sven Gothel2020-09-195-17/+30
| | | | | | | | | | | | | | | | | | 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
* *Octet::check_range(..): Pass file, line as argument, as inline won't work ↵Sven Gothel2020-09-191-2/+4
| | | | | | preservice __FILE__, __LINE__ and use macro calling it This change will preserve the caller __FILE__, __LINE__ information to please error analysis.
* POctets::malloc: throw new exception type OutOfMemoryError early on malloc ↵Sven Gothel2020-09-192-9/+26
| | | | | | | | | | | failure, also throw IllegalArgumentException on size <= 0 - Add exception type 'direct_bt::OutOfMemoryError' and wire it in helper_base for C++/JNI interoperability. - std::malloc may not return nullptr on zero size, but a valid dummy pointer usable by free. Hence check for malloc(0) and throw IllegalArgumentException - also throw OutOfMemoryError on nullptr == malloc(size)
* C++ *Octet noexcept, add/use more [get|put]_*_nc(..) where applicable ↵Sven Gothel2020-09-194-93/+116
| | | | | | | | | | | | | | | | | | | | | | | (pre-checked) - *Octets: Add put_*_nc(..) noexcept variants and use it where range has been pre-checked - ATTPDU: Use noexcept variant for prechecked value range. - DBTManager/HCIHandler: Use noexcept variant for prechecked value range. +++ TODO: Bug 4 - *Octets get_[w]ptr(..) methods shall be given a value range for security (exception) (https://jausoft.com/bugzilla/show_bug.cgi?id=4> *Octets get_[w]ptr(..) methos with exception should check the intended used range! Either the range has been pre-checked, then user shall use the noexcept '_nc' variant, otherwise the intended range shall be checked within the call for safety! Note: Both variants shall have the range given for compatible signature, as well as to force the user to determine the range and then decide whether noexcept applies.
* dbt_debug: Generalize ERR_PRINT2 -> ERR_PRINT_IMPL w/ prefix param; Add ↵Sven Gothel2020-09-191-5/+8
| | | | | | | | | | | | | IRQ_PRINT(.. "Interrupted" ), to clarify class of event. An interruption might not be an error, but expected behavior - e.g. if a device is powered off. Use IRQ_ERROR in GattHandler on: - l2cap write error -> disconnect + exception - l2cap nullptr reply (sendWithReply) -> disconnect + exception - l2cap read error (l2capReaderThread) -> disconnect We might find other occassions where this informal output fits.
* api/tinyb/BluetoothException: Conform to C++11Sven Gothel2020-09-191-13/+15
| | | | | We will include this header file in helper_base.hpp to accomodate both implementation within rethrow_and_raise_java_exception(..)
* DBTAdapter: Missed commit of noexcept marking for 'friend ... ↵Sven Gothel2020-09-181-1/+1
| | | | DBTDevice::getGATTServices()'
* DBTDevice: pingGATT and getGATTServices handle exceptions, hence mark both ↵Sven Gothel2020-09-181-2/+2
| | | | 'noexcept'
* dbt_debug: INFO_PRINT(..) -> WORDY_PRINT(..) cond DBTEnv::VERBOSE, add ↵Sven Gothel2020-09-181-2/+10
| | | | | | | | | | | | | | | uncond INFO_PRINT(..) Turns out INFO_PRINT(..) is confusing, as it was not clear that it is conditional on DBTEnv::VERBOSE. Hence rename it to the short English from for Latin 'verbosus', and hence hinting it is conditional on DBTEnv::VERBOSE. INFO_PRINT(..) renamed to WORDY_PRINT(..), using prefix 'Wordy:' (Verbose is just too long) Add unconditional INFO_PRINT(..) for plain informal messages. Hope this clears up the confusion. Hint: I was looking for an INFO_PRINT(..) ouput myself ;-)
* DBTDevice: Resolve disconnect/remove resource race condition @ rapid connect ↵v2.1.22Sven Gothel2020-09-181-1/+15
| | | | | | | | | | | | | | | | | | | | | | w/ one thread per device Testing w/ 2 devices in fastest rapid reconnect (using automatic disconnect) on Raspberry-Pi: (1) Native run-dbt_scanner10.sh -silent_gatt -mac C0:26:DA:01:DA:B1 -mac C0:26:DF:01:E5:CA -disconnect -count 12 (2) Java run-java-scanner10.sh -silent_gatt -mac C0:26:DA:01:DA:B1 -mac C0:26:DF:01:E5:CA -disconnect -count 12 The Java (2) test case disclosed a race condition as follows: "An application using one thread per device and rapid connect, should either use disconnect() or remove(), but never issue remove() after disconnect(). Doing so would eventually delete the device being already in use by another thread due to discovery post disconnect!" The example code was issuing (1) disconnect and waiting for being diconnected and only then (2) removing the device. In between the device got discovered already and a new processing thread has started while the closing previous processing thread is removing the device and hence the underlying DBTDevice. A user shall either use disconnect() or remove(), period.
* DBTEnv API Doc: Mention missing 'direct_bt.debug.adapter.event', order ↵Sven Gothel2020-09-181-2/+3
| | | | alphabetical
* HCIComm, L2CAPComm, GATTHandler: Better var- and accessor-naming, init fd in ↵Sven Gothel2020-09-183-19/+18
| | | | init-list of ctor
* Open [& Connect] @ ctor (RAII): HCIComm, L2CAPComm, GATTHandler, simplifying ↵Sven Gothel2020-09-184-40/+29
| | | | | | | | | | | | | | | | | | | | | | | 'connect' lifecycle Further: - L2CAPComm -- disconnect(): Only lock mtw_write if connected and mark noexcept -- Added '~L2CAPComm() noexcept' for RAII -- Removed unsued accessors - GATTHandler -- Similar treatment as L2CAPComm - DBTDevice -- Remove mtx_gatt and its locks, they were not consistent. Rely on mtx_connect (connectGATT/getGATTServices/disconnect) and atomic local GATTHandler copy when using. -- disconnect GATTHandler directly in disconnect, remove explicit method. -- pingGATT uses local gattHandler copy to avoid parallel disconnect nullptr, however, it will fail immediately due to disconnection.
* DBTAdapter: Atomic operation across discovered, connected and shared devicesSven Gothel2020-09-162-5/+3
| | | | | | | .. achieved via unique mutex lock. Hence perform DBTDevice::remove() within adapter to ensure disconnect and device reference removal is atomic covered by uniue lock.
* Correct API doc for DBTDevice::remove() (C++ and Java):Sven Gothel2020-09-161-4/+3
| | | | | | Fix order of explicitly removing shared reference: connected-devices, discovered-devices and shared-devices. Fix disconnect also removes its ref from discovered-devices, besides connected-devices, but not shared-devices.
* DBTEnv: Resolve using environment vars under Unix shells, e.g. try ↵Sven Gothel2020-09-151-1/+23
| | | | 'direct_bt_debug' if ''direct_bt.debug' wasn't found.
* C++ noexcept: DBTManager, DBTAdapter and DBTDevice (concluding for now)Sven Gothel2020-09-153-77/+77
| | | | | | | | | | | | | | | | | | RELEASE Builds w/ -O3: dist-amd64/lib/libdirect_bt.so.2.1.20 pre-opt: 2,131,720 post-opt: 74,424 bytes reduced: 3.5% 2,057,296 commit (this commit) Besides footprint and natural performance benefits, mostly quality regarding conscious managing of exception handling benefitted this last 'noexcept' changeset. Notable here *Octets and ATTPDU types range checking has been moved into the ctor to allow member access w/o range checks and hence avoiding potential exceptions.
* C++ noexcept: JavaUplink, DBTObject, JavaGlobalObjSven Gothel2020-09-152-15/+15
|
* dbt_debug: Use namespace for macro resolution in case macro being used ↵Sven Gothel2020-09-151-2/+2
| | | | ex-namespace w/o 'using'
* C++ noexcept: GATT* Data TypesSven Gothel2020-09-154-70/+71
|
* C++ noexcept: DBTManagerSven Gothel2020-09-141-45/+45
|
* C++ noexcept: GATTHandlerSven Gothel2020-09-141-18/+18
| | | | We had to keep quite many methods due to 'exception bail out' usage on broken connection.
* C++ noexcept: HCITypes and MgmtTypesSven Gothel2020-09-142-21/+21
|
* C++ noexcept: ATTPDUTypes string methods; DBTEnv; HCIComm and HCIHandlerSven Gothel2020-09-144-92/+92
|
* C++ noexcept: Remaining BasicTypes getCurrentMilliseconds(), ↵Sven Gothel2020-09-141-6/+6
| | | | uintXHexString(..) using ERR_PRINT and abort for internal error
* C++ noexcept: uuid_t and its implementations; Make uuid_t::TypeSize and ↵Sven Gothel2020-09-143-46/+51
| | | | | | 'enum class' type In case of an internal error, simply ERR_PRINT and abort, usually the toString() implementations.
* C++ noexcept: Ringbuffer and its LFRingbuffer implementationSven Gothel2020-09-142-57/+70
|
* C++ noexcept: Adjust all types and functions in DBTTypesSven Gothel2020-09-141-38/+38
|
* C++ noexcept: MgmtTypes: MgmtEvent ctor gets exp_param_size to validate data ↵Sven Gothel2020-09-142-179/+197
| | | | | | | | range, dropping checks on data usage... Also - Fix MgmtEvtNewConnectionParam's offset for getDataOffset() and getDataSize(): 14 -> 16 - HCIHandler: Use new IndexOutOfBoundsException ctor w/o bounds
* C++ noexcept: HCITypes: HCIEvent ctor gets exp_param_size to validate data ↵Sven Gothel2020-09-141-24/+24
| | | | range, dropping checks on data usage.
* C++ noexcept: FunctionDef.hppSven Gothel2020-09-141-53/+53
|
* C++ noexcept: Add missing 'AttPDUMsg::getSpecialized(..)'Sven Gothel2020-09-141-1/+1
|
* C++ IndexOutOfBoundsException: Add variant for just index + lengthSven Gothel2020-09-142-7/+10
|
* C++: Second round propagating noexcept and using OctetTypes nocheck '_nc'Sven Gothel2020-09-144-150/+153
| | | | | | | | | | | | | RELEASE Builds w/ -O3: pre-opt: 2,131,720 dist-amd64/lib/libdirect_bt.so.2.1.20 noexcept round-1: (added OctetTypes _nc methods, hence offsetting reduction) 2,132,112 dist-amd64/lib/libdirect_bt.so.2.1.20 noexcept round-2: (reductions only) ~20k less 2,111,632 dist-amd64/lib/libdirect_bt.so.2.1.20
* C++: First round propagating noexcept: Adding nocheck '_nc' variants in ↵Sven Gothel2020-09-145-240/+329
| | | | OctetTypes and use them if allowed.
* Fixing Example crossreference and Menu itemSven Gothel2020-09-031-0/+31
| | | | The \example tag referring to the example code file must be added to the actual API (header) files.
* README: More detailed Direct-BT description (event driven, build ↵Sven Gothel2020-09-032-4/+8
| | | | | | depenencies, build, ..); Add \example tag in examples. For unknown reason, examples are not visible in result.