aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-01-13 05:36:46 +0100
committerSven Gothel <[email protected]>2022-01-13 05:36:46 +0100
commitd9a3326e83951c9f1378ff53845c4193a798a352 (patch)
tree242622f7e8c335fdb08f8c7ba08de49dd058abf5 /java
parent48ff06cd7a4ebe0e22f82ac949624130f66dcdd1 (diff)
Add BTAdapter::setServerConnSecurity(..)
Diffstat (limited to 'java')
-rw-r--r--java/jau/direct_bt/DBTAdapter.java8
-rw-r--r--java/jni/direct_bt/DBTAdapter.cxx12
-rw-r--r--java/org/direct_bt/BTAdapter.java14
3 files changed, 34 insertions, 0 deletions
diff --git a/java/jau/direct_bt/DBTAdapter.java b/java/jau/direct_bt/DBTAdapter.java
index 88a7f2a4..0d83eaee 100644
--- a/java/jau/direct_bt/DBTAdapter.java
+++ b/java/jau/direct_bt/DBTAdapter.java
@@ -44,6 +44,7 @@ import org.direct_bt.BTException;
import org.direct_bt.BTManager;
import org.direct_bt.BTMode;
import org.direct_bt.BTRole;
+import org.direct_bt.BTSecurityLevel;
import org.direct_bt.BTUtils;
import org.direct_bt.DBGattServer;
import org.direct_bt.DiscoveryPolicy;
@@ -54,6 +55,7 @@ import org.direct_bt.HCIWhitelistConnectType;
import org.direct_bt.LE_Features;
import org.direct_bt.LE_PHYs;
import org.direct_bt.PairingMode;
+import org.direct_bt.SMPIOCapability;
import org.direct_bt.SMPPairingState;
import org.direct_bt.ScanType;
import org.jau.net.EUI48;
@@ -284,6 +286,12 @@ public class DBTAdapter extends DBTObject implements BTAdapter
public native boolean setSecureConnections(final boolean enable);
@Override
+ public final void setServerConnSecurity(final BTSecurityLevel sec_level, final SMPIOCapability io_cap) {
+ setServerConnSecurityImpl(sec_level.value, io_cap.value);
+ }
+ private final native void setServerConnSecurityImpl(final byte sec_level, final byte io_cap);
+
+ @Override
public native void setSMPKeyPath(final String path);
@Override
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx
index 27e50b75..60db4b36 100644
--- a/java/jni/direct_bt/DBTAdapter.cxx
+++ b/java/jni/direct_bt/DBTAdapter.cxx
@@ -845,6 +845,18 @@ jboolean Java_jau_direct_1bt_DBTAdapter_setSecureConnections(JNIEnv *env, jobjec
return JNI_FALSE;
}
+void Java_jau_direct_1bt_DBTAdapter_setServerConnSecurityImpl(JNIEnv *env, jobject obj, jbyte jsec_level, jbyte jio_cap) {
+ try {
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
+ jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
+
+ adapter->setServerConnSecurity( to_BTSecurityLevel( static_cast<uint8_t>(jsec_level) ),
+ to_SMPIOCapability( static_cast<uint8_t>(jio_cap) ) );
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+}
+
void Java_jau_direct_1bt_DBTAdapter_setSMPKeyPath(JNIEnv *env, jobject obj, jstring jpath) {
try {
BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
diff --git a/java/org/direct_bt/BTAdapter.java b/java/org/direct_bt/BTAdapter.java
index a0b4013b..615fdae3 100644
--- a/java/org/direct_bt/BTAdapter.java
+++ b/java/org/direct_bt/BTAdapter.java
@@ -578,6 +578,20 @@ public interface BTAdapter extends BTObject
boolean setSecureConnections(final boolean enable);
/**
+ * Sets the given ::BTSecurityLevel and ::SMPIOCapability for connecting device when in server (peripheral) mode, see [adapter's role](@ref BTAdapterRoles).
+ * <p>
+ * Method either changes both parameter for the upcoming connection or none at all.
+ * </p>
+ * @param[in] sec_level ::BTSecurityLevel to be applied.
+ * @param[in] io_cap ::SMPIOCapability to be applied.
+ * @see BTSecurityLevel
+ * @see SMPIOCapability
+ * @see BTDevice#setConnSecurity(BTSecurityLevel, SMPIOCapability)
+ * @see #startAdvertising(DBGattServer, EInfoReport, EIRDataTypeSet, EIRDataTypeSet, short, short, byte, byte, byte)
+ */
+ void setServerConnSecurity(final BTSecurityLevel sec_level, final SMPIOCapability io_cap);
+
+ /**
* Set the adapter's persistent storage directory for {@link SMPKeyBin} files.
* - if set, all {@link SMPKeyBin} instances will be managed and persistent.
* - if not set, all {@link SMPKeyBin} instances will be transient only.