2015-04-18 01:09:30

by Jakub Pawlowski

[permalink] [raw]
Subject: [PATCH 1/3] doc/device-api: Add TxPower

This adds TxPower from advertisement data.

Signed-off-by: Jakub Pawlowski <[email protected]>
---
doc/device-api.txt | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/doc/device-api.txt b/doc/device-api.txt
index 72c597e..875fd9d 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -196,6 +196,11 @@ Properties string Address [readonly]
Received Signal Strength Indicator of the remote
device (inquiry or advertising).

+ int16 TxPower [readonly, optional]
+
+ Advertised transmitted power level (inquiry or
+ advertising).
+
dict ManufacturerData [readonly, optional]

Manufacturer specific advertisement data. Keys are
--
2.2.0.rc0.207.ga3a616c



2015-04-23 20:07:33

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/3] doc/device-api: Add TxPower

Hi Jakub,

On Thu, Apr 23, 2015 at 10:58 PM, Jakub Pawlowski <[email protected]> wrote:
> On Thu, Apr 23, 2015 at 12:50 PM, Luiz Augusto von Dentz
> <[email protected]> wrote:
>> Hi Jakub,
>>
>> On Thu, Apr 23, 2015 at 6:56 PM, Jakub Pawlowski <[email protected]> wrote:
>>> Ping ?
>>
>> Sorry, I forgot about this one.
>>
>>> On Mon, Apr 20, 2015 at 8:55 AM, Jakub Pawlowski <[email protected]> wrote:
>>>> Hi Luiz
>>>>
>>>> On Mon, Apr 20, 2015 at 7:32 AM, Luiz Augusto von Dentz
>>>> <[email protected]> wrote:
>>>>> Hi Jakub,
>>>>>
>>>>> On Sat, Apr 18, 2015 at 4:09 AM, Jakub Pawlowski <[email protected]> wrote:
>>>>>> This adds TxPower from advertisement data.
>>>>>>
>>>>>> Signed-off-by: Jakub Pawlowski <[email protected]>
>>>>>> ---
>>>>>> doc/device-api.txt | 5 +++++
>>>>>> 1 file changed, 5 insertions(+)
>>>>>>
>>>>>> diff --git a/doc/device-api.txt b/doc/device-api.txt
>>>>>> index 72c597e..875fd9d 100644
>>>>>> --- a/doc/device-api.txt
>>>>>> +++ b/doc/device-api.txt
>>>>>> @@ -196,6 +196,11 @@ Properties string Address [readonly]
>>>>>> Received Signal Strength Indicator of the remote
>>>>>> device (inquiry or advertising).
>>>>>>
>>>>>> + int16 TxPower [readonly, optional]
>>>>>> +
>>>>>> + Advertised transmitted power level (inquiry or
>>>>>> + advertising).
>>>>>> +
>>>>>> dict ManufacturerData [readonly, optional]
>>>>>>
>>>>>> Manufacturer specific advertisement data. Keys are
>>>>>> --
>>>>>> 2.2.0.rc0.207.ga3a616c
>>>>>
>>>>> I thought we discussed about this before and we would like to have the
>>>>> pathloss instead of TxPower, or do you have something else useful for
>>>>> TxPower?
>>>>
>>>> I don't remember such discussion, I remember we were discussing about
>>>> SetDiscoveryFilter, and it have option to filter by pathloss.
>>>> So I exposed TxPower for two reasons:
>>>> 1. It's just a field in advertisement, and I wanted just to access it
>>>> as any other.
>>>> 2. If I turn it into Pathloss field, it would change together with
>>>> RSSI, and PropertyChanged event will be doubled. Pathloss is very
>>>> simple to compute, so having only RSSI that change is more efficient.
>>
>> Fair enough, I just notice I did not mark the these properties as
>> experimental in the documentation, but no need to send another version
>> I will fix it when applying your patches.
>
> Ok, Thanks!

Applied after removing Signed-off-by line as well as fixing the
missing experimental flag, thanks.


--
Luiz Augusto von Dentz

