From: Hemant Gupta <hemant.gupta@stericsson.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Hemant Gupta <hemant.gupta@stericsson.com>
Subject: [PATCH v1] mgmtops: Handle Start Discovery Complete in case of failure
Date: Tue, 10 Apr 2012 15:43:27 +0530 [thread overview]
Message-ID: <1334052807-14320-1-git-send-email-hemant.gupta@stericsson.com> (raw)
This patch adds handling of start discovery complete event in cases
when discovery fails to get started.
---
plugins/mgmtops.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index c08117f..9de490d 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1255,6 +1255,37 @@ static void read_local_oob_data_complete(int sk, uint16_t index, void *buf,
oob_read_local_data_complete(adapter, rp->hash, rp->randomizer);
}
+static void start_discovery_complete(int sk, uint16_t index, uint8_t status,
+ void *buf, size_t len)
+{
+ uint8_t *type = buf;
+ struct btd_adapter *adapter;
+
+ if (len != sizeof(*type)) {
+ error("start_discovery_complete event size mismatch "
+ "(%zu != %zu)", len, sizeof(*type));
+ return;
+ }
+
+ DBG("type %u status %u", *type, status);
+
+ if (index > max_index) {
+ error("Unexpected index %u in start_discovery_complete",
+ index);
+ return;
+ }
+
+ if (!status)
+ return;
+
+ DBG("hci%u", index);
+
+ adapter = manager_find_adapter_by_id(index);
+ if (adapter)
+ /* Start discovery failed, inform upper layers. */
+ adapter_set_discovering(adapter, FALSE);
+}
+
static void read_local_oob_data_failed(int sk, uint16_t index)
{
struct btd_adapter *adapter;
@@ -1421,7 +1452,7 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
DBG("set_fast_connectable complete");
break;
case MGMT_OP_START_DISCOVERY:
- DBG("start_discovery complete");
+ start_discovery_complete(sk, index, ev->status, ev->data, len);
break;
case MGMT_OP_STOP_DISCOVERY:
DBG("stop_discovery complete");
--
1.7.0.4
next reply other threads:[~2012-04-10 10:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-10 10:13 Hemant Gupta [this message]
2012-04-10 10:33 ` [PATCH v1] mgmtops: Handle Start Discovery Complete in case of failure Johan Hedberg
2012-04-10 11:47 ` Hemant Gupta
2012-04-10 11:58 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1334052807-14320-1-git-send-email-hemant.gupta@stericsson.com \
--to=hemant.gupta@stericsson.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox