2016-03-02 11:16:35

by Ivan Deviatkin

[permalink] [raw]
Subject: Fwd: GATT server example issues in BlueZ

Dears,

I am working on GATT server application and would like to use BlueZ for that.

Unfortunately, I have faced different issues during trying to
establish working GATT server from examples provided by Bluez.

First of all, I have tried to run gatt_example plugin from Bluez
package in Ubuntu environment (14.04 LTS 32 bit and 15.10 64 bit).
For that I have rebuild from source 5.37 (Ubuntu 14.04, default BlueZ
- 4.x) and 5.35 (Ubuntu 15.10 - default Bluez 5.35) with:

$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc
--localstatedir=/var --enable-experimental --enable-debug
--enable-maintainer-mode
--with-systemdsystemunitdir=/lib/systemd/system
--with-systemduserunitdir=/usr/lib/systemd

And I have ran "bluetoothd" (previously configured my Bluetooth
dongle Cirago BTA8000) via:
$ sudo ./bluetoothd --plugin=gatt_example -nEd

To communicate to my Linux environment I have used Android Nexus 6
with "BLE Scanner" application (I have checked also with other
applications - result the same). However it works as expected only for
version 5.27.

Starting from 5.28 till latest 5.37 it does not work to me. Logs
shows issue: "Not enough free handles to register service" (See logs
attached).
It looks similar to one mentioned here -
http://stackoverflow.com/questions/29891254/bluez-5-30-not-enough-free-handles-to-register-service-error-in-starting-blue.
I have checked this link, and can see, that method which adding
servers to "servers glist" btd_adapter_gatt_server_start() is called
in 5.27 but not called in 5.37 at all.

Additionally I have checked python example "example-gatt-server"
from \tests - it reports that GATT server is running but in bluetoothd
logs still the same issue.

Also I have tried to work with BlueZ D-Bus interface
(experimental) but I can see that some methods used during registering
of external service via D-Bus are not fully implemented yet, see
example (bluez 5.37/tools/gatt_service, line 414):
“ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
"{sv}", &dict);
/* TODO: Add options dictionary */ <-- it means what it
is not finished, right?

It seems to me, that without passing dictionary it is impossible
to register external service. Because dictionary includes information
about characteristics of service.

May I kindly ask you to clarify to me next:
- Should I apply manual fix (call of
btd_adapter_gatt_server_start() method or some other way of adding
server to list) for that in Bluez 5.37 source? If "yes" what is the
proper place to do that from design point of view?
- What is recommended (and working) example in BlueZ package to
run GATT server?
- What is recommended code to follow as example/sample for my own
GATT server application?
- If I would like to participate in development of BlueZ
(http://git.kernel.org/cgit/bluetooth/bluez.git) who is the right
person to get latest GATT serevr status and ask design questions, to
apply fixes in proper place?

BR,
Ivan


Attachments:
log.log (10.50 kB)

2016-03-03 16:31:23

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Ivan,

On Thu, Mar 3, 2016 at 1:24 PM, Ivan Deviatkin <[email protected]> wrote:
> Hi Kurt,
>
>> On 2 March 2016 at 21:42, Kurt McAlpine <[email protected]> wrote:
>> Hi Luiz,
>>
>> I too am having some with BlueZ 5.37 from git (I pulled today).
>>
>> I do see this but my android device cannot discover the GATT service within the
>> app. It is possible to pair with it, but not discover the services or even the
>> device within the app.
>>
>> I've tired "Bluetooth LE Scanner" and nRF Master Control Panel"
>>
>> Ivan if you have any success with this could you let me know how you did it?
>
> Unfortunately I have cloned BlueZ today too and have exactly the
> same issues as you.
> I believe some more investigation and fixes are required to make it work.
>

After removing the device, turn off/on the bluetooth, discover the
device using Android UI and then connecting using nRF master, or
whatever else since this apparently is bluedroid fault, this is the
outcome http://ix.io/oMm

It does connects, we do start sending responses but as soon as we send
any ATT request ourselves Bluedroid just seems unable to send any
request anymore. The spec is quite clear that we can send request as
well regardless if we are the peripheral or not, perhaps we can
disable our discovery when acting as a peripheral but not all profiles
have the GAP Peripheral must be the GATT server only and it is too bad
the test specification actually don't test this because now there are
probably a ton of Android devices just broken in this regard.



--
Luiz Augusto von Dentz

2016-03-03 11:24:01

by Ivan Deviatkin

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Kurt,

> On 2 March 2016 at 21:42, Kurt McAlpine <[email protected]> wrote:
> Hi Luiz,
>
> I too am having some with BlueZ 5.37 from git (I pulled today).
>
> I do see this but my android device cannot discover the GATT service within the
> app. It is possible to pair with it, but not discover the services or even the
> device within the app.
>
> I've tired "Bluetooth LE Scanner" and nRF Master Control Panel"
>
> Ivan if you have any success with this could you let me know how you did it?

Unfortunately I have cloned BlueZ today too and have exactly the
same issues as you.
I believe some more investigation and fixes are required to make it work.

BR,
Ivan

2016-03-03 11:20:07

by Ivan Deviatkin

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Luiz,

> On 3 March 2016 at 10:34, Luiz Augusto von Dentz <[email protected]> wrote:
> Do you guys remember that you have to advertise to be able to connect:
>
> ...
>
> Even with this I couldn't manage to connect using Android, even though
> it can find it but there is nothing set as a name (possible a bug in
> our end), if I do enable BR/EDR than it attempts to connect over it
> (priceless!) instead of LE where it got the advertisement.
>

I have setup my Bluetooth dongle via:
"
# activate bluetooth
sudo hciconfig hci0 up
sudo hciconfig hci0 pscan
# set advertise data: "hello world"
sudo hcitool -i hci0 cmd 0x08 0x0008 48 45 4c 4c 4f 57 4f 52 4c 44
# start advertising as connectable
sudo hciconfig hci0 leadv
"

And it works OK (pairing, retrieveing of services list) for BlueZ
5.27 in connection to my Android phone, except issues with name of
services.
Is anything missed or should be done additionally for latest BlueZ?

2016-03-03 11:11:26

by Ivan Deviatkin

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Luiz,

Thanks for fast reply and interesting details from your side.
Please find my explanations and questions below.

On 2 March 2016 at 14:50, Luiz Augusto von Dentz <[email protected]> wrote:
> Hi Ivan,
>
> On Wed, Mar 2, 2016 at 1:16 PM, Ivan Deviatkin <[email protected]> wrote:
>> Additionally I have checked python example "example-gatt-server"
>> from \tests - it reports that GATT server is running but in bluetoothd
>> logs still the same issue.
>
> So you don't see something like this:
>
>
> ./example-gatt-server
> GetManagedObjects
> GATT application registered
> ...
> Service added to local database
> bluetoothd[16205]: src/gatt-database.c:client_ready_cb() GATT
> application registered: :1.603:/

I have seen "GATT server registered" in console for
"example-gatt-server" in BlueZ 5.37 - but that fact does not mean that
service is visible and available on my Android Phone (Motorola Nexus
6, Android 5.1, LMY47I) via BLE Scanner, Bluetooth LE Scanner or BLE
Reader. I have seen a little bit different logs for bluetoothd, but I
think it is mainly because of using releases, not git upstream code.

>
>
>> Also I have tried to work with BlueZ D-Bus interface
>> (experimental) but I can see that some methods used during registering
>> of external service via D-Bus are not fully implemented yet, see
>> example (bluez 5.37/tools/gatt_service, line 414):
>> “ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
>> "{sv}", &dict);
>> /* TODO: Add options dictionary */ <-- it means what it
>> is not finished, right?
>> ”
>> It seems to me, that without passing dictionary it is impossible
>> to register external service. Because dictionary includes information
>> about characteristics of service.
>
> Also works just fine:
>
> ./gatt-service
> gatt-service unique name: :1.604
> Registered service: /service1
> Get Primary: True
> Get UUID: 00001802-0000-1000-8000-00805f9b34fb
> Exist Includes: 00001802-0000-1000-8000-00805f9b34fb
> Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value")
> Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value")
> Get Primary: True
> Get UUID: 00001802-0000-1000-8000-00805f9b34fb
> Exist Includes: 00001802-0000-1000-8000-00805f9b34fb
> Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value")
> Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value")
> RegisterApplication: OK
>
> bluetoothd[16205]: src/gatt-database.c:manager_register_app()
> Registering application: :1.604:/
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /service1, iface: org.bluez.GattService1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /service1/characteristic1, iface: org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /service1/characteristic1/descriptor2, iface:
> org.bluez.GattDescriptor1
> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
> Service added to local database
> bluetoothd[16205]: src/gatt-database.c:client_ready_cb() GATT
> application registered: :1.604:/
>

