From: Szymon Janc <szymon.janc@codecoup.pl>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 4/6] tools/btpclient: Add device found event
Date: Fri, 22 Dec 2017 11:48:27 +0100 [thread overview]
Message-ID: <2953094.NzN3KtlSTN@ix> (raw)
In-Reply-To: <20171221164720.20925-4-grzegorz.kolodziejczyk@codecoup.pl>
Hi Grzegorz,
On Thursday, 21 December 2017 17:47:18 CET Grzegorz Kolodziejczyk wrote:
> This patch adds device found event handler. It's called when rssi
> property of device changes and new device interface is added.
> ---
> tools/btpclient.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/tools/btpclient.c b/tools/btpclient.c
> index 095c5ea3e..c0ad03b68 100644
> --- a/tools/btpclient.c
> +++ b/tools/btpclient.c
> @@ -399,6 +399,37 @@ failed:
> btp_send_error(btp, BTP_GAP_SERVICE, index, status);
> }
>
> +static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)
> +{
> + struct btp_device_found_ev ev;
> + const char *str;
> +
> + if (!l_dbus_proxy_get_property(proxy, "Address", "s", &str) ||
> + (str2addr(str, ev.address) != 6))
> + return;
> +
> + if (!l_dbus_proxy_get_property(proxy, "AddressType", "s", &str))
> + return;
> +
> + ev.address_type = strcmp(str, "public") ? BTP_GAP_ADDR_RANDOM :
> + BTP_GAP_ADDR_PUBLIC;
> +
> + if (!l_dbus_proxy_get_property(proxy, "RSSI", "n", &ev.rssi))
"n" expects pointer to int16_t so you need to use local tmp for this.
(this is due to no signed int8_t on D-Bus, only byte type)
> + return;
> +
> + /* TODO Temporary set all flags */
> + ev.flags = (BTP_EV_GAP_DEVICE_FOUND_FLAG_RSSI |
> + BTP_EV_GAP_DEVICE_FOUND_FLAG_AD |
> + BTP_EV_GAP_DEVICE_FOUND_FLAG_SR);
> +
> + /* TODO Add eir to device found event */
> + ev.eir_len = 0;
> +
> + btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND,
> + BTP_INDEX_NON_CONTROLLER,
> + sizeof(ev) + ev.eir_len, &ev);
> +}
> +
> static void register_gap_service(void)
> {
> btp_register(btp, BTP_GAP_SERVICE, BTP_OP_GAP_READ_SUPPORTED_COMMANDS,
> @@ -661,6 +692,8 @@ static void proxy_added(struct l_dbus_proxy *proxy, void
> *user_data)
>
> l_queue_push_tail(adapter->devices, device);
>
> + btp_gap_device_found_ev(proxy);
> +
> return;
> }
>
> @@ -782,6 +815,15 @@ static void property_changed(struct l_dbus_proxy
> *proxy, const char *name, update_current_settings(adapter, new_settings);
>
> return;
> + } else if (!strcmp(interface, "org.bluez.Device1")) {
> + if (!strcmp(name, "RSSI")) {
> + uint16_t rssi;
Should be int16_t.
> +
> + if (!l_dbus_message_get_arguments(msg, "n", &rssi))
> + return;
> +
> + btp_gap_device_found_ev(proxy);
> + }
> }
> }
--
pozdrawiam
Szymon Janc
next prev parent reply other threads:[~2017-12-22 10:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 16:47 [PATCH BlueZ 1/6] shared/btp: define gap device found flags as bit mask Grzegorz Kolodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 2/6] tools/btpclient: Move string to address conversion to helper Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc
2017-12-22 13:49 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 3/6] tools/btpclient: Add advertising proxy to adapter Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc
2017-12-22 13:50 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 4/6] tools/btpclient: Add device found event Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc [this message]
2017-12-22 13:51 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 5/6] tools/btpclient: Add start, stop discovery commands Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc
2017-12-22 13:53 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 6/6] tools/btpclient: Add set connectable command Grzegorz Kolodziejczyk
2017-12-22 10:49 ` [PATCH BlueZ 1/6] shared/btp: define gap device found flags as bit mask 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=2953094.NzN3KtlSTN@ix \
--to=szymon.janc@codecoup.pl \
--cc=grzegorz.kolodziejczyk@codecoup.pl \
--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).