From 5232f762143bcd340c97826ca1212c4d5b07575a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 6 Jun 2012 09:02:23 +0300 Subject: [PATCH] attrib: Fix always requiring high security If we get an insufficient encryption error for ATT it doesn't necessarily mean that we need to have high secirity. If we have an unauthenticated key and are unencrypted it could also mean that we just need to encrypt the link (medium security). Always requiring high security would make the connection fail for unauthenticated keys. --- attrib/client.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/attrib/client.c b/attrib/client.c index 7aefd963e..8d119df09 100644 --- a/attrib/client.c +++ b/attrib/client.c @@ -702,9 +702,17 @@ static void update_char_desc(guint8 status, const guint8 *pdu, guint16 len, (void *) chr->desc, len); } else if (status == ATT_ECODE_INSUFF_ENC) { GIOChannel *io = g_attrib_get_channel(gatt->attrib); + BtIOSecLevel level = BT_IO_SEC_HIGH; + + bt_io_get(io, BT_IO_L2CAP, NULL, + BT_IO_OPT_SEC_LEVEL, &level, + BT_IO_OPT_INVALID); + + if (level < BT_IO_SEC_HIGH) + level++; if (bt_io_set(io, BT_IO_L2CAP, NULL, - BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_HIGH, + BT_IO_OPT_SEC_LEVEL, level, BT_IO_OPT_INVALID)) { gatt_read_char(gatt->attrib, current->handle, 0, update_char_desc, current); -- 2.47.3