aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-10-10 04:44:45 +0200
committerSven Gothel <[email protected]>2021-10-10 04:44:45 +0200
commitb8a7f626fadcf6b21e5df67cdf0df4369885a6b8 (patch)
treeeb2a05fabe63e8b8ccb61bcdb019459a69eaa251 /java
parent5295208f805a3389a6a3d91b5cd27404fe3fa01c (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.
Diffstat (limited to 'java')
-rw-r--r--java/jau/direct_bt/DBTAdapter.java95
-rw-r--r--java/jau/direct_bt/DBTDevice.java96
-rw-r--r--java/jau/direct_bt/DBTGattChar.java75
-rw-r--r--java/jau/direct_bt/DBTGattDesc.java11
-rw-r--r--java/jau/direct_bt/DBTGattService.java73
-rw-r--r--java/jau/direct_bt/DBTManager.java208
-rw-r--r--java/jau/direct_bt/DBTObject.java8
-rw-r--r--java/jni/helper_base.cxx16
-rw-r--r--java/jni/helper_base.hpp7
-rw-r--r--java/org/direct_bt/BTAdapter.java3
-rw-r--r--java/org/direct_bt/BTDevice.java3
-rw-r--r--java/org/direct_bt/BTException.java3
-rw-r--r--java/org/direct_bt/BTFactory.java10
-rw-r--r--java/org/direct_bt/BTGattChar.java19
-rw-r--r--java/org/direct_bt/BTGattDesc.java12
-rw-r--r--java/org/direct_bt/BTGattService.java16
-rw-r--r--java/org/direct_bt/BTManager.java109
-rw-r--r--java/org/direct_bt/BTObject.java8
-rw-r--r--java/org/direct_bt/BTType.java32
19 files changed, 67 insertions, 737 deletions
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;
-}