aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/jau/direct_bt/DBTDevice.java9
-rw-r--r--java/jni/direct_bt/DBTDevice.cxx24
-rw-r--r--java/org/direct_bt/BTDevice.java43
-rw-r--r--java/tinyb/dbus/DBusDevice.java6
4 files changed, 82 insertions, 0 deletions
diff --git a/java/jau/direct_bt/DBTDevice.java b/java/jau/direct_bt/DBTDevice.java
index a1d1d6ee..1985aae9 100644
--- a/java/jau/direct_bt/DBTDevice.java
+++ b/java/jau/direct_bt/DBTDevice.java
@@ -409,6 +409,15 @@ public class DBTDevice extends DBTObject implements BTDevice
}
@Override
+ public final boolean setConnSecurityAuto(final SMPIOCapability iocap_auto) {
+ return setConnSecurityAutoImpl( iocap_auto.value );
+ }
+ private final native boolean setConnSecurityAutoImpl(final byte io_cap);
+
+ @Override
+ public final native boolean isConnSecurityAutoEnabled();
+
+ @Override
public HCIStatusCode setPairingPasskey(final int passkey) {
return HCIStatusCode.get( setPairingPasskeyImpl(passkey) );
}
diff --git a/java/jni/direct_bt/DBTDevice.cxx b/java/jni/direct_bt/DBTDevice.cxx
index b3881ac8..0e56eb6e 100644
--- a/java/jni/direct_bt/DBTDevice.cxx
+++ b/java/jni/direct_bt/DBTDevice.cxx
@@ -564,6 +564,30 @@ jbyte Java_jau_direct_1bt_DBTDevice_getPairingStateImpl(JNIEnv *env, jobject obj
return static_cast<uint8_t>( SMPPairingState::NONE );
}
+jboolean Java_jau_direct_1bt_DBTDevice_setConnSecurityAutoImpl(JNIEnv *env, jobject obj, jbyte jio_cap) {
+ try {
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
+ JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
+
+ return device->setConnSecurityAuto( getSMPIOCapability( static_cast<uint8_t>(jio_cap) ) );
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+ return JNI_FALSE;
+}
+
+jboolean Java_jau_direct_1bt_DBTDevice_isConnSecurityAutoEnabled(JNIEnv *env, jobject obj) {
+ try {
+ BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
+ JavaGlobalObj::check(device->getJavaObject(), E_FILE_LINE);
+
+ return device->isConnSecurityAutoEnabled();
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+ return JNI_FALSE;
+}
+
jbyte Java_jau_direct_1bt_DBTDevice_setPairingPasskeyImpl(JNIEnv *env, jobject obj, jint jpasskey) {
try {
BTDevice *device = getJavaUplinkObject<BTDevice>(env, obj);
diff --git a/java/org/direct_bt/BTDevice.java b/java/org/direct_bt/BTDevice.java
index 20460792..cb28f0d6 100644
--- a/java/org/direct_bt/BTDevice.java
+++ b/java/org/direct_bt/BTDevice.java
@@ -387,10 +387,53 @@ public interface BTDevice extends BTObject
* @see #setConnIOCapability(SMPIOCapability)
* @see #getConnIOCapability()
* @see #setConnSecurity(BTSecurityLevel, SMPIOCapability)
+ * @see #setConnSecurityAuto(SMPIOCapability)
*/
boolean setConnSecurityBest(final BTSecurityLevel sec_level, final SMPIOCapability io_cap);
/**
+ * Set automatic security negotiation of {@link BTSecurityLevel} and {@link SMPIOCapability} pairing mode.
+ * <p>
+ * Disabled by default and if set to {@link SMPIOCapability#NO_INPUT_NO_OUTPUT}
+ * </p>
+ * Implementation iterates through below setup from highest security to lowest,
+ * while performing a full connection attempt for each.
+ * <pre>
+ * BTSecurityLevel::ENC_AUTH_FIPS, iocap_auto*
+ * BTSecurityLevel::ENC_AUTH, iocap_auto*
+ * BTSecurityLevel::ENC_ONLY, SMPIOCapability::NO_INPUT_NO_OUTPUT
+ * BTSecurityLevel::NONE, SMPIOCapability::NO_INPUT_NO_OUTPUT
+ *
+ * (*): user SMPIOCapability choice of for authentication IO, skipped if ::SMPIOCapability::NO_INPUT_NO_OUTPUT
+ * </pre>
+ * <p>
+ * Implementation may perform multiple connection and disconnect actions
+ * until successful pairing or failure.
+ * </p>
+ * <p>
+ * Intermediate {@link AdapterStatusListener#deviceConnected(BTDevice, short, long) deviceConnected(..)} and
+ * {@link AdapterStatusListener#deviceDisconnected(BTDevice, HCIStatusCode, short, long) deviceDisconnected(..)}
+ * callbacks are not delivered while negotiating. This avoids any interference by the user application.
+ * </p>
+ * @param auth_io_cap user {@link SMPIOCapability} choice for negotiation
+ * @since 2.2.0
+ * @implNote not implemented in {@code tinyb.dbus}
+ * @see #isConnSecurityAutoEnabled()
+ * @see BTSecurityLevel
+ * @see SMPIOCapability
+ */
+ boolean setConnSecurityAuto(final SMPIOCapability iocap_auto);
+
+ /**
+ * Returns true if automatic security negotiation has been enabled via {@link #setConnSecurityAuto(SMPIOCapability)},
+ * otherwise false.
+ * @since 2.2.0
+ * @implNote not implemented in {@code tinyb.dbus}
+ * @see #setConnSecurityAuto(SMPIOCapability)
+ */
+ boolean isConnSecurityAutoEnabled();
+
+ /**
* 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},
diff --git a/java/tinyb/dbus/DBusDevice.java b/java/tinyb/dbus/DBusDevice.java
index 902efec0..42a37117 100644
--- a/java/tinyb/dbus/DBusDevice.java
+++ b/java/tinyb/dbus/DBusDevice.java
@@ -147,6 +147,12 @@ public class DBusDevice extends DBusObject implements BTDevice
public final boolean setConnSecurityBest(final BTSecurityLevel sec_level, final SMPIOCapability io_cap) { return false; } // FIXME
@Override
+ public final boolean setConnSecurityAuto(final SMPIOCapability iocap_auto) { return false; } // FIXME
+
+ @Override
+ public final boolean isConnSecurityAutoEnabled() { return false; } // FIXME
+
+ @Override
public HCIStatusCode setPairingPasskey(final int passkey) { return HCIStatusCode.INTERNAL_FAILURE; }
@Override