diff options
author | Sven Gothel <[email protected]> | 2021-02-01 16:59:36 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-02-01 16:59:36 +0100 |
commit | 616dc84e1a4fc4dbff1374baeacdfb9315fa4e34 (patch) | |
tree | f2886e590bb74ef181f25dc1fbaf6169e0d0c96b /java/org | |
parent | d9bf9549679fee3af82891ad2040b44102a669cc (diff) |
BTDevice: Add automatic security negotiation of BTSecurityLevel and SMPIOCapability pairing mode - 'setConnSecurityAuto(const SMPIOCapability iocap_auto)'
See BTDevice::setConnSecurityAuto(..).
Added to C++ and Java.
SMPPDUMsg::Opcode::PAIRING_FAILED in hciSMPMsgCallback(..),
will no more lead to L2CAP reopening w/o encryption, but device left in failed pairing state connected.
Diffstat (limited to 'java/org')
-rw-r--r-- | java/org/direct_bt/BTDevice.java | 43 |
1 files changed, 43 insertions, 0 deletions
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}, |