2015-04-23 19:58:25

by Jakub Pawlowski

[permalink] [raw]
Subject: Re: [PATCH 1/3] doc/device-api: Add TxPower

On Thu, Apr 23, 2015 at 12:50 PM, Luiz Augusto von Dentz
<[email protected]> wrote:
> Hi Jakub,
>
> On Thu, Apr 23, 2015 at 6:56 PM, Jakub Pawlowski <[email protected]> wrote:
>> Ping ?
>
> Sorry, I forgot about this one.
>
>> On Mon, Apr 20, 2015 at 8:55 AM, Jakub Pawlowski <[email protected]> wrote:
>>> Hi Luiz
>>>
>>> On Mon, Apr 20, 2015 at 7:32 AM, Luiz Augusto von Dentz
>>> <[email protected]> wrote:
>>>> Hi Jakub,
>>>>
>>>> On Sat, Apr 18, 2015 at 4:09 AM, Jakub Pawlowski <[email protected]> wrote:
>>>>> This adds TxPower from advertisement data.
>>>>>
>>>>> Signed-off-by: Jakub Pawlowski <[email protected]>
>>>>> ---
>>>>> doc/device-api.txt | 5 +++++
>>>>> 1 file changed, 5 insertions(+)
>>>>>
>>>>> diff --git a/doc/device-api.txt b/doc/device-api.txt
>>>>> index 72c597e..875fd9d 100644
>>>>> --- a/doc/device-api.txt
>>>>> +++ b/doc/device-api.txt
>>>>> @@ -196,6 +196,11 @@ Properties string Address [readonly]
>>>>> Received Signal Strength Indicator of the remote
>>>>> device (inquiry or advertising).
>>>>>
>>>>> + int16 TxPower [readonly, optional]
>>>>> +
>>>>> + Advertised transmitted power level (inquiry or
>>>>> + advertising).
>>>>> +
>>>>> dict ManufacturerData [readonly, optional]
>>>>>
>>>>> Manufacturer specific advertisement data. Keys are
>>>>> --
>>>>> 2.2.0.rc0.207.ga3a616c
>>>>
>>>> I thought we discussed about this before and we would like to have the
>>>> pathloss instead of TxPower, or do you have something else useful for
>>>> TxPower?
>>>
>>> I don't remember such discussion, I remember we were discussing about
>>> SetDiscoveryFilter, and it have option to filter by pathloss.
>>> So I exposed TxPower for two reasons:
>>> 1. It's just a field in advertisement, and I wanted just to access it
>>> as any other.
>>> 2. If I turn it into Pathloss field, it would change together with
>>> RSSI, and PropertyChanged event will be doubled. Pathloss is very
>>> simple to compute, so having only RSSI that change is more efficient.
>
> Fair enough, I just notice I did not mark the these properties as
> experimental in the documentation, but no need to send another version
> I will fix it when applying your patches.

Ok, Thanks!
>
>
> --
> Luiz Augusto von Dentz

2015-04-23 19:50:03

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/3] doc/device-api: Add TxPower

Hi Jakub,

On Thu, Apr 23, 2015 at 6:56 PM, Jakub Pawlowski <[email protected]> wrote:
> Ping ?

Sorry, I forgot about this one.

