From: Martin Fuzzey <mfuzzey@parkeon.com>
To: linux-bluetooth@vger.kernel.org
Subject: [BlueZ PATCH 2/3] android: Get max advertising instances from kernel
Date: Tue, 10 Oct 2017 11:27:53 +0200 [thread overview]
Message-ID: <20171010092753.30705.21331.stgit@localhost> (raw)
In-Reply-To: <20171010092748.30705.23283.stgit@localhost>
Use the mgmnt "advinfo" operation to obtain the number of advertising
instances supported by the kernel.
Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com>
---
android/bluetooth.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 8ea521e..ba8f405 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -3345,6 +3345,37 @@ static void clear_auto_connect_list(void)
error("Could not clear auto connect list");
}
+static void read_adv_features_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ const struct mgmt_rp_read_adv_features *rp = param;
+ bt_bluetooth_ready cb = user_data;
+ int err;
+
+ if (status) {
+ error("Failed to read advertising features for index %u: %s (0x%02x)",
+ adapter.index, mgmt_errstr(status), status);
+ err = -EIO;
+ goto failed;
+ }
+
+ if (length < sizeof(*rp)) {
+ error("Too small read advertising features response");
+ err = -EIO;
+ goto failed;
+ }
+
+ adapter.max_advert_instance = rp->max_instances;
+ info("Max LE advertising instances: %d", adapter.max_advert_instance);
+
+ load_devices_info(cb);
+
+ return;
+
+failed:
+ cb(err, NULL);
+}
+
static void read_info_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -3416,7 +3447,17 @@ static void read_info_complete(uint8_t status, uint16_t length,
if (missing_settings & MGMT_SETTING_BONDABLE)
set_mode(MGMT_OP_SET_BONDABLE, 0x01);
- load_devices_info(cb);
+ if (adapter.supported_settings & MGMT_SETTING_LE) {
+ if (mgmt_send(mgmt_if, MGMT_OP_READ_ADV_FEATURES, adapter.index, 0, NULL,
+ read_adv_features_complete, cb, NULL) == 0) {
+ error("Cannot get LE adv features");
+ err = -EIO;
+ goto failed;
+ }
+ } else {
+ load_devices_info(cb);
+ }
+
load_devices_cache();
return;
next prev parent reply other threads:[~2017-10-10 9:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 9:27 [PATCH BlueZ 0/3] android: Add LE Peripheral role support Martin Fuzzey
2017-10-10 9:27 ` [BlueZ PATCH 1/3] android: Do not fail if empty keyset cannot be loaded Martin Fuzzey
2017-10-11 7:32 ` Szymon Janc
2017-10-10 9:27 ` Martin Fuzzey [this message]
2017-10-10 9:27 ` [BlueZ PATCH 3/3] android: Enable multiadvertising Martin Fuzzey
2017-10-11 7:33 ` Szymon Janc
2017-10-13 13:32 ` Martin Fuzzey
2017-10-11 10:15 ` Luiz Augusto von Dentz
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=20171010092753.30705.21331.stgit@localhost \
--to=mfuzzey@parkeon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.