diff options
author | Sven Gothel <[email protected]> | 2021-01-25 18:44:32 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-01-25 18:44:32 +0100 |
commit | e7d892210343dc50c8978954f8daa71395584f2e (patch) | |
tree | 4d5f1dfcede30af5cad2a7afb97b535f40600a85 /java/org | |
parent | feaff07f5942ee6ff2bd94e70bf140c678379490 (diff) |
Java: New API Layout: Shorten named [Bluetooth -> BT], [Characteristic -> Char] etc (align naming with direct_bt == java; reduce java code footprint and too long code lines)
Diffstat (limited to 'java/org')
-rw-r--r-- | java/org/direct_bt/AdapterSettings.java | 4 | ||||
-rw-r--r-- | java/org/direct_bt/AdapterStatusListener.java | 74 | ||||
-rw-r--r-- | java/org/direct_bt/BTAdapter.java (renamed from java/org/direct_bt/BluetoothAdapter.java) | 42 | ||||
-rw-r--r-- | java/org/direct_bt/BTCallback.java (renamed from java/org/direct_bt/BluetoothCallback.java) | 2 | ||||
-rw-r--r-- | java/org/direct_bt/BTDevice.java (renamed from java/org/direct_bt/BluetoothDevice.java) | 116 | ||||
-rw-r--r-- | java/org/direct_bt/BTEvent.java (renamed from java/org/direct_bt/BluetoothEvent.java) | 4 | ||||
-rw-r--r-- | java/org/direct_bt/BTException.java (renamed from java/org/direct_bt/BluetoothException.java) | 4 | ||||
-rw-r--r-- | java/org/direct_bt/BTFactory.java (renamed from java/org/direct_bt/BluetoothFactory.java) | 52 | ||||
-rw-r--r-- | java/org/direct_bt/BTGattChar.java (renamed from java/org/direct_bt/BluetoothGattCharacteristic.java) | 54 | ||||
-rw-r--r-- | java/org/direct_bt/BTGattCharListener.java (renamed from java/org/direct_bt/GATTCharacteristicListener.java) | 58 | ||||
-rw-r--r-- | java/org/direct_bt/BTGattDesc.java (renamed from java/org/direct_bt/BluetoothGattDescriptor.java) | 10 | ||||
-rw-r--r-- | java/org/direct_bt/BTGattService.java (renamed from java/org/direct_bt/BluetoothGattService.java) | 88 | ||||
-rw-r--r-- | java/org/direct_bt/BTManager.java (renamed from java/org/direct_bt/BluetoothManager.java) | 72 | ||||
-rw-r--r-- | java/org/direct_bt/BTNotification.java (renamed from java/org/direct_bt/BluetoothNotification.java) | 2 | ||||
-rw-r--r-- | java/org/direct_bt/BTObject.java (renamed from java/org/direct_bt/BluetoothObject.java) | 6 | ||||
-rw-r--r-- | java/org/direct_bt/BTType.java (renamed from java/org/direct_bt/BluetoothType.java) | 2 | ||||
-rw-r--r-- | java/org/direct_bt/BTUtils.java (renamed from java/org/direct_bt/BluetoothUtils.java) | 6 | ||||
-rw-r--r-- | java/org/direct_bt/EUI48.java | 2 | ||||
-rw-r--r-- | java/org/direct_bt/ObjectArgCallback.java | 2 | ||||
-rw-r--r-- | java/org/direct_bt/ObjectArrayArgCallback.java | 2 | ||||
-rw-r--r-- | java/org/direct_bt/PlatformToolkit.java | 18 | ||||
-rw-r--r-- | java/org/direct_bt/SMPLongTermKeyInfo.java | 6 | ||||
-rw-r--r-- | java/org/direct_bt/SMPSignatureResolvingKeyInfo.java | 2 |
23 files changed, 314 insertions, 314 deletions
diff --git a/java/org/direct_bt/AdapterSettings.java b/java/org/direct_bt/AdapterSettings.java index 52a090d4..8bf0ea2d 100644 --- a/java/org/direct_bt/AdapterSettings.java +++ b/java/org/direct_bt/AdapterSettings.java @@ -25,7 +25,7 @@ package org.direct_bt; /** - * Bit mask of '{@link BluetoothAdapter} setting' data fields, + * Bit mask of '{@link BTAdapter} setting' data fields, * indicating a set of related data. * * @since 2.0.0 @@ -33,7 +33,7 @@ package org.direct_bt; public class AdapterSettings { /** - * Bits representing '{@link BluetoothAdapter} setting' data fields. + * Bits representing '{@link BTAdapter} setting' data fields. * * @since 2.0.0 */ diff --git a/java/org/direct_bt/AdapterStatusListener.java b/java/org/direct_bt/AdapterStatusListener.java index 7e3b1634..68377957 100644 --- a/java/org/direct_bt/AdapterStatusListener.java +++ b/java/org/direct_bt/AdapterStatusListener.java @@ -26,20 +26,20 @@ package org.direct_bt; /** - * {@link BluetoothAdapter} status listener for {@link BluetoothDevice} discovery events: Added, updated and removed; - * as well as for certain {@link BluetoothAdapter} events. + * {@link BTAdapter} status listener for {@link BTDevice} discovery events: Added, updated and removed; + * as well as for certain {@link BTAdapter} events. * <p> * User implementations shall return as early as possible to avoid blocking the event-handler thread, - * if not specified within the methods otherwise (see {@link #deviceReady(BluetoothDevice, long)}).<br> + * if not specified within the methods otherwise (see {@link #deviceReady(BTDevice, long)}).<br> * Especially complex mutable operations on DBTDevice or DBTAdapter should be issued off-thread! * </p> * <p> - * A listener instance may be attached to a {@link BluetoothAdapter} via - * {@link BluetoothAdapter#addStatusListener(AdapterStatusListener, BluetoothDevice)}. + * A listener instance may be attached to a {@link BTAdapter} via + * {@link BTAdapter#addStatusListener(AdapterStatusListener, BTDevice)}. * </p> * <p> * One {@link AdapterStatusListener} instance can only be attached to a listener receiver once at a time, - * i.e. you cannot attach the same instance more than once to a {@link BluetoothAdapter}. + * i.e. you cannot attach the same instance more than once to a {@link BTAdapter}. * <br> * To attach multiple listener, one instance per attachment must be created. * <br> @@ -67,75 +67,75 @@ public abstract class AdapterStatusListener { } /** - * {@link BluetoothAdapter} setting(s) changed. + * {@link BTAdapter} setting(s) changed. * @param adapter the adapter which settings have changed. * @param oldmask the previous settings mask. {@link AdapterSettings#isEmpty()} indicates the initial setting notification, - * see {@link BluetoothAdapter#addStatusListener(AdapterStatusListener, BluetoothDevice) addStatusListener(..)}. + * see {@link BTAdapter#addStatusListener(AdapterStatusListener, BTDevice) addStatusListener(..)}. * @param newmask the new settings mask * @param changedmask the changes settings mask. {@link AdapterSettings#isEmpty()} indicates the initial setting notification, - * see {@link BluetoothAdapter#addStatusListener(AdapterStatusListener, BluetoothDevice) addStatusListener(..)}. - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. + * see {@link BTAdapter#addStatusListener(AdapterStatusListener, BTDevice) addStatusListener(..)}. + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. */ - public void adapterSettingsChanged(final BluetoothAdapter adapter, + public void adapterSettingsChanged(final BTAdapter adapter, final AdapterSettings oldmask, final AdapterSettings newmask, final AdapterSettings changedmask, final long timestamp) { } /** - * {@link BluetoothAdapter}'s discovery state has changed, i.e. enabled or disabled. + * {@link BTAdapter}'s discovery state has changed, i.e. enabled or disabled. * @param adapter the adapter which discovering state has changed. * @param currentMeta the current meta {@link ScanType} * @param changedType denotes the changed {@link ScanType} * @param changedEnabled denotes whether the changed {@link ScanType} has been enabled or disabled * @param keepAlive if {@code true}, the denoted changed {@link ScanType} will be re-enabled if disabled by the underlying Bluetooth implementation. - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. */ - public void discoveringChanged(final BluetoothAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { } + public void discoveringChanged(final BTAdapter adapter, final ScanType currentMeta, final ScanType changedType, final boolean changedEnabled, final boolean keepAlive, final long timestamp) { } /** - * A {@link BluetoothDevice} has been newly discovered. + * A {@link BTDevice} has been newly discovered. * <p> * The boolean return value informs the adapter whether the device shall be made persistent for connection {@code true}, * or that it can be discarded {@code false}.<br> - * If no registered {@link AdapterStatusListener#deviceFound(BluetoothDevice, long) deviceFound(..)} implementation returns {@code true}, + * If no registered {@link AdapterStatusListener#deviceFound(BTDevice, long) deviceFound(..)} implementation returns {@code true}, * the device instance will be removed from all internal lists and can no longer being used.<br> - * If any registered {@link AdapterStatusListener#deviceFound(BluetoothDevice, long) deviceFound(..)} implementation returns {@code true}, - * the device will be made persistent, is ready to connect and {@link BluetoothDevice#remove() remove} shall be called after usage. + * If any registered {@link AdapterStatusListener#deviceFound(BTDevice, long) deviceFound(..)} implementation returns {@code true}, + * the device will be made persistent, is ready to connect and {@link BTDevice#remove() remove} shall be called after usage. * </p> * @param device the found device - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. - * @return true if the device shall be made persistent and {@link BluetoothDevice#remove() remove} issued later. Otherwise false to remove device right away. + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. + * @return true if the device shall be made persistent and {@link BTDevice#remove() remove} issued later. Otherwise false to remove device right away. */ - public boolean deviceFound(final BluetoothDevice device, final long timestamp) { return false; } + public boolean deviceFound(final BTDevice device, final long timestamp) { return false; } /** - * An already discovered {@link BluetoothDevice} has been updated. + * An already discovered {@link BTDevice} has been updated. * @param device the updated device * @param updateMask the update mask of changed data - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. */ - public void deviceUpdated(final BluetoothDevice device, final EIRDataTypeSet updateMask, final long timestamp) { } + public void deviceUpdated(final BTDevice device, final EIRDataTypeSet updateMask, final long timestamp) { } /** - * {@link BluetoothDevice} got connected. + * {@link BTDevice} got connected. * @param device the device which has been connected, holding the new connection handle. * @param handle the new connection handle, which has been assigned to the device already - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. */ - public void deviceConnected(final BluetoothDevice device, final short handle, final long timestamp) { } + public void deviceConnected(final BTDevice device, final short handle, final long timestamp) { } /** - * An already connected {@link BluetoothDevice}'s {@link SMPPairingState} has changed. + * An already connected {@link BTDevice}'s {@link SMPPairingState} has changed. * @param device the device which {@link PairingMode} has been changed. * @param state the current {@link SMPPairingState} of the connected device, see DBTDevice::getCurrentPairingState() * @param mode the current {@link PairingMode} of the connected device, see DBTDevice::getCurrentPairingMode() - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. - * @see BluetoothDevice#setPairingPasskey(int) - * @see BluetoothDevice#setPairingNumericComparison(boolean) + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. + * @see BTDevice#setPairingPasskey(int) + * @see BTDevice#setPairingNumericComparison(boolean) */ - public void devicePairingState(final BluetoothDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {} + public void devicePairingState(final BTDevice device, final SMPPairingState state, final PairingMode mode, final long timestamp) {} /** - * {@link BluetoothDevice} is ready for user (GATT) processing, i.e. already connected, optionally paired and ATT MTU size negotiated via connected GATT. + * {@link BTDevice} is ready for user (GATT) processing, i.e. already connected, optionally paired and ATT MTU size negotiated via connected GATT. * <p> * Method is being called from a dedicated native thread, hence restrictions on method duration and complex mutable operations don't apply here. * </p> @@ -143,14 +143,14 @@ public abstract class AdapterStatusListener { * @param timestamp the time in monotonic milliseconds when this event occurred. See BasicTypes::getCurrentMilliseconds(). * @see {@link SMPPairingState#COMPLETED} */ - public void deviceReady(final BluetoothDevice device, final long timestamp) {} + public void deviceReady(final BTDevice device, final long timestamp) {} /** - * {@link BluetoothDevice} got disconnected. + * {@link BTDevice} got disconnected. * @param device the device which has been disconnected with zeroed connection handle. * @param reason the {@link HCIStatusCode} reason for disconnection * @param handle the disconnected connection handle, which has been unassigned from the device already - * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BluetoothUtils#currentTimeMillis()}. + * @param timestamp the time in monotonic milliseconds when this event occurred. See {@link BTUtils#currentTimeMillis()}. */ - public void deviceDisconnected(final BluetoothDevice device, final HCIStatusCode reason, final short handle, final long timestamp) { } + public void deviceDisconnected(final BTDevice device, final HCIStatusCode reason, final short handle, final long timestamp) { } }; diff --git a/java/org/direct_bt/BluetoothAdapter.java b/java/org/direct_bt/BTAdapter.java index 65558731..77a00f8c 100644 --- a/java/org/direct_bt/BluetoothAdapter.java +++ b/java/org/direct_bt/BTAdapter.java @@ -35,15 +35,15 @@ import java.util.UUID; * Provides access to Bluetooth adapters. Follows the BlueZ adapter API * available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/adapter-api.txt */ -public interface BluetoothAdapter extends BluetoothObject +public interface BTAdapter extends BTObject { @Override - public BluetoothAdapter clone(); + public BTAdapter clone(); /** - * Returns the used singleton {@link BluetoothManager} instance, used to create this adapter. + * Returns the used singleton {@link BTManager} instance, used to create this adapter. */ - public BluetoothManager getManager(); + public BTManager getManager(); /** Find a BluetoothDevice. If parameters name and address are not null, * the returned object will have to match them. @@ -58,7 +58,7 @@ public interface BluetoothAdapter extends BluetoothObject * @return An object matching the name and address or null if not found before * timeout expires. */ - public BluetoothDevice find(String name, BDAddressAndType addressAndType, long timeoutMS); + public BTDevice find(String name, BDAddressAndType addressAndType, long timeoutMS); /** Find a BluetoothDevice. If parameters name and address are not null, * the returned object will have to match them. @@ -70,7 +70,7 @@ public interface BluetoothAdapter extends BluetoothObject * waiting for * @return An object matching the name and address. */ - public BluetoothDevice find(String name, BDAddressAndType addressAndType); + public BTDevice find(String name, BDAddressAndType addressAndType); /* Bluetooth specific API */ @@ -145,7 +145,7 @@ public interface BluetoothAdapter extends BluetoothObject * @deprecated since 2.0.0, use {@link #startDiscovery(boolean)}. */ @Deprecated - public boolean startDiscovery() throws BluetoothException; + public boolean startDiscovery() throws BTException; /** * Turns on device discovery if it is disabled. @@ -168,12 +168,12 @@ public interface BluetoothAdapter extends BluetoothObject * and {@link #stopDiscovery()} is the recommended workflow * for a reliable discovery process. * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state - * @throws BluetoothException + * @throws BTException * @since 2.0.0 * @implNote {@code keepAlive} not implemented in tinyb.dbus * @see #getDiscovering() */ - public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException; + public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException; /** * Turns off device discovery if it is enabled. @@ -181,23 +181,23 @@ public interface BluetoothAdapter extends BluetoothObject * @apiNote return {@link HCIStatusCode} since 2.0.0 * @since 2.0.0 */ - public HCIStatusCode stopDiscovery() throws BluetoothException; + public HCIStatusCode stopDiscovery() throws BTException; /** Returns a list of discovered BluetoothDevices from this adapter. * @return A list of discovered BluetoothDevices on this adapter, * NULL if an error occurred */ - public List<BluetoothDevice> getDiscoveredDevices(); + public List<BTDevice> getDiscoveredDevices(); /** * Remove all the discovered devices found on this adapter. * * @return The number of removed discovered devices on this adapter - * @throws BluetoothException + * @throws BTException * @since 2.2.0 * @implNote Changed from 'removeDiscoveredDevices()' for clarity since version 2.2.0 */ - public int removeDiscoveredDevices() throws BluetoothException; + public int removeDiscoveredDevices() throws BTException; /** * Discards matching discovered devices. @@ -304,7 +304,7 @@ public interface BluetoothAdapter extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the powered * property. */ - public void enablePoweredNotifications(BluetoothNotification<Boolean> callback); + public void enablePoweredNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the powered property and unregisters the callback @@ -346,7 +346,7 @@ public interface BluetoothAdapter extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the discoverable * property. */ - public void enableDiscoverableNotifications(BluetoothNotification<Boolean> callback); + public void enableDiscoverableNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the discoverable property and unregisters the callback * object passed through the corresponding enable method. @@ -397,7 +397,7 @@ public interface BluetoothAdapter extends BluetoothObject * <li>{@code random} - Random address</li> * </ul> */ - public BluetoothDevice connectDevice(BDAddressAndType addressAndType); + public BTDevice connectDevice(BDAddressAndType addressAndType); /** Returns the pairable state the adapter. * @return The pairable state of the adapter. @@ -411,7 +411,7 @@ public interface BluetoothAdapter extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the pairable * property. */ - public void enablePairableNotifications(BluetoothNotification<Boolean> callback); + public void enablePairableNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the pairable property and unregisters the callback @@ -469,18 +469,18 @@ public interface BluetoothAdapter extends BluetoothObject * Add the given {@link AdapterStatusListener} to the list if not already present. * <p> * The newly added {@link AdapterStatusListener} will receive an initial - * {@link AdapterStatusListener#adapterSettingsChanged(BluetoothAdapter, AdapterSettings, AdapterSettings, AdapterSettings, long) adapterSettingsChanged} + * {@link AdapterStatusListener#adapterSettingsChanged(BTAdapter, AdapterSettings, AdapterSettings, AdapterSettings, long) adapterSettingsChanged} * event, passing an {@link AdapterSettings empty oldMask and changedMask}, as well as {@link AdapterSettings current newMask}. <br> * This allows the receiver to be aware of this adapter's current settings. * </p> * @param listener A {@link AdapterStatusListener} instance - * @param deviceMatch Optional {@link BluetoothDevice} to be matched before calling any + * @param deviceMatch Optional {@link BTDevice} to be matched before calling any * {@link AdapterStatusListener} {@code device*} methods. Pass {@code null} for no filtering. * @return true if the given listener is not element of the list and has been newly added, otherwise false. * @since 2.0.0 * @implNote not implemented in tinyb.dbus */ - public boolean addStatusListener(final AdapterStatusListener listener, final BluetoothDevice deviceMatch); + public boolean addStatusListener(final AdapterStatusListener listener, final BTDevice deviceMatch); /** * Remove the given {@link AdapterStatusListener} from the list. @@ -506,7 +506,7 @@ public interface BluetoothAdapter extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the discovering * property. */ - public void enableDiscoveringNotifications(BluetoothNotification<Boolean> callback); + public void enableDiscoveringNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the discovering property and unregisters the discovering diff --git a/java/org/direct_bt/BluetoothCallback.java b/java/org/direct_bt/BTCallback.java index a179c812..86b3f542 100644 --- a/java/org/direct_bt/BluetoothCallback.java +++ b/java/org/direct_bt/BTCallback.java @@ -26,7 +26,7 @@ package org.direct_bt; import tinyb.dbus.DBusObject; -public abstract class BluetoothCallback implements Runnable +public abstract class BTCallback implements Runnable { protected DBusObject bObj; diff --git a/java/org/direct_bt/BluetoothDevice.java b/java/org/direct_bt/BTDevice.java index d80e2d64..4a92cf57 100644 --- a/java/org/direct_bt/BluetoothDevice.java +++ b/java/org/direct_bt/BTDevice.java @@ -35,10 +35,10 @@ import java.util.Map; * Provides access to Bluetooth adapters. Follows the BlueZ adapter API * available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/device-api.txt */ -public interface BluetoothDevice extends BluetoothObject +public interface BTDevice extends BTObject { @Override - public BluetoothDevice clone(); + public BTDevice clone(); /** Find a BluetoothGattService. If parameter UUID is not null, * the returned object will have to match it. @@ -51,7 +51,7 @@ public interface BluetoothDevice extends BluetoothObject * @return An object matching the UUID or null if not found before * timeout expires or event is canceled. */ - BluetoothGattService find(String UUID, long timeoutMS); + BTGattService find(String UUID, long timeoutMS); /** Find a BluetoothGattService. If parameter UUID is not null, * the returned object will have to match it. @@ -62,7 +62,7 @@ public interface BluetoothDevice extends BluetoothObject * @return An object matching the UUID or null if not found before * timeout expires or event is canceled. */ - BluetoothGattService find(String UUID); + BTGattService find(String UUID); /* Bluetooth method calls: */ @@ -78,7 +78,7 @@ public interface BluetoothDevice extends BluetoothObject * </p> * <p> * The device will be removed from the managing adapter's connected devices - * when {@link AdapterStatusListener#deviceDisconnected(BluetoothDevice, HCIStatusCode, long)} has been received. + * when {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)} has been received. * </p> * <p> * An open GATT connection will also be closed.<br> @@ -92,7 +92,7 @@ public interface BluetoothDevice extends BluetoothObject * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection. * @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i> */ - HCIStatusCode disconnect() throws BluetoothException; + HCIStatusCode disconnect() throws BTException; /** * <b>direct_bt.tinyb</b>: Establish a default HCI connection to this device, using certain default parameter. @@ -107,8 +107,8 @@ public interface BluetoothDevice extends BluetoothObject * </p> * <p> * The actual new connection handle will be delivered asynchronous and - * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BluetoothDevice, long)}, - * or if failed via {@link AdapterStatusListener#deviceDisconnected(BluetoothDevice, HCIStatusCode, long)}. + * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BTDevice, long)}, + * or if failed via {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)}. * </p> * <p> * The device is tracked by the managing adapter. @@ -121,7 +121,7 @@ public interface BluetoothDevice extends BluetoothObject * @see #connectLE(short, short, short, short, short, short) * @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i> */ - HCIStatusCode connect() throws BluetoothException; + HCIStatusCode connect() throws BTException; /** * Establish a HCI BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM connection to this device. @@ -134,8 +134,8 @@ public interface BluetoothDevice extends BluetoothObject * </p> * <p> * The actual new connection handle will be delivered asynchronous and - * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BluetoothDevice, long)}, - * or if failed via {@link AdapterStatusListener#deviceDisconnected(BluetoothDevice, HCIStatusCode, long)}. + * the connection event can be caught via {@link AdapterStatusListener#deviceConnected(BTDevice, long)}, + * or if failed via {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, long)}. * </p> * <p> * The device is tracked by the managing adapter. @@ -158,7 +158,7 @@ public interface BluetoothDevice extends BluetoothObject * @param conn_latency slave latency in units of connection events, default value 0; Value range [0 .. 0x01F3]. * @param supervision_timeout in units of 10ms, default value >= 10 x conn_interval_max, we use 500 ms minimum; Value range [0xA-0x0C80] for [100ms - 32s]. * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection. - * @see BluetoothUtils#getHCIConnSupervisorTimeout(int, int, int, int) + * @see BTUtils#getHCIConnSupervisorTimeout(int, int, int, int) * @see #connect() * @since 2.1.0 change API, i.e. return value from boolean to HCIStatusCode in favor of <i>direct_bt</i> * @implNote not implemented in <b>tinyb.dbus</b> @@ -172,13 +172,13 @@ public interface BluetoothDevice extends BluetoothObject * @param arg_UUID The UUID of the profile to be connected * @return TRUE if the profile connected successfully */ - boolean connectProfile(String arg_UUID) throws BluetoothException; + boolean connectProfile(String arg_UUID) throws BTException; /** Disconnects a specific profile available on the device, given by UUID * @param arg_UUID The UUID of the profile to be disconnected * @return TRUE if the profile disconnected successfully */ - boolean disconnectProfile(String arg_UUID) throws BluetoothException; + boolean disconnectProfile(String arg_UUID) throws BTException; /** * Returns the available {@link SMPKeyMask.KeyType} {@link SMPKeyMask} for the responder (LL slave) or initiator (LL master). @@ -194,7 +194,7 @@ public interface BluetoothDevice extends BluetoothObject * @param responder true will return the responder's LTK info (remote device, LL slave), otherwise the initiator's (the LL master). * @return the resulting key. {@link SMPLongTermKeyInfo#enc_size} will be zero if invalid. * @see {@link SMPPairingState#COMPLETED} - * @see {@link AdapterStatusListener#deviceReady(BluetoothDevice, long)} + * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)} * @since 2.2.0 * @implNote not implemented in tinyb.dbus */ @@ -217,7 +217,7 @@ public interface BluetoothDevice extends BluetoothObject * @param responder true will return the responder's LTK info (remote device, LL slave), otherwise the initiator's (the LL master). * @return the resulting key * @see {@link SMPPairingState#COMPLETED} - * @see {@link AdapterStatusListener#deviceReady(BluetoothDevice, long)} + * @see {@link AdapterStatusListener#deviceReady(BTDevice, long)} * @since 2.2.0 * @implNote not implemented in tinyb.dbus */ @@ -232,7 +232,7 @@ public interface BluetoothDevice extends BluetoothObject * @return TRUE if the device connected and paired * @implNote not implemented in direct_bt.tinyb */ - boolean pair() throws BluetoothException; + boolean pair() throws BTException; /** * Unpairs this device from the adapter while staying connected. @@ -390,7 +390,7 @@ public interface BluetoothDevice extends BluetoothObject * Method sets the given passkey entry, see {@link PairingMode#PASSKEY_ENTRY_ini}. * <p> * Call this method if the device shall be securely paired with {@link PairingMode#PASSKEY_ENTRY_ini}, - * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) devicePairingState} + * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState} * in state {@link SMPPairingState#PASSKEY_EXPECTED}. * </p> * @@ -400,7 +400,7 @@ public interface BluetoothDevice extends BluetoothObject * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection. * @see PairingMode * @see SMPPairingState - * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) + * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) * @see #setPairingPasskey(int) * @see #setPairingNumericComparison(boolean) * @see #getPairingMode() @@ -414,7 +414,7 @@ public interface BluetoothDevice extends BluetoothObject * Method sets the numeric comparison result, see {@link PairingMode#NUMERIC_COMPARE_ini}. * <p> * Call this method if the device shall be securely paired with {@link PairingMode#NUMERIC_COMPARE_ini}, - * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) devicePairingState} + * i.e. when notified via {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState} * in state {@link SMPPairingState#NUMERIC_COMPARE_EXPECTED}. * </p> * @@ -424,7 +424,7 @@ public interface BluetoothDevice extends BluetoothObject * @return {@link HCIStatusCode#SUCCESS} if the command has been accepted, otherwise {@link HCIStatusCode} may disclose reason for rejection. * @see PairingMode * @see SMPPairingState - * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) + * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) * @see #setPairingPasskey(int) * @see #setPairingNumericComparison(boolean) * @see #getPairingMode() @@ -442,7 +442,7 @@ public interface BluetoothDevice extends BluetoothObject * <p> * If the Pairing Feature Exchange is completed, i.e. {@link SMPPairingState#FEATURE_EXCHANGE_COMPLETED} * as notified by - * {@link AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) devicePairingState} + * {@link AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) devicePairingState} * the current mode reflects the currently used {@link PairingMode}. * </p> * <p> @@ -451,7 +451,7 @@ public interface BluetoothDevice extends BluetoothObject * @return current PairingMode. * @see PairingMode * @see SMPPairingState - * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) + * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) * @see #setPairingPasskey(int) * @see #setPairingNumericComparison(boolean) * @see #getPairingMode() @@ -468,7 +468,7 @@ public interface BluetoothDevice extends BluetoothObject * </p> * @see PairingMode * @see SMPPairingState - * @see AdapterStatusListener#devicePairingState(BluetoothDevice, SMPPairingState, PairingMode, long) + * @see AdapterStatusListener#devicePairingState(BTDevice, SMPPairingState, PairingMode, long) * @see #setPairingPasskey(int) * @see #setPairingNumericComparison(boolean) * @see #getPairingMode() @@ -504,20 +504,20 @@ public interface BluetoothDevice extends BluetoothObject * but never issue remove() after disconnect() if the device is in use. * </p> * @return TRUE if the device has been removed - * @throws BluetoothException + * @throws BTException */ - boolean remove() throws BluetoothException; + boolean remove() throws BTException; /** Cancels an initiated pairing operation * @return TRUE if the paring is cancelled successfully */ - boolean cancelPairing() throws BluetoothException; + boolean cancelPairing() throws BTException; /** Returns a list of BluetoothGattServices available on this device. * @return A list of BluetoothGattServices available on this device, * NULL if an error occurred */ - List<BluetoothGattService> getServices(); + List<BTGattService> getServices(); /** * Issues a GATT ping to the device, validating whether it is still reachable. @@ -541,7 +541,7 @@ public interface BluetoothDevice extends BluetoothObject * Returns the timestamp in monotonic milliseconds when this device instance has been created, * either via its initial discovery or its initial direct connection. * - * @see BluetoothUtils#currentTimeMillis() + * @see BTUtils#currentTimeMillis() * @since 2.0.0 */ long getCreationTimestamp(); @@ -550,7 +550,7 @@ public interface BluetoothDevice extends BluetoothObject * Returns the timestamp in monotonic milliseconds when this device instance has * discovered or connected directly the last time. * - * @see BluetoothUtils#currentTimeMillis() + * @see BTUtils#currentTimeMillis() * @since 2.0.0 * @implNote not implemented in tinyb.dbus, returns {@link #getCreationTimestamp()} */ @@ -560,7 +560,7 @@ public interface BluetoothDevice extends BluetoothObject * Returns the timestamp in monotonic milliseconds when this device instance underlying data * has been updated the last time. * - * @see BluetoothUtils#currentTimeMillis() + * @see BTUtils#currentTimeMillis() * @since 2.0.0 * @implNote not implemented in tinyb.dbus, returns {@link #getCreationTimestamp()} */ @@ -623,7 +623,7 @@ public interface BluetoothDevice extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the paired * property. */ - void enablePairedNotifications(BluetoothNotification<Boolean> callback); + void enablePairedNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the paired property and unregisters the callback @@ -643,7 +643,7 @@ public interface BluetoothDevice extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the trusted * property. */ - void enableTrustedNotifications(BluetoothNotification<Boolean> callback); + void enableTrustedNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the trusted property and unregisters the callback @@ -667,7 +667,7 @@ public interface BluetoothDevice extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the blocked * property. */ - void enableBlockedNotifications(BluetoothNotification<Boolean> callback); + void enableBlockedNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the blocked property and unregisters the callback @@ -696,7 +696,7 @@ public interface BluetoothDevice extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the RSSI * property. */ - void enableRSSINotifications(BluetoothNotification<Short> callback); + void enableRSSINotifications(BTNotification<Short> callback); /** * Disables notifications of the RSSI property and unregisters the callback @@ -723,7 +723,7 @@ public interface BluetoothDevice extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the connected * property. */ - void enableConnectedNotifications(BluetoothNotification<Boolean> callback); + void enableConnectedNotifications(BTNotification<Boolean> callback); /** * Disables notifications of the connected property and unregisters the callback @@ -745,7 +745,7 @@ public interface BluetoothDevice extends BluetoothObject * connected. * @return The adapter. */ - BluetoothAdapter getAdapter(); + BTAdapter getAdapter(); /** Returns a map containing manufacturer specific advertisement data. * An entry has a uint16_t key and an array of bytes. @@ -761,7 +761,7 @@ public interface BluetoothDevice extends BluetoothObject * property. */ void enableManufacturerDataNotifications( - BluetoothNotification<Map<Short, byte[]>> callback); + BTNotification<Map<Short, byte[]>> callback); /** * Disables notifications of the manufacturer data property and unregisters the callback @@ -783,7 +783,7 @@ public interface BluetoothDevice extends BluetoothObject * property. */ void enableServiceDataNotifications( - BluetoothNotification<Map<String, byte[]>> callback); + BTNotification<Map<String, byte[]>> callback); /** * Disables notifications of the service data property and unregisters the callback @@ -809,7 +809,7 @@ public interface BluetoothDevice extends BluetoothObject * property. */ void enableServicesResolvedNotifications( - BluetoothNotification<Boolean> callback); + BTNotification<Boolean> callback); /** * Disables notifications of the services resolved property and unregisters the callback @@ -818,40 +818,40 @@ public interface BluetoothDevice extends BluetoothObject void disableServicesResolvedNotifications(); /** - * Add the given {@link GATTCharacteristicListener} to the listener list if not already present. + * Add the given {@link BTGattCharListener} to the listener list if not already present. * <p> * To enable the actual BLE notification and/or indication, one needs to call - * {@link BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[])} - * or {@link BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[])}. + * {@link BTGattChar#configNotificationIndication(boolean, boolean, boolean[])} + * or {@link BTGattChar#enableNotificationOrIndication(boolean[])}. * </p> - * @param listener A {@link GATTCharacteristicListener} instance, listening to all {@link BluetoothGattCharacteristic} events of this device + * @param listener A {@link BTGattCharListener} instance, listening to all {@link BTGattChar} events of this device * @return true if the given listener is not element of the list and has been newly added, otherwise false. - * @throws IllegalStateException if the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected - * @throws IllegalStateException if the given {@link GATTCharacteristicListener} is already in use, i.e. added. - * @see BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[]) - * @see BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[]) + * @throws IllegalStateException if the {@link BTDevice}'s GATTHandler is null, i.e. not connected + * @throws IllegalStateException if the given {@link BTGattCharListener} is already in use, i.e. added. + * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[]) + * @see BTGattChar#enableNotificationOrIndication(boolean[]) * @since 2.0.0 * @implNote not implemented in <b>tinyb.dbus</b> */ - public boolean addCharacteristicListener(final GATTCharacteristicListener listener) + public boolean addCharListener(final BTGattCharListener listener) throws IllegalStateException; /** - * Remove the given {@link GATTCharacteristicListener} from the listener list. + * Remove the given {@link BTGattCharListener} from the listener list. * <p> - * If the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected, {@code false} is being returned. + * If the {@link BTDevice}'s GATTHandler is null, i.e. not connected, {@code false} is being returned. * </p> - * @param listener A {@link GATTCharacteristicListener} instance + * @param listener A {@link BTGattCharListener} instance * @return true if the given listener is an element of the list and has been removed, otherwise false. * @since 2.0.0 * @implNote not implemented in <b>tinyb.dbus</b> */ - public boolean removeCharacteristicListener(final GATTCharacteristicListener l); + public boolean removeCharListener(final BTGattCharListener l); /** - * Remove all {@link GATTCharacteristicListener} from the list, which are associated to the given {@link BluetoothGattCharacteristic}. + * Remove all {@link BTGattCharListener} from the list, which are associated to the given {@link BTGattChar}. * <p> - * Implementation tests all listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic()} + * Implementation tests all listener's {@link BTGattCharListener#getAssociatedChar()} * to match with the given associated characteristic. * </p> * @param associatedCharacteristic the match criteria to remove any GATTCharacteristicListener from the list @@ -859,13 +859,13 @@ public interface BluetoothDevice extends BluetoothObject * @since 2.0.0 * @implNote not implemented in <b>tinyb.dbus</b> */ - public int removeAllAssociatedCharacteristicListener(final BluetoothGattCharacteristic associatedCharacteristic); + public int removeAllAssociatedCharListener(final BTGattChar associatedCharacteristic); /** - * Remove all {@link GATTCharacteristicListener} from the list. + * Remove all {@link BTGattCharListener} from the list. * @return number of removed listener. * @since 2.0.0 * @implNote not implemented in <b>tinyb.dbus</b> */ - public int removeAllCharacteristicListener(); + public int removeAllCharListener(); } diff --git a/java/org/direct_bt/BluetoothEvent.java b/java/org/direct_bt/BTEvent.java index 8ccce79b..12cf5f9e 100644 --- a/java/org/direct_bt/BluetoothEvent.java +++ b/java/org/direct_bt/BTEvent.java @@ -28,9 +28,9 @@ package org.direct_bt; -public interface BluetoothEvent +public interface BTEvent { - public BluetoothType getType(); + public BTType getType(); public String getName(); public String getIdentifier(); public boolean executeCallback(); diff --git a/java/org/direct_bt/BluetoothException.java b/java/org/direct_bt/BTException.java index d89eb154..b3ef62dd 100644 --- a/java/org/direct_bt/BluetoothException.java +++ b/java/org/direct_bt/BTException.java @@ -29,8 +29,8 @@ package org.direct_bt; @SuppressWarnings("serial") -public class BluetoothException extends RuntimeException { - protected BluetoothException(final String msg) { +public class BTException extends RuntimeException { + protected BTException(final String msg) { super(msg); } } diff --git a/java/org/direct_bt/BluetoothFactory.java b/java/org/direct_bt/BTFactory.java index 66db7917..cee2aa7f 100644 --- a/java/org/direct_bt/BluetoothFactory.java +++ b/java/org/direct_bt/BTFactory.java @@ -41,17 +41,17 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; /** - * One stop {@link BluetoothManager} API entry point. + * One stop {@link BTManager} API entry point. * <p> * Further provides access to certain property settings, * see {@link #DEBUG}, {@link #VERBOSE}, {@link #DIRECTBT_CHARACTERISTIC_VALUE_CACHE_NOTIFICATION_COMPAT}. * </p> */ -public class BluetoothFactory { +public class BTFactory { /** - * Identifier names, allowing {@link BluetoothFactory#getBluetoothManager(ImplementationIdentifier)} - * to initialize the required native libraries and to instantiate the root {@link BluetoothManager} instance. + * Identifier names, allowing {@link BTFactory#getBluetoothManager(ImplementationIdentifier)} + * to initialize the required native libraries and to instantiate the root {@link BTManager} instance. * <p> * The implementation class must provide the static factory method * <pre> @@ -61,7 +61,7 @@ public class BluetoothFactory { */ public static class ImplementationIdentifier { /** - * Fully qualified class name for the {@link BluetoothManager} implementation + * Fully qualified class name for the {@link BTManager} implementation * <p> * The implementation class must provide the static factory method * <pre> @@ -120,7 +120,7 @@ public class BluetoothFactory { * This value is exposed for convenience, user implementations are welcome. * </p> */ - public static final ImplementationIdentifier DirectBTImplementationID = new ImplementationIdentifier("direct_bt.tinyb.DBTManager", "direct_bt", "javadirect_bt"); + public static final ImplementationIdentifier DirectBTImplementationID = new ImplementationIdentifier("jau.direct_bt.DBTManager", "direct_bt", "javadirect_bt"); private static final List<ImplementationIdentifier> implIDs = new ArrayList<ImplementationIdentifier>(); @@ -206,10 +206,10 @@ public class BluetoothFactory { try { final Throwable[] t = { null }; - if( !PlatformToolkit.loadLibrary(id.ImplementationNativeLibraryBasename, BluetoothFactory.class.getClassLoader(), t) ) { + if( !PlatformToolkit.loadLibrary(id.ImplementationNativeLibraryBasename, BTFactory.class.getClassLoader(), t) ) { throw new RuntimeException("Couldn't load native library with basename <"+id.ImplementationNativeLibraryBasename+">", t[0]); } - if( !PlatformToolkit.loadLibrary(id.JavaNativeLibraryBasename, BluetoothFactory.class.getClassLoader(), t) ) { + if( !PlatformToolkit.loadLibrary(id.JavaNativeLibraryBasename, BTFactory.class.getClassLoader(), t) ) { throw new RuntimeException("Couldn't load native library with basename <"+id.JavaNativeLibraryBasename+">", t[0]); } } catch (final Throwable e) { @@ -247,7 +247,7 @@ public class BluetoothFactory { } try { - final Manifest manifest = getManifest(BluetoothFactory.class.getClassLoader(), new String[] { "org.tinyb" } ); + final Manifest manifest = getManifest(BTFactory.class.getClassLoader(), new String[] { "org.tinyb" } ); final Attributes mfAttributes = null != manifest ? manifest.getMainAttributes() : null; // major.minor must match! @@ -301,12 +301,12 @@ public class BluetoothFactory { } } - private static synchronized BluetoothManager getBluetoothManager(final Class<?> factoryImplClass) - throws BluetoothException, NoSuchMethodException, SecurityException, + private static synchronized BTManager getBluetoothManager(final Class<?> factoryImplClass) + throws BTException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { final Method m = factoryImplClass.getMethod("getManager"); - return (BluetoothManager)m.invoke(null); + return (BTManager)m.invoke(null); } /** @@ -328,7 +328,7 @@ public class BluetoothFactory { /** * Returns the matching {@link ImplementationIdentifier} from the internal list or {@code null} if not found. - * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BluetoothManager} implementation + * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BTManager} implementation */ public static synchronized ImplementationIdentifier getImplementationIdentifier(final String fqBluetoothManagerImplementationClassName) { for(final ImplementationIdentifier id : implIDs) { @@ -349,8 +349,8 @@ public class BluetoothFactory { * The chosen implementation can't be changed within a running implementation, an exception is thrown if tried. * </p> * - * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BluetoothManager} implementation - * @throws BluetoothException + * @param fqBluetoothManagerImplementationClassName fully qualified class name for the {@link BTManager} implementation + * @throws BTException * @throws NoSuchMethodException * @throws SecurityException * @throws IllegalAccessException @@ -360,8 +360,8 @@ public class BluetoothFactory { * @see {@link #DBusFactoryImplClassName} * @see {@link #DirectBTFactoryImplClassName} */ - public static synchronized BluetoothManager getBluetoothManager(final String fqBluetoothManagerImplementationClassName) - throws BluetoothException, NoSuchMethodException, SecurityException, + public static synchronized BTManager getBluetoothManager(final String fqBluetoothManagerImplementationClassName) + throws BTException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException { final ImplementationIdentifier id = getImplementationIdentifier(fqBluetoothManagerImplementationClassName); @@ -381,7 +381,7 @@ public class BluetoothFactory { * The chosen implementation can't be changed within a running implementation, an exception is thrown if tried. * </p> * @param id the specific {@link ImplementationIdentifier} - * @throws BluetoothException + * @throws BTException * @throws NoSuchMethodException * @throws SecurityException * @throws IllegalAccessException @@ -391,8 +391,8 @@ public class BluetoothFactory { * @see {@link #DBusFactoryImplClassName} * @see {@link #DirectBTFactoryImplClassName} */ - public static synchronized BluetoothManager getBluetoothManager(final ImplementationIdentifier id) - throws BluetoothException, NoSuchMethodException, SecurityException, + public static synchronized BTManager getBluetoothManager(final ImplementationIdentifier id) + throws BTException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException { registerImplementationIdentifier(id); @@ -409,7 +409,7 @@ public class BluetoothFactory { * <p> * The chosen implementation can't be changed within a running implementation, an exception is thrown if tried. * </p> - * @throws BluetoothException + * @throws BTException * @throws NoSuchMethodException * @throws SecurityException * @throws IllegalAccessException @@ -417,8 +417,8 @@ public class BluetoothFactory { * @throws InvocationTargetException * @throws ClassNotFoundException */ - public static synchronized BluetoothManager getDBusBluetoothManager() - throws BluetoothException, NoSuchMethodException, SecurityException, + public static synchronized BTManager getDBusBluetoothManager() + throws BTException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException { return getBluetoothManager(DBusImplementationID); @@ -432,7 +432,7 @@ public class BluetoothFactory { * <p> * The chosen implementation can't be changed within a running implementation, an exception is thrown if tried. * </p> - * @throws BluetoothException + * @throws BTException * @throws NoSuchMethodException * @throws SecurityException * @throws IllegalAccessException @@ -440,8 +440,8 @@ public class BluetoothFactory { * @throws InvocationTargetException * @throws ClassNotFoundException */ - public static synchronized BluetoothManager getDirectBTBluetoothManager() - throws BluetoothException, NoSuchMethodException, SecurityException, + public static synchronized BTManager getDirectBTBluetoothManager() + throws BTException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException { return getBluetoothManager(DirectBTImplementationID); diff --git a/java/org/direct_bt/BluetoothGattCharacteristic.java b/java/org/direct_bt/BTGattChar.java index 580e30a3..8e7330dc 100644 --- a/java/org/direct_bt/BluetoothGattCharacteristic.java +++ b/java/org/direct_bt/BTGattChar.java @@ -34,10 +34,10 @@ import java.util.List; * Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API * available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt */ -public interface BluetoothGattCharacteristic extends BluetoothObject +public interface BTGattChar extends BTObject { @Override - public BluetoothGattCharacteristic clone(); + public BTGattChar clone(); /** Find a BluetoothGattDescriptor. If parameter UUID is not null, * the returned object will have to match it. @@ -50,7 +50,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * @return An object matching the UUID or null if not found before * timeout expires or event is canceled. */ - public BluetoothGattDescriptor find(final String UUID, final long timeoutMS); + public BTGattDesc find(final String UUID, final long timeoutMS); /** Find a BluetoothGattDescriptor. If parameter UUID is not null, * the returned object will have to match it. @@ -61,14 +61,14 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * @return An object matching the UUID or null if not found before * timeout expires or event is canceled. */ - public BluetoothGattDescriptor find(final String UUID); + public BTGattDesc find(final String UUID); /* D-Bus method calls: */ /** Reads the value of this characteristic. * @return A std::vector<unsgined char> containing the value of this characteristic. */ - public byte[] readValue() throws BluetoothException; + public byte[] readValue() throws BTException; /** * BT Core Spec v5.2: Vol 3, Part G GATT: 3.3.3.3 Client Characteristic Configuration @@ -93,7 +93,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed. * Otherwise returns true. * @throws IllegalStateException if notification or indication is set to be enabled - * and the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected + * and the {@link BTDevice}'s GATTHandler is null, i.e. not connected * @see #enableNotificationOrIndication(boolean[]) * @since 2.0.0 * @implNote not implemented in tinyb.dbus @@ -119,7 +119,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * or there is no GATTDescriptor of type ClientCharacteristicConfiguration, or if the operation has failed. * Otherwise returns true. * @throws IllegalStateException if notification or indication is set to be enabled - * and the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected + * and the {@link BTDevice}'s GATTHandler is null, i.e. not connected * @see #configNotificationIndication(boolean, boolean, boolean[]) * @since 2.0.0 * @implNote not implemented in tinyb.dbus @@ -128,26 +128,26 @@ public interface BluetoothGattCharacteristic extends BluetoothObject throws IllegalStateException; /** - * Add the given {@link GATTCharacteristicListener} to the listener list if not already present. + * Add the given {@link BTGattCharListener} to the listener list if not already present. * <p> * Occurring notifications and indications, if enabled via {@link #configNotificationIndication(boolean, boolean, boolean[])} * or {@link #enableNotificationOrIndication(boolean[])}, * will call the respective GATTCharacteristicListener callback method. * </p> - * @param listener A {@link GATTCharacteristicListener} instance, listening to this {@link BluetoothGattCharacteristic}'s events + * @param listener A {@link BTGattCharListener} instance, listening to this {@link BTGattChar}'s events * @return true if the given listener is not element of the list and has been newly added, otherwise false. * @throws IllegalStateException if the DBTDevice's GATTHandler is null, i.e. not connected - * @throws IllegalStateException if the given {@link GATTCharacteristicListener} is already in use, i.e. added. + * @throws IllegalStateException if the given {@link BTGattCharListener} is already in use, i.e. added. * @see #enableNotificationOrIndication(boolean[]) * @see #configNotificationIndication(boolean, boolean, boolean[]) * @since 2.0.0 * @implNote not implemented in tinyb.dbus */ - public boolean addCharacteristicListener(final GATTCharacteristicListener listener) + public boolean addCharacteristicListener(final BTGattCharListener listener) throws IllegalStateException; /** - * Add the given {@link GATTCharacteristicListener} to the listener list if not already present + * Add the given {@link BTGattCharListener} to the listener list if not already present * and if enabling the notification <i>or</i> indication for this characteristic at BLE level was successful.<br> * Notification and/or indication configuration is only performed per characteristic if changed. * <p> @@ -156,33 +156,33 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * Implementation uses {@link #enableNotificationOrIndication(boolean[])} to enable one. * </p> * <p> - * Occurring notifications and indications will call the respective {@link GATTCharacteristicListener} + * Occurring notifications and indications will call the respective {@link BTGattCharListener} * callback method. * </p> - * @param listener A {@link GATTCharacteristicListener} instance, listening to this {@link BluetoothGattCharacteristic}'s events + * @param listener A {@link BTGattCharListener} instance, listening to this {@link BTGattChar}'s events * @param enabledState array of size 2, holding the resulting enabled state for notification and indication * using {@link #enableNotificationOrIndication(boolean[])} * @return true if enabling the notification and/or indication was successful * and if the given listener is not element of the list and has been newly added, otherwise false. - * @throws IllegalStateException if the {@link BluetoothDevice}'s GATTHandler is null, i.e. not connected - * @throws IllegalStateException if the given {@link GATTCharacteristicListener} is already in use, i.e. added. + * @throws IllegalStateException if the {@link BTDevice}'s GATTHandler is null, i.e. not connected + * @throws IllegalStateException if the given {@link BTGattCharListener} is already in use, i.e. added. * @see #enableNotificationOrIndication(boolean[]) * @see #configNotificationIndication(boolean, boolean, boolean[]) * @since 2.0.0 * @implNote not implemented in tinyb.dbus */ - public boolean addCharacteristicListener(final GATTCharacteristicListener listener, final boolean enabledState[/*2*/]) + public boolean addCharacteristicListener(final BTGattCharListener listener, final boolean enabledState[/*2*/]) throws IllegalStateException; /** * Disables the notification and/or indication for this characteristic at BLE level * if {@code disableIndicationNotification == true} - * and removes the given {@link GATTCharacteristicListener} from the listener list. + * and removes the given {@link BTGattCharListener} from the listener list. * <p> * If the DBTDevice's GATTHandler is null, i.e. not connected, {@code false} is being returned. * </p> * - * @param listener A {@link GATTCharacteristicListener} instance + * @param listener A {@link BTGattCharListener} instance * @param disableIndicationNotification if true, disables the notification and/or indication for this characteristic * using {@link #configNotificationIndication(boolean, boolean, boolean[])} * @return true if the given listener is an element of the list and has been removed, otherwise false. @@ -190,15 +190,15 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * @since 2.0.0 * @implNote not implemented in tinyb.dbus */ - public boolean removeCharacteristicListener(final GATTCharacteristicListener l, final boolean disableIndicationNotification); + public boolean removeCharacteristicListener(final BTGattCharListener l, final boolean disableIndicationNotification); /** * Disables the notification and/or indication for this characteristic BLE level * if {@code disableIndicationNotification == true} - * and removes all {@link GATTCharacteristicListener} from the listener list, + * and removes all {@link BTGattCharListener} from the listener list, * which are associated with this characteristic instance. * <p> - * Implementation tests all listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic()} + * Implementation tests all listener's {@link BTGattCharListener#getAssociatedChar()} * to match with this characteristic instance. * </p> * <p> @@ -209,7 +209,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * using {@link #configNotificationIndication(boolean, boolean, boolean[])} * @return number of removed listener. * @see #configNotificationIndication(boolean, boolean, boolean[]) - * @see BluetoothDevice#removeAllAssociatedCharacteristicListener(BluetoothGattCharacteristic) + * @see BTDevice#removeAllAssociatedCharacteristicListener(BTGattChar) * @since 2.0.0 * @implNote not implemented in tinyb.dbus */ @@ -225,7 +225,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the value * property. */ - public void enableValueNotifications(BluetoothNotification<byte[]> callback); + public void enableValueNotifications(BTNotification<byte[]> callback); /** * Disables notifications of the value and unregisters the callback object @@ -249,7 +249,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * @implNote {@code withResponse} parameter has been added since 2.0.0 * @implNote tinyb.dbus does not support {@code withResponse = true} */ - public boolean writeValue(byte[] argValue, boolean withResponse) throws BluetoothException; + public boolean writeValue(byte[] argValue, boolean withResponse) throws BTException; /* D-Bus property accessors: */ @@ -261,7 +261,7 @@ public interface BluetoothGattCharacteristic extends BluetoothObject /** Returns the service to which this characteristic belongs to. * @return The service. */ - public BluetoothGattService getService(); + public BTGattService getService(); /** Returns the cached value of this characteristic, if any. * @return The cached value of this characteristic. @@ -293,5 +293,5 @@ public interface BluetoothGattCharacteristic extends BluetoothObject * @return A list of BluetoothGattDescriptors exposed by this characteristic * NULL if an error occurred */ - public List<BluetoothGattDescriptor> getDescriptors(); + public List<BTGattDesc> getDescriptors(); } diff --git a/java/org/direct_bt/GATTCharacteristicListener.java b/java/org/direct_bt/BTGattCharListener.java index fad76d51..f95e0166 100644 --- a/java/org/direct_bt/GATTCharacteristicListener.java +++ b/java/org/direct_bt/BTGattCharListener.java @@ -28,25 +28,25 @@ package org.direct_bt; import java.lang.ref.WeakReference; /** - * {@link BluetoothGattCharacteristic} event listener for notification and indication events. + * {@link BTGattChar} event listener for notification and indication events. * <p> - * A listener instance may be attached to a {@link BluetoothGattCharacteristic} via - * {@link BluetoothGattCharacteristic#addCharacteristicListener(GATTCharacteristicListener)} to listen to its events. + * A listener instance may be attached to a {@link BTGattChar} via + * {@link BTGattChar#addCharacteristicListener(BTGattCharListener)} to listen to its events. * </p> * <p> - * A listener instance may be attached to a {@link BluetoothDevice} via - * {@link BluetoothDevice#addCharacteristicListener(GATTCharacteristicListener, BluetoothGattCharacteristic)} + * A listener instance may be attached to a {@link BTDevice} via + * {@link BTDevice#addCharacteristicListener(BTGattCharListener, BTGattChar)} * to listen to all events of the device or the matching filtered events. * </p> * <p> - * One {@link GATTCharacteristicListener} instance can only be attached to a listener receiver once at a time, - * i.e. you cannot attach the same instance more than once to a {@link BluetoothDevice} - * or {@link BluetoothGattCharacteristic}. + * One {@link BTGattCharListener} instance can only be attached to a listener receiver once at a time, + * i.e. you cannot attach the same instance more than once to a {@link BTDevice} + * or {@link BTGattChar}. * <br> * To attach multiple listener, one instance per attachment must be created. * <br> * This restriction is due to implementation semantics of strictly associating - * one Java {@link GATTCharacteristicListener} instance to one C++ {@code GATTCharacteristicListener} instance. + * one Java {@link BTGattCharListener} instance to one C++ {@code GATTCharacteristicListener} instance. * The latter will be added to the native list of listeners. * This class's {@code nativeInstance} field links the Java instance to mentioned C++ listener. * <br> @@ -54,61 +54,61 @@ import java.lang.ref.WeakReference; * this restriction is more esoteric. * </p> */ -public abstract class GATTCharacteristicListener { +public abstract class BTGattCharListener { @SuppressWarnings("unused") private long nativeInstance; - private final WeakReference<BluetoothGattCharacteristic> associatedCharacteristic; + private final WeakReference<BTGattChar> associatedChar; /** - * Returns the weakly associated {@link BluetoothGattCharacteristic} to this listener instance. + * Returns the weakly associated {@link BTGattChar} to this listener instance. * <p> * Returns {@code null} if no association has been made - * or if the associated {@link BluetoothGattCharacteristic} has been garbage collected. + * or if the associated {@link BTGattChar} has been garbage collected. * </p> */ - public final BluetoothGattCharacteristic getAssociatedCharacteristic() { - return null != associatedCharacteristic ? associatedCharacteristic.get() : null; + public final BTGattChar getAssociatedChar() { + return null != associatedChar ? associatedChar.get() : null; } /** - * @param associatedCharacteristic weakly associates this listener instance to one {@link BluetoothGattCharacteristic}, + * @param associatedCharacteristic weakly associates this listener instance to one {@link BTGattChar}, * may be {@code null} for no association. - * @see #getAssociatedCharacteristic() + * @see #getAssociatedChar() */ - public GATTCharacteristicListener(final BluetoothGattCharacteristic associatedCharacteristic) { + public BTGattCharListener(final BTGattChar associatedCharacteristic) { if( null != associatedCharacteristic ) { - this.associatedCharacteristic = new WeakReference<BluetoothGattCharacteristic>(associatedCharacteristic); + this.associatedChar = new WeakReference<BTGattChar>(associatedCharacteristic); } else { - this.associatedCharacteristic = null; + this.associatedChar = null; } } /** * Called from native BLE stack, initiated by a received notification associated - * with the given {@link BluetoothGattCharacteristic}. - * @param charDecl {@link BluetoothGattCharacteristic} related to this notification + * with the given {@link BTGattChar}. + * @param charDecl {@link BTGattChar} related to this notification * @param value the notification value - * @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#currentTimeMillis()} + * @param timestamp the indication monotonic timestamp, see {@link BTUtils#currentTimeMillis()} */ - public void notificationReceived(final BluetoothGattCharacteristic charDecl, + public void notificationReceived(final BTGattChar charDecl, final byte[] value, final long timestamp) { } /** * Called from native BLE stack, initiated by a received indication associated - * with the given {@link BluetoothGattCharacteristic}. - * @param charDecl {@link BluetoothGattCharacteristic} related to this indication + * with the given {@link BTGattChar}. + * @param charDecl {@link BTGattChar} related to this indication * @param value the indication value - * @param timestamp the indication monotonic timestamp, see {@link BluetoothUtils#currentTimeMillis()} + * @param timestamp the indication monotonic timestamp, see {@link BTUtils#currentTimeMillis()} * @param confirmationSent if true, the native stack has sent the confirmation, otherwise user is required to do so. */ - public void indicationReceived(final BluetoothGattCharacteristic charDecl, + public void indicationReceived(final BTGattChar charDecl, final byte[] value, final long timestamp, final boolean confirmationSent) { } public String toString() { - final BluetoothGattCharacteristic c = getAssociatedCharacteristic(); + final BTGattChar c = getAssociatedChar(); final String cs = null != c ? c.toString() : "null"; return "GATTCharacteristicListener[associated "+cs+"]"; } diff --git a/java/org/direct_bt/BluetoothGattDescriptor.java b/java/org/direct_bt/BTGattDesc.java index b09f58c0..68db424a 100644 --- a/java/org/direct_bt/BluetoothGattDescriptor.java +++ b/java/org/direct_bt/BTGattDesc.java @@ -32,10 +32,10 @@ package org.direct_bt; * Provides access to Bluetooth GATT descriptor. Follows the BlueZ adapter API * available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt */ -public interface BluetoothGattDescriptor extends BluetoothObject +public interface BTGattDesc extends BTObject { @Override - public BluetoothGattDescriptor clone(); + public BTGattDesc clone(); /* D-Bus method calls: */ @@ -49,7 +49,7 @@ public interface BluetoothGattDescriptor extends BluetoothObject * to be written packed in a GBytes struct * @return TRUE if value was written succesfully */ - public boolean writeValue(byte[] argValue) throws BluetoothException; + public boolean writeValue(byte[] argValue) throws BTException; /** * Enables notifications for the value and calls run function of the BluetoothNotification @@ -58,7 +58,7 @@ public interface BluetoothGattDescriptor extends BluetoothObject * when a notification is issued. The run function will deliver the new value of the value * property. */ - public void enableValueNotifications(BluetoothNotification<byte[]> callback); + public void enableValueNotifications(BTNotification<byte[]> callback); /** * Disables notifications of the value and unregisters the callback object * passed through the corresponding enable method. @@ -75,7 +75,7 @@ public interface BluetoothGattDescriptor extends BluetoothObject /** Returns the characteristic to which this descriptor belongs to. * @return The characteristic. */ - public BluetoothGattCharacteristic getCharacteristic(); + public BTGattChar getCharacteristic(); /** Returns the cached value of this descriptor, if any. * @return The cached value of this descriptor. diff --git a/java/org/direct_bt/BluetoothGattService.java b/java/org/direct_bt/BTGattService.java index 35d4fe9c..898fd959 100644 --- a/java/org/direct_bt/BluetoothGattService.java +++ b/java/org/direct_bt/BTGattService.java @@ -35,10 +35,10 @@ import java.util.List; * Provides access to Bluetooth GATT characteristic. Follows the BlueZ adapter API * available at: http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt */ -public interface BluetoothGattService extends BluetoothObject +public interface BTGattService extends BTObject { @Override - public BluetoothGattService clone(); + public BTGattService clone(); /** Find a BluetoothGattCharacteristic. If parameter UUID is not null, * the returned object will have to match it. @@ -51,7 +51,7 @@ public interface BluetoothGattService extends BluetoothObject * @return An object matching the UUID or null if not found before * timeout expires or event is canceled. */ - public BluetoothGattCharacteristic find(String UUID, long timeoutMS); + public BTGattChar find(String UUID, long timeoutMS); /** Find a BluetoothGattCharacteristic. If parameter UUID is not null, * the returned object will have to match it. @@ -62,7 +62,7 @@ public interface BluetoothGattService extends BluetoothObject * @return An object matching the UUID or null if not found before * timeout expires or event is canceled. */ - public BluetoothGattCharacteristic find(String UUID); + public BTGattChar find(String UUID); /* D-Bus property accessors: */ @@ -74,45 +74,45 @@ public interface BluetoothGattService extends BluetoothObject /** Returns the device to which this service belongs to. * @return The device. */ - public BluetoothDevice getDevice(); + public BTDevice getDevice(); /** Returns true if this service is a primary service, false if secondary. * @return true if this service is a primary service, false if secondary. */ public boolean getPrimary(); - /** Returns a list of BluetoothGattCharacteristics this service exposes. - * @return A list of BluetoothGattCharacteristics exposed by this service + /** Returns a list of BTGattChar this service exposes. + * @return A list of BTGattChar exposed by this service */ - public List<BluetoothGattCharacteristic> getCharacteristics(); + public List<BTGattChar> getChars(); /** - * Adds the given {@link GATTCharacteristicListener} to the {@link BluetoothDevice} - * and {@link BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[])} for all {@link BluetoothGattCharacteristic} instances. - * @param listener {@link GATTCharacteristicListener} to add to the {@link BluetoothDevice}. - * It is important to have hte listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic() associated characteristic} == null, + * Adds the given {@link BTGattCharListener} to the {@link BTDevice} + * and {@link BTGattChar#enableNotificationOrIndication(boolean[])} for all {@link BTGattChar} instances. + * @param listener {@link BTGattCharListener} to add to the {@link BTDevice}. + * It is important to have hte listener's {@link BTGattCharListener#getAssociatedChar() associated characteristic} == null, * otherwise the listener can't be used for all characteristics. * @return true if successful, otherwise false - * @throws IllegalArgumentException if listener's {@link GATTCharacteristicListener#getAssociatedCharacteristic() associated characteristic} + * @throws IllegalArgumentException if listener's {@link BTGattCharListener#getAssociatedChar() associated characteristic} * is not null. * @since 2.0.0 * @implNote not implemented in tinyb.dbus - * @see BluetoothGattCharacteristic#enableNotificationOrIndication(boolean[]) - * @see BluetoothDevice#addCharacteristicListener(GATTCharacteristicListener, BluetoothGattCharacteristic) + * @see BTGattChar#enableNotificationOrIndication(boolean[]) + * @see BTDevice#addCharacteristicListener(BTGattCharListener, BTGattChar) */ - public static boolean addCharacteristicListenerToAll(final BluetoothDevice device, final List<BluetoothGattService> services, - final GATTCharacteristicListener listener) { + public static boolean addCharListenerToAll(final BTDevice device, final List<BTGattService> services, + final BTGattCharListener listener) { if( null == listener ) { throw new IllegalArgumentException("listener argument null"); } - if( null != listener.getAssociatedCharacteristic() ) { + if( null != listener.getAssociatedChar() ) { throw new IllegalArgumentException("listener's associated characteristic is not null"); } - final boolean res = device.addCharacteristicListener(listener); - for(final Iterator<BluetoothGattService> is = services.iterator(); is.hasNext(); ) { - final BluetoothGattService s = is.next(); - final List<BluetoothGattCharacteristic> characteristics = s.getCharacteristics(); - for(final Iterator<BluetoothGattCharacteristic> ic = characteristics.iterator(); ic.hasNext(); ) { + final boolean res = device.addCharListener(listener); + for(final Iterator<BTGattService> is = services.iterator(); is.hasNext(); ) { + final BTGattService s = is.next(); + final List<BTGattChar> characteristics = s.getChars(); + for(final Iterator<BTGattChar> ic = characteristics.iterator(); ic.hasNext(); ) { ic.next().enableNotificationOrIndication(new boolean[2]); } } @@ -120,42 +120,42 @@ public interface BluetoothGattService extends BluetoothObject } /** - * Removes the given {@link GATTCharacteristicListener} from the {@link BluetoothDevice}. - * @param listener {@link GATTCharacteristicListener} to remove from the {@link BluetoothDevice}. + * Removes the given {@link BTGattCharListener} from the {@link BTDevice}. + * @param listener {@link BTGattCharListener} to remove from the {@link BTDevice}. * @return true if successful, otherwise false * @since 2.0.0 * @implNote not implemented in tinyb.dbus - * @see BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[]) - * @see BluetoothDevice#removeCharacteristicListener(GATTCharacteristicListener) + * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[]) + * @see BTDevice#removeCharacteristicListener(BTGattCharListener) */ - public static boolean removeCharacteristicListenerFromAll(final BluetoothDevice device, final List<BluetoothGattService> services, - final GATTCharacteristicListener listener) { - for(final Iterator<BluetoothGattService> is = services.iterator(); is.hasNext(); ) { - final BluetoothGattService s = is.next(); - final List<BluetoothGattCharacteristic> characteristics = s.getCharacteristics(); - for(final Iterator<BluetoothGattCharacteristic> ic = characteristics.iterator(); ic.hasNext(); ) { + public static boolean removeCharListenerFromAll(final BTDevice device, final List<BTGattService> services, + final BTGattCharListener listener) { + for(final Iterator<BTGattService> is = services.iterator(); is.hasNext(); ) { + final BTGattService s = is.next(); + final List<BTGattChar> characteristics = s.getChars(); + for(final Iterator<BTGattChar> ic = characteristics.iterator(); ic.hasNext(); ) { ic.next().configNotificationIndication(false /* enableNotification */, false /* enableIndication */, new boolean[2]); } } - return device.removeCharacteristicListener(listener); + return device.removeCharListener(listener); } /** - * Removes all {@link GATTCharacteristicListener} from the {@link BluetoothDevice}. - * @return count of removed {@link GATTCharacteristicListener} + * Removes all {@link BTGattCharListener} from the {@link BTDevice}. + * @return count of removed {@link BTGattCharListener} * @since 2.0.0 * @implNote not implemented in tinyb.dbus - * @see BluetoothGattCharacteristic#configNotificationIndication(boolean, boolean, boolean[]) - * @see BluetoothDevice#removeAllCharacteristicListener() + * @see BTGattChar#configNotificationIndication(boolean, boolean, boolean[]) + * @see BTDevice#removeAllCharacteristicListener() */ - public static int removeAllCharacteristicListener(final BluetoothDevice device, final List<BluetoothGattService> services) { - for(final Iterator<BluetoothGattService> is = services.iterator(); is.hasNext(); ) { - final BluetoothGattService s = is.next(); - final List<BluetoothGattCharacteristic> characteristics = s.getCharacteristics(); - for(final Iterator<BluetoothGattCharacteristic> ic = characteristics.iterator(); ic.hasNext(); ) { + public static int removeAllCharListener(final BTDevice device, final List<BTGattService> services) { + for(final Iterator<BTGattService> is = services.iterator(); is.hasNext(); ) { + final BTGattService s = is.next(); + final List<BTGattChar> characteristics = s.getChars(); + for(final Iterator<BTGattChar> ic = characteristics.iterator(); ic.hasNext(); ) { ic.next().configNotificationIndication(false /* enableNotification */, false /* enableIndication */, new boolean[2]); } } - return device.removeAllCharacteristicListener(); + return device.removeAllCharListener(); } } diff --git a/java/org/direct_bt/BluetoothManager.java b/java/org/direct_bt/BTManager.java index 2c80a7e6..c770d6cf 100644 --- a/java/org/direct_bt/BluetoothManager.java +++ b/java/org/direct_bt/BTManager.java @@ -30,7 +30,7 @@ package org.direct_bt; import java.util.List; -public interface BluetoothManager +public interface BTManager { /** * Interface allowing to retrieve certain settings @@ -52,15 +52,15 @@ public interface BluetoothManager boolean isTinyB(); /** - * Returns whether {@link BluetoothGattCharacteristic} API: {@link BluetoothGattCharacteristic#getValue() value cache} and - * {@link BluetoothGattCharacteristic#enableValueNotifications(BluetoothNotification) value notification} + * Returns whether {@link BTGattChar} API: {@link BTGattChar#getValue() value cache} and + * {@link BTGattChar#enableValueNotifications(BluetoothNotification) value notification} * is supported. * <p> * This is enabled using {@link #isTinyB() TinyB}, but disabled by default using {@link #isDirectBT() Direct-BT}. * </p> * <p> * If using {@link #isDirectBT() Direct-BT}, user are encouraged to - * {@link BluetoothGattCharacteristic#addCharacteristicListener(GATTCharacteristicListener, boolean[]) utilize GATTCharacteristicListener} + * {@link BTGattChar#addCharacteristicListener(GATTCharacteristicListener, boolean[]) utilize GATTCharacteristicListener} * to handle value notifications when they occur w/o caching. * </p> * <p> @@ -77,8 +77,8 @@ public interface BluetoothManager /** - * Event listener to receive change events regarding the system's {@link BluetoothAdapter} set, - * e.g. a removed or added {@link BluetoothAdapter} due to user interaction or 'cold reset'. + * 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> * When a new callback is added, all available adapter's will be reported as added, * this allows a fully event driven workflow. @@ -89,25 +89,25 @@ public interface BluetoothManager * </p> * @since 2.0.0 * @implNote Not implemented on tinyb.dbus - * @see BluetoothManager#addChangedAdapterSetListener(ChangedAdapterSetListener) - * @see BluetoothManager#removeChangedAdapterSetListener(ChangedAdapterSetListener) + * @see BTManager#addChangedAdapterSetListener(ChangedAdapterSetListener) + * @see BTManager#removeChangedAdapterSetListener(ChangedAdapterSetListener) */ public static interface ChangedAdapterSetListener { /** - * {@link BluetoothAdapter} was added to the system. - * @param adapter the newly added {@link BluetoothAdapter} to the system + * {@link BTAdapter} was added to the system. + * @param adapter the newly added {@link BTAdapter} to the system */ - void adapterAdded(final BluetoothAdapter adapter); + void adapterAdded(final BTAdapter adapter); /** - * {@link BluetoothAdapter} was removed from the system. + * {@link BTAdapter} was removed from the system. * <p> - * {@link BluetoothAdapter#close()} is being called by the native manager after issuing all - * {@link #adapterRemoved(BluetoothAdapter)} calls. + * {@link BTAdapter#close()} is being called by the native manager after issuing all + * {@link #adapterRemoved(BTAdapter)} calls. * </p> - * @param adapter the removed {@link BluetoothAdapter} from the system + * @param adapter the removed {@link BTAdapter} from the system */ - void adapterRemoved(final BluetoothAdapter adapter); + void adapterRemoved(final BTAdapter adapter); } /** @@ -134,7 +134,7 @@ public interface BluetoothManager * @return An object matching the name, identifier, parent or null if not found before * timeout expires or event is canceled. */ - public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent, long timeoutMS); + public BTObject find(BTType type, String name, String identifier, BTObject parent, long timeoutMS); /** Find a BluetoothObject of a type matching type. If parameters name, @@ -153,7 +153,7 @@ public interface BluetoothManager * waiting for * @return An object matching the name, identifier and parent. */ - public BluetoothObject find(BluetoothType type, String name, String identifier, BluetoothObject parent); + public BTObject find(BTType type, String name, String identifier, BTObject parent); /** Find a BluetoothObject of type T. If parameters name, identifier and * parent are not null, the returned object will have to match them. @@ -171,7 +171,7 @@ public interface BluetoothManager * @return An object matching the name, identifier, parent or null if not found before * timeout expires or event is canceled. */ - public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent, long timeoutMS); + public <T extends BTObject> T find(String name, String identifier, BTObject parent, long timeoutMS); /** Find a BluetoothObject of type T. If parameters name, identifier and * parent are not null, the returned object will have to match them. @@ -186,7 +186,7 @@ public interface BluetoothManager * waiting for * @return An object matching the name, identifier and parent. */ - public <T extends BluetoothObject> T find(String name, String identifier, BluetoothObject parent); + public <T extends BTObject> T find(String name, String identifier, BTObject parent); /** Return a BluetoothObject of a type matching type. If parameters name, * identifier and parent are not null, the returned object will have to @@ -202,8 +202,8 @@ public interface BluetoothManager * waiting for * @return An object matching the name, identifier, parent or null if not found. */ - public BluetoothObject getObject(BluetoothType type, String name, - String identifier, BluetoothObject parent); + public BTObject getObject(BTType type, String name, + String identifier, BTObject parent); /** Return a List of BluetoothObject of a type matching type. If parameters name, * identifier and parent are not null, the returned object will have to @@ -219,13 +219,13 @@ public interface BluetoothManager * waiting for * @return A vector of object matching the name, identifier, parent. */ - public List<BluetoothObject> getObjects(BluetoothType type, String name, - String identifier, BluetoothObject parent); + public List<BTObject> getObjects(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 */ - public List<BluetoothAdapter> getAdapters(); + public List<BTAdapter> getAdapters(); /** * Returns the BluetoothAdapter matching the given dev_id or null if not found. @@ -237,29 +237,29 @@ public interface BluetoothManager * @since 2.0.0 * @implNote Not implemented on tinyb.dbus */ - public BluetoothAdapter getAdapter(final int dev_id); + public BTAdapter getAdapter(final int dev_id); /** Returns a list of discovered BluetoothDevices * @return A list of discovered BluetoothDevices */ - public List<BluetoothDevice> getDevices(); + public List<BTDevice> getDevices(); /** Returns a list of available BluetoothGattServices * @return A list of available BluetoothGattServices */ - public List<BluetoothGattService> getServices(); + public List<BTGattService> getServices(); /** * Sets a default adapter to use for discovery. * @return TRUE if the device was set * @implNote not implemented for direct_bt.tinyb */ - public boolean setDefaultAdapter(BluetoothAdapter adapter); + public boolean setDefaultAdapter(BTAdapter adapter); /** * Gets the default adapter to use for discovery. * <p> - * <i>direct_bt.tinyb</i>: The default adapter is either the first {@link BluetoothAdapter#isPowered() powered} {@link BluetoothAdapter}, + * <i>direct_bt.tinyb</i>: The default adapter is either the first {@link BTAdapter#isPowered() powered} {@link BTAdapter}, * or function returns nullptr if none is enabled. * </p> * <p> @@ -267,14 +267,14 @@ public interface BluetoothManager * </p> * @return the used default adapter */ - public BluetoothAdapter getDefaultAdapter(); + public BTAdapter getDefaultAdapter(); /** Turns on device discovery on the default adapter if it is disabled. * @return TRUE if discovery was successfully enabled * @deprecated since 2.0.0, use {@link #startDiscovery(boolean)}. */ @Deprecated - public boolean startDiscovery() throws BluetoothException; + public boolean startDiscovery() throws BTException; /** * Turns on device discovery on the default adapter if it is disabled. @@ -284,11 +284,11 @@ public interface BluetoothManager * and {@link #stopDiscovery()} is the recommended workflow * for a reliable discovery process. * @return {@link HCIStatusCode#SUCCESS} if successful, otherwise the {@link HCIStatusCode} error state - * @throws BluetoothException + * @throws BTException * @since 2.0.0 * @implNote {@code keepAlive} not implemented in tinyb.dbus */ - public HCIStatusCode startDiscovery(final boolean keepAlive) throws BluetoothException; + public HCIStatusCode startDiscovery(final boolean keepAlive) throws BTException; /** * Turns off device discovery on the default adapter if it is enabled. @@ -296,12 +296,12 @@ public interface BluetoothManager * @apiNote return {@link HCIStatusCode} since 2.0.0 * @since 2.0.0 */ - public HCIStatusCode stopDiscovery() throws BluetoothException; + public HCIStatusCode stopDiscovery() throws BTException; /** Returns if the discovers is running or not. * @return TRUE if discovery is running */ - public boolean getDiscovering() throws BluetoothException; + public boolean getDiscovering() throws BTException; /** * Add the given {@link ChangedAdapterSetListener} to this manager. diff --git a/java/org/direct_bt/BluetoothNotification.java b/java/org/direct_bt/BTNotification.java index 01e145bb..961008f7 100644 --- a/java/org/direct_bt/BluetoothNotification.java +++ b/java/org/direct_bt/BTNotification.java @@ -30,6 +30,6 @@ package org.direct_bt; * to the enable*Notifications function. When a notification of that type is received, * the run function of the class will be called. */ -public interface BluetoothNotification<T> { +public interface BTNotification<T> { public void run(T value); } diff --git a/java/org/direct_bt/BluetoothObject.java b/java/org/direct_bt/BTObject.java index df90df4a..05821e48 100644 --- a/java/org/direct_bt/BluetoothObject.java +++ b/java/org/direct_bt/BTObject.java @@ -27,17 +27,17 @@ */ package org.direct_bt; -public interface BluetoothObject extends Cloneable, AutoCloseable +public interface BTObject extends Cloneable, AutoCloseable { /** Returns the BluetoothType of this object * @return The BluetoothType of this object */ - public BluetoothType getBluetoothType(); + public BTType getBluetoothType(); /** Returns a clone of the BluetoothObject * @return A clone of the BluetoothObject */ - public BluetoothObject clone(); + public BTObject clone(); @Override public boolean equals(Object obj); diff --git a/java/org/direct_bt/BluetoothType.java b/java/org/direct_bt/BTType.java index ef62d803..07817897 100644 --- a/java/org/direct_bt/BluetoothType.java +++ b/java/org/direct_bt/BTType.java @@ -24,7 +24,7 @@ package org.direct_bt; -public enum BluetoothType +public enum BTType { NONE, ADAPTER, DEVICE, GATT_SERVICE, GATT_CHARACTERISTIC, diff --git a/java/org/direct_bt/BluetoothUtils.java b/java/org/direct_bt/BTUtils.java index 99ded5a9..e2266856 100644 --- a/java/org/direct_bt/BluetoothUtils.java +++ b/java/org/direct_bt/BTUtils.java @@ -24,7 +24,7 @@ */ package org.direct_bt; -public class BluetoothUtils { +public class BTUtils { private static long t0; static { t0 = startupTimeMillisImpl(); @@ -62,8 +62,8 @@ public class BluetoothUtils { * @param min_result_ms the minimum resulting supervisor timeout, defaults to 500ms. * If above formula results in a smaller value, min_result_ms/10 will be returned. * @param multiplier recommendation is 6, we use 10 as default for safety. - * @return the resulting supervising timeout in 1/10 [ms], suitable for the {@link BluetoothDevice#connectLE(short, short, short, short, short, short)}. - * @see BluetoothDevice#connectLE(short, short, short, short, short, short) + * @return the resulting supervising timeout in 1/10 [ms], suitable for the {@link BTDevice#connectLE(short, short, short, short, short, short)}. + * @see BTDevice#connectLE(short, short, short, short, short, short) */ public static int getHCIConnSupervisorTimeout(final int conn_latency, final int conn_interval_max_ms, final int min_result_ms, final int multiplier) { diff --git a/java/org/direct_bt/EUI48.java b/java/org/direct_bt/EUI48.java index 1d9c2618..2d4b2756 100644 --- a/java/org/direct_bt/EUI48.java +++ b/java/org/direct_bt/EUI48.java @@ -241,7 +241,7 @@ public class EUI48 { public final String toString() { final StringBuilder sb = new StringBuilder(17); for(int i=byte_size-1; 0 <= i; i--) { - BluetoothUtils.byteHexString(sb, b[i], false /* lowerCase */); + BTUtils.byteHexString(sb, b[i], false /* lowerCase */); if( 0 < i ) { sb.append(":"); } diff --git a/java/org/direct_bt/ObjectArgCallback.java b/java/org/direct_bt/ObjectArgCallback.java index a2f22f48..36430f8a 100644 --- a/java/org/direct_bt/ObjectArgCallback.java +++ b/java/org/direct_bt/ObjectArgCallback.java @@ -26,7 +26,7 @@ package org.direct_bt; import tinyb.dbus.DBusObject; -public class ObjectArgCallback extends BluetoothCallback +public class ObjectArgCallback extends BTCallback { @SuppressWarnings("unused") private final Object callbackArg; diff --git a/java/org/direct_bt/ObjectArrayArgCallback.java b/java/org/direct_bt/ObjectArrayArgCallback.java index 59d2d72e..8fb196b4 100644 --- a/java/org/direct_bt/ObjectArrayArgCallback.java +++ b/java/org/direct_bt/ObjectArrayArgCallback.java @@ -26,7 +26,7 @@ package org.direct_bt; import tinyb.dbus.DBusObject; -public class ObjectArrayArgCallback extends BluetoothCallback +public class ObjectArrayArgCallback extends BTCallback { @SuppressWarnings("unused") private final Object[] callbackArg; diff --git a/java/org/direct_bt/PlatformToolkit.java b/java/org/direct_bt/PlatformToolkit.java index decee20c..480200e3 100644 --- a/java/org/direct_bt/PlatformToolkit.java +++ b/java/org/direct_bt/PlatformToolkit.java @@ -279,7 +279,7 @@ final class PlatformToolkit { final String _os_arch2 = getArchName(CPU_TYPE, ABI_TYPE, LITTLE_ENDIAN); os_arch = null != _os_arch2 ? _os_arch2 : _os_arch1; os_and_arch = os_name+"-"+os_arch; - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println("PlatformToolkit: os_name "+os_name+", os_arch ("+_os_arch1+" -> "+_os_arch2+" ->) "+os_arch+" (final), "+ "CPU_TYPE "+CPU_TYPE+", ABI_TYPE "+ABI_TYPE+", LITTLE_ENDIAN "+LITTLE_ENDIAN); } @@ -458,7 +458,7 @@ final class PlatformToolkit { // f.getCanonicalPath() also resolved '.', '..' and symbolic links in contrast to f.getAbsolutePath() return f.getCanonicalPath(); } catch (final Throwable t) { - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println("getAbsolutePath("+path+") failed: "+t.getMessage()); } return null; @@ -471,7 +471,7 @@ final class PlatformToolkit { final String abspath = getCanonicalPath(fullpath); if( null != abspath ) { final boolean isDup = paths.contains(abspath); - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(" "+abspath+" (addPath "+msg+", dropped duplicate "+isDup+")"); } if( !isDup ) { @@ -542,12 +542,12 @@ final class PlatformToolkit { * @return {@code true} if successful, otherwise {@code false}. */ static boolean loadLibrary(final String libBaseName, final ClassLoader cl, final Throwable[] t) { - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(); System.err.println("PlatformToolkit.loadLibrary: libBaseName "+libBaseName+":"); } final List<String> possiblePaths = enumerateLibraryPaths(libBaseName, true /* searchSystemPath */, false /* searchSystemPathFirst */, cl); - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(); } @@ -556,12 +556,12 @@ final class PlatformToolkit { final String path = iter.next(); try { System.load(path); - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(" "+path+" success"); } return true; } catch (final Throwable t0) { - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(" "+path+" failed: "+t0.getMessage()); } t[0] = t0; @@ -571,12 +571,12 @@ final class PlatformToolkit { // Fall back to loadLibrary try { System.loadLibrary(libBaseName); - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(" "+libBaseName+" success"); } return true; } catch (final Throwable t0) { - if( BluetoothFactory.DEBUG ) { + if( BTFactory.DEBUG ) { System.err.println(" "+libBaseName+" failed: "+t0.getMessage()); } t[0] = t0; diff --git a/java/org/direct_bt/SMPLongTermKeyInfo.java b/java/org/direct_bt/SMPLongTermKeyInfo.java index ce3e3254..7db7455e 100644 --- a/java/org/direct_bt/SMPLongTermKeyInfo.java +++ b/java/org/direct_bt/SMPLongTermKeyInfo.java @@ -208,9 +208,9 @@ public class SMPLongTermKeyInfo { @Override public String toString() { // hex-fmt aligned with btmon return "LTK[props "+properties.toString()+", enc_size "+enc_size+ - ", ediv "+BluetoothUtils.bytesHexString(ediv, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+ - ", rand "+BluetoothUtils.bytesHexString(rand, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+ - ", ltk "+BluetoothUtils.bytesHexString(ltk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+ + ", ediv "+BTUtils.bytesHexString(ediv, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+ + ", rand "+BTUtils.bytesHexString(rand, 0, -1, false /* lsbFirst */, true /* leading0X */, true /* lowerCase */)+ + ", ltk "+BTUtils.bytesHexString(ltk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+ "]"; } diff --git a/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java b/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java index c517741f..89e8428c 100644 --- a/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java +++ b/java/org/direct_bt/SMPSignatureResolvingKeyInfo.java @@ -180,7 +180,7 @@ public class SMPSignatureResolvingKeyInfo { @Override public String toString() { // hex-fmt aligned with btmon return "LTK[props "+properties.toString()+ - ", csrk "+BluetoothUtils.bytesHexString(csrk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+ + ", csrk "+BTUtils.bytesHexString(csrk, 0, -1, true /* lsbFirst */, false /* leading0X */, true /* lowerCase */)+ "]"; } |