All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: szymon.janc@tieto.com, Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH v3 1/2] android/bluetooth: Expose API to set advertising
Date: Mon, 14 Apr 2014 22:53:06 +0200	[thread overview]
Message-ID: <1397508787-25137-1-git-send-email-lukasz.rymanowski@tieto.com> (raw)

With this patch android GAP expose start/stop advertising API
---
 android/bluetooth.c | 41 +++++++++++++++++++++++++++++++++++++++++
 android/bluetooth.h |  4 ++++
 2 files changed, 45 insertions(+)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index b3fad59..93c7935 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2882,6 +2882,47 @@ static bool stop_discovery(uint8_t type)
 	return false;
 }
 
+struct adv_user_data {
+	bt_le_set_advertising_done cb;
+	void *user_data;
+};
+
+static void set_advertising_cb(uint8_t status, uint16_t length,
+			const void *param, void *user_data)
+{
+	struct adv_user_data *data = user_data;
+
+	DBG("");
+
+	if (status)
+		error("Failed to set adverising %s (0x%02x))",
+						mgmt_errstr(status), status);
+
+	data->cb(status, data->user_data);
+}
+
+bool bt_le_set_advertising(bool advertising, bt_le_set_advertising_done cb,
+							 void *user_data)
+{
+	struct adv_user_data *data;
+	uint8_t adv = advertising ? 0x01 : 0x00;
+
+	data = new0(struct adv_user_data, 1);
+	if (!data)
+		return false;
+
+	data->cb = cb;
+	data->user_data = user_data;
+
+	if (mgmt_send(mgmt_if, MGMT_OP_SET_ADVERTISING, adapter.index,
+			sizeof(adv), &adv, set_advertising_cb, data, free) > 0)
+		return true;
+
+	error("Failed to set advertising");
+	free(data);
+	return false;
+}
+
 bool bt_le_discovery_stop(bt_le_discovery_stopped cb)
 {
 	if (!adapter.cur_discovery_type) {
diff --git a/android/bluetooth.h b/android/bluetooth.h
index 807ebe7..3eddf16 100644
--- a/android/bluetooth.h
+++ b/android/bluetooth.h
@@ -42,3 +42,7 @@ bool bt_le_discovery_start(bt_le_device_found cb);
 
 typedef void (*bt_le_discovery_stopped)(void);
 bool bt_le_discovery_stop(bt_le_discovery_stopped cb);
+
+typedef void (*bt_le_set_advertising_done)(uint8_t status, void *user_data);
+bool bt_le_set_advertising(bool advertising, bt_le_set_advertising_done cb,
+							void *user_data);
-- 
1.8.4


             reply	other threads:[~2014-04-14 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-14 20:53 Lukasz Rymanowski [this message]
2014-04-14 20:53 ` [PATCH v3 2/2] android/gatt: Add support for client listen command Lukasz Rymanowski
2014-04-16  9:46 ` [PATCH v3 1/2] android/bluetooth: Expose API to set advertising Szymon Janc

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=1397508787-25137-1-git-send-email-lukasz.rymanowski@tieto.com \
    --to=lukasz.rymanowski@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=szymon.janc@tieto.com \
    /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.