diff options
author | Sven Gothel <[email protected]> | 2021-10-10 04:44:45 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-10-10 04:44:45 +0200 |
commit | b8a7f626fadcf6b21e5df67cdf0df4369885a6b8 (patch) | |
tree | eb2a05fabe63e8b8ccb61bcdb019459a69eaa251 | |
parent | 5295208f805a3389a6a3d91b5cd27404fe3fa01c (diff) |
Removed TinyB API artifacts, fix copyright notice. Add README.md 'Direct-BT Origins'
Removed remaining TinyB API artifacts:
- BTType.java and related search functions (class_type())
- Java's clone()
- BTManager's device/gatt functionality, only covers adapter.
+++
Direct-BT originated from TinyB.
Major TinyB autors were:
- Andrei Vasiliu <[email protected]>
- Petre Eftime <[email protected]>
TinyB Copyright (c) 2016 Intel Corporation.
With the removal of TinyB from Direct-BT
we removed all substantial parts (if not all, i.e. > 99.9%)
of its copyright holder.
This change removes remaining source file Intel (c) notices.
This change does not disregard the author's original work,
on the contrary, we keep attribution about Direct-BT's history
in the README.md file 'Direct-BT Origins' section.
The Intel (c) notice and TinyB authors stay in the COPYING file.
We are grateful for their excellent work.
This change is to clarify authorship and copyright of Direct-BT's work,
as well as to not mislead association with the work of TinyB.
24 files changed, 159 insertions, 857 deletions
@@ -1,8 +1,7 @@ The MIT License (MIT) -Copyright © 2015-2016 Intel Corporation Copyright © 2020 Gothel Software e.K. Copyright © 2020 ZAFENA AB - +Copyright © 2015-2016 Intel Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -27,8 +26,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -Direct-BT Sub-Module License & Copyright -======================================== +Direct-BT License & Copyright +=============================== The MIT License (MIT) (see above) Copyright © 2020 Gothel Software e.K. Copyright © 2020 ZAFENA AB @@ -65,3 +64,26 @@ This documentation of our usage is certainly better than GOOG's approach: <https://android.googlesource.com/platform/system/bluetooth/+/eclair-release/bluez-clean-headers/bluetooth?autodive=0/>, which removes all authorship and origin. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Copyright Intel Corporation +============================ +Direct-BT was initially developed as an +alternative implementation to TinyB's Java API. + +The latter was developed by the Intel Corporation +and licensed under the MIT license. +Main authors of TinyB were: +- Petre Eftime <[email protected]> +- Andrei Vasiliu <[email protected]> + +Today, TinyB has been removed from this project. + +This copyright notice shall stay, +since some code fragments and portions of the infrastructure +contains their work. + +See also README.md: 'Direct-BT Origins'. + @@ -13,6 +13,8 @@ fully accessible through C++, Java and other languages. *Direct-BT* provides direct [Bluetooth LE and BREDR](https://www.bluetooth.com/specifications/bluetooth-core-specification/) programming, offering robust high-performance support for embedded & desktop with zero overhead via C++ and Java. +Below you can find a few notes about [*Direct-BT* Origins](#direct_bt_origins). + You will find a [detailed overview of *Direct-BT*](https://jausoft.com/projects/direct_bt/build/documentation/cpp/html/namespacedirect__bt.html#details) (C++) and the [same in the Java API](https://jausoft.com/projects/direct_bt/build/documentation/java/html/namespaceorg_1_1direct__bt.html#details). @@ -364,12 +366,72 @@ Please check the [Contribution](CONTRIBUTING.md) document for more details. ## Historical Notes +<a name="direct_bt_origins"></a> + +### *Direct-BT* Origins +*Direct-BT* development started around April 2020, +initially as an alternative *TinyB* Java-API implementation. + +The work was motivated due to strict +performance, discovery- and connection timing requirements, +as well as being able to handle multiple devices concurrently +using a real-time event driven low-overhead architecture. + +Zafena's [POC-Workstation](https://www.zafena.se/en/product/zafena-552-poc-workstation/) +was originally implemented using *TinyB* and hence the D-Bus layer to the *BlueZ* client library. + +Real time knowledge when devices are discovered and connected +were not available and *cloaked* by the caching mechanism. +Advertising package details were not exposed. + +Connections attempts often took up to 10 seconds to be completed. +Detailed information from the *Bluetooth* layer were inaccessible +including detailed error states. + +Fine grained control about discovery and connection parameter +were not exposed by the D-Bus API and hence *TinyB*. + +In Januaray 2020 we tried to remedy certain aspects to meet our goals, +but concluded to require direct *Bluetooth* control +via the *BlueZ*/*Linux* kernel implementation. + +*Direct-BT* was born. + +We then implemented data types for +- *HCI Packets* to handle HCI communication to the adapter +- *Mgmt Packets* to support *BlueZ*/Linux communication +- *ATT PDU Messages* to handle GATT communication to the remote device +- *SMP Packets* to implement *Secure Connections (SC)* + +Last but not least we added +- *Bluetooth* version 5 support +- GATT-Server support to enable implementing peripheral devices, + as well as to allow self-testing of *Direct-BT*. + +Today, *Direct-BT*'s C++ and Java API match 1:1 +and shall not contain legacy API artifacts. + ### *TinyB* Removal since version 2.3 -Starting with version 2.3, the previously refactored *TinyB* has been removed completely. +Heading towards feature completion for *Direct-BT*, +we completely removed the previously refactored *TinyB*. + +Detailing full *Bluetooth* support in *Direct-BT* including the addition +of GATT-Server support rendered *TinyB* an obstacle for the public API. + +However, *TinyB* inspired us and was a great reference implementation while developing and testing *Direct-BT*. + +We like to thank the authors of *TinyB* for their great work helping others and us moving forward. +Thank you! + +### *TinyB* +*TinyB* was developed by the *Intel Corporation* +and its main authors were +- Petre Eftime <[email protected]> +- Andrei Vasiliu <[email protected]> -Motivation was lack of detailed Bluetooth support, inclusive increasing diversion with *Direct-BT*. -Furthermore, work is underway for `BLE slave peripheral and GATT server` support and its mapping to *BlueZ D-Bus* is questionable -and would be resource intensive. +*TinyB* was licensed under the *The MIT License (MIT)* +and the *Intel Corporation* holds its copyright +from the year 2016. ## Changes **3.0.0 *Direct-BT* Maturity (Bluetooth LE)** diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp index bf107d3d..1c2a69a0 100644 --- a/api/direct_bt/BTManager.hpp +++ b/api/direct_bt/BTManager.hpp @@ -408,13 +408,6 @@ namespace direct_bt { HCIStatusCode initializeAdapter(AdapterInfo& adapterInfo, const uint16_t dev_id, const BTRole btRole, const BTMode btMode) noexcept; - /** Start discovery on given adapter dev_id with a ScanType matching the given BTMode. Returns set ScanType. */ - ScanType startDiscovery(const uint16_t dev_id, const BTMode btMode) noexcept; - /** Start discovery on given adapter dev_id with given ScanType. Returns set ScanType. */ - ScanType startDiscovery(const uint16_t dev_id, const ScanType type) noexcept; - /** Stop discovery on given adapter dev_id. */ - bool stopDiscovery(const uint16_t dev_id, const ScanType type) noexcept; - /** * Uploads given connection parameter for given device to the kernel. * @@ -453,10 +446,6 @@ namespace direct_bt { /** Remove all previously added devices from the autoconnect whitelist. Returns number of removed devices. */ int removeAllDevicesFromWhitelist() noexcept; - bool disconnect(const bool ioErrorCause, - const uint16_t dev_id, const BDAddressAndType & addressAndType, - const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ) noexcept; - std::shared_ptr<ConnectionInfo> getConnectionInfo(const uint16_t dev_id, const BDAddressAndType& addressAndType) noexcept; std::shared_ptr<NameAndShortName> setLocalName(const uint16_t dev_id, const std::string & name, const std::string & short_name) noexcept; @@ -472,7 +461,6 @@ namespace direct_bt { MgmtStatus userPasskeyNegativeReply(const uint16_t dev_id, const BDAddressAndType & addressAndType) noexcept; MgmtStatus userConfirmReply(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool positive) noexcept; - bool pairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPIOCapability iocap) noexcept; MgmtStatus unpairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool disconnect) noexcept; /** MgmtEventCallback handling */ diff --git a/java/jau/direct_bt/DBTAdapter.java b/java/jau/direct_bt/DBTAdapter.java index cafe536d..f67bff89 100644 --- a/java/jau/direct_bt/DBTAdapter.java +++ b/java/jau/direct_bt/DBTAdapter.java @@ -41,14 +41,9 @@ import org.direct_bt.BDAddressType; import org.direct_bt.BTAdapter; import org.direct_bt.BTDevice; import org.direct_bt.BTException; -import org.direct_bt.BTGattChar; -import org.direct_bt.BTGattDesc; -import org.direct_bt.BTGattService; import org.direct_bt.BTManager; import org.direct_bt.BTMode; -import org.direct_bt.BTObject; import org.direct_bt.BTRole; -import org.direct_bt.BTType; import org.direct_bt.BTUtils; import org.direct_bt.EIRDataTypeSet; import org.direct_bt.HCIStatusCode; @@ -206,11 +201,6 @@ public class DBTAdapter extends DBTObject implements BTAdapter private native byte setNameImpl(final String name, String short_name); @Override - public BTType getBluetoothType() { return class_type(); } - - static BTType class_type() { return BTType.ADAPTER; } - - @Override public BTDevice find(final String name, final BDAddressAndType addressAndType, final long timeoutMS) { return findDeviceInCache(name, addressAndType); } @@ -611,91 +601,6 @@ public class DBTAdapter extends DBTObject implements BTAdapter }; - /** - * Returns the matching {@link DBTObject} from the internal cache if found, - * otherwise {@code null}. - * <p> - * The returned {@link DBTObject} may be of type - * <ul> - * <li>{@link DBTDevice}</li> - * <li>{@link DBTGattService}</li> - * <li>{@link DBTGattChar}</li> - * <li>{@link DBTGattDesc}</li> - * </ul> - * or alternatively in {@link BTObject} space - * <ul> - * <li>{@link BTType#DEVICE} -> {@link BTDevice}</li> - * <li>{@link BTType#GATT_SERVICE} -> {@link BTGattService}</li> - * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li> - * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li> - * </ul> - * </p> - * @param name name of the desired {@link BTType#DEVICE device}. - * Maybe {@code null}. - * @param identifier EUI48 address of the desired {@link BTType#DEVICE device} - * or UUID of the desired {@link BTType#GATT_SERVICE service}, - * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found. - * Maybe {@code null}, in which case the first object of the desired type is being returned - if existing. - * @param type specify the type of the object to be found, either - * {@link BTType#DEVICE device}, - * {@link BTType#GATT_SERVICE service}, {@link BTType#GATT_CHARACTERISTIC characteristic} - * or {@link BTType#GATT_DESCRIPTOR descriptor}. - * {@link BTType#NONE none} means anything. - */ - /* pp */ DBTObject findInCache(final String name, final String identifier, final BTType type) { - final boolean anyType = BTType.NONE == type; - final boolean deviceType = BTType.DEVICE == type; - final boolean serviceType = BTType.GATT_SERVICE == type; - final boolean charType = BTType.GATT_CHARACTERISTIC== type; - final boolean descType = BTType.GATT_DESCRIPTOR == type; - - if( !anyType && !deviceType && !serviceType && !charType && !descType ) { - return null; - } - synchronized(discoveredDevicesLock) { - cleanDiscoveredDevice(); - - if( null == name && null == identifier && ( anyType || deviceType ) ) { - // special case for 1st valid device - if( discoveredDevices.size() > 0 ) { - return (DBTDevice) discoveredDevices.get(0).get(); - } - return null; // no device - } - for(int devIdx = discoveredDevices.size() - 1; devIdx >= 0; devIdx-- ) { - final DBTDevice device = (DBTDevice) discoveredDevices.get(devIdx).get(); - if( ( anyType || deviceType ) ) { - if( null != name && null != identifier && - device.getName().equals(name) && - device.getAddressAndType().address.toString().equals(identifier) - ) - { - return device; - } - if( null != identifier && - device.getAddressAndType().address.toString().equals(identifier) - ) - { - return device; - } - if( null != name && - device.getName().equals(name) - ) - { - return device; - } - } - if( anyType || serviceType || charType || descType ) { - final DBTObject dbtObj = device.findInCache(identifier, type); - if( null != dbtObj ) { - return dbtObj; - } - } - } - return null; - } - } - /* pp */ DBTDevice findDeviceInCache(final String name, final BDAddressAndType addressAndType) { synchronized(discoveredDevicesLock) { cleanDiscoveredDevice(); diff --git a/java/jau/direct_bt/DBTDevice.java b/java/jau/direct_bt/DBTDevice.java index 07cc61ce..db1de0f5 100644 --- a/java/jau/direct_bt/DBTDevice.java +++ b/java/jau/direct_bt/DBTDevice.java @@ -39,11 +39,8 @@ import org.direct_bt.BTSecurityLevel; import org.direct_bt.BTDevice; import org.direct_bt.BTException; import org.direct_bt.BTGattChar; -import org.direct_bt.BTGattDesc; import org.direct_bt.BTGattService; -import org.direct_bt.BTObject; import org.direct_bt.BTRole; -import org.direct_bt.BTType; import org.direct_bt.BTUtils; import org.direct_bt.EIRDataTypeSet; import org.direct_bt.BTGattCharListener; @@ -186,13 +183,23 @@ public class DBTDevice extends DBTObject implements BTDevice private native String getNameImpl(); @Override - public BTType getBluetoothType() { return class_type(); } - - static BTType class_type() { return BTType.DEVICE; } - - @Override public BTGattService findGattService(final String service_uuid) { - return (BTGattService) findInCache(service_uuid, BTType.GATT_SERVICE); + synchronized(serviceCache) { + if( !checkServiceCache(true) ) { + return null; + } + for(int srvIdx = serviceCache.size() - 1; srvIdx >= 0; srvIdx-- ) { + final DBTGattService service = serviceCache.get(srvIdx).get(); + if( null == service ) { + serviceCache.remove(srvIdx); // remove dead ref + continue; // cont w/ next service + } + if( service.getUUID().equals(service_uuid) ) { + return service; + } + } + return null; + } } @Override @@ -569,75 +576,4 @@ public class DBTDevice extends DBTObject implements BTDevice return true; } } - - /** - * Returns the matching {@link DBTObject} from the internal cache if found, - * otherwise {@code null}. - * <p> - * The returned {@link DBTObject} may be of type - * <ul> - * <li>{@link DBTGattService}</li> - * <li>{@link DBTGattChar}</li> - * <li>{@link DBTGattDesc}</li> - * </ul> - * or alternatively in {@link BTObject} space - * <ul> - * <li>{@link BTType#GATT_SERVICE} -> {@link BTGattService}</li> - * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li> - * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li> - * </ul> - * </p> - * @param uuid UUID of the desired {@link BTType#GATT_SERVICE service}, - * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found. - * Maybe {@code null}, in which case the first object of the desired type is being returned - if existing. - * @param type specify the type of the object to be found, either - * {@link BTType#GATT_SERVICE service}, {@link BTType#GATT_CHARACTERISTIC characteristic} - * or {@link BTType#GATT_DESCRIPTOR descriptor}. - * {@link BTType#NONE none} means anything. - */ - /* pp */ DBTObject findInCache(final String uuid, final BTType type) { - final boolean anyType = BTType.NONE == type; - final boolean serviceType = BTType.GATT_SERVICE == type; - final boolean charType = BTType.GATT_CHARACTERISTIC== type; - final boolean descType = BTType.GATT_DESCRIPTOR == type; - - if( !anyType && !serviceType && !charType && !descType ) { - return null; - } - synchronized(serviceCache) { - if( !checkServiceCache(true) ) { - return null; - } - - if( null == uuid && ( anyType || serviceType ) ) { - // special case for 1st valid service ref - while( !serviceCache.isEmpty() ) { - final DBTGattService service = serviceCache.get(0).get(); - if( null == service ) { - serviceCache.remove(0); - } else { - return service; - } - } - return null; // empty valid service refs - } - for(int srvIdx = serviceCache.size() - 1; srvIdx >= 0; srvIdx-- ) { - final DBTGattService service = serviceCache.get(srvIdx).get(); - if( null == service ) { - serviceCache.remove(srvIdx); // remove dead ref - continue; // cont w/ next service - } - if( ( anyType || serviceType ) && service.getUUID().equals(uuid) ) { - return service; - } - if( anyType || charType || descType ) { - final DBTObject dbtObj = service.findInCache(uuid, type); - if( null != dbtObj ) { - return dbtObj; - } - } - } - return null; - } - } } diff --git a/java/jau/direct_bt/DBTGattChar.java b/java/jau/direct_bt/DBTGattChar.java index 01c7172e..d98da9be 100644 --- a/java/jau/direct_bt/DBTGattChar.java +++ b/java/jau/direct_bt/DBTGattChar.java @@ -32,11 +32,8 @@ import org.direct_bt.BTException; import org.direct_bt.BTGattChar; import org.direct_bt.BTGattDesc; import org.direct_bt.BTGattService; -import org.direct_bt.BTObject; -import org.direct_bt.BTType; import org.direct_bt.BTUtils; import org.direct_bt.GattCharPropertySet; -import org.direct_bt.BTGattChar.Listener; import org.direct_bt.BTGattCharListener; public class DBTGattChar extends DBTObject implements BTGattChar @@ -137,20 +134,23 @@ public class DBTGattChar extends DBTObject implements BTGattChar public String getUUID() { return value_type_uuid; } @Override - public BTType getBluetoothType() { return class_type(); } - - static BTType class_type() { return BTType.GATT_CHARACTERISTIC; } - - @Override - public BTGattChar clone() - { throw new UnsupportedOperationException(); } // FIXME - - @Override public BTGattDesc findGattDesc(final String desc_uuid) { - if( !checkServiceCache() ) { + final DBTGattService service = wbr_service.get(); + if( null == service ) { return null; } - return (DBTGattDesc) findInCache(desc_uuid, BTType.GATT_DESCRIPTOR); + final DBTDevice device = service.wbr_device.get(); + if( null != device ) { + return null; + } + final int size = descriptorList.size(); + for(int i = 0; i < size; i++ ) { + final DBTGattDesc descr = (DBTGattDesc) descriptorList.get(i); + if( descr.getUUID().equals(desc_uuid) ) { + return descr; + } + } + return null; } @Override @@ -332,51 +332,4 @@ public class DBTGattChar extends DBTObject implements BTGattChar @Override protected native void deleteImpl(long nativeInstance); - - /* local functionality */ - - /* pp */ boolean checkServiceCache() { - final DBTGattService service = wbr_service.get(); - if( null == service ) { - return false; - } - final DBTDevice device = service.wbr_device.get(); - return null != device && device.checkServiceCache(false); - } - - /** - * Returns the matching {@link DBTObject} from the internal cache if found, - * otherwise {@code null}. - * <p> - * The returned {@link DBTObject} may be of type - * <ul> - * <li>{@link DBTGattDesc}</li> - * </ul> - * or alternatively in {@link BTObject} space - * <ul> - * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li> - * </ul> - * </p> - * @param uuid UUID of the desired - * {@link BTType#GATT_DESCRIPTOR descriptor} to be found. - * Maybe {@code null}, in which case the first object of the desired type is being returned - if existing. - * @param type specify the type of the object to be found, a {@link BTType#GATT_DESCRIPTOR descriptor}. - * {@link BTType#NONE none} means anything. - */ - /* pp */ DBTObject findInCache(final String uuid, final BTType type) { - final boolean anyType = BTType.NONE == type; - final boolean descType = BTType.GATT_DESCRIPTOR == type; - - if( !anyType && !descType ) { - return null; - } - final int size = descriptorList.size(); - for(int i = 0; i < size; i++ ) { - final DBTGattDesc descr = (DBTGattDesc) descriptorList.get(i); - if( null == uuid || descr.getUUID().equals(uuid) ) { - return descr; - } - } - return null; - } } diff --git a/java/jau/direct_bt/DBTGattDesc.java b/java/jau/direct_bt/DBTGattDesc.java index a9ead765..3c586488 100644 --- a/java/jau/direct_bt/DBTGattDesc.java +++ b/java/jau/direct_bt/DBTGattDesc.java @@ -26,11 +26,9 @@ package jau.direct_bt; import java.lang.ref.WeakReference; -import java.util.Arrays; import org.direct_bt.BTException; import org.direct_bt.BTGattDesc; -import org.direct_bt.BTType; public class DBTGattDesc extends DBTObject implements BTGattDesc { @@ -89,15 +87,6 @@ public class DBTGattDesc extends DBTObject implements BTGattDesc public String getUUID() { return type_uuid; } @Override - public BTType getBluetoothType() { return class_type(); } - - static BTType class_type() { return BTType.GATT_DESCRIPTOR; } - - @Override - public final BTGattDesc clone() - { throw new UnsupportedOperationException(); } // FIXME - - @Override public final DBTGattChar getCharacteristic() { return wbr_characteristic.get(); } @Override diff --git a/java/jau/direct_bt/DBTGattService.java b/java/jau/direct_bt/DBTGattService.java index e63cc2e4..97630a80 100644 --- a/java/jau/direct_bt/DBTGattService.java +++ b/java/jau/direct_bt/DBTGattService.java @@ -33,7 +33,6 @@ import org.direct_bt.BTGattChar; import org.direct_bt.BTGattDesc; import org.direct_bt.BTGattService; import org.direct_bt.BTObject; -import org.direct_bt.BTType; public class DBTGattService extends DBTObject implements BTGattService { @@ -72,20 +71,23 @@ public class DBTGattService extends DBTObject implements BTGattService public String getUUID() { return type_uuid; } @Override - public BTType getBluetoothType() { return class_type(); } - - static BTType class_type() { return BTType.GATT_SERVICE; } - - @Override public final BTGattService clone() { throw new UnsupportedOperationException(); } // FIXME @Override public BTGattChar findGattChar(final String char_uuid) { - if( !checkServiceCache() ) { + final DBTDevice device = wbr_device.get(); + if( null != device ) { return null; } - return (DBTGattChar) findInCache(char_uuid, BTType.GATT_CHARACTERISTIC); + final int characteristicSize = charList.size(); + for(int charIdx = 0; charIdx < characteristicSize; charIdx++ ) { + final DBTGattChar characteristic = (DBTGattChar) charList.get(charIdx); + if( characteristic.getUUID().equals(char_uuid) ) { + return characteristic; + } + } + return null; } @Override @@ -129,59 +131,4 @@ public class DBTGattService extends DBTObject implements BTGattService @Override protected native void deleteImpl(long nativeInstance); - - /* local functionality */ - - /* pp */ boolean checkServiceCache() { - final DBTDevice device = wbr_device.get(); - return null != device && device.checkServiceCache(false); - } - - /** - * Returns the matching {@link DBTObject} from the internal cache if found, - * otherwise {@code null}. - * <p> - * The returned {@link DBTObject} may be of type - * <ul> - * <li>{@link DBTGattChar}</li> - * <li>{@link DBTGattDesc}</li> - * </ul> - * or alternatively in {@link BTObject} space - * <ul> - * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li> - * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li> - * </ul> - * </p> - * @param uuid UUID of the desired - * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found. - * Maybe {@code null}, in which case the first object of the desired type is being returned - if existing. - * @param type specify the type of the object to be found, either - * {@link BTType#GATT_CHARACTERISTIC characteristic} - * or {@link BTType#GATT_DESCRIPTOR descriptor}. - * {@link BTType#NONE none} means anything. - */ - /* pp */ DBTObject findInCache(final String uuid, final BTType type) { - final boolean anyType = BTType.NONE == type; - final boolean charType = BTType.GATT_CHARACTERISTIC== type; - final boolean descType = BTType.GATT_DESCRIPTOR == type; - - if( !anyType && !charType && !descType ) { - return null; - } - final int characteristicSize = charList.size(); - for(int charIdx = 0; charIdx < characteristicSize; charIdx++ ) { - final DBTGattChar characteristic = (DBTGattChar) charList.get(charIdx); - if( ( anyType || charType ) && ( null == uuid || characteristic.getUUID().equals(uuid) ) ) { - return characteristic; - } - if( anyType || descType ) { - final DBTObject dbtObj = characteristic.findInCache(uuid, type); - if( null != dbtObj ) { - return dbtObj; - } - } - } - return null; - } - } diff --git a/java/jau/direct_bt/DBTManager.java b/java/jau/direct_bt/DBTManager.java index 37972726..33729ded 100644 --- a/java/jau/direct_bt/DBTManager.java +++ b/java/jau/direct_bt/DBTManager.java @@ -35,17 +35,9 @@ import java.util.function.Consumer; import java.util.function.Predicate; import org.direct_bt.BTAdapter; -import org.direct_bt.BTDevice; import org.direct_bt.BTException; import org.direct_bt.BTFactory; -import org.direct_bt.BTGattChar; -import org.direct_bt.BTGattDesc; -import org.direct_bt.BTGattService; import org.direct_bt.BTManager; -import org.direct_bt.BTObject; -import org.direct_bt.BTType; -import org.direct_bt.HCIStatusCode; -import org.direct_bt.ScanType; public class DBTManager implements BTManager { @@ -156,23 +148,6 @@ public class DBTManager implements BTManager private final List<BTAdapter> adapters = new CopyOnWriteArrayList<BTAdapter>(); private final List<ChangedAdapterSetListener> changedAdapterSetListenerList = new CopyOnWriteArrayList<ChangedAdapterSetListener>(); - private final Settings settings; - - @Override - public final Settings getSettings() { return settings; } - - public BTType getBluetoothType() { return BTType.NONE; } - - @Override - public DBTObject find(final BTType type, final String name, final String identifier, final BTObject parent, final long timeoutMS) { - return findInCache((DBTObject)parent, type, name, identifier); - } - - @Override - public DBTObject find(final BTType type, final String name, final String identifier, final BTObject parent) { - return find(type, name, identifier, parent, 0); - } - @Override public List<BTAdapter> getAdapters() { return new ArrayList<BTAdapter>(adapters); } @@ -188,40 +163,6 @@ public class DBTManager implements BTManager } @Override - public List<BTDevice> getDevices() { return getDefaultAdapter().getDiscoveredDevices(); } - - /** - * {@inheritDoc} - * <p> - * This call could be a quite expensive service query, see below. - * </p> - * <p> - * This implementation returns all {@link BTGattService} from all {@link BTDevice}s - * from the {@link #getDefaultAdapter()} using {@link BTDevice#getServices()}. - * </p> - * <p> - * This implementation does not {@link BTAdapter#startDiscovery() start} an explicit discovery, - * but previous {@link BTAdapter#getDiscoveredDevices() discovered devices} are being queried. - * </p> - */ - @Override - public List<BTGattService> getServices() { - final List<BTGattService> res = new ArrayList<BTGattService>(); - for(final Iterator<BTAdapter> iterA=adapters.iterator(); iterA.hasNext(); ) { - final BTAdapter adapter = iterA.next(); - final List<BTDevice> devices = adapter.getDiscoveredDevices(); - for(final Iterator<BTDevice> iterD=devices.iterator(); iterD.hasNext(); ) { - final BTDevice device = iterD.next(); - final List<BTGattService> devServices = device.getServices(); - if( null != devServices ) { - res.addAll(devServices); - } - } - } - return res; - } - - @Override public boolean setDefaultAdapter(final BTAdapter adapter) { return false; } @@ -238,19 +179,6 @@ public class DBTManager implements BTManager } @Override - public HCIStatusCode startDiscovery(final boolean keepAlive, final boolean le_scan_active) throws BTException { - return getDefaultAdapter().startDiscovery(keepAlive, le_scan_active); - } - - @Override - public HCIStatusCode stopDiscovery() throws BTException { return getDefaultAdapter().stopDiscovery(); } - - @Override - public final ScanType getCurrentScanType() { - return getDefaultAdapter().getCurrentScanType(); - } - - @Override public final void addChangedAdapterSetListener(final ChangedAdapterSetListener l) { changedAdapterSetListenerList.add(l); @@ -380,16 +308,6 @@ public class DBTManager implements BTManager } catch (final BTException be) { be.printStackTrace(); } - settings = new Settings() { - @Override - public final boolean isDirectBT() { - return true; - } - @Override - public String toString() { - return "Settings[dbt true]"; - } - }; } /** Returns an instance of BluetoothManager, to be used instead of constructor. @@ -417,130 +335,4 @@ public class DBTManager implements BTManager adapters.clear(); deleteImpl(nativeInstance); } - - /** - * Returns the matching {@link DBTObject} from the internal cache if found, - * otherwise {@code null}. - * <p> - * The returned {@link DBTObject} may be of type - * <ul> - * <li>{@link DBTAdapter}</li> - * <li>{@link DBTDevice}</li> - * <li>{@link DBTGattService}</li> - * <li>{@link DBTGattChar}</li> - * <li>{@link DBTGattDesc}</li> - * </ul> - * or alternatively in {@link BTObject} space - * <ul> - * <li>{@link BTType#ADAPTER} -> {@link BTAdapter}</li> - * <li>{@link BTType#DEVICE} -> {@link BTDevice}</li> - * <li>{@link BTType#GATT_SERVICE} -> {@link BTGattService}</li> - * <li>{@link BTType#GATT_CHARACTERISTIC} -> {@link BTGattChar}</li> - * <li>{@link BTType#GATT_DESCRIPTOR} -> {@link BTGattDesc}</li> - * </ul> - * </p> - * @param name name of the desired {@link BTType#ADAPTER adapter} or {@link BTType#DEVICE device}. - * Maybe {@code null}. - * @param identifier EUI48 address of the desired {@link BTType#ADAPTER adapter} or {@link BTType#DEVICE device} - * or UUID of the desired {@link BTType#GATT_SERVICE service}, - * {@link BTType#GATT_CHARACTERISTIC characteristic} or {@link BTType#GATT_DESCRIPTOR descriptor} to be found. - * Maybe {@code null}, in which case the first object of the desired type is being returned - if existing. - * @param type specify the type of the object to be found, either - * {@link BTType#ADAPTER adapter}, {@link BTType#DEVICE device}, - * {@link BTType#GATT_SERVICE service}, {@link BTType#GATT_CHARACTERISTIC characteristic} - * or {@link BTType#GATT_DESCRIPTOR descriptor}. - * {@link BTType#NONE none} means anything. - */ - /* pp */ DBTObject findInCache(final String name, final String identifier, final BTType type) { - final boolean anyType = BTType.NONE == type; - final boolean adapterType = BTType.ADAPTER == type; - - if( null == name && null == identifier && ( anyType || adapterType ) ) { - // special case for 1st valid adapter - if( adapters.size() > 0 ) { - return (DBTAdapter) adapters.get(0); - } - return null; // no adapter - } - for(final Iterator<BTAdapter> iter = adapters.iterator(); iter.hasNext(); ) { - final DBTAdapter adapter = (DBTAdapter) iter.next(); - if( !adapter.isValid() ) { - continue; - } - if( ( anyType || adapterType ) ) { - if( null != name && null != identifier && - adapter.getName().equals(name) && - adapter.getAddressAndType().address.toString().equals(identifier) - ) - { - return adapter; - } - if( null != identifier && - adapter.getAddressAndType().address.toString().equals(identifier) - ) - { - return adapter; - } - if( null != name && - adapter.getName().equals(name) - ) - { - return adapter; - } - } - final DBTObject dbtObj = adapter.findInCache(name, identifier, type); - if( null != dbtObj ) { - return dbtObj; - } - } - return null; - } - - /* pp */ DBTObject findInCache(final DBTObject parent, final BTType type, final String name, final String identifier) { - if( null == parent ) { - return findInCache(name, identifier, type); - } - final boolean anyType = BTType.NONE == type; - final boolean deviceType = BTType.DEVICE == type; - final boolean serviceType = BTType.GATT_SERVICE == type; - final boolean charType = BTType.GATT_CHARACTERISTIC== type; - final boolean descType = BTType.GATT_DESCRIPTOR == type; - - final BTType parentType = parent.getBluetoothType(); - - if( BTType.ADAPTER == parentType && - ( anyType || deviceType || serviceType || charType || descType ) - ) - { - return ((DBTAdapter) parent).findInCache(name, identifier, type); - } - if( BTType.DEVICE == parentType && - ( anyType || serviceType || charType || descType ) - ) - { - return ((DBTDevice) parent).findInCache(identifier, type); - } - if( BTType.GATT_SERVICE == parentType && - ( anyType || charType || descType ) - ) - { - final DBTGattService service = (DBTGattService) parent; - if( !service.checkServiceCache() ) { - return null; - } - return service.findInCache(identifier, type); - } - if( BTType.GATT_CHARACTERISTIC == parentType && - ( anyType || descType ) - ) - { - final DBTGattChar characteristic = (DBTGattChar) parent; - if( !characteristic.checkServiceCache() ) { - return null; - } - return characteristic.findInCache(identifier, type); - } - return null; - } - } diff --git a/java/jau/direct_bt/DBTObject.java b/java/jau/direct_bt/DBTObject.java index 80266d84..d5de04a8 100644 --- a/java/jau/direct_bt/DBTObject.java +++ b/java/jau/direct_bt/DBTObject.java @@ -26,7 +26,6 @@ package jau.direct_bt; import org.direct_bt.BTObject; -import org.direct_bt.BTType; public abstract class DBTObject extends DBTNativeDownlink implements BTObject { @@ -49,8 +48,6 @@ public abstract class DBTObject extends DBTNativeDownlink implements BTObject this.hashValue = hashValue; } - static BTType class_type() { return BTType.NONE; } - @Override public abstract boolean equals(final Object obj); @@ -69,9 +66,4 @@ public abstract class DBTObject extends DBTNativeDownlink implements BTObject public synchronized void close() { delete(); } - - @Override - public BTObject clone() - { throw new UnsupportedOperationException(); } // FIXME - } diff --git a/java/jni/helper_base.cxx b/java/jni/helper_base.cxx index c154d65b..07799dde 100644 --- a/java/jni/helper_base.cxx +++ b/java/jni/helper_base.cxx @@ -1,7 +1,4 @@ -/* - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * +/** * Author: Sven Gothel <[email protected]> * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB @@ -35,17 +32,6 @@ #define JAVA_MAIN_PACKAGE "org/direct_bt" -jobject get_bluetooth_type(JNIEnv *env, const char *field_name) -{ - jclass b_type_enum = jau::search_class(env, JAVA_MAIN_PACKAGE "/BTType"); - - jfieldID b_type_field = jau::search_field(env, b_type_enum, field_name, "L" JAVA_MAIN_PACKAGE "/BTType;", true); - - jobject result = env->GetStaticObjectField(b_type_enum, b_type_field); - env->DeleteLocalRef(b_type_enum); - return result; -} - void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line) { jau::print_native_caught_exception_fwd2java(e, file, line); env->ThrowNew(env->FindClass("org/direct_bt/BTException"), e.what()); diff --git a/java/jni/helper_base.hpp b/java/jni/helper_base.hpp index 2e678236..629e3b78 100644 --- a/java/jni/helper_base.hpp +++ b/java/jni/helper_base.hpp @@ -1,7 +1,4 @@ -/* - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * +/** * Author: Sven Gothel <[email protected]> * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB @@ -38,8 +35,6 @@ #include "direct_bt/BTTypes0.hpp" -jobject get_bluetooth_type(JNIEnv *env, const char *field_name); - void raise_java_exception(JNIEnv *env, const direct_bt::BTException &e, const char* file, int line); /** diff --git a/java/org/direct_bt/BTAdapter.java b/java/org/direct_bt/BTAdapter.java index 1dcb4c38..d2dd9a45 100644 --- a/java/org/direct_bt/BTAdapter.java +++ b/java/org/direct_bt/BTAdapter.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including diff --git a/java/org/direct_bt/BTDevice.java b/java/org/direct_bt/BTDevice.java index bd92abe9..5d953385 100644 --- a/java/org/direct_bt/BTDevice.java +++ b/java/org/direct_bt/BTDevice.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including diff --git a/java/org/direct_bt/BTException.java b/java/org/direct_bt/BTException.java index b3ef62dd..dfc994a3 100644 --- a/java/org/direct_bt/BTException.java +++ b/java/org/direct_bt/BTException.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Petre Eftime <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including diff --git a/java/org/direct_bt/BTFactory.java b/java/org/direct_bt/BTFactory.java index 2d89036d..c8e93177 100644 --- a/java/org/direct_bt/BTFactory.java +++ b/java/org/direct_bt/BTFactory.java @@ -538,16 +538,10 @@ public class BTFactory { try { final BTManager mngr = getDirectBTManager(); final List<BTAdapter> adapters = mngr.getAdapters(); - System.err.println("BTManager: Settings "+mngr.getSettings().toString()+", adapters "+adapters.size()); - final boolean isDBT = mngr.getSettings().isDirectBT(); + System.err.println("BTManager: adapters "+adapters.size()); int i=0; for(final Iterator<BTAdapter> iter = adapters.iterator(); iter.hasNext(); ++i) { - if( isDBT ) { - System.err.println("BTAdapter["+i+"]: "+iter.next().toString()); // has full toString() - } else { - final BTAdapter a = iter.next(); - System.err.println("BTAdapter["+i+"]: dev_id "+a.getDevID()+", address "+a.getAddressAndType()+", name "+a.getName()); - } + System.err.println("BTAdapter["+i+"]: "+iter.next().toString()); // has full toString() } } catch (BTException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException diff --git a/java/org/direct_bt/BTGattChar.java b/java/org/direct_bt/BTGattChar.java index 26558012..d359ecca 100644 --- a/java/org/direct_bt/BTGattChar.java +++ b/java/org/direct_bt/BTGattChar.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -31,11 +28,17 @@ package org.direct_bt; import java.util.List; /** - * Provides access to Bluetooth GATT characteristic. - * - * @see [Bluetooth Specification](https://www.bluetooth.com/specifications/bluetooth-core-specification/) - * @see [BlueZ GATT API](http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt) - */ + * Representing a Gatt Characteristic object from the GATT client perspective. + * + * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3 Characteristic Definition + * + * handle -> CDAV value + * + * BT Core Spec v5.2: Vol 3, Part G GATT: 4.6.1 Discover All Characteristics of a Service + * + * The handle represents a service's characteristics-declaration + * and the value the Characteristics Property, Characteristics Value Handle _and_ Characteristics UUID. + */ public interface BTGattChar extends BTObject { /** diff --git a/java/org/direct_bt/BTGattDesc.java b/java/org/direct_bt/BTGattDesc.java index b079225d..e3d6fb3b 100644 --- a/java/org/direct_bt/BTGattDesc.java +++ b/java/org/direct_bt/BTGattDesc.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -29,11 +26,10 @@ package org.direct_bt; /** - * Provides access to Bluetooth GATT descriptor. - * - * @see [Bluetooth Specification](https://www.bluetooth.com/specifications/bluetooth-core-specification/) - * @see [BlueZ GATT API](http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt) - */ + * Representing a Gatt Characteristic Descriptor object from the GATT client perspective. + * + * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3 Characteristic Descriptor + */ public interface BTGattDesc extends BTObject { /** Reads the value of this descriptor diff --git a/java/org/direct_bt/BTGattService.java b/java/org/direct_bt/BTGattService.java index ae65a7d4..a3158b71 100644 --- a/java/org/direct_bt/BTGattService.java +++ b/java/org/direct_bt/BTGattService.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -32,11 +29,14 @@ import java.util.Iterator; import java.util.List; /** - * Provides access to Bluetooth GATT characteristic. - * - * @see [Bluetooth Specification](https://www.bluetooth.com/specifications/bluetooth-core-specification/) - * @see [BlueZ GATT API](http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt) - */ + * Representing a Gatt Service object from the GATT client perspective. + * + * BT Core Spec v5.2: Vol 3, Part G GATT: 3.1 Service Definition + * + * Includes a complete [Primary] Service Declaration + * including its list of Characteristic Declarations, + * which also may include its client config if available. + */ public interface BTGattService extends BTObject { /** diff --git a/java/org/direct_bt/BTManager.java b/java/org/direct_bt/BTManager.java index 120ef7c8..d9b6967d 100644 --- a/java/org/direct_bt/BTManager.java +++ b/java/org/direct_bt/BTManager.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -33,25 +30,6 @@ import java.util.List; public interface BTManager { /** - * Interface allowing to retrieve certain settings - * of the implementation. - * <p> - * In case this interface will have to add a multitude of settings in the future, - * we will revise the API using a more efficient bitfield approach. - * </p> - */ - public static interface Settings { - /** - * Returns true if underlying implementation is Direct-BT. - */ - boolean isDirectBT(); - - @Override - String toString(); - } - - - /** * Event listener to receive change events regarding the system's {@link BTAdapter} set, * e.g. a removed or added {@link BTAdapter} due to user interaction or 'cold reset'. * <p> @@ -84,51 +62,6 @@ public interface BTManager void adapterRemoved(final BTAdapter adapter); } - /** - * Returns this implmentation's {@link Settings}. - */ - public Settings getSettings(); - - /** Find a BluetoothObject of a type matching type. If parameters name, - * identifier and parent are not null, the returned object will have to - * match them. - * It will first check for existing objects. It will not turn on discovery - * or connect to devices. - * @parameter type specify the type of the object you are - * waiting for, NONE means anything. - * @parameter name optionally specify the name of the object you are - * waiting for (for Adapter or Device) - * @parameter identifier optionally specify the identifier of the object you are - * waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address - * for Adapter or Device) - * @parameter parent optionally specify the parent of the object you are - * waiting for - * @parameter timeoutMS the function will return after timeout time in milliseconds, a - * value of zero means wait forever. If object is not found during this time null will be returned. - * @return An object matching the name, identifier, parent or null if not found before - * timeout expires or event is canceled. - */ - public BTObject find(BTType type, String name, String identifier, BTObject parent, long timeoutMS); - - - /** Find a BluetoothObject of a type matching type. If parameters name, - * identifier and parent are not null, the returned object will have to - * match them. - * It will first check for existing objects. It will not turn on discovery - * or connect to devices. - * @parameter type specify the type of the object you are - * waiting for, NONE means anything. - * @parameter name optionally specify the name of the object you are - * waiting for (for Adapter or Device) - * @parameter identifier optionally specify the identifier of the object you are - * waiting for (UUID for GattService, GattCharacteristic or GattDescriptor, address - * for Adapter or Device) - * @parameter parent optionally specify the parent of the object you are - * waiting for - * @return An object matching the name, identifier and parent. - */ - public BTObject find(BTType type, String name, String identifier, BTObject parent); - /** Returns a list of BluetoothAdapters available in the system * @return A list of BluetoothAdapters available in the system */ @@ -145,16 +78,6 @@ public interface BTManager */ public BTAdapter getAdapter(final int dev_id); - /** Returns a list of discovered BluetoothDevices - * @return A list of discovered BluetoothDevices - */ - public List<BTDevice> getDevices(); - - /** Returns a list of available BluetoothGattServices - * @return A list of available BluetoothGattServices - */ - public List<BTGattService> getServices(); - /** * Sets a default adapter to use for discovery. * @return TRUE if the device was set @@ -173,38 +96,6 @@ public interface BTManager public BTAdapter getDefaultAdapter(); /** - * Turns on device discovery on the default adapter if it is disabled. - * @param keepAlive if {@code true}, indicates that discovery shall be restarted - * if stopped by the underlying Bluetooth implementation (BlueZ, ..). - * Using {@link #startDiscovery(boolean) startDiscovery}({@code keepAlive=true}) - * and {@link #stopDiscovery()} is the recommended workflow - * for a reliable discovery process. - * @param le_scan_active true enables delivery of active scanning PDUs, otherwise no scanning PDUs shall be sent (default) - * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state - * @throws BTException - * @since 2.0.0 - * @since 2.2.8 - */ - public HCIStatusCode startDiscovery(final boolean keepAlive, final boolean le_scan_active) throws BTException; - - /** - * Turns off device discovery on the default adapter if it is enabled. - * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state - * @apiNote return {@link HCIStatusCode} since 2.0.0 - * @since 2.0.0 - */ - public HCIStatusCode stopDiscovery() throws BTException; - - /** - * Returns the current meta discovering {@link ScanType} of the {@link #getDefaultAdapter()} - * via {@link BTAdapter#getCurrentScanType()}. - * @see BTAdapter#getCurrentScanType() - * @see #getDefaultAdapter() - * @since 2.3 - */ - public ScanType getCurrentScanType(); - - /** * Add the given {@link ChangedAdapterSetListener} to this manager. * <p> * When a new callback is added, all available adapter's will be reported as added, diff --git a/java/org/direct_bt/BTObject.java b/java/org/direct_bt/BTObject.java index 2c44ad4a..a00f6ee4 100644 --- a/java/org/direct_bt/BTObject.java +++ b/java/org/direct_bt/BTObject.java @@ -3,9 +3,6 @@ * Copyright (c) 2020 Gothel Software e.K. * Copyright (c) 2020 ZAFENA AB * - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -29,11 +26,6 @@ package org.direct_bt; public interface BTObject extends AutoCloseable { - /** Returns the BluetoothType of this object - * @return The BluetoothType of this object - */ - public BTType getBluetoothType(); - @Override public boolean equals(Object obj); diff --git a/java/org/direct_bt/BTType.java b/java/org/direct_bt/BTType.java deleted file mode 100644 index 07817897..00000000 --- a/java/org/direct_bt/BTType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Author: Andrei Vasiliu <[email protected]> - * Copyright (c) 2016 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package org.direct_bt; - -public enum BTType -{ - NONE, ADAPTER, DEVICE, - GATT_SERVICE, GATT_CHARACTERISTIC, - GATT_DESCRIPTOR; -} diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp index 7a26716a..e49ddb5a 100644 --- a/src/direct_bt/BTDevice.cpp +++ b/src/direct_bt/BTDevice.cpp @@ -1270,39 +1270,6 @@ HCIStatusCode BTDevice::setLinkKey(const SMPLinkKey& lk) noexcept { #endif } -HCIStatusCode BTDevice::pair(const SMPIOCapability io_cap) noexcept { - /** - * Experimental only. - * <pre> - * adapter.stopDiscovery(): Renders pairDevice(..) to fail: Busy! - * pairDevice(..) behaves quite instable within our connected workflow: Not used! - * </pre> - */ - if( SMPIOCapability::UNSET == io_cap ) { - DBG_PRINT("BTDevice::pairDevice: io %s, invalid value.", to_string(io_cap).c_str()); - return HCIStatusCode::INVALID_PARAMS; - } -#if USE_LINUX_BT_SECURITY - BTManager& mngr = adapter.getManager(); - - DBG_PRINT("BTDevice::pairDevice: Start: io %s, %s", to_string(io_cap).c_str(), toString().c_str()); - mngr.uploadConnParam(adapter.dev_id, addressAndType); - - jau::sc_atomic_critical sync(sync_data); - pairing_data.ioCap_conn = io_cap; - const bool res = mngr.pairDevice(adapter.dev_id, addressAndType, io_cap); - if( !res ) { - pairing_data.ioCap_conn = SMPIOCapability::UNSET; - } - DBG_PRINT("BTDevice::pairDevice: End: io %s, %s", to_string(io_cap).c_str(), toString().c_str()); - return res ? HCIStatusCode::SUCCESS : HCIStatusCode::FAILED; -#elif SMP_SUPPORTED_BY_OS - return HCIStatusCode::NOT_SUPPORTED; -#else - return HCIStatusCode::NOT_SUPPORTED; -#endif -} - bool BTDevice::setConnSecurityLevel(const BTSecurityLevel sec_level) noexcept { if( BTSecurityLevel::UNSET == sec_level ) { DBG_PRINT("DBTAdapter::setConnSecurityLevel: lvl %s, invalid value.", to_string(sec_level).c_str()); diff --git a/src/direct_bt/BTManager.cpp b/src/direct_bt/BTManager.cpp index d7256e7b..36468e16 100644 --- a/src/direct_bt/BTManager.cpp +++ b/src/direct_bt/BTManager.cpp @@ -783,37 +783,6 @@ MgmtStatus BTManager::setDiscoverable(const uint16_t dev_id, const uint8_t state return res; } -ScanType BTManager::startDiscovery(const uint16_t dev_id, const BTMode btMode) noexcept { - return startDiscovery(dev_id, to_ScanType(btMode)); -} - -ScanType BTManager::startDiscovery(const uint16_t dev_id, const ScanType scanType) noexcept { - MgmtUint8Cmd req(MgmtCommand::Opcode::START_DISCOVERY, dev_id, number(scanType)); - std::unique_ptr<MgmtEvent> res = sendWithReply(req); - ScanType type = ScanType::NONE; - if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) { - const MgmtEvtCmdComplete &res1 = *static_cast<const MgmtEvtCmdComplete *>(res.get()); - if( MgmtStatus::SUCCESS == res1.getStatus() && 1 <= res1.getDataSize() ) { - const uint8_t *p = res1.getData(); - if( nullptr == p ) { // G++ 10: -Werror=null-dereference - ERR_PRINT("DBTManager::startDiscovery: Impossible MgmtEvtCmdComplete data nullptr: %s - %s", res1.toString().c_str(), req.toString().c_str()); - return type; - } - type = static_cast<ScanType>( p[0] ); - } - } - return type; -} -bool BTManager::stopDiscovery(const uint16_t dev_id, const ScanType type) noexcept { - MgmtUint8Cmd req(MgmtCommand::Opcode::STOP_DISCOVERY, dev_id, number(type)); - std::unique_ptr<MgmtEvent> res = sendWithReply(req); - if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) { - const MgmtEvtCmdComplete &res1 = *static_cast<const MgmtEvtCmdComplete *>(res.get()); - return MgmtStatus::SUCCESS == res1.getStatus(); - } - return false; -} - bool BTManager::uploadConnParam(const uint16_t dev_id, const BDAddressAndType & addressAndType, const uint16_t conn_min_interval, const uint16_t conn_max_interval, const uint16_t conn_latency, const uint16_t supervision_timeout) noexcept { @@ -948,15 +917,6 @@ MgmtStatus BTManager::userConfirmReply(const uint16_t dev_id, const BDAddressAnd #endif } -bool BTManager::pairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const SMPIOCapability iocap) noexcept { -#if USE_LINUX_BT_SECURITY - MgmtPairDeviceCmd cmd(dev_id, addressAndType, iocap); - return send(cmd); -#else - return false; -#endif -} - MgmtStatus BTManager::unpairDevice(const uint16_t dev_id, const BDAddressAndType & addressAndType, const bool disconnect) noexcept { #if USE_LINUX_BT_SECURITY MgmtUnpairDeviceCmd cmd(dev_id, addressAndType, disconnect); @@ -1056,33 +1016,6 @@ bool BTManager::removeDeviceFromWhitelist(const uint16_t dev_id, const BDAddress return false; } -bool BTManager::disconnect(const bool ioErrorCause, - const uint16_t dev_id, const BDAddressAndType & addressAndType, - const HCIStatusCode reason) noexcept { - bool bres = false; - - // Always issue DISCONNECT command, even in case of an ioError (lost-connection), - // see Issue #124 fast re-connect on CSR adapter. - // This will always notify the adapter of a disconnected device. - { - MgmtDisconnectCmd req(dev_id, addressAndType); - std::unique_ptr<MgmtEvent> res = sendWithReply(req); - if( nullptr != res && res->getOpcode() == MgmtEvent::Opcode::CMD_COMPLETE ) { - const MgmtEvtCmdComplete &res1 = *static_cast<const MgmtEvtCmdComplete *>(res.get()); - if( MgmtStatus::SUCCESS == res1.getStatus() ) { - bres = true; - } - } - } - if( !ioErrorCause ) { - // In case of an ioError (lost-connection), don't wait for the lagging - // DISCONN_COMPLETE event but send it directly. - const MgmtEvtDeviceDisconnected e(dev_id, addressAndType, reason, 0xffff); - sendMgmtEvent(e); - } - return bres; -} - std::shared_ptr<ConnectionInfo> BTManager::getConnectionInfo(const uint16_t dev_id, const BDAddressAndType& addressAndType) noexcept { MgmtGetConnectionInfoCmd req(dev_id, addressAndType); std::unique_ptr<MgmtEvent> res = sendWithReply(req); |