As I noticed above - I am afraid that logs from BlueZ by itself does
not mean that it works as it should. I have checked DBus interfaces
via d-feet and dbus-monitor. And as it was mentioned before - it was
empty to me. I have checked that on "example-gatt-server" - because it
uses DBus to register services.

>> May I kindly ask you to clarify to me next:
>> - Should I apply manual fix (call of
>> btd_adapter_gatt_server_start() method or some other way of adding
>> server to list) for that in Bluez 5.37 source? If "yes" what is the
>> proper place to do that from design point of view?
>
> Nope, just use the D-Bus API, perhaps you are missing some fixes
> upstream if so just use the latest git version.
>

I think it makes sense to check this issue, because check of server
list to NULL is done through a code in Bluez, but adding to that list
only in one place - method "btd_adapter_gatt_server_start()". And this
method is not called anywhere in BlueZ 5.37.

>> - What is recommended (and working) example in BlueZ package to
>> run GATT server?
>
> Both python and C example should actually work, the tricky part is
> making Android not to attempt to connect over BR/EDR once it realize
> you are running in dual mode which is usually the case, if you connect
> using another BlueZ it should work just fine.
>

Thanks for explanation. However, not clear - that do you mean by
"over BR/EDR" in retrospective to my Android phone - I can't find any
option to setup differently bluetooth.
Actually my goal is to use usual Android phone to connect to Linux
with Bluez using Bluetooth LE. I see that all examples BlueZ have
right now not working to me and other users as they should - that is
the problem to investigate and fix. Does BlueZ releases tested with
devices on market with Android or iOS? Because to me using Linux BlueZ
to connect another Linux Bluez seriously limitates it's usage.