> On Mon, Apr 20, 2015 at 8:55 AM, Jakub Pawlowski <[email protected]> wrote:
>> Hi Luiz
>>
>> On Mon, Apr 20, 2015 at 7:32 AM, Luiz Augusto von Dentz
>> <[email protected]> wrote:
>>> Hi Jakub,
>>>
>>> On Sat, Apr 18, 2015 at 4:09 AM, Jakub Pawlowski <[email protected]> wrote:
>>>> This adds TxPower from advertisement data.
>>>>
>>>> Signed-off-by: Jakub Pawlowski <[email protected]>
>>>> ---
>>>> doc/device-api.txt | 5 +++++
>>>> 1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/doc/device-api.txt b/doc/device-api.txt
>>>> index 72c597e..875fd9d 100644
>>>> --- a/doc/device-api.txt
>>>> +++ b/doc/device-api.txt
>>>> @@ -196,6 +196,11 @@ Properties string Address [readonly]
>>>> Received Signal Strength Indicator of the remote
>>>> device (inquiry or advertising).
>>>>
>>>> + int16 TxPower [readonly, optional]
>>>> +
>>>> + Advertised transmitted power level (inquiry or
>>>> + advertising).
>>>> +
>>>> dict ManufacturerData [readonly, optional]
>>>>
>>>> Manufacturer specific advertisement data. Keys are
>>>> --
>>>> 2.2.0.rc0.207.ga3a616c
>>>
>>> I thought we discussed about this before and we would like to have the
>>> pathloss instead of TxPower, or do you have something else useful for
>>> TxPower?
>>
>> I don't remember such discussion, I remember we were discussing about
>> SetDiscoveryFilter, and it have option to filter by pathloss.
>> So I exposed TxPower for two reasons:
>> 1. It's just a field in advertisement, and I wanted just to access it
>> as any other.
>> 2. If I turn it into Pathloss field, it would change together with
>> RSSI, and PropertyChanged event will be doubled. Pathloss is very
>> simple to compute, so having only RSSI that change is more efficient.

Fair enough, I just notice I did not mark the these properties as
experimental in the documentation, but no need to send another version
I will fix it when applying your patches.


--
Luiz Augusto von Dentz

2015-04-23 15:56:47

by Jakub Pawlowski

[permalink] [raw]
Subject: Re: [PATCH 1/3] doc/device-api: Add TxPower

Ping ?

On Mon, Apr 20, 2015 at 8:55 AM, Jakub Pawlowski <[email protected]> wrote:
> Hi Luiz
>
> On Mon, Apr 20, 2015 at 7:32 AM, Luiz Augusto von Dentz
> <[email protected]> wrote:
>> Hi Jakub,
>>
>> On Sat, Apr 18, 2015 at 4:09 AM, Jakub Pawlowski <[email protected]> wrote:
>>> This adds TxPower from advertisement data.
>>>
>>> Signed-off-by: Jakub Pawlowski <[email protected]>
>>> ---
>>> doc/device-api.txt | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/doc/device-api.txt b/doc/device-api.txt
>>> index 72c597e..875fd9d 100644
>>> --- a/doc/device-api.txt
>>> +++ b/doc/device-api.txt
>>> @@ -196,6 +196,11 @@ Properties string Address [readonly]
>>> Received Signal Strength Indicator of the remote
>>> device (inquiry or advertising).
>>>
>>> + int16 TxPower [readonly, optional]
>>> +
>>> + Advertised transmitted power level (inquiry or
>>> + advertising).
>>> +
>>> dict ManufacturerData [readonly, optional]
>>>
>>> Manufacturer specific advertisement data. Keys are
>>> --
>>> 2.2.0.rc0.207.ga3a616c
>>
>> I thought we discussed about this before and we would like to have the
>> pathloss instead of TxPower, or do you have something else useful for
>> TxPower?
>
> I don't remember such discussion, I remember we were discussing about
> SetDiscoveryFilter, and it have option to filter by pathloss.
> So I exposed TxPower for two reasons:
> 1. It's just a field in advertisement, and I wanted just to access it
> as any other.
> 2. If I turn it into Pathloss field, it would change together with
> RSSI, and PropertyChanged event will be doubled. Pathloss is very
> simple to compute, so having only RSSI that change is more efficient.
>
>
>>
>>
>> --
>> Luiz Augusto von Dentz

2015-04-20 15:55:28

by Jakub Pawlowski

[permalink] [raw]
Subject: Re: [PATCH 1/3] doc/device-api: Add TxPower

Hi Luiz

