Skip to contentSkip to conversation

doc: Add EIR to device properties

RFC In review Scott James Remnant 2 participants 13 messages Jun 27, 2014 – Jul 1, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

RFC 1/1 doc: Add EIR to device properties

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

Rationale is that increasing numbers of LE profiles are using custom fields in the advertising and scan response reports to carry important information. e.g. the Anki Drive peripherals include necessary information in the advertiesment that is not replicated in the GATT Service they export.

It would be nice if it were possible to support these profiles at the application layer without extending BlueZ every time via a plugin.

Since EIR has a variable-length type field, more complex parsing would require applications registering the types with BlueZ in advance putting a higher complexity burden on the daemon, including resolving conflicts where types overlap. Exposing the raw EIR data to the application allows them to deal with all such problems in whatever manner they require.

---
 doc/device-api.txt | 5 +++++
 1 file changed, 5 insertions(+)
doc/device-api.txt +5 -0
index 577ee60..9620ec0 100644
@@ -193,3 +193,8 @@ Properties	string Address [readonly]
 
 			Received Signal Strength Indicator of the remote
 			device (inquiry or advertising).
+
+		array{byte} EIR [readonly, optional]
+
+			Last received EIR data from the remote device
+			during inquiry or advertising.
Signature · 1 line
1.9.3 (Apple Git-50)
maintainer
#1 lore raw

Hi Scott,

Quoted 28 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

Rationale is that increasing numbers of LE profiles are using custom fields in the advertising and scan response reports to carry important information. e.g. the Anki Drive peripherals include necessary information in the advertiesment that is not replicated in the GATT Service they export.

It would be nice if it were possible to support these profiles at the application layer without extending BlueZ every time via a plugin.

Since EIR has a variable-length type field, more complex parsing would require applications registering the types with BlueZ in advance putting a higher complexity burden on the daemon, including resolving conflicts where types overlap. Exposing the raw EIR data to the application allows them to deal with all such problems in whatever manner they require.
---
doc/device-api.txt | 5 +++++

1 file changed, 5 insertions(+)
doc/device-api.txt +0 -0
index 577ee60..9620ec0 100644

doc/device-api.txt Properties string Address [readonly] · line 200

Quoted 8 lines
doc/device-api.txt +5 -0
@@ -193,3 +193,8 @@ Properties	string Address [readonly]
 
 			Received Signal Strength Indicator of the remote
 			device (inquiry or advertising).
+
+		array{byte} EIR [readonly, optional]
+
+			Last received EIR data from the remote device
+			during inquiry or advertising.

in general I have no objections in exposing the EIR and AD information. However I do not like to use EIR as property key. I know that on mgmt API we simply went with EIR_Data, but on the D-Bus API we most likely need to find a name that is a bit more generic and allows to represent EIR and AD information.

One important thing we have to consider are dual-mode devices that are found via LE and BR/EDR. With dual-mode topology from Bluetooth 4.1 this will become a real possibility and we want them to show under one object path. I think we need to brainstorm a little on how this can be done best.

Regards

Marcel

#2 lore raw

On Fri, Jun 27, 2014 at 12:55 PM, Marcel Holtmann <[email protected]> wro= te:

Quoted 5 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

in general I have no objections in exposing the EIR and AD information. H=

owever I do not like to use EIR as property key. I know that on mgmt API we=
simply went with EIR_Data, but on the D-Bus API we most likely need to fin=
d a name that is a bit more generic and allows to represent EIR and AD info= rmation.

Quoted 1 line

I did indeed just copy the mgmt API terminology here, since it's obviously _also_ not just the AD report but also the SR report as well since they're concatenated in the kernel during active scanning.

Quoted 1 line

One important thing we have to consider are dual-mode devices that are fo=

und via LE and BR/EDR. With dual-mode topology from Bluetooth 4.1 this will=
become a real possibility and we want them to show under one object path. =
I think we need to brainstorm a little on how this can be done best.

Quoted 1 line