>> - If I would like to participate in development of BlueZ
>> (http://git.kernel.org/cgit/bluetooth/bluez.git) who is the right
>> person to get latest GATT serevr status and ask design questions, to
>> apply fixes in proper place?
>
> I probably should be that person, but other individuals in the mailing
> list should be able to help as well, btw you could just figure this
> by looking at the git history but it seems you don't even have cloned
> the git tree.

Thank you for an explanation. A small remark - I have cloned the
git tree and have seen your name. However in BlueZ guidelines strictly
recommended to avoid direct contacts first ("Contact" section on BlueZ
site). So for me it is only gentle way of communication - to avoid
messy bothering of developers.

BR,
Ivan

2016-03-03 09:46:54

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi,

On Thu, Mar 03, 2016 at 11:34:04AM +0200, Luiz Augusto von Dentz wrote:
> > I do see this but my android device cannot discover the GATT service within the
> > app. It is possible to pair with it, but not discover the services or even the
> > device within the app.
> >
> > I've tired "Bluetooth LE Scanner" and nRF Master Control Panel"
> >
> > Ivan if you have any success with this could you let me know how you did it?
>
> Do you guys remember that you have to advertise to be able to connect:

I do it with btmgmt:

[mgmt]# advertising on
hci0 Set Advertising complete, settings: powered bondable ssp br/edr le
advertising secure-conn
[mgmt]# connectable on
hci0 Set Connectable complete, settings: powered connectable bondable
ssp br/edr le advertising secure-conn

Best regards
Andrei Emeltchenko


2016-03-03 09:34:04

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Kurt, Ivan,

On Wed, Mar 2, 2016 at 10:42 PM, Kurt McAlpine <[email protected]> wrote:
> Hi Luiz,
>
> I too am having some with BlueZ 5.37 from git (I pulled today).
>
> On Wed, Mar 02, 2016 at 03:50:50PM +0200, Luiz Augusto von Dentz wrote:
>> Hi Ivan,
>>
>> On Wed, Mar 2, 2016 at 1:16 PM, Ivan Deviatkin <[email protected]> wrote:
>> > Additionally I have checked python example "example-gatt-server"
>> > from \tests - it reports that GATT server is running but in bluetoothd
>> > logs still the same issue.
>>
>> So you don't see something like this:
>>
>>
>> ./example-gatt-server
>> GetManagedObjects
>> GATT application registered
>>
>> bluetoothd[16205]: src/gatt-database.c:manager_register_app()
>> Registering application: :1.603:/
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service0, iface: org.bluez.GattService1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service0/char0, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service0/char1, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service0/char2, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service1, iface: org.bluez.GattService1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service1/char0, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2, iface: org.bluez.GattService1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2/char0, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2/char0/desc0, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2/char0/desc1, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2/char1, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2/char1/desc2, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
>> path: /org/bluez/example/service2/char1/desc3, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16205]: src/gatt-database.c:database_add_ccc() Created CCC
>> entry for characteristic
>> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
>> Service added to local database
>> bluetoothd[16205]: src/gatt-database.c:database_add_ccc() Created CCC
>> entry for characteristic
>> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
>> Service added to local database
>> bluetoothd[16205]: src/gatt-database.c:cep_write_cb() Stored CEP value
>> in the database
>> bluetoothd[16205]: src/gatt-database.c:database_add_cep() Created CEP
>> entry for characteristic
>> bluetoothd[16205]: src/gatt-database.c:cep_write_cb() Stored CEP value
>> in the database
>> bluetoothd[16205]: src/gatt-database.c:database_add_cep() Created CEP
>> entry for characteristic
>> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
>> Service added to local database
>> bluetoothd[16205]: src/gatt-database.c:client_ready_cb() GATT
>> application registered: :1.603:/
>
> I do see this but my android device cannot discover the GATT service within the
> app. It is possible to pair with it, but not discover the services or even the
> device within the app.
>
> I've tired "Bluetooth LE Scanner" and nRF Master Control Panel"
>
> Ivan if you have any success with this could you let me know how you did it?

Do you guys remember that you have to advertise to be able to connect:

< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
[hci0] 686245.066488
Length: 30
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
16-bit Service UUIDs (complete): 2 entries
Heart Rate (0x180d)
Battery Service (0x180f)
Company: internal use (65535)
Data: 0001020304
Service Data (UUID 0x9999): 0001020304
TX power: 9 dBm
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 686245.139564
LE Set Advertising Data (0x08|0x0008) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Response Data (0x08|0x0009) plen 32
[hci0] 686245.139585
Length: 0
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 686245.140582
LE Set Scan Response Data (0x08|0x0009) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15
[hci0] 686245.140628
Min advertising interval: 1280.000 msec (0x0800)
Max advertising interval: 1280.000 msec (0x0800)
Type: Connectable undirected - ADV_IND (0x00)
Own address type: Public (0x00)
Direct address type: Public (0x00)
Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
Channel map: 37, 38, 39 (0x07)
Filter policy: Allow Scan Request from Any, Allow Connect
Request from Any (0x00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 686245.141553
LE Set Advertising Parameters (0x08|0x0006) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1
[hci0] 686245.141563
Advertising: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 686245.142554
LE Set Advertise Enable (0x08|0x000a) ncmd 2
Status: Success (0x00)

Even with this I couldn't manage to connect using Android, even though
it can find it but there is nothing set as a name (possible a bug in
our end), if I do enable BR/EDR than it attempts to connect over it
(priceless!) instead of LE where it got the advertisement.

--
Luiz Augusto von Dentz

2016-03-02 20:42:23

by Kurt McAlpine

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Luiz,

I too am having some with BlueZ 5.37 from git (I pulled today).

On Wed, Mar 02, 2016 at 03:50:50PM +0200, Luiz Augusto von Dentz wrote:
> Hi Ivan,
>
> On Wed, Mar 2, 2016 at 1:16 PM, Ivan Deviatkin <[email protected]> wrote:
> > Additionally I have checked python example "example-gatt-server"
> > from \tests - it reports that GATT server is running but in bluetoothd
> > logs still the same issue.
>
> So you don't see something like this:
>
>
> ./example-gatt-server
> GetManagedObjects
> GATT application registered
>
> bluetoothd[16205]: src/gatt-database.c:manager_register_app()
> Registering application: :1.603:/
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service0, iface: org.bluez.GattService1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service0/char0, iface:
> org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service0/char1, iface:
> org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service0/char2, iface:
> org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service1, iface: org.bluez.GattService1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service1/char0, iface:
> org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2, iface: org.bluez.GattService1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2/char0, iface:
> org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2/char0/desc0, iface:
> org.bluez.GattDescriptor1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2/char0/desc1, iface:
> org.bluez.GattDescriptor1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2/char1, iface:
> org.bluez.GattCharacteristic1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2/char1/desc2, iface:
> org.bluez.GattDescriptor1
> bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
> path: /org/bluez/example/service2/char1/desc3, iface:
> org.bluez.GattDescriptor1
> bluetoothd[16205]: src/gatt-database.c:database_add_ccc() Created CCC
> entry for characteristic
> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
> Service added to local database
> bluetoothd[16205]: src/gatt-database.c:database_add_ccc() Created CCC
> entry for characteristic
> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
> Service added to local database
> bluetoothd[16205]: src/gatt-database.c:cep_write_cb() Stored CEP value
> in the database
> bluetoothd[16205]: src/gatt-database.c:database_add_cep() Created CEP
> entry for characteristic
> bluetoothd[16205]: src/gatt-database.c:cep_write_cb() Stored CEP value
> in the database
> bluetoothd[16205]: src/gatt-database.c:database_add_cep() Created CEP
> entry for characteristic
> bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
> Service added to local database
> bluetoothd[16205]: src/gatt-database.c:client_ready_cb() GATT
> application registered: :1.603:/

I do see this but my android device cannot discover the GATT service within the
app. It is possible to pair with it, but not discover the services or even the
device within the app.

I've tired "Bluetooth LE Scanner" and nRF Master Control Panel"

Ivan if you have any success with this could you let me know how you did it?

Thanks,
Kurt

2016-03-02 13:50:50

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: GATT server example issues in BlueZ

Hi Ivan,

On Wed, Mar 2, 2016 at 1:16 PM, Ivan Deviatkin <[email protected]> wrote:
> Additionally I have checked python example "example-gatt-server"
> from \tests - it reports that GATT server is running but in bluetoothd
> logs still the same issue.

So you don't see something like this:


./example-gatt-server
GetManagedObjects
GATT application registered

bluetoothd[16205]: src/gatt-database.c:manager_register_app()
Registering application: :1.603:/
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service0, iface: org.bluez.GattService1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service0/char0, iface:
org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service0/char1, iface:
org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service0/char2, iface:
org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service1, iface: org.bluez.GattService1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service1/char0, iface:
org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2, iface: org.bluez.GattService1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2/char0, iface:
org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2/char0/desc0, iface:
org.bluez.GattDescriptor1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2/char0/desc1, iface:
org.bluez.GattDescriptor1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2/char1, iface:
org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2/char1/desc2, iface:
org.bluez.GattDescriptor1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /org/bluez/example/service2/char1/desc3, iface:
org.bluez.GattDescriptor1
bluetoothd[16205]: src/gatt-database.c:database_add_ccc() Created CCC
entry for characteristic
bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
Service added to local database
bluetoothd[16205]: src/gatt-database.c:database_add_ccc() Created CCC
entry for characteristic
bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
Service added to local database
bluetoothd[16205]: src/gatt-database.c:cep_write_cb() Stored CEP value
in the database
bluetoothd[16205]: src/gatt-database.c:database_add_cep() Created CEP
entry for characteristic
bluetoothd[16205]: src/gatt-database.c:cep_write_cb() Stored CEP value
in the database
bluetoothd[16205]: src/gatt-database.c:database_add_cep() Created CEP
entry for characteristic
bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
Service added to local database
bluetoothd[16205]: src/gatt-database.c:client_ready_cb() GATT
application registered: :1.603:/


> Also I have tried to work with BlueZ D-Bus interface
> (experimental) but I can see that some methods used during registering
> of external service via D-Bus are not fully implemented yet, see
> example (bluez 5.37/tools/gatt_service, line 414):
> “ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
> "{sv}", &dict);
> /* TODO: Add options dictionary */ <-- it means what it
> is not finished, right?
> ”
> It seems to me, that without passing dictionary it is impossible
> to register external service. Because dictionary includes information
> about characteristics of service.