On Mon, Apr 20, 2015 at 7:32 AM, Luiz Augusto von Dentz
<[email protected]> wrote:
> Hi Jakub,
>
> On Sat, Apr 18, 2015 at 4:09 AM, Jakub Pawlowski <[email protected]> wrote:
>> This adds TxPower from advertisement data.
>>
>> Signed-off-by: Jakub Pawlowski <[email protected]>
>> ---
>> doc/device-api.txt | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/doc/device-api.txt b/doc/device-api.txt
>> index 72c597e..875fd9d 100644
>> --- a/doc/device-api.txt
>> +++ b/doc/device-api.txt
>> @@ -196,6 +196,11 @@ Properties string Address [readonly]
>> Received Signal Strength Indicator of the remote
>> device (inquiry or advertising).
>>
>> + int16 TxPower [readonly, optional]
>> +
>> + Advertised transmitted power level (inquiry or
>> + advertising).
>> +
>> dict ManufacturerData [readonly, optional]
>>
>> Manufacturer specific advertisement data. Keys are
>> --
>> 2.2.0.rc0.207.ga3a616c
>
> I thought we discussed about this before and we would like to have the
> pathloss instead of TxPower, or do you have something else useful for
> TxPower?

I don't remember such discussion, I remember we were discussing about
SetDiscoveryFilter, and it have option to filter by pathloss.
So I exposed TxPower for two reasons:
1. It's just a field in advertisement, and I wanted just to access it
as any other.
2. If I turn it into Pathloss field, it would change together with
RSSI, and PropertyChanged event will be doubled. Pathloss is very
simple to compute, so having only RSSI that change is more efficient.


>
>
> --
> Luiz Augusto von Dentz

2015-04-20 14:32:18

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/3] doc/device-api: Add TxPower

Hi Jakub,

On Sat, Apr 18, 2015 at 4:09 AM, Jakub Pawlowski <[email protected]> wrote:
> This adds TxPower from advertisement data.
>
> Signed-off-by: Jakub Pawlowski <[email protected]>
> ---
> doc/device-api.txt | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/doc/device-api.txt b/doc/device-api.txt
> index 72c597e..875fd9d 100644
> --- a/doc/device-api.txt
> +++ b/doc/device-api.txt
> @@ -196,6 +196,11 @@ Properties string Address [readonly]
> Received Signal Strength Indicator of the remote
> device (inquiry or advertising).
>
> + int16 TxPower [readonly, optional]
> +
> + Advertised transmitted power level (inquiry or
> + advertising).
> +
> dict ManufacturerData [readonly, optional]
>
> Manufacturer specific advertisement data. Keys are
> --
> 2.2.0.rc0.207.ga3a616c

I thought we discussed about this before and we would like to have the
pathloss instead of TxPower, or do you have something else useful for
TxPower?


--
Luiz Augusto von Dentz

2015-04-18 01:09:32

by Jakub Pawlowski

[permalink] [raw]
Subject: [PATCH 3/3] client: Make command info print TxPower and RSSI

This makes command info to also print TxPower and RSSI if available.

Signed-off-by: Jakub Pawlowski <[email protected]>
---
client/main.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/client/main.c b/client/main.c
index 5250a33..46ef72a 100644
--- a/client/main.c
+++ b/client/main.c
@@ -952,6 +952,8 @@ static void cmd_info(const char *arg)
print_property(proxy, "Modalias");
print_property(proxy, "ManufacturerData");
print_property(proxy, "ServiceData");
+ print_property(proxy, "RSSI");
+ print_property(proxy, "TxPower");
}

static void pair_reply(DBusMessage *message, void *user_data)
--
2.2.0.rc0.207.ga3a616c


2015-04-18 01:09:31

by Jakub Pawlowski

[permalink] [raw]
Subject: [PATCH 2/3] core: Add implementation of TxPower

This adds 'TxPower' property to Device interface.

Signed-off-by: Jakub Pawlowski <[email protected]>
---
src/adapter.c | 9 +++++++--
src/device.c | 43 +++++++++++++++++++++++++++++++++++++++++++
src/device.h | 1 +
3 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 5af8489..8ee5b5b 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1680,16 +1680,18 @@ static int compare_sender(gconstpointer a, gconstpointer b)
return g_strcmp0(client->owner, sender);
}

