From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 09/15] android/scpp: Add bt_scpp_set_interval and bt_scpp_set_window
Date: Thu, 26 Jun 2014 17:46:42 +0300 [thread overview]
Message-ID: <1403794008-18585-9-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1403794008-18585-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
These functions can be used to change the current values.
---
android/scpp.c | 43 +++++++++++++++++++++++++++++++++++++------
android/scpp.h | 3 +++
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/android/scpp.c b/android/scpp.c
index c73a015..751d3f2 100644
--- a/android/scpp.c
+++ b/android/scpp.c
@@ -77,6 +77,9 @@ struct bt_scpp *bt_scpp_new(void *primary)
if (!scan)
return NULL;
+ scan->interval = SCAN_INTERVAL;
+ scan->window = SCAN_WINDOW;
+
if (primary)
scan->primary = g_memdup(primary, sizeof(*scan->primary));
@@ -104,12 +107,13 @@ void bt_scpp_unref(struct bt_scpp *scan)
scpp_free(scan);
}
-static void write_scan_params(GAttrib *attrib, uint16_t handle)
+static void write_scan_params(GAttrib *attrib, uint16_t handle,
+ uint16_t interval, uint16_t window)
{
uint8_t value[4];
- put_le16(SCAN_INTERVAL, &value[0]);
- put_le16(SCAN_WINDOW, &value[2]);
+ put_le16(interval, &value[0]);
+ put_le16(window, &value[2]);
gatt_write_cmd(attrib, handle, value, sizeof(value), NULL, NULL);
}
@@ -122,7 +126,8 @@ static void refresh_value_cb(const uint8_t *pdu, uint16_t len,
DBG("Server requires refresh: %d", pdu[3]);
if (pdu[3] == SERVER_REQUIRES_REFRESH)
- write_scan_params(scan->attrib, scan->iwhandle);
+ write_scan_params(scan->attrib, scan->iwhandle, scan->interval,
+ scan->window);
}
static void ccc_written_cb(guint8 status, const guint8 *pdu,
@@ -215,7 +220,8 @@ static void iwin_discovered_cb(uint8_t status, GSList *chars, void *user_data)
DBG("Scan Interval Window handle: 0x%04x", scan->iwhandle);
- write_scan_params(scan->attrib, scan->iwhandle);
+ write_scan_params(scan->attrib, scan->iwhandle, scan->interval,
+ scan->window);
}
bool bt_scpp_attach(struct bt_scpp *scan, void *attrib)
@@ -228,7 +234,8 @@ bool bt_scpp_attach(struct bt_scpp *scan, void *attrib)
scan->attrib = g_attrib_ref(attrib);
if (scan->iwhandle) {
- write_scan_params(scan->attrib, scan->iwhandle);
+ write_scan_params(scan->attrib, scan->iwhandle, scan->interval,
+ scan->window);
return true;
}
@@ -254,3 +261,27 @@ void bt_scpp_detach(struct bt_scpp *scan)
g_attrib_unref(scan->attrib);
scan->attrib = NULL;
}
+
+bool bt_scpp_set_interval(struct bt_scpp *scan, uint16_t value)
+{
+ if (!scan)
+ return false;
+
+ /* TODO: Check valid range */
+
+ scan->interval = value;
+
+ return true;
+}
+
+bool bt_scpp_set_window(struct bt_scpp *scan, uint16_t value)
+{
+ if (!scan)
+ return false;
+
+ /* TODO: Check valid range */
+
+ scan->window = value;
+
+ return true;
+}
diff --git a/android/scpp.h b/android/scpp.h
index f374cee..048fb9f 100644
--- a/android/scpp.h
+++ b/android/scpp.h
@@ -30,3 +30,6 @@ void bt_scpp_unref(struct bt_scpp *scan);
bool bt_scpp_attach(struct bt_scpp *scan, void *gatt);
void bt_scpp_detach(struct bt_scpp *scan);
+
+bool bt_scpp_set_interval(struct bt_scpp *scan, uint16_t value);
+bool bt_scpp_set_window(struct bt_scpp *scan, uint16_t value);
--
1.9.3
next prev parent reply other threads:[~2014-06-26 14:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 14:46 [PATCH BlueZ v2 01/15] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 02/15] android/dis: Strip dependencies from deviceinfo plugin Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 03/15] android/dis: Add bt_dis_set_notification Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 04/15] android/dis: Only cache the handle not all the characteristics Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 05/15] android/hog: Add support for reading device details via DIS Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 06/15] lib/uuid: Add define for Scan Parameter UUID Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 07/15] android/scpp: Add copy to Scan Parameter Profile implementation Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 08/15] android/scpp: Strip dependencies from scan plugin Luiz Augusto von Dentz
2014-06-26 14:46 ` Luiz Augusto von Dentz [this message]
2014-06-26 14:46 ` [PATCH BlueZ v2 10/15] android/scpp: Check for cached handles on attach Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 11/15] android/hog: Add support for Scan Parameter Service Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 12/15] android: Add initial implementation of Battery Service client Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 13/15] lib/uuid: Add define for Battery UUID Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 14/15] android/hog: Add support for Battery Service Luiz Augusto von Dentz
2014-06-26 14:46 ` [PATCH BlueZ v2 15/15] android/hog: Add support for multiple instaces 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=1403794008-18585-9-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.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;
as well as URLs for NNTP newsgroup(s).