Also works just fine:

./gatt-service
gatt-service unique name: :1.604
Registered service: /service1
Get Primary: True
Get UUID: 00001802-0000-1000-8000-00805f9b34fb
Exist Includes: 00001802-0000-1000-8000-00805f9b34fb
Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value")
Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value")
Get Primary: True
Get UUID: 00001802-0000-1000-8000-00805f9b34fb
Exist Includes: 00001802-0000-1000-8000-00805f9b34fb
Characteristic(00002a06-0000-1000-8000-00805f9b34fb): Get("Value")
Descriptor(8260c653-1a54-426b-9e36-e84c238bc669): Get("Value")
RegisterApplication: OK

bluetoothd[16205]: src/gatt-database.c:manager_register_app()
Registering application: :1.604:/
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /service1, iface: org.bluez.GattService1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /service1/characteristic1, iface: org.bluez.GattCharacteristic1
bluetoothd[16205]: src/gatt-database.c:proxy_added_cb() Object added:
path: /service1/characteristic1/descriptor2, iface:
org.bluez.GattDescriptor1
bluetoothd[16205]: src/gatt-database.c:gatt_db_service_added() GATT
Service added to local database
bluetoothd[16205]: src/gatt-database.c:client_ready_cb() GATT
application registered: :1.604:/

> May I kindly ask you to clarify to me next:
> - Should I apply manual fix (call of
> btd_adapter_gatt_server_start() method or some other way of adding
> server to list) for that in Bluez 5.37 source? If "yes" what is the
> proper place to do that from design point of view?

Nope, just use the D-Bus API, perhaps you are missing some fixes
upstream if so just use the latest git version.

> - What is recommended (and working) example in BlueZ package to
> run GATT server?

Both python and C example should actually work, the tricky part is
making Android not to attempt to connect over BR/EDR once it realize
you are running in dual mode which is usually the case, if you connect
using another BlueZ it should work just fine.

> - What is recommended code to follow as example/sample for my own
> GATT server application?

That will probably depend on the D-Bus library and language you intend
to use, we actually still have some problems with bindings that don't
maintain the order of objects, but I believe I should have a fix for
that pretty soon/

> - If I would like to participate in development of BlueZ
> (http://git.kernel.org/cgit/bluetooth/bluez.git) who is the right
> person to get latest GATT serevr status and ask design questions, to
> apply fixes in proper place?

I probably should be that person, but other individuals in the mailing
list should be able to help as well, btw you could just figure this
by looking at the git history but it seems you don't even have cloned
the git tree.