-static void invalidate_rssi(gpointer a)
+static void invalidate_rssi_and_tx_power(gpointer a)
{
struct btd_device *dev = a;

device_set_rssi(dev, 0);
+ device_set_tx_power(dev, 127);
}

static void discovery_cleanup(struct btd_adapter *adapter)
{
- g_slist_free_full(adapter->discovery_found, invalidate_rssi);
+ g_slist_free_full(adapter->discovery_found,
+ invalidate_rssi_and_tx_power);
adapter->discovery_found = NULL;
}

@@ -5449,6 +5451,9 @@ static void update_found_devices(struct btd_adapter *adapter,
else
device_set_rssi(dev, rssi);

+ if (eir_data.tx_power != 127)
+ device_set_tx_power(dev, eir_data.tx_power);
+
if (eir_data.appearance != 0)
device_set_appearance(dev, eir_data.appearance);

diff --git a/src/device.c b/src/device.c
index 3552999..03d8494 100644
--- a/src/device.c
+++ b/src/device.c
@@ -257,6 +257,7 @@ struct btd_device {

bool legacy;
int8_t rssi;
+ int8_t tx_power;

GIOChannel *att_io;
guint store_id;
@@ -925,6 +926,28 @@ static gboolean dev_property_exists_rssi(const GDBusPropertyTable *property,
return TRUE;
}

+static gboolean dev_property_get_tx_power(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct btd_device *dev = data;
+ dbus_int16_t val = dev->tx_power;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT16, &val);
+
+ return TRUE;
+}
+
+static gboolean dev_property_exists_tx_power(const GDBusPropertyTable *property,
+ void *data)
+{
+ struct btd_device *dev = data;
+
+ if (dev->tx_power == 127)
+ return FALSE;
+
+ return TRUE;
+}
+
static gboolean dev_property_get_trusted(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
@@ -2294,6 +2317,8 @@ static const GDBusPropertyTable device_properties[] = {
{ "Blocked", "b", dev_property_get_blocked, dev_property_set_blocked },
{ "LegacyPairing", "b", dev_property_get_legacy },
{ "RSSI", "n", dev_property_get_rssi, NULL, dev_property_exists_rssi },
+ { "TxPower", "n", dev_property_get_tx_power, NULL,
+ dev_property_exists_tx_power },
{ "Connected", "b", dev_property_get_connected },
{ "UUIDs", "as", dev_property_get_uuids },
{ "Modalias", "s", dev_property_get_modalias, NULL,
@@ -3046,6 +3071,8 @@ static struct btd_device *device_new(struct btd_adapter *adapter,
if (device == NULL)
return NULL;

+ device->tx_power = 127;
+
device->db = gatt_db_new();
if (!device->db) {
g_free(device);
@@ -4724,6 +4751,22 @@ void device_set_rssi(struct btd_device *device, int8_t rssi)
device_set_rssi_with_delta(device, rssi, RSSI_THRESHOLD);
}

+void device_set_tx_power(struct btd_device *device, int8_t tx_power)
+{
+ if (!device)
+ return;
+
+ if (device->tx_power == tx_power)
+ return;
+
+ DBG("tx_power %d", tx_power);
+
+ device->tx_power = tx_power;
+
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE, "TxPower");
+}
+
static gboolean start_discovery(gpointer user_data)
{
struct btd_device *device = user_data;
diff --git a/src/device.h b/src/device.h
index b91916d..1955f54 100644
--- a/src/device.h
+++ b/src/device.h
@@ -95,6 +95,7 @@ void device_set_legacy(struct btd_device *device, bool legacy);
void device_set_rssi_with_delta(struct btd_device *device, int8_t rssi,
int8_t delta_threshold);
void device_set_rssi(struct btd_device *device, int8_t rssi);
+void device_set_tx_power(struct btd_device *device, int8_t tx_power);
bool btd_device_is_connected(struct btd_device *dev);
uint8_t btd_device_get_bdaddr_type(struct btd_device *dev);
bool device_is_retrying(struct btd_device *device);
--
2.2.0.rc0.207.ga3a616c