diff --git a/src/shared/att-types.h b/src/shared/att-types.h
index ee20992..d474495 100644
--- a/src/shared/att-types.h
+++ b/src/shared/att-types.h
#define __packed __attribute__((packed))
#endif
-#define BT_ATT_SECURITY_NONE 0
+#define BT_ATT_SECURITY_AUTO 0
#define BT_ATT_SECURITY_LOW 1
#define BT_ATT_SECURITY_MEDIUM 2
#define BT_ATT_SECURITY_HIGH 3
diff --git a/src/shared/att.c b/src/shared/att.c
index e8be4cc..70f5d72 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
int security;
security = bt_att_get_security(att);
+ if (security != BT_ATT_SECURITY_AUTO)
+ return false;
+
if (ecode == BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION &&
security < BT_ATT_SECURITY_MEDIUM)
security = BT_ATT_SECURITY_MEDIUM;
*opcode = rsp->opcode;
- /* Only try to change security on L2CAP */
- if (!att->io_on_l2cap)
- return false;
-
/* Attempt to change security */
if (!change_security(att, rsp->ecode))
return false;
{
struct bt_security sec;
- if (!att || level < BT_ATT_SECURITY_LOW || level > BT_ATT_SECURITY_HIGH)
+ if (!att || level < BT_ATT_SECURITY_AUTO ||
+ level > BT_ATT_SECURITY_HIGH)
return false;
if (!att->io_on_l2cap) {