The other interesting issue for 4.1 dual-mode topology, which turns out to be somewhat related, is that if there's only one object path for a BR/EDR/LE dual-mode device, which bearer is connected when the application calls org.bluez.Device1.Connect ?

At least the ConnectToProfile call makes that explicit since there's a Profile object, but even then, if the device supports LE L2CAP Connection Oriented Channels, do you want that profile connected over the BR/EDR or LE bearer if the device supports both?

But that method isn't used for establishing the GATT connection on the LE bearer. (And then you have the whole GATT over BR/EDR thing to worry about too).

(I also don't remember reading any limitation that a BR/EDR/LE device _must_ use its Public address during LE Advertisement, but you'd know better than me on that. Would there be a case where we see advertising from a device, that on pairing/connection turns out to be, via receiving IRK, a BR/EDR device we already knew about, and thus we'd have to deal with device objects merging?)

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?

maintainer
#3 lore raw

Hi Scott,

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

in general I have no objections in exposing the EIR and AD information. However I do not like to use EIR as property key. I know that on mgmt API we simply went with EIR_Data, but on the D-Bus API we most likely need to find a name that is a bit more generic and allows to represent EIR and AD information.

I did indeed just copy the mgmt API terminology here, since it's obviously _also_ not just the AD report but also the SR report as well since they're concatenated in the kernel during active scanning.

maybe something generic like InformationData. Honestly I do not know yet. I do however have bad feeling with calling it just EIR.

Quoted 7 lines
Quoted 2 lines

One important thing we have to consider are dual-mode devices that are found via LE and BR/EDR. With dual-mode topology from Bluetooth 4.1 this will become a real possibility and we want them to show under one object path. I think we need to brainstorm a little on how this can be done best.

The other interesting issue for 4.1 dual-mode topology, which turns out to be somewhat related, is that if there's only one object path for a BR/EDR/LE dual-mode device, which bearer is connected when the application calls org.bluez.Device1.Connect ?

Simple answer without overthinking it is both.

Quoted 4 lines

At least the ConnectToProfile call makes that explicit since there's a Profile object, but even then, if the device supports LE L2CAP Connection Oriented Channels, do you want that profile connected over the BR/EDR or LE bearer if the device supports both?

We do not have services that will expose L2CAP Connection Oriented channels on both BR/EDR and LE and use the same UUID. The classic BR/EDR profiles will not be mapped over LE at this moment.

Quoted 3 lines

But that method isn't used for establishing the GATT connection on the LE bearer. (And then you have the whole GATT over BR/EDR thing to worry about too).

The database is suppose to be the same. And honestly with dual-mode topology, the GATT over BR/EDR is essentially pointless. You will be just doing it over LE which is way simpler.

Quoted 6 lines

(I also don't remember reading any limitation that a BR/EDR/LE device _must_ use its Public address during LE Advertisement, but you'd know better than me on that. Would there be a case where we see advertising from a device, that on pairing/connection turns out to be, via receiving IRK, a BR/EDR device we already knew about, and thus we'd have to deal with device objects merging?)

There is no requirement to use your public address in advertising. You can always use random private address.

And public address on BR/EDR and RPA on LE can be the case. The iPhone being the prime example here. And we already merge the objects together as good as we can. Johan can explain this since I have to admit I spaced out when he told me on how he did it. Or I just imagined it, which is possible ;)

If you have seen my proposal for Privacy mode 0x02, then I think that we are going for using public address when we are discoverable and RPA when non-discoverable. That allows us to avoid trackability in the most cases and still allow for a smoother operation during pairing.

Regards

Marcel

#4 lore raw
In reply to Marcel Holtmann

On Fri, Jun 27, 2014 at 12:55 PM, Marcel Holtmann <[email protected]> wro= te:

Quoted 5 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

in general I have no objections in exposing the EIR and AD information. H=

owever I do not like to use EIR as property key. I know that on mgmt API we=
simply went with EIR_Data, but on the D-Bus API we most likely need to fin=
d a name that is a bit more generic and allows to represent EIR and AD info= rmation.

Quoted 1 line

Thinking about this a little bit more, I'm not sure this should be a Device property either. The advertisement data isn't really a property of the device, but a property of the advertisement itself.

A peripheral could theoretically send different advertisements, a weird example might be a peripheral sending a non-connectable undirected advertisement generally, and a connectable directed advertisement to us directly, with different AD.

This seems to fold back nicely into the discussion about a "Find Devices" API, intended for applications and separate from the StartDiscovery API. If that were an "agent" mode, it could look something like this:

    <- Search( { Data: "FF4C000214" }, agent_object_path )
    -> DeviceFound( device_object_path, data )
    -> DeviceFound( device_object_path, data )
    -> DeviceFound( device_object_path, data )

Where data in the agent method is the unparsed advertisement data, if the application is interested in it. The above example is looking for an iBeacon by presence of a specific data structure, so the app probably wants the unparsed data parameter and doesn't care so much about the object path.

But looking for heart rate monitors might be:

    <- Search( { UUID: "180D" }, agent_object_path )
    -> DeviceFound( device_object_path, data )
    -> DeviceFound( device_object_path, data )
    -> DeviceFound( device_object_path, data )

In which case the application probably just wants the device object path.

If this is broadly along the lines you're thinking, I'll draft a doc to begin discussion.

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?

maintainer
#5 lore raw

Hi Scott,

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

in general I have no objections in exposing the EIR and AD information. However I do not like to use EIR as property key. I know that on mgmt API we simply went with EIR_Data, but on the D-Bus API we most likely need to find a name that is a bit more generic and allows to represent EIR and AD information.

Quoted 8 lines

Thinking about this a little bit more, I'm not sure this should be a Device property either. The advertisement data isn't really a property of the device, but a property of the advertisement itself.

A peripheral could theoretically send different advertisements, a weird example might be a peripheral sending a non-connectable undirected advertisement generally, and a connectable directed advertisement to us directly, with different AD.

that is indeed possible. They can also interleave them with one time targeting a different central.

Keep in mind that there is also something called service solicitation. Meaning a peripheral start indicated that it want a device with service UUID x to find us. iOS is for example using that to filter for the Notification Center stuff.

Quoted 23 lines

This seems to fold back nicely into the discussion about a "Find Devices" API, intended for applications and separate from the StartDiscovery API. If that were an "agent" mode, it could look something like this:

   <- Search( { Data: "FF4C000214" }, agent_object_path )
   -> DeviceFound( device_object_path, data )
   -> DeviceFound( device_object_path, data )
   -> DeviceFound( device_object_path, data )

Where data in the agent method is the unparsed advertisement data, if the application is interested in it. The above example is looking for an iBeacon by presence of a specific data structure, so the app probably wants the unparsed data parameter and doesn't care so much about the object path.

But looking for heart rate monitors might be:

   <- Search( { UUID: "180D" }, agent_object_path )
   -> DeviceFound( device_object_path, data )
   -> DeviceFound( device_object_path, data )
   -> DeviceFound( device_object_path, data )
Quoted 5 lines

In which case the application probably just wants the device object path.

If this is broadly along the lines you're thinking, I'll draft a doc to begin discussion.

I think this looks pretty along the lines what I am looking for. However I was thinking in a bit more detail likes this:

	<- Search method call
	-> New Device object / Updated device object
	-> New Device object / Updated device object
	-> Search method return -> array of objects with properties

So you can treat the search dead simple and just display the results. However that way you can not monitor progress. If you want to monitor progress while search is running, you need to monitor changes to the device objects.

Regards

Marcel

#6 lore raw
Quoted 5 lines · Marcel Holtmann
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

Quoted 9 lines

I think this looks pretty along the lines what I am looking for. However I was thinking in a bit more detail likes this:

        <- Search method call
        -> New Device object / Updated device object
        -> New Device object / Updated device object
        -> Search method return -> array of objects with properties

So you can treat the search dead simple and just display the results. However that way you can not monitor progress. If you want to monitor progress while search is running, you need to monitor changes to the device objects.

Sounds reasonable, would make it very easy from an application point of view.

This would place the EIR/AD/SR data in the device objects as a property then?

Scott

Signature · 2 lines
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?
maintainer
#7 lore raw

Hi Scott,

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

I think this looks pretty along the lines what I am looking for. However I was thinking in a bit more detail likes this:

       <- Search method call
       -> New Device object / Updated device object
       -> New Device object / Updated device object
       -> Search method return -> array of objects with properties
Quoted 6 lines
Quoted 2 lines

So you can treat the search dead simple and just display the results. However that way you can not monitor progress. If you want to monitor progress while search is running, you need to monitor changes to the device objects.

Sounds reasonable, would make it very easy from an application point of view.

This would place the EIR/AD/SR data in the device objects as a property then?

we could do that, but I would like to discuss this a bit more. For example we might not duplicate the information that we have properties for. For example device name or appearance.

The information would also become invalid once the discovery gets aborted. Similar to the RSSI value where we actually declare the property invalid once discovery is over.

I think we have to see how this works out. We might need a prototype implementation to play with it a little bit.

Regards

Marcel

maintainer
#8 lore raw

Hi Scott,

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

This patch proposes an extension to the D-Bus Device API to allow an application access to the last EIR data received from a device in inquiry or advertising mode.

I think this looks pretty along the lines what I am looking for. However I was thinking in a bit more detail likes this:

      <- Search method call
      -> New Device object / Updated device object
      -> New Device object / Updated device object
      -> Search method return -> array of objects with properties
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

So you can treat the search dead simple and just display the results. However that way you can not monitor progress. If you want to monitor progress while search is running, you need to monitor changes to the device objects.

Sounds reasonable, would make it very easy from an application point of view.

This would place the EIR/AD/SR data in the device objects as a property then?

we could do that, but I would like to discuss this a bit more. For example we might not duplicate the information that we have properties for. For example device name or appearance.

coming to think about it, we might should just focus on the manufacturer specific field and make sure that gets exposed over D-Bus. The other ones are Bluetooth SIG defined and we can define good properties for it.

We could add a property with array{uint16,array{byte}} that allows us to provide all the manufacturer information we find. On BR/EDR they are pretty static and would just stay around. On LE they would be removed (same as RSSI) once the result becomes invalid. For dual-mode devices found on both transports we just combine them.

Regards

Marcel

#9 lore raw

On Tue, Jul 1, 2014 at 8:58 AM, Marcel Holtmann <[email protected]> wrote= :

Quoted 1 line
Quoted 1 line
Quoted 1 line

This would place the EIR/AD/SR data in the device objects as a property=

then?

Quoted 2 lines
Quoted 2 lines

we could do that, but I would like to discuss this a bit more. For examp=

le we might not duplicate the information that we have properties for. For = example device name or appearance.

Quoted 2 lines

coming to think about it, we might should just focus on the manufacturer =

specific field and make sure that gets exposed over D-Bus. The other ones a= re Bluetooth SIG defined and we can define good properties for it.

Quoted 1 line

The main missing SIG defined fields which don't have properties would be:

- TX Power (CSSv4 1.5)
- URL (https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=
=3D287247)

All of the others are reasonably internal to BlueZ and not of interest to applications.

Quoted 1 line

We could add a property with array{uint16,array{byte}} that allows us to =

provide all the manufacturer information we find. On BR/EDR they are pretty=
static and would just stay around. On LE they would be removed (same as RS=
SI) once the result becomes invalid. For dual-mode devices found on both tr= ansports we just combine them.

Quoted 1 line

If multiple fields of manufacturer data for the same manufacturer are found, we'd just duplicate them in the array? e.g.

[

    ( 004C, [ 01, 08, ... ] ),
    ( 004C, [ 02, 15, ... ] )

]

For a fruit-flavored device acting as both an Airdrop target and an iBeacon (this seems to be how they show up - but could be a side effect of one field being in AD and one in SR)

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? Are you going round the twist?

maintainer
#10 lore raw

Hi Scott,

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

This would place the EIR/AD/SR data in the device objects as a property then?

we could do that, but I would like to discuss this a bit more. For example we might not duplicate the information that we have properties for. For example device name or appearance.

coming to think about it, we might should just focus on the manufacturer specific field and make sure that gets exposed over D-Bus. The other ones are Bluetooth SIG defined and we can define good properties for it.

The main missing SIG defined fields which don't have properties would be:

- TX Power (CSSv4 1.5)

we should do the proper math here and provide Pathloss when discovered (again, similar disappearance to RSSI).

Quoted 1 line

- URL (https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=287247)

Is that one new? Could be. That seems to be dead simple and can really just get its own property.

Quoted 2 lines

All of the others are reasonably internal to BlueZ and not of interest to applications.

Examples would be Service Solicitation as mentioned before. However there bluetoothd should just combine all fields into a single array with UUID-128.

Quoted 6 lines
Quoted 2 lines

We could add a property with array{uint16,array{byte}} that allows us to provide all the manufacturer information we find. On BR/EDR they are pretty static and would just stay around. On LE they would be removed (same as RSSI) once the result becomes invalid. For dual-mode devices found on both transports we just combine them.

If multiple fields of manufacturer data for the same manufacturer are found, we'd just duplicate them in the array? e.g.

Quoted 8 lines

[
( 004C, [ 01, 08, ... ] ),
( 004C, [ 02, 15, ... ] )
]

For a fruit-flavored device acting as both an Airdrop target and an iBeacon (this seems to be how they show up - but could be a side effect of one field being in AD and one in SR)

That is what I am thinking is the safest. Same as on BR/EDR they will give you the product name so you can pick the right icon. I also think that for manufacturer specific entries it is explicitly allowed to show up more than once.

Regards

Marcel

#11 lore raw
Quoted 6 lines · Marcel Holtmann
Quoted 3 lines

The main missing SIG defined fields which don't have properties would be:

- TX Power (CSSv4 1.5)

we should do the proper math here and provide Pathloss when discovered (again, similar disappearance to RSSI).

We'd still need the RSSI property because certain existing peripherals are placing the TX Power in the manufacturer data, which means the app would have to calculate path loss itself.

Is there a circumstance in which additional manuf data could make the path loss calculation more accurate?

Quoted 4 lines
Quoted 1 line

- URL (https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=287247)

Is that one new? Could be. That seems to be dead simple and can really just get its own property.

Yeah, some guys here are working on a prototype and sticking URLs in the name field ... Robin Heydon saw it and decided that was useful enough to declare a standard field for it.

Still at NWP, I don't think the CSWG has proposed assigned numbers changes yet, but worth keeping an eye on.

Scott

Signature · 2 lines
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?
maintainer
#12 lore raw

Hi Scott,

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

The main missing SIG defined fields which don't have properties would be:

- TX Power (CSSv4 1.5)

we should do the proper math here and provide Pathloss when discovered (again, similar disappearance to RSSI).

We'd still need the RSSI property because certain existing peripherals are placing the TX Power in the manufacturer data, which means the app would have to calculate path loss itself.

the idea was not to remove RSSI property. The idea was to add Pathloss property additionally instead of just adding TX Power property.

Quoted 2 lines

Is there a circumstance in which additional manuf data could make the path loss calculation more accurate?

No. The reason why iBeacons have them in the manufacturer data is that there is no space for the TX Power element.

Quoted 11 lines
Quoted 4 lines
Quoted 1 line

- URL (https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=287247)

Is that one new? Could be. That seems to be dead simple and can really just get its own property.

Yeah, some guys here are working on a prototype and sticking URLs in the name field ... Robin Heydon saw it and decided that was useful enough to declare a standard field for it.

Still at NWP, I don't think the CSWG has proposed assigned numbers changes yet, but worth keeping an eye on.

Becomes tricky size wise, but once it is official, we can easily support that one.

Regards

Marcel