aboutsummaryrefslogtreecommitdiffstats
path: root/java/jni
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-10-29 05:49:43 +0200
committerSven Gothel <[email protected]>2021-10-29 05:49:43 +0200
commit88456111f8020081eeea719143f42584a62f8ac6 (patch)
treefb77f5cf0a287cb0b982ba7570231868579685a7 /java/jni
parent4f0f232301a2a2ffc1e396e29ccf8ab423edece6 (diff)
Add BTAdapter's Slave Peripheral SMP Key Management
To have full SMP key persitency in peripheral slave mode, BTAdapter requires fine grained control over - Passing stored keys to BTDevice's PairingData (w/o uploading them) - Uploading BTDevice's PairingData to the adapter This required interaction in certain places, only enabled if adapter is BTRole::Slave (peripheral): - BTAdapter::mgmtEvDeviceConnectedHCI() Only issue unpairDevice() if not pre-paired. Unpairing is required for new pairing to avoid DHKey Check failures! - BTAdapter::mgmtEvDeviceDisconnectedHCI() - First unpairDevice() will be issued via notifyDisconnect() - Set and upload stored keys for disconnected device (if existing), preparing for next connect. - BTAdapter::sendDevicePairingState() - SMPPairingState::COMPLETED && not SMPPairingState::PRE_PAIRED: Store keys - SMPPairingState::COMPLETED && SMPPairingState::PRE_PAIRED: Refresh keys to BTDevice (set), no upload! - SMPPairingState::FAILED: Remove and delete keys +++ BTAdapter::setSMPKeyPath(path) allows user to enable the persistent key storage by setting its local filesystem path. It will also read all key files (SMPKeyBin) and if valid and matching with the adapter, uploads them for pre-pairing. See dbt_peripheral00.cpp: adapter->setSMPKeyPath(ADAPTER_KEY_PATH); +++
Diffstat (limited to 'java/jni')
-rw-r--r--java/jni/direct_bt/DBTAdapter.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/java/jni/direct_bt/DBTAdapter.cxx b/java/jni/direct_bt/DBTAdapter.cxx
index 524f2064..9af80f24 100644
--- a/java/jni/direct_bt/DBTAdapter.cxx
+++ b/java/jni/direct_bt/DBTAdapter.cxx
@@ -910,6 +910,17 @@ jboolean Java_jau_direct_1bt_DBTAdapter_setSecureConnections(JNIEnv *env, jobjec
return JNI_FALSE;
}
+void Java_jau_direct_1bt_DBTAdapter_setSMPKeyPath(JNIEnv *env, jobject obj, jstring jpath) {
+ try {
+ BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);
+ jau::JavaGlobalObj::check(adapter->getJavaObject(), E_FILE_LINE);
+ std::string path = jau::from_jstring_to_string(env, jpath);
+ adapter->setSMPKeyPath(path);
+ } catch(...) {
+ rethrow_and_raise_java_exception(env);
+ }
+}
+
jbyte Java_jau_direct_1bt_DBTAdapter_initializeImpl(JNIEnv *env, jobject obj, jbyte jbtMode) {
try {
BTAdapter *adapter = jau::getJavaUplinkObject<BTAdapter>(env, obj);