Hi,
I created pull request which contains patch that introduces ble_addr_t type
and makes public API use it:
https://github.com/apache/incubator-mynewt-core/pull/173
In most cases internals are not updated since this in some cases requires a
lot of additional work and can be done later.
Apart from this change, it includes also:
- cleanup usage of address types and own address types (they use the same
values, but have different meaning and in some places improper symbols were
used)
- fixed pairing with privacy enabled (so when we use RPA)
- added event which tells application that we received peer's identity
address (after pairing)
Also please find some comments below for further discussion.
BR,
Andrzej
On Thu, Jan 26, 2017 at 5:59 PM, Christopher Collins
wrote:
> Hi Andrzej,
>
> On Thu, Jan 26, 2017 at 03:41:53PM +0100, Andrzej Kaczmarek wrote:
> > Hi,
> >
> > I think it would be nice to do one more API refactoring before 1.0
> release
> > and simplify using BLE device address in API.
> >
> > The current state here is similar to what we had with UUIDs in ATT code,
> > i.e. addresses are passed as pair of address type and address value and
> > there is no common way to e.g. compare or copy them. What more, with
> > Privacy enabled things are even more complicated since application needs
> to
> > chose which address to use when advertising or scanning and can use
> > different addresses for the same peer device.
> >
> > So I propose few changes:
> >
> > 1. Application does not specify own_addr_type in APIs
> > This should be selected automatically by host. By this I mean that
> > application tells host somehow at startup which address to use (public or
> > random static) and host will set parameters accordingly depending on
> > whether Privacy is enabled (IRK is provided) or disabled (no IRK
> provided).
>
> I think I have the same concern as Will. I was under the impression
> that a device can use different own_addr_type values for each
> connection. I know this has been useful for some low level debugging in
> the past, and it would nice if the host could support it.
>
Well, it depends on what you want to do :-)
#1 For some hacking, having low level (in this case HCI-like) interface is
definitely useful.
#2 For developing an application I'd prefer not to think about address
types too much. I just say: here's my identity, do what needs to be done
when I scan/advertise/connect.
I think main API should be application-friendly. I am perfectly fine with
lower level APIs as an addition though.
> In Zephyr, does the application specify a single own_addr_type at
> startup?
>
I don't know how it works in details, but IIRC host reads information on
statup from controller (address) or storage (address, IRK) and
automatically selects what it should do. Basically, you could as well
define this in build-time which is not much different than setting this at
startup.
My understanding is that this could work as below:
- read public device address
- if not found, check if we have stored random static address and use it
- if not found, randomize new random static address
- use the above as our address
- if privacy is enabled, try to load stored IRK or generated new one
- depending on privacy settings use proper own_addr_type when initiating
actions
> > 2. Application should always use peer identity address, if possible
> > Since host manages resolving list in controller already, address
> resolving
> > will be done automatically anyway. We can then assume that for any known
> > device, the address we use in API is identity address (assuming our IRK
> is
> > provided and thus Privacy is enabled)
>
> This is already the case, isn't it? As far as I know, whenever the host
> API accepts a peer address type / peer address pair, it is always the
> identity address.
>
In some cases this was not possible, see below :-)
> and honestly it does not need to know so-called OTA address, because
> > this is what host and controller take care of. The only exception here
> > would be for new devices for which application will have random (RPA)
> > address at first, but as soon as we are paired host should notify
> > application about identity address of such device - for this new event
> > shall be added.
>
> Currently, when a connection is established, the host tells the
> application two peer addresses:
> * Identity address
> * OTA address (we made up this term; I couldn't find a name for this
> in the spec).
>
Yes and no.
Yes, because if connection is established with bonded device then
controller will indeed provide identity address and OTA address.
No, because in case other than above both "identity" address and OTA
address are the same (which makes sense).
The problem is that once you are paired and identity address information is
exchanged, application still does only know "identity"=OTA=RPA and the only
way to know peer's actual identity address is to... disconnect and then