diff options
author | Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl> | 2018-02-28 13:41:25 +0100 |
---|---|---|
committer | Szymon Janc <szymon.janc@codecoup.pl> | 2018-03-05 09:23:06 +0100 |
commit | 1cf57a43e7fe56bc3c864a8dc000df5994105a25 (patch) | |
tree | ed9f93b1fd5e4927dcf7ec22c1df2d2e77710ca9 /tools/btpclient.c | |
parent | 704b2973d3e78394f5a5585081edfbc914f9c068 (diff) | |
download | bluez-1cf57a43e7fe56bc3c864a8dc000df5994105a25.tar.gz |
tools/btpclient: Add passkey confirm event
This patch adds support for send passkey confirm event when requested.
Diffstat (limited to 'tools/btpclient.c')
-rw-r--r-- | tools/btpclient.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/tools/btpclient.c b/tools/btpclient.c index 4097c05d0..92fa742ce 100644 --- a/tools/btpclient.c +++ b/tools/btpclient.c @@ -1707,12 +1707,42 @@ static struct l_dbus_message *ag_request_confirmation_call(struct l_dbus *dbus, struct l_dbus_message *message, void *user_data) { - struct l_dbus_message *reply; + struct btp_gap_passkey_confirm_ev ev; + struct btp_device *device; + struct btp_adapter *adapter; + const char *path, *str_addr, *str_addr_type; + uint32_t passkey; - reply = l_dbus_message_new_method_return(message); - l_dbus_message_set_arguments(reply, ""); + l_dbus_message_get_arguments(message, "ou", &path, &passkey); - return reply; + device = find_device_by_path(path); + + if (!l_dbus_proxy_get_property(device->proxy, "Address", "s", &str_addr) + || !l_dbus_proxy_get_property(device->proxy, "AddressType", "s", + &str_addr_type)) { + l_info("Cannot get device properties"); + + return NULL; + } + + ev.passkey = L_CPU_TO_LE32(passkey); + ev.address_type = strcmp(str_addr_type, "public") ? + BTP_GAP_ADDR_RANDOM : + BTP_GAP_ADDR_PUBLIC; + if (str2ba(str_addr, &ev.address) < 0) { + l_info("Incorrect device address"); + + return NULL; + } + + adapter = find_adapter_by_device(device); + + ag.pending_req = l_dbus_message_ref(message); + + btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_PASSKEY_CONFIRM, + adapter->index, sizeof(ev), &ev); + + return NULL; } static struct l_dbus_message *ag_request_authorization_call(struct l_dbus *dbus, |