From: Szymon Janc <szymon.janc@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH 03/14] android: Add support for handling new link key mgmt event
Date: Thu, 31 Oct 2013 02:55:43 +0000 [thread overview]
Message-ID: <1383188154-22905-4-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1383188154-22905-1-git-send-email-szymon.janc@tieto.com>
When link key is emitted by kernel bond state change notification is
send to HAL. Storing link key is not yet implemented.
---
android/adapter.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/android/adapter.c b/android/adapter.c
index 15b65e5..4b4905b 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -195,6 +195,60 @@ static void mgmt_dev_class_changed_event(uint16_t index, uint16_t length,
/* TODO: Gatt attrib set*/
}
+static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
+ uint8_t type, uint8_t pin_length)
+{
+ /* TODO store link key */
+
+}
+
+static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
+ uint8_t state)
+{
+ struct hal_ev_bond_state_changed ev;
+
+ ev.status = status;
+ ev.state = state;
+ bdaddr2android(addr, ev.bdaddr);
+
+ ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
+ HAL_EV_BOND_STATE_CHANGED, sizeof(ev), &ev, -1);
+}
+
+static void new_link_key_callback(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ const struct mgmt_ev_new_link_key *ev = param;
+ const struct mgmt_addr_info *addr = &ev->key.addr;
+ char dst[18];
+
+ if (length < sizeof(*ev)) {
+ error("Too small new link key event");
+ return;
+ }
+
+ ba2str(&addr->bdaddr, dst);
+
+ DBG("new key for %s type %u pin_len %u",
+ dst, ev->key.type, ev->key.pin_len);
+
+ if (ev->key.pin_len > 16) {
+ error("Invalid PIN length (%u) in new_key event",
+ ev->key.pin_len);
+ return;
+ }
+
+ if (ev->store_hint) {
+ const struct mgmt_link_key_info *key = &ev->key;
+
+ store_link_key(&addr->bdaddr, key->val, key->type,
+ key->pin_len);
+ }
+
+ send_bond_state_change(&addr->bdaddr, HAL_STATUS_SUCCESS,
+ HAL_BOND_STATE_BONDED);
+}
+
static void register_mgmt_handlers(void)
{
mgmt_register(adapter->mgmt, MGMT_EV_NEW_SETTINGS, adapter->index,
@@ -207,6 +261,9 @@ static void register_mgmt_handlers(void)
mgmt_register(adapter->mgmt, MGMT_EV_LOCAL_NAME_CHANGED,
adapter->index, mgmt_local_name_changed_event,
NULL, NULL);
+
+ mgmt_register(adapter->mgmt, MGMT_EV_NEW_LINK_KEY, adapter->index,
+ new_link_key_callback, NULL, NULL);
}
static void load_link_keys_complete(uint8_t status, uint16_t length,
--
1.8.4.rc3
next prev parent reply other threads:[~2013-10-31 2:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-31 2:55 [PATCH 00/14] android: Initial support for pairing Szymon Janc
2013-10-31 2:55 ` [PATCH 01/14] android: Add missing bonding state definitions to IPC specification Szymon Janc
2013-10-31 2:55 ` [PATCH 02/14] android: Add missing bond state definition to IPC header Szymon Janc
2013-10-31 2:55 ` Szymon Janc [this message]
2013-10-31 2:55 ` [PATCH 04/14] android: Make load_link_keys function load keys Szymon Janc
2013-10-31 2:55 ` [PATCH 05/14] android: Set default IO capability on daemon start Szymon Janc
2013-10-31 2:55 ` [PATCH 06/14] android: Add support for handling create bond command Szymon Janc
2013-10-31 2:55 ` [PATCH 07/14] android: Add support for handling cancel " Szymon Janc
2013-10-31 8:50 ` Johan Hedberg
2013-10-31 2:55 ` [PATCH 08/14] android: Add support for handling remove " Szymon Janc
2013-10-31 8:48 ` Johan Hedberg
2013-10-31 2:55 ` [PATCH 09/14] android: Add support for sending pin code request Szymon Janc
2013-10-31 2:55 ` [PATCH 10/14] android: Add initial support for sending SSP request event Szymon Janc
2013-10-31 2:55 ` [PATCH 11/14] android: Add support for entry variant in " Szymon Janc
2013-10-31 2:55 ` [PATCH 12/14] android: Add support for notify " Szymon Janc
2013-10-31 2:55 ` [PATCH 13/14] android: Add support for handling pin reply command Szymon Janc
2013-10-31 2:55 ` [PATCH 14/14] android: Add support for handling SSP " Szymon Janc
2013-10-31 8:52 ` 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=1383188154-22905-4-git-send-email-szymon.janc@tieto.com \
--to=szymon.janc@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox