All of lore.kernel.org
 help / color / mirror / Atom feed
* bluez: Disable GATT client at non-initiator side?
@ 2019-03-19 15:04 Yauhen Kharuzhy
  2019-03-19 20:21 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: Yauhen Kharuzhy @ 2019-03-19 15:04 UTC (permalink / raw)
  To: linux-bluetooth

Hello,

I am trying to implement GATT services with bluez API.

If external device initiated LE connection to device with bluez
running, bluez start to discover services at initiator and, if one of
characteristics required pairing, request pairing. This is not
intended behaviour for some reason in my case, so I need to disable
GATT client if bluez is not initiator side of the connection, similar
to ReverseServiceDiscovery config option for non-LE.

Is it possible by any way? As i see code, device_attach_att() function
in src/device.c initializes GATT client unconditionally in both cases.
For debug, I disabled client initializing and this seems works for
external-initiated connections.

-- 
Yauhen Kharuzhy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bluez: Disable GATT client at non-initiator side?
  2019-03-19 15:04 bluez: Disable GATT client at non-initiator side? Yauhen Kharuzhy
@ 2019-03-19 20:21 ` Luiz Augusto von Dentz
  2019-03-20 11:25   ` Yauhen Kharuzhy
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2019-03-19 20:21 UTC (permalink / raw)
  To: Yauhen Kharuzhy; +Cc: linux-bluetooth

Hi Yauhen,

On Tue, Mar 19, 2019 at 5:07 PM Yauhen Kharuzhy <jekhor@gmail.com> wrote:
>
> Hello,
>
> I am trying to implement GATT services with bluez API.
>
> If external device initiated LE connection to device with bluez
> running, bluez start to discover services at initiator and, if one of
> characteristics required pairing, request pairing. This is not
> intended behaviour for some reason in my case, so I need to disable
> GATT client if bluez is not initiator side of the connection, similar
> to ReverseServiceDiscovery config option for non-LE.
>
> Is it possible by any way? As i see code, device_attach_att() function
> in src/device.c initializes GATT client unconditionally in both cases.
> For debug, I disabled client initializing and this seems works for
> external-initiated connections.

We could perhaps reuse the same logic to disable the GATT service
discovery, though the should not cause any pairing request since the
discovery don't actually read any value, apart from characteristic
declaration which shall not require authentication.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bluez: Disable GATT client at non-initiator side?
  2019-03-19 20:21 ` Luiz Augusto von Dentz
@ 2019-03-20 11:25   ` Yauhen Kharuzhy
  0 siblings, 0 replies; 3+ messages in thread
From: Yauhen Kharuzhy @ 2019-03-20 11:25 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

вт, 19 мар. 2019 г. в 23:22, Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
>
> Hi Yauhen,
>
> On Tue, Mar 19, 2019 at 5:07 PM Yauhen Kharuzhy <jekhor@gmail.com> wrote:
> >
> > Hello,
> >
> > I am trying to implement GATT services with bluez API.
> >
> > If external device initiated LE connection to device with bluez
> > running, bluez start to discover services at initiator and, if one of
> > characteristics required pairing, request pairing. This is not
> > intended behaviour for some reason in my case, so I need to disable
> > GATT client if bluez is not initiator side of the connection, similar
> > to ReverseServiceDiscovery config option for non-LE.
> >
> > Is it possible by any way? As i see code, device_attach_att() function
> > in src/device.c initializes GATT client unconditionally in both cases.
> > For debug, I disabled client initializing and this seems works for
> > external-initiated connections.
>
> We could perhaps reuse the same logic to disable the GATT service
> discovery, though the should not cause any pairing request since the
> discovery don't actually read any value, apart from characteristic
> declaration which shall not require authentication.

Yes, problem really in BATT profile accept stage:

164    16.407237    localhost (jeknotez)    5c:ca:67:f8:3b:11 ()
ATT    12    Sent Read Request, Handle: 0x0016 (Battery Service:
Battery Level)
166    16.466794    5c:ca:67:f8:3b:11 ()    localhost (jeknotez)
ATT    14    Rcvd Error Response - Insufficient Encryption, Handle:
0x0016 (Battery Service: Battery Level)
167    16.467125    localhost (jeknotez)    5c:ca:67:f8:3b:11 ()
SMP    11    Sent Security Request: AuthReq: Bonding,
SecureConnection, Reserved

сак 20 13:53:42 jeknotez bluetoothd[4945]:
profiles/battery/battery.c:batt_probe() BATT profile probe
(74:E0:C9:69:D2:8C)
сак 20 13:53:42 jeknotez bluetoothd[4945]:
src/service.c:change_state() 0x5557fcda23b0: device 74:E0:C9:69:D2:8C
profile batt-profile state changed: unavailable -> disconnected (0)
сак 20 13:53:42 jeknotez bluetoothd[4945]:
profiles/battery/battery.c:batt_accept() BATT profile accept
(74:E0:C9:69:D2:8C)
сак 20 13:53:42 jeknotez bluetoothd[4945]:
src/service.c:change_state() 0x5557fcda23b0: device 74:E0:C9:69:D2:8C
profile batt-profile state changed: disconnected -> connected (0)

device_probe_profiles()
...
batt_accept()
  gatt_db_foreach_service()
    foreach_batt_service()
      handle_batt_service()
        gatt_db_service_foreach_char()
          handle_characteristic()
                    if (uuid_cmp(GATT_CHARAC_BATTERY_LEVEL, &uuid)) {
                         handle_battery_level(batt, value_handle);
                    }



-- 
Yauhen Kharuzhy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-20 11:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 15:04 bluez: Disable GATT client at non-initiator side? Yauhen Kharuzhy
2019-03-19 20:21 ` Luiz Augusto von Dentz
2019-03-20 11:25   ` Yauhen Kharuzhy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.