2015-12-05 21:21:22

by jacques klein

[permalink] [raw]
Subject: read data from a BLE device using gatt-client

Hello,

I am currently writing a small Bluez-5.35 Linux app to interact with a
BLE device.
I used as starting point and example the code in btgatt-client.c and
most things work.

But I have trouble to find out how to implement the "reading of data
sent" by the device after having sent the command "REQUEST_THIS_DATA".
Things are working because I can see the data displayed by the
att_debug_cb function.

# my (added) function
[GATT client]# request-day-prog <device> <day>
[GATT client]# att: ATT op 0x12
[GATT client]# att: < 12 11 04 20
04 ... .
[GATT client]# att: >
13 .
[GATT client]# att: ATT response received: 0x13
[GATT client]#
Write successful
# displayed by att_debug_cb, it's ok, the bytes make sense.
[GATT client]# att: > 1b 21 04 21 04 22 24 2a 36 22 66 2a 8a 22 90
22 .!.!."$*6"f*."."
[GATT client]# att: 90 22
90 .".
[GATT client]# att: ATT PDU received: 0x1b

what I don't know, is what I have to setup ( call some
bt_att_register_????() ? )
in order for a callback function of my app. to be called.

Any pointer to example, documentation, or even google search keywords
will be appreciated.
( I don't want to go into DBUS or Python, just stay with simple C
calling bt_att_... and/or bt_gatt_... functions )




2015-12-05 21:54:41

by Łukasz Rymanowski

[permalink] [raw]
Subject: Re: read data from a BLE device using gatt-client

Hi Jacques,

On Sat, Dec 5, 2015 at 10:21 PM, jacques klein <[email protected]> wrote:
> Hello,
>
> I am currently writing a small Bluez-5.35 Linux app to interact with a
> BLE device.
> I used as starting point and example the code in btgatt-client.c and
> most things work.
>
> But I have trouble to find out how to implement the "reading of data
> sent" by the device after having sent the command "REQUEST_THIS_DATA".
> Things are working because I can see the data displayed by the
> att_debug_cb function.
>
> # my (added) function
> [GATT client]# request-day-prog <device> <day>
> [GATT client]# att: ATT op 0x12
> [GATT client]# att: < 12 11 04 20
> 04 ... .
> [GATT client]# att: >
> 13 .
> [GATT client]# att: ATT response received: 0x13
> [GATT client]#
> Write successful
> # displayed by att_debug_cb, it's ok, the bytes make sense.
> [GATT client]# att: > 1b 21 04 21 04 22 24 2a 36 22 66 2a 8a 22 90
> 22 .!.!."$*6"f*."."
> [GATT client]# att: 90 22
> 90 .".
> [GATT client]# att: ATT PDU received: 0x1b
>
> what I don't know, is what I have to setup ( call some
> bt_att_register_????() ? )
> in order for a callback function of my app. to be called.
>
> Any pointer to example, documentation, or even google search keywords
> will be appreciated.
> ( I don't want to go into DBUS or Python, just stay with simple C
> calling bt_att_... and/or bt_gatt_... functions )
>
>

I'm not sure what is you goal. Anyway, data which has been sent you
can see with btmon tool
If your application wants to make sure what data has been sent to
remote then you might want
to check reliable session which uses prepare/execute write.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html


--
BR / Pozdrawiam
Łukasz