* Re: [PATCH v3 1/4] dt-bindings: net: Add TI WiLink shared transport binding
From: Sebastian Reichel @ 2017-04-15 19:38 UTC (permalink / raw)
To: Rob Herring
Cc: Marcel Holtmann, linux-bluetooth, linux-arm-kernel,
Gustavo Padovan, Johan Hedberg, Mark Rutland, Wei Xu, Eyal Reizer,
Satish Patel, netdev, devicetree
In-Reply-To: <20170413150353.7389-2-robh@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2021 bytes --]
Hi,
On Thu, Apr 13, 2017 at 10:03:50AM -0500, Rob Herring wrote:
> Add serial slave device binding for the TI WiLink series of Bluetooth/FM/GPS
> devices.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: netdev@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> ---
> v3:
> - rebase on bluetooth-next
>
> .../devicetree/bindings/net/ti,wilink-st.txt | 35 ++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/ti,wilink-st.txt
>
> diff --git a/Documentation/devicetree/bindings/net/ti,wilink-st.txt b/Documentation/devicetree/bindings/net/ti,wilink-st.txt
> new file mode 100644
> index 000000000000..cbad73a84ac4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/ti,wilink-st.txt
> @@ -0,0 +1,35 @@
> +TI WiLink 7/8 (wl12xx/wl18xx) Shared Transport BT/FM/GPS devices
> +
> +TI WiLink devices have a UART interface for providing Bluetooth, FM radio,
> +and GPS over what's called "shared transport". The shared transport is
> +standard BT HCI protocol with additional channels for the other functions.
> +
> +These devices also have a separate WiFi interface as described in
> +wireless/ti,wlcore.txt.
> +
> +This bindings follows the UART slave device binding in
> +../serial/slave-device.txt.
> +
> +Required properties:
> + - compatible: should be one of the following:
> + "ti,wl1271-st"
> + "ti,wl1273-st"
> + "ti,wl1831-st"
> + "ti,wl1835-st"
> + "ti,wl1837-st"
> +
> +Optional properties:
> + - enable-gpios : GPIO signal controlling enabling of BT. Active high.
> + - vio-supply : Vio input supply (1.8V)
> + - vbat-supply : Vbat input supply (2.9-4.8V)
> +
> +Example:
> +
> +&serial0 {
> + compatible = "ns16550a";
> + ...
> + bluetooth {
> + compatible = "ti,wl1835-st";
> + enable-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
> + };
> +};
Reviewed-by: Sebastian Reichel <sre@kernel.org>
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Olivier MARTIN @ 2017-04-15 11:11 UTC (permalink / raw)
To: Barry Byford; +Cc: Bluez mailing list
In-Reply-To: <CAAu3APaxi82L56NNEnpZP4o+Z99qE_aGcAzGRJFOe+j0N_8irA@mail.gmail.com>
Thanks a lot Barry for the following up. I will keep the workaround for
now.
I will likely come back on this issue in the next months to see how I
can help implementing a fix for Bluez.
On 14.04.2017 20:31, Barry Byford wrote:
> Hello Olivier,
>
> On 14 April 2017 at 19:14, Olivier MARTIN <olivier@labapart.com> wrote:
>> Thanks Barry, setting 'ControllerMode = le' in
>> /etc/bluetooth/main.conf
>> fixed my issue. I can now see the GATT services.
>
> Good news!
>
>> But I guess my adapter now only works as BLE adapter and will ignore
>> the
>> non-LE devices.
>> In the comment of /etc/bluetooth/main.conf it is written the adapter
>> should
>> be by default set as 'dual'.
>>
>> Is it a bug in Bluez? Why GATT services are not exposed while using
>> the
>> default value for 'ControllerMode'?
>
> This issue has come up before and was discuss here:
> http://marc.info/?l=linux-bluetooth&m=146071596012263&w=2
>
>
>
>
>> On 14.04.2017 14:30, Barry Byford wrote:
>>>
>>> Hello Olivier,
>>>
>>>
>>> On 14 April 2017 at 12:01, Olivier MARTIN <olivier@labapart.com>
>>> wrote:
>>>>
>>>> You are right Barry, `example-advertisement` seems to work well (I
>>>> installed
>>>> and tried Nordic nRF Connect and I can see the expected advertisemet
>>>> data).
>>>
>>>
>>> Excellent!
>>>
>>>
>>>> But I cannot still manage to get `example-gatt-server` :-(
>>>> I am sure I got it working last year with an older version of Bluez.
>>>> But
>>>> I
>>>> cannot make it work with Bluez v5.44.
>>>
>>>
>>> OK, I've taken a look at "example-gatt-server" and have it working...
>>>
>>>>
>>>> My testing procedure:
>>>>
>>>> 1. [Laptop] First terminal: Start `sudo ./src/bluetoothd -E -n -d`
>>>> 2. [Laptop] Second terminal: Start unmodified Bluez
>>>> ./test/example-gatt-server
>>>> 3. [Laptop] Third terminal: Ensure the adapter is "Powered: yes" and
>>>> "Discoverable: yes"
>>>
>>>
>>> OK, I've done this slightly different (details below). However, the
>>> first thing I did was edit "/etc/bluetooth/main.conf"
>>> I added the following line to the end of the file:
>>>
>>> ControllerMode = le
>>>
>>> Then I did the following:
>>> 1. [SBC1:T1] sudo ./src/bluetoothd -E -n -d
>>> 2. [SBC1:T2] ./example-gatt-server
>>> 3. [SBC1:T3] ./example-advertisement
>>>
>>>
>>>>
>>>> 4. [Android] Connect using Nordic nRF Connect (I also tried with
>>>> "BLE
>>>> Scanner") and check I see the exposed GATT services by
>>>> `example-gatt-server`
>>>> Unfortunately, I can only see:
>>>> - Generic Access Service (0x1800)
>>>> - Generic Attribute Service (0x1801)
>>>>
>>>
>>> I've used bluetoothctl on SBC2 to connect and read the battery values
>>> that the GATT server is counting down.
>>>
>>> $ bluetoothctl
>>> [NEW] Controller 00:00:00:00:5A:AD linaro-alip [default]
>>> [bluetooth]# scan on
>>> Discovery started
>>> [CHG] Controller 00:00:00:00:5A:AD Discovering: yes
>>> [NEW] Device B8:27:EB:22:57:E0 BluezeroLight
>>> [bluetooth]# scan off
>>> Discovery stopped
>>> [CHG] Controller 00:00:00:00:5A:AD Discovering: no
>>> [bluetooth]# connect B8:27:EB:22:57:E0
>>> Attempting to connect to B8:27:EB:22:57:E0
>>> [CHG] Device B8:27:EB:22:57:E0 Connected: yes
>>> Connection successful
>>> [...snip...]
>>> [NEW] Primary Service
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a
>>> 0000180f-0000-1000-8000-00805f9b34fb
>>> Battery Service
>>> [NEW] Characteristic
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
>>> 00002a19-0000-1000-8000-00805f9b34fb
>>> Battery Level
>>> [...snip...]
>>> [CHG] Device B8:27:EB:22:57:E0 ServicesResolved: yes
>>> [BluezeroLight]# select-attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
>>> [BluezeroLight:/service000a/char000b]# read
>>> Attempting to read
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value:
>>> 0x46
>>> 46 F
>>> [BluezeroLight:/service000a/char000b]# notify on
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
>>> yes
>>> Notify started
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value:
>>> 0x46
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value:
>>> 0x44
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value:
>>> 0x42
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value:
>>> 0x40
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value:
>>> 0x3e
>>> [BluezeroLight:/service000a/char000b]# notify off
>>> [CHG] Attribute
>>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
>>> no
>>> Notify stopped
>>>
>>>
>>> That seems to be working then. When I didn't have "ControllerMode =
>>> le" set then I did see it be unpredictable if it successfully
>>> connected or not.
>>> This also worked connecting with the nRF app.
>>>
>>>
>>> Does that work for you?
>>>
>>>
>>>
>>>
>>>> If I had to suspect Bluez code, I will guess there is something
>>>> missing
>>>> around here:
>>>>
>>>> bluetoothd[20429]: src/device.c:gatt_server_init() #
>>>> gatt_server_init
>>>> bluetoothd[20429]: src/device.c:gatt_debug() Primary services found:
>>>> 2
>>>> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0001, end:
>>>> 0x0005,
>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0014, end:
>>>> 0xffff,
>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[20429]: src/device.c:gatt_debug() Registered handler for
>>>> "Service
>>>> Changed": 0
>>>> bluetoothd[20429]: src/device.c:gatt_client_ready_cb() status:
>>>> success,
>>>> error: 0
>>>>
>>>> As Bluez daemon does not get the GATT services from Buez GATT
>>>> Database.
>>>> But
>>>> it might be me who miss a step...
>>>>
>>>>
>>>> On 14.04.2017 12:37, Barry Byford wrote:
>>>>>
>>>>>
>>>>> example-advertisementHello Oliver,
>>>>>
>>>>>
>>>>> On 14 April 2017 at 11:03, Olivier MARTIN <olivier@labapart.com>
>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> Thanks for replying my message Barry,
>>>>>>
>>>>>> Sorry, I forgot to mention but I start Bluez daemon with `sudo
>>>>>> ./src/bluetoothd -E -n -d` (after stopping the bluetooth service).
>>>>>> So I
>>>>>> already run it with sudo and experimental option.
>>>>>>
>>>>>> I am not sure to understand what you mean by "this kind of error
>>>>>> message".
>>>>>> Because I do not see any error message in the log I provided.
>>>>>
>>>>>
>>>>>
>>>>> OK, that was bad on my part. I read it as complaining that there
>>>>> were
>>>>> too many advertisements. Looking again that wasn't what it was say.
>>>>> Apologies.
>>>>>
>>>>>>
>>>>>> Any other idea?
>>>>>
>>>>>
>>>>>
>>>>> I am by Linux Single Board Computers (SBC) today so I'm able to run
>>>>> what you are running and can show you what I'm seeing. I'll focus
>>>>> on
>>>>> example-advertisement first as example-gatt-server doesn't change
>>>>> the
>>>>> advertisements.
>>>>>
>>>>> I've started the BlueZ daemon with "./src/bluetoothd -E -n -d"
>>>>>
>>>>> In another shell when I start "./example-advertisement" I see the
>>>>> following in the output:
>>>>>
>>>>> bluetoothd[2325]: src/adapter.c:property_set_mode() sending Set
>>>>> Powered command for index 0
>>>>> bluetoothd[2325]: src/adapter.c:property_set_mode_complete()
>>>>> Success
>>>>> (0x00)
>>>>> bluetoothd[2325]: src/adapter.c:new_settings_callback() Settings:
>>>>> 0x00000ad1
>>>>> bluetoothd[2325]: src/adapter.c:settings_changed() Changed
>>>>> settings:
>>>>> 0x00000001
>>>>> bluetoothd[2325]: src/adapter.c:adapter_start() adapter
>>>>> /org/bluez/hci0 has been enabled
>>>>> bluetoothd[2325]: src/adapter.c:trigger_passive_scanning()
>>>>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>>>>> RegisterAdvertisement
>>>>> bluetoothd[2325]: src/advertising.c:client_create() Adding proxy
>>>>> for
>>>>> /org/bluez/example/advertisement0
>>>>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>>>>> Registered advertisement at path /org/bluez/example/advertisement0
>>>>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>>>>> ServiceUUID: 180D
>>>>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>>>>> ServiceUUID: 180F
>>>>> bluetoothd[2325]: src/advertising.c:parse_manufacturer_data()
>>>>> Adding
>>>>> ManufacturerData for ffff
>>>>> bluetoothd[2325]: src/advertising.c:parse_service_data() Adding
>>>>> ServiceData for 9999
>>>>> bluetoothd[2325]: src/advertising.c:refresh_advertisement()
>>>>> Refreshing
>>>>> advertisement: /org/bluez/example/advertisement0
>>>>> bluetoothd[2325]: src/advertising.c:add_adv_callback()
>>>>> Advertisement
>>>>> registered: /org/bluez/example/advertisement0
>>>>>
>>>>>
>>>>> On a second SBC, at the command line I run "bluetoothctl" and do
>>>>> "scan
>>>>> on". Once my first SBC is found I do "scan off". I then do "info
>>>>> B8:27:EB:22:57:E0" (this is the address of the first SBC) which
>>>>> gives
>>>>> the following output:
>>>>>
>>>>> [bluetooth]# info B8:27:EB:22:57:E0
>>>>> Device B8:27:EB:22:57:E0
>>>>> Alias: B8-27-EB-22-57-E0
>>>>> Paired: no
>>>>> Trusted: no
>>>>> Blocked: no
>>>>> Connected: no
>>>>> LegacyPairing: no
>>>>> UUID: Heart Rate
>>>>> (0000180d-0000-1000-8000-00805f9b34fb)
>>>>> UUID: Battery Service
>>>>> (0000180f-0000-1000-8000-00805f9b34fb)
>>>>> ManufacturerData Key: 0xffff
>>>>> ManufacturerData Value: 0x00
>>>>> ManufacturerData Value: 0x01
>>>>> ManufacturerData Value: 0x02
>>>>> ManufacturerData Value: 0x03
>>>>> ManufacturerData Value: 0x04
>>>>> ServiceData Key: 00009999-0000-1000-8000-00805f9b34fb
>>>>> ServiceData Value: 0x00
>>>>> ServiceData Value: 0x01
>>>>> ServiceData Value: 0x02
>>>>> ServiceData Value: 0x03
>>>>> ServiceData Value: 0x04
>>>>>
>>>>>
>>>>> I've also done a scan from my Android phone (using the Nordic nRF
>>>>> Connect app) and can see the advertisements also (just hard to
>>>>> share
>>>>> that information on here).
>>>>>
>>>>> Does that help?
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>>> On 13.04.2017 19:59, Barry Byford wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Hello Olivier,
>>>>>>>
>>>>>>>
>>>>>>> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Hi all,
>>>>>>>> I am having issue to advertise/export GATT services exposed
>>>>>>>> through
>>>>>>>> DBus
>>>>>>>> API. I tried `./test/example-gatt-server`. And I also tried to
>>>>>>>> merge
>>>>>>>> `./test/example-advertisement` into
>>>>>>>> `./test/example-gatt-server`. But
>>>>>>>> in
>>>>>>>> both cases I only see the two compulsory GATT services:
>>>>>>>> - Generic Access Service (0x1800)
>>>>>>>> - Generic Attribute Service (0x1801)
>>>>>>>>
>>>>>>>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>>>>>>>
>>>>>>>> GATT Services seem to be discovered by Bluez (note: I added
>>>>>>>> additional
>>>>>>>> debug
>>>>>>>> statement all prefixed with '#'):
>>>>>>>>
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>>>>>>>> manager_register_app
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app()
>>>>>>>> Registering
>>>>>>>> application: :1.404:/
>>>>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>>>>> RegisterAdvertisement
>>>>>>>> bluetoothd[16877]: src/advertising.c:client_create() Adding
>>>>>>>> proxy for
>>>>>>>> /org/bluez/example/advertisement0
>>>>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>>>>> Registered
>>>>>>>> advertisement at path /org/bluez/example/advertisement0
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service0/char2, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char0/desc0, iface:
>>>>>>>> org.bluez.GattDescriptor1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char2/desc3, iface:
>>>>>>>> org.bluez.GattDescriptor1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char2, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service1/char0, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char1, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service0/char1, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char1/desc3, iface:
>>>>>>>> org.bluez.GattDescriptor1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char1/desc2, iface:
>>>>>>>> org.bluez.GattDescriptor1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service0/char0, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2, iface: org.bluez.GattService1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service1, iface: org.bluez.GattService1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service0, iface: org.bluez.GattService1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char0/desc1, iface:
>>>>>>>> org.bluez.GattDescriptor1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char2/desc2, iface:
>>>>>>>> org.bluez.GattDescriptor1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>>> received:
>>>>>>>> /org/bluez/example/service2/char0, iface:
>>>>>>>> org.bluez.GattCharacteristic1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>>>>>>>> client_ready_cb
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>>>> create_service
>>>>>>>> from /org/bluez/example/service2
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>>>> create_service
>>>>>>>> from /org/bluez/example/service1
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>>>> create_service
>>>>>>>> from /org/bluez/example/service0
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>>>>>>>> database_add_app
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>>>> database_add_service
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>>>> value
>>>>>>>> in
>>>>>>>> the database
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep()
>>>>>>>> Created CEP
>>>>>>>> entry
>>>>>>>> for characteristic
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>>>> value
>>>>>>>> in
>>>>>>>> the database
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep()
>>>>>>>> Created CEP
>>>>>>>> entry
>>>>>>>> for characteristic
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>>>> value
>>>>>>>> in
>>>>>>>> the database
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep()
>>>>>>>> Created CEP
>>>>>>>> entry
>>>>>>>> for characteristic
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>>>> database_add_service
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc()
>>>>>>>> Created CCC
>>>>>>>> entry
>>>>>>>> for characteristic
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>>>> database_add_service
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc()
>>>>>>>> Created CCC
>>>>>>>> entry
>>>>>>>> for characteristic
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT
>>>>>>>> application
>>>>>>>> registered: :1.404:/
>>>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids()
>>>>>>>> Adding
>>>>>>>> ServiceUUID: 180D
>>>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids()
>>>>>>>> Adding
>>>>>>>> ServiceUUID: 180F
>>>>>>>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data()
>>>>>>>> Adding
>>>>>>>> ManufacturerData for ffff
>>>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>>>>>>>> ServiceData
>>>>>>>> for 9999
>>>>>>>> bluetoothd[16877]: src/advertising.c:refresh_advertisement()
>>>>>>>> Refreshing
>>>>>>>> advertisement: /org/bluez/example/advertisement0
>>>>>>>> bluetoothd[16877]: src/advertising.c:add_adv_callback()
>>>>>>>> Advertisement
>>>>>>>> registered: /org/bluez/example/advertisement0
>>>>>>>>
>>>>>>>> I start `./test/example-gatt-server` as a normal user. But Bluez
>>>>>>>> does
>>>>>>>> not
>>>>>>>> seem to have any permission issue with it.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Building from source I've seen something similar if I've used
>>>>>>> sudo for
>>>>>>> the
>>>>>>> make.
>>>>>>>
>>>>>>> To compile and install I use sudo for the install only:
>>>>>>>
>>>>>>> make -j 4 && sudo make install
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>
>>>>>>>> I am using 'BLE scanner' on Android to discover the GATT
>>>>>>>> services.
>>>>>>>> But
>>>>>>>> I
>>>>>>>> think the problem is coming from Bluez. When I connect the
>>>>>>>> Android
>>>>>>>> device
>>>>>>>> to
>>>>>>>> Bluez, I can see this log:
>>>>>>>>
>>>>>>>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0
>>>>>>>> device
>>>>>>>> 98:D6:F7:31:7B:0D connected eir_len 14
>>>>>>>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming
>>>>>>>> BR/EDR
>>>>>>>> ATT
>>>>>>>> connection
>>>>>>>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>>>>>>>> g_attrib_ref=1
>>>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db:
>>>>>>>> Restoring
>>>>>>>> 98:D6:F7:31:7B:0D gatt database from file
>>>>>>>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>>>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() #
>>>>>>>> load_gatt_db_impl
>>>>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>>>>>> loading
>>>>>>>> service: 0x0001, end: 0x0005, uuid:
>>>>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>>>>>> loading
>>>>>>>> service: 0x0014, end: 0xffff, uuid:
>>>>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading
>>>>>>>> characteristic
>>>>>>>> handle:
>>>>>>>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>>>>>>>> 00002a05-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading
>>>>>>>> characteristic
>>>>>>>> handle:
>>>>>>>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>>>>>>>> 00002a00-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading
>>>>>>>> characteristic
>>>>>>>> handle:
>>>>>>>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>>>>>>>> 00002a01-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT
>>>>>>>> Primaries
>>>>>>>> before
>>>>>>>> being free:
>>>>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile
>>>>>>>> accept
>>>>>>>> (98:D6:F7:31:7B:0D)
>>>>>>>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0:
>>>>>>>> device
>>>>>>>> 98:D6:F7:31:7B:0D profile gap-profile state changed:
>>>>>>>> disconnected ->
>>>>>>>> connected (0)
>>>>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected()
>>>>>>>> Device
>>>>>>>> connected.
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_server_init() #
>>>>>>>> gatt_server_init
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services
>>>>>>>> found:
>>>>>>>> 2
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>>>>> 0x0005,
>>>>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>>>>> 0xffff,
>>>>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler
>>>>>>>> for
>>>>>>>> "Service
>>>>>>>> Changed": 0
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status:
>>>>>>>> success,
>>>>>>>> error: 0
>>>>>>>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>>>>>>>> register_gatt_services
>>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>>> bluetoothd[16877]: src/device.c:add_gatt_service() #
>>>>>>>> add_gatt_service:
>>>>>>>> UUID:00001801-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready()
>>>>>>>> GATT
>>>>>>>> client
>>>>>>>> ready
>>>>>>>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting
>>>>>>>> objects
>>>>>>>> for
>>>>>>>> GATT services: 98:D6:F7:31:7B:0D
>>>>>>>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported
>>>>>>>> GATT
>>>>>>>> service:
>>>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>>>>>>>> bluetoothd[16877]: src/gatt-client.c:characteristic_create()
>>>>>>>> Exported
>>>>>>>> GATT
>>>>>>>> characteristic:
>>>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>>>>>>>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>>>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>>>>>>>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>>>>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP
>>>>>>>> Device
>>>>>>>> Name:
>>>>>>>> Nexus 4
>>>>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>>>>>>>> Appearance:
>>>>>>>> 0x0000
>>>>>>>>
>>>>>>>> I also reduced DBus 'TestAdvertisement' interface to only expose
>>>>>>>> one
>>>>>>>> GATT
>>>>>>>> Service as many BLE adapter got a limitation in the size of the
>>>>>>>> advertisement packet:
>>>>>>>> class TestAdvertisement(Advertisement):
>>>>>>>>
>>>>>>>> def __init__(self, bus, index):
>>>>>>>> Advertisement.__init__(self, bus, index, 'peripheral')
>>>>>>>> #self.add_service_uuid('180D') # HeartRate
>>>>>>>> self.add_service_uuid('180F') # Battery
>>>>>>>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02,
>>>>>>>> 0x03,
>>>>>>>> 0x04])
>>>>>>>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03,
>>>>>>>> 0x04])
>>>>>>>> self.include_tx_power = True
>>>>>>>>
>>>>>>>> My concern is mainly these lines:
>>>>>>>>
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services
>>>>>>>> found:
>>>>>>>> 2
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>>>>> 0x0005,
>>>>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>>>>> 0xffff,
>>>>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>>>>
>>>>>>>
>>>>>>> I've seen this kind of error message when I've had a failure of a
>>>>>>> previous script and the Bluetooth daemon is in some unknown
>>>>>>> state. At
>>>>>>> this point it is worth restarting the bluetooth service with:
>>>>>>> sudo service bluetooth restart
>>>>>>>
>>>>>>> You will see in the advertising DBus API documentation that it is
>>>>>>> still in experimental mode in 5.44.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>>>>>>>
>>>>>>> This means that you need to make sure bluetoothd is started in
>>>>>>> experimental mode. Have you done this?
>>>>>>> You can check with "sudo service bluetooth status"
>>>>>>>
>>>>>>> Experimental can be switched on by default in the
>>>>>>> bluetooth.service
>>>>>>> file
>>>>>>>
>>>>>>> Edit /lib/systemd/system/bluetooth.service file to add
>>>>>>> --experimental
>>>>>>> flag
>>>>>>> e.g:
>>>>>>>
>>>>>>> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
>>>>>>> /lib/systemd/system/bluetooth.service
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> I have not found the code that export GATT Services from GATT
>>>>>>>> Database
>>>>>>>> to
>>>>>>>> the BLE central.
>>>>>>>>
>>>>>>>> From my search on Internet, it looks I am not the only one who
>>>>>>>> is
>>>>>>>> having
>>>>>>>> this issue
>>>>>>>> I am happy to share/test anything that could help to make some
>>>>>>>> progress.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Olivier
>>>>>>>> --
>>>>>>>> To unsubscribe from this list: send the line "unsubscribe
>>>>>>>> linux-bluetooth"
>>>>>>>> in
>>>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>>>> More majordomo info at
>>>>>>>> http://vger.kernel.org/majordomo-info.html
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Barry Byford @ 2017-04-14 18:31 UTC (permalink / raw)
To: Olivier MARTIN; +Cc: Bluez mailing list
In-Reply-To: <a43ea6310f8292d7d5c053a7ab027fec@labapart.com>
Hello Olivier,
On 14 April 2017 at 19:14, Olivier MARTIN <olivier@labapart.com> wrote:
> Thanks Barry, setting 'ControllerMode = le' in /etc/bluetooth/main.conf
> fixed my issue. I can now see the GATT services.
Good news!
> But I guess my adapter now only works as BLE adapter and will ignore the
> non-LE devices.
> In the comment of /etc/bluetooth/main.conf it is written the adapter should
> be by default set as 'dual'.
>
> Is it a bug in Bluez? Why GATT services are not exposed while using the
> default value for 'ControllerMode'?
This issue has come up before and was discuss here:
http://marc.info/?l=linux-bluetooth&m=146071596012263&w=2
> On 14.04.2017 14:30, Barry Byford wrote:
>>
>> Hello Olivier,
>>
>>
>> On 14 April 2017 at 12:01, Olivier MARTIN <olivier@labapart.com> wrote:
>>>
>>> You are right Barry, `example-advertisement` seems to work well (I
>>> installed
>>> and tried Nordic nRF Connect and I can see the expected advertisemet
>>> data).
>>
>>
>> Excellent!
>>
>>
>>> But I cannot still manage to get `example-gatt-server` :-(
>>> I am sure I got it working last year with an older version of Bluez. But
>>> I
>>> cannot make it work with Bluez v5.44.
>>
>>
>> OK, I've taken a look at "example-gatt-server" and have it working...
>>
>>>
>>> My testing procedure:
>>>
>>> 1. [Laptop] First terminal: Start `sudo ./src/bluetoothd -E -n -d`
>>> 2. [Laptop] Second terminal: Start unmodified Bluez
>>> ./test/example-gatt-server
>>> 3. [Laptop] Third terminal: Ensure the adapter is "Powered: yes" and
>>> "Discoverable: yes"
>>
>>
>> OK, I've done this slightly different (details below). However, the
>> first thing I did was edit "/etc/bluetooth/main.conf"
>> I added the following line to the end of the file:
>>
>> ControllerMode = le
>>
>> Then I did the following:
>> 1. [SBC1:T1] sudo ./src/bluetoothd -E -n -d
>> 2. [SBC1:T2] ./example-gatt-server
>> 3. [SBC1:T3] ./example-advertisement
>>
>>
>>>
>>> 4. [Android] Connect using Nordic nRF Connect (I also tried with "BLE
>>> Scanner") and check I see the exposed GATT services by
>>> `example-gatt-server`
>>> Unfortunately, I can only see:
>>> - Generic Access Service (0x1800)
>>> - Generic Attribute Service (0x1801)
>>>
>>
>> I've used bluetoothctl on SBC2 to connect and read the battery values
>> that the GATT server is counting down.
>>
>> $ bluetoothctl
>> [NEW] Controller 00:00:00:00:5A:AD linaro-alip [default]
>> [bluetooth]# scan on
>> Discovery started
>> [CHG] Controller 00:00:00:00:5A:AD Discovering: yes
>> [NEW] Device B8:27:EB:22:57:E0 BluezeroLight
>> [bluetooth]# scan off
>> Discovery stopped
>> [CHG] Controller 00:00:00:00:5A:AD Discovering: no
>> [bluetooth]# connect B8:27:EB:22:57:E0
>> Attempting to connect to B8:27:EB:22:57:E0
>> [CHG] Device B8:27:EB:22:57:E0 Connected: yes
>> Connection successful
>> [...snip...]
>> [NEW] Primary Service
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a
>> 0000180f-0000-1000-8000-00805f9b34fb
>> Battery Service
>> [NEW] Characteristic
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
>> 00002a19-0000-1000-8000-00805f9b34fb
>> Battery Level
>> [...snip...]
>> [CHG] Device B8:27:EB:22:57:E0 ServicesResolved: yes
>> [BluezeroLight]# select-attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
>> [BluezeroLight:/service000a/char000b]# read
>> Attempting to read
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x46
>> 46 F
>> [BluezeroLight:/service000a/char000b]# notify on
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
>> yes
>> Notify started
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x46
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x44
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x42
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x40
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x3e
>> [BluezeroLight:/service000a/char000b]# notify off
>> [CHG] Attribute
>> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
>> no
>> Notify stopped
>>
>>
>> That seems to be working then. When I didn't have "ControllerMode =
>> le" set then I did see it be unpredictable if it successfully
>> connected or not.
>> This also worked connecting with the nRF app.
>>
>>
>> Does that work for you?
>>
>>
>>
>>
>>> If I had to suspect Bluez code, I will guess there is something missing
>>> around here:
>>>
>>> bluetoothd[20429]: src/device.c:gatt_server_init() # gatt_server_init
>>> bluetoothd[20429]: src/device.c:gatt_debug() Primary services found: 2
>>> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>> bluetoothd[20429]: src/device.c:gatt_debug() Registered handler for
>>> "Service
>>> Changed": 0
>>> bluetoothd[20429]: src/device.c:gatt_client_ready_cb() status: success,
>>> error: 0
>>>
>>> As Bluez daemon does not get the GATT services from Buez GATT Database.
>>> But
>>> it might be me who miss a step...
>>>
>>>
>>> On 14.04.2017 12:37, Barry Byford wrote:
>>>>
>>>>
>>>> example-advertisementHello Oliver,
>>>>
>>>>
>>>> On 14 April 2017 at 11:03, Olivier MARTIN <olivier@labapart.com> wrote:
>>>>>
>>>>>
>>>>> Thanks for replying my message Barry,
>>>>>
>>>>> Sorry, I forgot to mention but I start Bluez daemon with `sudo
>>>>> ./src/bluetoothd -E -n -d` (after stopping the bluetooth service). So I
>>>>> already run it with sudo and experimental option.
>>>>>
>>>>> I am not sure to understand what you mean by "this kind of error
>>>>> message".
>>>>> Because I do not see any error message in the log I provided.
>>>>
>>>>
>>>>
>>>> OK, that was bad on my part. I read it as complaining that there were
>>>> too many advertisements. Looking again that wasn't what it was say.
>>>> Apologies.
>>>>
>>>>>
>>>>> Any other idea?
>>>>
>>>>
>>>>
>>>> I am by Linux Single Board Computers (SBC) today so I'm able to run
>>>> what you are running and can show you what I'm seeing. I'll focus on
>>>> example-advertisement first as example-gatt-server doesn't change the
>>>> advertisements.
>>>>
>>>> I've started the BlueZ daemon with "./src/bluetoothd -E -n -d"
>>>>
>>>> In another shell when I start "./example-advertisement" I see the
>>>> following in the output:
>>>>
>>>> bluetoothd[2325]: src/adapter.c:property_set_mode() sending Set
>>>> Powered command for index 0
>>>> bluetoothd[2325]: src/adapter.c:property_set_mode_complete() Success
>>>> (0x00)
>>>> bluetoothd[2325]: src/adapter.c:new_settings_callback() Settings:
>>>> 0x00000ad1
>>>> bluetoothd[2325]: src/adapter.c:settings_changed() Changed settings:
>>>> 0x00000001
>>>> bluetoothd[2325]: src/adapter.c:adapter_start() adapter
>>>> /org/bluez/hci0 has been enabled
>>>> bluetoothd[2325]: src/adapter.c:trigger_passive_scanning()
>>>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>>>> RegisterAdvertisement
>>>> bluetoothd[2325]: src/advertising.c:client_create() Adding proxy for
>>>> /org/bluez/example/advertisement0
>>>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>>>> Registered advertisement at path /org/bluez/example/advertisement0
>>>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>>>> ServiceUUID: 180D
>>>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>>>> ServiceUUID: 180F
>>>> bluetoothd[2325]: src/advertising.c:parse_manufacturer_data() Adding
>>>> ManufacturerData for ffff
>>>> bluetoothd[2325]: src/advertising.c:parse_service_data() Adding
>>>> ServiceData for 9999
>>>> bluetoothd[2325]: src/advertising.c:refresh_advertisement() Refreshing
>>>> advertisement: /org/bluez/example/advertisement0
>>>> bluetoothd[2325]: src/advertising.c:add_adv_callback() Advertisement
>>>> registered: /org/bluez/example/advertisement0
>>>>
>>>>
>>>> On a second SBC, at the command line I run "bluetoothctl" and do "scan
>>>> on". Once my first SBC is found I do "scan off". I then do "info
>>>> B8:27:EB:22:57:E0" (this is the address of the first SBC) which gives
>>>> the following output:
>>>>
>>>> [bluetooth]# info B8:27:EB:22:57:E0
>>>> Device B8:27:EB:22:57:E0
>>>> Alias: B8-27-EB-22-57-E0
>>>> Paired: no
>>>> Trusted: no
>>>> Blocked: no
>>>> Connected: no
>>>> LegacyPairing: no
>>>> UUID: Heart Rate (0000180d-0000-1000-8000-00805f9b34fb)
>>>> UUID: Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
>>>> ManufacturerData Key: 0xffff
>>>> ManufacturerData Value: 0x00
>>>> ManufacturerData Value: 0x01
>>>> ManufacturerData Value: 0x02
>>>> ManufacturerData Value: 0x03
>>>> ManufacturerData Value: 0x04
>>>> ServiceData Key: 00009999-0000-1000-8000-00805f9b34fb
>>>> ServiceData Value: 0x00
>>>> ServiceData Value: 0x01
>>>> ServiceData Value: 0x02
>>>> ServiceData Value: 0x03
>>>> ServiceData Value: 0x04
>>>>
>>>>
>>>> I've also done a scan from my Android phone (using the Nordic nRF
>>>> Connect app) and can see the advertisements also (just hard to share
>>>> that information on here).
>>>>
>>>> Does that help?
>>>>
>>>>
>>>>>
>>>>>
>>>>> On 13.04.2017 19:59, Barry Byford wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hello Olivier,
>>>>>>
>>>>>>
>>>>>> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com>
>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Hi all,
>>>>>>> I am having issue to advertise/export GATT services exposed through
>>>>>>> DBus
>>>>>>> API. I tried `./test/example-gatt-server`. And I also tried to merge
>>>>>>> `./test/example-advertisement` into `./test/example-gatt-server`. But
>>>>>>> in
>>>>>>> both cases I only see the two compulsory GATT services:
>>>>>>> - Generic Access Service (0x1800)
>>>>>>> - Generic Attribute Service (0x1801)
>>>>>>>
>>>>>>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>>>>>>
>>>>>>> GATT Services seem to be discovered by Bluez (note: I added
>>>>>>> additional
>>>>>>> debug
>>>>>>> statement all prefixed with '#'):
>>>>>>>
>>>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>>>>>>> manager_register_app
>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>>>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app()
>>>>>>> Registering
>>>>>>> application: :1.404:/
>>>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>>>> RegisterAdvertisement
>>>>>>> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy for
>>>>>>> /org/bluez/example/advertisement0
>>>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>>>> Registered
>>>>>>> advertisement at path /org/bluez/example/advertisement0
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service0/char2, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char0/desc0, iface:
>>>>>>> org.bluez.GattDescriptor1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char2/desc3, iface:
>>>>>>> org.bluez.GattDescriptor1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char2, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service1/char0, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char1, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service0/char1, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char1/desc3, iface:
>>>>>>> org.bluez.GattDescriptor1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char1/desc2, iface:
>>>>>>> org.bluez.GattDescriptor1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service0/char0, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2, iface: org.bluez.GattService1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service1, iface: org.bluez.GattService1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service0, iface: org.bluez.GattService1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char0/desc1, iface:
>>>>>>> org.bluez.GattDescriptor1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char2/desc2, iface:
>>>>>>> org.bluez.GattDescriptor1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>>> received:
>>>>>>> /org/bluez/example/service2/char0, iface:
>>>>>>> org.bluez.GattCharacteristic1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>>>>>>> client_ready_cb
>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>>> create_service
>>>>>>> from /org/bluez/example/service2
>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>>> create_service
>>>>>>> from /org/bluez/example/service1
>>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>>> create_service
>>>>>>> from /org/bluez/example/service0
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>>>>>>> database_add_app
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>>> database_add_service
>>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>>> value
>>>>>>> in
>>>>>>> the database
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>>>>>> entry
>>>>>>> for characteristic
>>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>>> value
>>>>>>> in
>>>>>>> the database
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>>>>>> entry
>>>>>>> for characteristic
>>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>>> value
>>>>>>> in
>>>>>>> the database
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>>>>>> entry
>>>>>>> for characteristic
>>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>>> database_add_service
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>>>>>>> entry
>>>>>>> for characteristic
>>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>>> database_add_service
>>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>>>>>>> entry
>>>>>>> for characteristic
>>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT
>>>>>>> application
>>>>>>> registered: :1.404:/
>>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>>>>> ServiceUUID: 180D
>>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>>>>> ServiceUUID: 180F
>>>>>>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data() Adding
>>>>>>> ManufacturerData for ffff
>>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>>>>>>> ServiceData
>>>>>>> for 9999
>>>>>>> bluetoothd[16877]: src/advertising.c:refresh_advertisement()
>>>>>>> Refreshing
>>>>>>> advertisement: /org/bluez/example/advertisement0
>>>>>>> bluetoothd[16877]: src/advertising.c:add_adv_callback() Advertisement
>>>>>>> registered: /org/bluez/example/advertisement0
>>>>>>>
>>>>>>> I start `./test/example-gatt-server` as a normal user. But Bluez does
>>>>>>> not
>>>>>>> seem to have any permission issue with it.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Building from source I've seen something similar if I've used sudo for
>>>>>> the
>>>>>> make.
>>>>>>
>>>>>> To compile and install I use sudo for the install only:
>>>>>>
>>>>>> make -j 4 && sudo make install
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> I am using 'BLE scanner' on Android to discover the GATT services.
>>>>>>> But
>>>>>>> I
>>>>>>> think the problem is coming from Bluez. When I connect the Android
>>>>>>> device
>>>>>>> to
>>>>>>> Bluez, I can see this log:
>>>>>>>
>>>>>>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
>>>>>>> 98:D6:F7:31:7B:0D connected eir_len 14
>>>>>>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming
>>>>>>> BR/EDR
>>>>>>> ATT
>>>>>>> connection
>>>>>>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>>>>>>> g_attrib_ref=1
>>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db:
>>>>>>> Restoring
>>>>>>> 98:D6:F7:31:7B:0D gatt database from file
>>>>>>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() #
>>>>>>> load_gatt_db_impl
>>>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>>>>> loading
>>>>>>> service: 0x0001, end: 0x0005, uuid:
>>>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>>>>> loading
>>>>>>> service: 0x0014, end: 0xffff, uuid:
>>>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>>>> handle:
>>>>>>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>>>>>>> 00002a05-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>>>> handle:
>>>>>>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>>>>>>> 00002a00-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>>>> handle:
>>>>>>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>>>>>>> 00002a01-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries
>>>>>>> before
>>>>>>> being free:
>>>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile accept
>>>>>>> (98:D6:F7:31:7B:0D)
>>>>>>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
>>>>>>> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected ->
>>>>>>> connected (0)
>>>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected()
>>>>>>> Device
>>>>>>> connected.
>>>>>>> bluetoothd[16877]: src/device.c:gatt_server_init() # gatt_server_init
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found:
>>>>>>> 2
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>>>> 0x0005,
>>>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>>>> 0xffff,
>>>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler for
>>>>>>> "Service
>>>>>>> Changed": 0
>>>>>>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status:
>>>>>>> success,
>>>>>>> error: 0
>>>>>>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>>>>>>> register_gatt_services
>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>>> bluetoothd[16877]: src/device.c:add_gatt_service() #
>>>>>>> add_gatt_service:
>>>>>>> UUID:00001801-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT
>>>>>>> client
>>>>>>> ready
>>>>>>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting
>>>>>>> objects
>>>>>>> for
>>>>>>> GATT services: 98:D6:F7:31:7B:0D
>>>>>>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported GATT
>>>>>>> service:
>>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>>>>>>> bluetoothd[16877]: src/gatt-client.c:characteristic_create() Exported
>>>>>>> GATT
>>>>>>> characteristic:
>>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>>>>>>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>>>>>>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>>>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP
>>>>>>> Device
>>>>>>> Name:
>>>>>>> Nexus 4
>>>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>>>>>>> Appearance:
>>>>>>> 0x0000
>>>>>>>
>>>>>>> I also reduced DBus 'TestAdvertisement' interface to only expose one
>>>>>>> GATT
>>>>>>> Service as many BLE adapter got a limitation in the size of the
>>>>>>> advertisement packet:
>>>>>>> class TestAdvertisement(Advertisement):
>>>>>>>
>>>>>>> def __init__(self, bus, index):
>>>>>>> Advertisement.__init__(self, bus, index, 'peripheral')
>>>>>>> #self.add_service_uuid('180D') # HeartRate
>>>>>>> self.add_service_uuid('180F') # Battery
>>>>>>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02, 0x03,
>>>>>>> 0x04])
>>>>>>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03,
>>>>>>> 0x04])
>>>>>>> self.include_tx_power = True
>>>>>>>
>>>>>>> My concern is mainly these lines:
>>>>>>>
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found:
>>>>>>> 2
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>>>> 0x0005,
>>>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>>>> 0xffff,
>>>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>>>
>>>>>>
>>>>>> I've seen this kind of error message when I've had a failure of a
>>>>>> previous script and the Bluetooth daemon is in some unknown state. At
>>>>>> this point it is worth restarting the bluetooth service with:
>>>>>> sudo service bluetooth restart
>>>>>>
>>>>>> You will see in the advertising DBus API documentation that it is
>>>>>> still in experimental mode in 5.44.
>>>>>>
>>>>>>
>>>>>>
>>>>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>>>>>>
>>>>>> This means that you need to make sure bluetoothd is started in
>>>>>> experimental mode. Have you done this?
>>>>>> You can check with "sudo service bluetooth status"
>>>>>>
>>>>>> Experimental can be switched on by default in the bluetooth.service
>>>>>> file
>>>>>>
>>>>>> Edit /lib/systemd/system/bluetooth.service file to add --experimental
>>>>>> flag
>>>>>> e.g:
>>>>>>
>>>>>> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
>>>>>> /lib/systemd/system/bluetooth.service
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I have not found the code that export GATT Services from GATT
>>>>>>> Database
>>>>>>> to
>>>>>>> the BLE central.
>>>>>>>
>>>>>>> From my search on Internet, it looks I am not the only one who is
>>>>>>> having
>>>>>>> this issue
>>>>>>> I am happy to share/test anything that could help to make some
>>>>>>> progress.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Olivier
>>>>>>> --
>>>>>>> To unsubscribe from this list: send the line "unsubscribe
>>>>>>> linux-bluetooth"
>>>>>>> in
>>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Olivier MARTIN @ 2017-04-14 18:14 UTC (permalink / raw)
To: Barry Byford; +Cc: Bluez mailing list
In-Reply-To: <CAAu3APbUAnKX_RD3R8TbXmhuUpz-G4fPj5tk=2HOUTVYXJ-Y5w@mail.gmail.com>
Thanks Barry, setting 'ControllerMode = le' in /etc/bluetooth/main.conf
fixed my issue. I can now see the GATT services.
But I guess my adapter now only works as BLE adapter and will ignore the
non-LE devices.
In the comment of /etc/bluetooth/main.conf it is written the adapter
should be by default set as 'dual'.
Is it a bug in Bluez? Why GATT services are not exposed while using the
default value for 'ControllerMode'?
On 14.04.2017 14:30, Barry Byford wrote:
> Hello Olivier,
>
>
> On 14 April 2017 at 12:01, Olivier MARTIN <olivier@labapart.com> wrote:
>> You are right Barry, `example-advertisement` seems to work well (I
>> installed
>> and tried Nordic nRF Connect and I can see the expected advertisemet
>> data).
>
> Excellent!
>
>
>> But I cannot still manage to get `example-gatt-server` :-(
>> I am sure I got it working last year with an older version of Bluez.
>> But I
>> cannot make it work with Bluez v5.44.
>
> OK, I've taken a look at "example-gatt-server" and have it working...
>
>>
>> My testing procedure:
>>
>> 1. [Laptop] First terminal: Start `sudo ./src/bluetoothd -E -n -d`
>> 2. [Laptop] Second terminal: Start unmodified Bluez
>> ./test/example-gatt-server
>> 3. [Laptop] Third terminal: Ensure the adapter is "Powered: yes" and
>> "Discoverable: yes"
>
> OK, I've done this slightly different (details below). However, the
> first thing I did was edit "/etc/bluetooth/main.conf"
> I added the following line to the end of the file:
>
> ControllerMode = le
>
> Then I did the following:
> 1. [SBC1:T1] sudo ./src/bluetoothd -E -n -d
> 2. [SBC1:T2] ./example-gatt-server
> 3. [SBC1:T3] ./example-advertisement
>
>
>>
>> 4. [Android] Connect using Nordic nRF Connect (I also tried with "BLE
>> Scanner") and check I see the exposed GATT services by
>> `example-gatt-server`
>> Unfortunately, I can only see:
>> - Generic Access Service (0x1800)
>> - Generic Attribute Service (0x1801)
>>
>
> I've used bluetoothctl on SBC2 to connect and read the battery values
> that the GATT server is counting down.
>
> $ bluetoothctl
> [NEW] Controller 00:00:00:00:5A:AD linaro-alip [default]
> [bluetooth]# scan on
> Discovery started
> [CHG] Controller 00:00:00:00:5A:AD Discovering: yes
> [NEW] Device B8:27:EB:22:57:E0 BluezeroLight
> [bluetooth]# scan off
> Discovery stopped
> [CHG] Controller 00:00:00:00:5A:AD Discovering: no
> [bluetooth]# connect B8:27:EB:22:57:E0
> Attempting to connect to B8:27:EB:22:57:E0
> [CHG] Device B8:27:EB:22:57:E0 Connected: yes
> Connection successful
> [...snip...]
> [NEW] Primary Service
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a
> 0000180f-0000-1000-8000-00805f9b34fb
> Battery Service
> [NEW] Characteristic
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
> 00002a19-0000-1000-8000-00805f9b34fb
> Battery Level
> [...snip...]
> [CHG] Device B8:27:EB:22:57:E0 ServicesResolved: yes
> [BluezeroLight]# select-attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
> [BluezeroLight:/service000a/char000b]# read
> Attempting to read
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x46
> 46 F
> [BluezeroLight:/service000a/char000b]# notify on
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
> yes
> Notify started
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x46
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x44
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x42
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x40
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x3e
> [BluezeroLight:/service000a/char000b]# notify off
> [CHG] Attribute
> /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
> no
> Notify stopped
>
>
> That seems to be working then. When I didn't have "ControllerMode =
> le" set then I did see it be unpredictable if it successfully
> connected or not.
> This also worked connecting with the nRF app.
>
>
> Does that work for you?
>
>
>
>
>> If I had to suspect Bluez code, I will guess there is something
>> missing
>> around here:
>>
>> bluetoothd[20429]: src/device.c:gatt_server_init() # gatt_server_init
>> bluetoothd[20429]: src/device.c:gatt_debug() Primary services found: 2
>> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0001, end:
>> 0x0005,
>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0014, end:
>> 0xffff,
>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>> bluetoothd[20429]: src/device.c:gatt_debug() Registered handler for
>> "Service
>> Changed": 0
>> bluetoothd[20429]: src/device.c:gatt_client_ready_cb() status:
>> success,
>> error: 0
>>
>> As Bluez daemon does not get the GATT services from Buez GATT
>> Database. But
>> it might be me who miss a step...
>>
>>
>> On 14.04.2017 12:37, Barry Byford wrote:
>>>
>>> example-advertisementHello Oliver,
>>>
>>>
>>> On 14 April 2017 at 11:03, Olivier MARTIN <olivier@labapart.com>
>>> wrote:
>>>>
>>>> Thanks for replying my message Barry,
>>>>
>>>> Sorry, I forgot to mention but I start Bluez daemon with `sudo
>>>> ./src/bluetoothd -E -n -d` (after stopping the bluetooth service).
>>>> So I
>>>> already run it with sudo and experimental option.
>>>>
>>>> I am not sure to understand what you mean by "this kind of error
>>>> message".
>>>> Because I do not see any error message in the log I provided.
>>>
>>>
>>> OK, that was bad on my part. I read it as complaining that there were
>>> too many advertisements. Looking again that wasn't what it was say.
>>> Apologies.
>>>
>>>>
>>>> Any other idea?
>>>
>>>
>>> I am by Linux Single Board Computers (SBC) today so I'm able to run
>>> what you are running and can show you what I'm seeing. I'll focus on
>>> example-advertisement first as example-gatt-server doesn't change the
>>> advertisements.
>>>
>>> I've started the BlueZ daemon with "./src/bluetoothd -E -n -d"
>>>
>>> In another shell when I start "./example-advertisement" I see the
>>> following in the output:
>>>
>>> bluetoothd[2325]: src/adapter.c:property_set_mode() sending Set
>>> Powered command for index 0
>>> bluetoothd[2325]: src/adapter.c:property_set_mode_complete() Success
>>> (0x00)
>>> bluetoothd[2325]: src/adapter.c:new_settings_callback() Settings:
>>> 0x00000ad1
>>> bluetoothd[2325]: src/adapter.c:settings_changed() Changed settings:
>>> 0x00000001
>>> bluetoothd[2325]: src/adapter.c:adapter_start() adapter
>>> /org/bluez/hci0 has been enabled
>>> bluetoothd[2325]: src/adapter.c:trigger_passive_scanning()
>>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>>> RegisterAdvertisement
>>> bluetoothd[2325]: src/advertising.c:client_create() Adding proxy for
>>> /org/bluez/example/advertisement0
>>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>>> Registered advertisement at path /org/bluez/example/advertisement0
>>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>>> ServiceUUID: 180D
>>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>>> ServiceUUID: 180F
>>> bluetoothd[2325]: src/advertising.c:parse_manufacturer_data() Adding
>>> ManufacturerData for ffff
>>> bluetoothd[2325]: src/advertising.c:parse_service_data() Adding
>>> ServiceData for 9999
>>> bluetoothd[2325]: src/advertising.c:refresh_advertisement()
>>> Refreshing
>>> advertisement: /org/bluez/example/advertisement0
>>> bluetoothd[2325]: src/advertising.c:add_adv_callback() Advertisement
>>> registered: /org/bluez/example/advertisement0
>>>
>>>
>>> On a second SBC, at the command line I run "bluetoothctl" and do
>>> "scan
>>> on". Once my first SBC is found I do "scan off". I then do "info
>>> B8:27:EB:22:57:E0" (this is the address of the first SBC) which gives
>>> the following output:
>>>
>>> [bluetooth]# info B8:27:EB:22:57:E0
>>> Device B8:27:EB:22:57:E0
>>> Alias: B8-27-EB-22-57-E0
>>> Paired: no
>>> Trusted: no
>>> Blocked: no
>>> Connected: no
>>> LegacyPairing: no
>>> UUID: Heart Rate
>>> (0000180d-0000-1000-8000-00805f9b34fb)
>>> UUID: Battery Service
>>> (0000180f-0000-1000-8000-00805f9b34fb)
>>> ManufacturerData Key: 0xffff
>>> ManufacturerData Value: 0x00
>>> ManufacturerData Value: 0x01
>>> ManufacturerData Value: 0x02
>>> ManufacturerData Value: 0x03
>>> ManufacturerData Value: 0x04
>>> ServiceData Key: 00009999-0000-1000-8000-00805f9b34fb
>>> ServiceData Value: 0x00
>>> ServiceData Value: 0x01
>>> ServiceData Value: 0x02
>>> ServiceData Value: 0x03
>>> ServiceData Value: 0x04
>>>
>>>
>>> I've also done a scan from my Android phone (using the Nordic nRF
>>> Connect app) and can see the advertisements also (just hard to share
>>> that information on here).
>>>
>>> Does that help?
>>>
>>>
>>>>
>>>>
>>>> On 13.04.2017 19:59, Barry Byford wrote:
>>>>>
>>>>>
>>>>> Hello Olivier,
>>>>>
>>>>>
>>>>> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com>
>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> Hi all,
>>>>>> I am having issue to advertise/export GATT services exposed
>>>>>> through
>>>>>> DBus
>>>>>> API. I tried `./test/example-gatt-server`. And I also tried to
>>>>>> merge
>>>>>> `./test/example-advertisement` into `./test/example-gatt-server`.
>>>>>> But
>>>>>> in
>>>>>> both cases I only see the two compulsory GATT services:
>>>>>> - Generic Access Service (0x1800)
>>>>>> - Generic Attribute Service (0x1801)
>>>>>>
>>>>>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>>>>>
>>>>>> GATT Services seem to be discovered by Bluez (note: I added
>>>>>> additional
>>>>>> debug
>>>>>> statement all prefixed with '#'):
>>>>>>
>>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>>>>>> manager_register_app
>>>>>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app()
>>>>>> Registering
>>>>>> application: :1.404:/
>>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>>> RegisterAdvertisement
>>>>>> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy
>>>>>> for
>>>>>> /org/bluez/example/advertisement0
>>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>>> Registered
>>>>>> advertisement at path /org/bluez/example/advertisement0
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service0/char2, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char0/desc0, iface:
>>>>>> org.bluez.GattDescriptor1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char2/desc3, iface:
>>>>>> org.bluez.GattDescriptor1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char2, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service1/char0, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char1, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service0/char1, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char1/desc3, iface:
>>>>>> org.bluez.GattDescriptor1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char1/desc2, iface:
>>>>>> org.bluez.GattDescriptor1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service0/char0, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2, iface: org.bluez.GattService1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service1, iface: org.bluez.GattService1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service0, iface: org.bluez.GattService1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char0/desc1, iface:
>>>>>> org.bluez.GattDescriptor1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char2/desc2, iface:
>>>>>> org.bluez.GattDescriptor1
>>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>>> received:
>>>>>> /org/bluez/example/service2/char0, iface:
>>>>>> org.bluez.GattCharacteristic1
>>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>>>>>> client_ready_cb
>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>> create_service
>>>>>> from /org/bluez/example/service2
>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>> create_service
>>>>>> from /org/bluez/example/service1
>>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>>> create_service
>>>>>> from /org/bluez/example/service0
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>>>>>> database_add_app
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>> database_add_service
>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>> value
>>>>>> in
>>>>>> the database
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created
>>>>>> CEP
>>>>>> entry
>>>>>> for characteristic
>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>> value
>>>>>> in
>>>>>> the database
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created
>>>>>> CEP
>>>>>> entry
>>>>>> for characteristic
>>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>>>> value
>>>>>> in
>>>>>> the database
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created
>>>>>> CEP
>>>>>> entry
>>>>>> for characteristic
>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>> database_add_service
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created
>>>>>> CCC
>>>>>> entry
>>>>>> for characteristic
>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>>> database_add_service
>>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created
>>>>>> CCC
>>>>>> entry
>>>>>> for characteristic
>>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>>> gatt_db_service_added: GATT Service added to local database
>>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT
>>>>>> application
>>>>>> registered: :1.404:/
>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>>>> ServiceUUID: 180D
>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>>>> ServiceUUID: 180F
>>>>>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data()
>>>>>> Adding
>>>>>> ManufacturerData for ffff
>>>>>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>>>>>> ServiceData
>>>>>> for 9999
>>>>>> bluetoothd[16877]: src/advertising.c:refresh_advertisement()
>>>>>> Refreshing
>>>>>> advertisement: /org/bluez/example/advertisement0
>>>>>> bluetoothd[16877]: src/advertising.c:add_adv_callback()
>>>>>> Advertisement
>>>>>> registered: /org/bluez/example/advertisement0
>>>>>>
>>>>>> I start `./test/example-gatt-server` as a normal user. But Bluez
>>>>>> does
>>>>>> not
>>>>>> seem to have any permission issue with it.
>>>>>
>>>>>
>>>>>
>>>>> Building from source I've seen something similar if I've used sudo
>>>>> for
>>>>> the
>>>>> make.
>>>>>
>>>>> To compile and install I use sudo for the install only:
>>>>>
>>>>> make -j 4 && sudo make install
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> I am using 'BLE scanner' on Android to discover the GATT services.
>>>>>> But
>>>>>> I
>>>>>> think the problem is coming from Bluez. When I connect the Android
>>>>>> device
>>>>>> to
>>>>>> Bluez, I can see this log:
>>>>>>
>>>>>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
>>>>>> 98:D6:F7:31:7B:0D connected eir_len 14
>>>>>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming
>>>>>> BR/EDR
>>>>>> ATT
>>>>>> connection
>>>>>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>>>>>> g_attrib_ref=1
>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db:
>>>>>> Restoring
>>>>>> 98:D6:F7:31:7B:0D gatt database from file
>>>>>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() #
>>>>>> load_gatt_db_impl
>>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>>>> loading
>>>>>> service: 0x0001, end: 0x0005, uuid:
>>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>>>> loading
>>>>>> service: 0x0014, end: 0xffff, uuid:
>>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>>> handle:
>>>>>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>>>>>> 00002a05-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>>> handle:
>>>>>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>>>>>> 00002a00-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>>> handle:
>>>>>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>>>>>> 00002a01-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries
>>>>>> before
>>>>>> being free:
>>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile
>>>>>> accept
>>>>>> (98:D6:F7:31:7B:0D)
>>>>>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
>>>>>> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected
>>>>>> ->
>>>>>> connected (0)
>>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected()
>>>>>> Device
>>>>>> connected.
>>>>>> bluetoothd[16877]: src/device.c:gatt_server_init() #
>>>>>> gatt_server_init
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services
>>>>>> found: 2
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>>> 0x0005,
>>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>>> 0xffff,
>>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler
>>>>>> for
>>>>>> "Service
>>>>>> Changed": 0
>>>>>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status:
>>>>>> success,
>>>>>> error: 0
>>>>>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>>>>>> register_gatt_services
>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>>> bluetoothd[16877]: src/device.c:add_gatt_service() #
>>>>>> add_gatt_service:
>>>>>> UUID:00001801-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT
>>>>>> client
>>>>>> ready
>>>>>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting
>>>>>> objects
>>>>>> for
>>>>>> GATT services: 98:D6:F7:31:7B:0D
>>>>>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported
>>>>>> GATT
>>>>>> service:
>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>>>>>> bluetoothd[16877]: src/gatt-client.c:characteristic_create()
>>>>>> Exported
>>>>>> GATT
>>>>>> characteristic:
>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>>>>>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>>>>>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP
>>>>>> Device
>>>>>> Name:
>>>>>> Nexus 4
>>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>>>>>> Appearance:
>>>>>> 0x0000
>>>>>>
>>>>>> I also reduced DBus 'TestAdvertisement' interface to only expose
>>>>>> one
>>>>>> GATT
>>>>>> Service as many BLE adapter got a limitation in the size of the
>>>>>> advertisement packet:
>>>>>> class TestAdvertisement(Advertisement):
>>>>>>
>>>>>> def __init__(self, bus, index):
>>>>>> Advertisement.__init__(self, bus, index, 'peripheral')
>>>>>> #self.add_service_uuid('180D') # HeartRate
>>>>>> self.add_service_uuid('180F') # Battery
>>>>>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02,
>>>>>> 0x03,
>>>>>> 0x04])
>>>>>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03,
>>>>>> 0x04])
>>>>>> self.include_tx_power = True
>>>>>>
>>>>>> My concern is mainly these lines:
>>>>>>
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services
>>>>>> found: 2
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>>> 0x0005,
>>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>>> 0xffff,
>>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>>
>>>>>
>>>>> I've seen this kind of error message when I've had a failure of a
>>>>> previous script and the Bluetooth daemon is in some unknown state.
>>>>> At
>>>>> this point it is worth restarting the bluetooth service with:
>>>>> sudo service bluetooth restart
>>>>>
>>>>> You will see in the advertising DBus API documentation that it is
>>>>> still in experimental mode in 5.44.
>>>>>
>>>>>
>>>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>>>>>
>>>>> This means that you need to make sure bluetoothd is started in
>>>>> experimental mode. Have you done this?
>>>>> You can check with "sudo service bluetooth status"
>>>>>
>>>>> Experimental can be switched on by default in the bluetooth.service
>>>>> file
>>>>>
>>>>> Edit /lib/systemd/system/bluetooth.service file to add
>>>>> --experimental
>>>>> flag
>>>>> e.g:
>>>>>
>>>>> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
>>>>> /lib/systemd/system/bluetooth.service
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> I have not found the code that export GATT Services from GATT
>>>>>> Database
>>>>>> to
>>>>>> the BLE central.
>>>>>>
>>>>>> From my search on Internet, it looks I am not the only one who is
>>>>>> having
>>>>>> this issue
>>>>>> I am happy to share/test anything that could help to make some
>>>>>> progress.
>>>>>>
>>>>>> Thanks,
>>>>>> Olivier
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe
>>>>>> linux-bluetooth"
>>>>>> in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>
>>>>
>>>>
>>
^ permalink raw reply
* pull request: bluetooth-next 2017-04-14
From: Johan Hedberg @ 2017-04-14 18:12 UTC (permalink / raw)
To: davem; +Cc: linux-bluetooth, netdev
[-- Attachment #1: Type: text/plain, Size: 7996 bytes --]
Hi Dave,
Here's the main batch of Bluetooth & 802.15.4 patches for the 4.12
kernel.
- Many fixes to 6LoWPAN, in particular for BLE
- New CA8210 IEEE 802.15.4 device driver (accounting for most of the
lines of code added in this pull request)
- Added Nokia Bluetooth (UART) HCI driver
- Some serdev & TTY changes that are dependencies for the Nokia
driver (with acks from relevant maintainers and an agreement that
these come through the bluetooth tree)
- Support for new Intel Bluetooth device
- Various other minor cleanups/fixes here and there
Please let me know if there are any issues pulling. Thanks.
Johan
---
The following changes since commit d92be7a41ef15463eb816a4a2d42bf094b56dfce:
net: make struct net_device::min_header_len 8-bit (2017-04-12 13:59:21 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git for-upstream
for you to fetch changes up to 019aa56b7df8a796b2c01a56269a370ad3442ec7:
arm64: dts: hikey: add WL1835 Bluetooth device node (2017-04-13 19:22:53 +0200)
----------------------------------------------------------------
Alexander Aring (2):
6lowpan: iphc: override l2 packet information
ipv6: addrconf: fix 48 bit 6lowpan autoconfiguration
Andy Shevchenko (1):
Bluetooth: hci_bcm: Support platform enumeration
Colin Ian King (4):
Bluetooth: btmrvl: fix spelling mistake: "unregester" -> "unregister"
Bluetooth: fix assignments on error variable err
6lowpan: fix assignment of peer_addr
ieee802154: ca8210: Add checks for kmalloc allocation failures
Dean Jenkins (2):
Bluetooth: Handle bt_accept_enqueue() socket atomically
Bluetooth: Avoid bt_accept_unlink() double unlinking
Elena Reshetova (1):
Bluetooth: convert rfcomm_dlc.refcnt from atomic_t to refcount_t
Gabriel (1):
Bluetooth: Added support for Rivet Networks Killer 1535
Geliang Tang (1):
Bluetooth: bluecard: use setup_timer
Harry Morris (3):
ieee802154: Add CA8210 IEEE 802.15.4 device driver
ieee802154: Add device tree documentation for CA8210
ieee802154: Add entry in MAINTAINTERS for CA8210 driver
Jeffy Chen (2):
Bluetooth: btusb: wake system up when receives a wake irq
Bluetooth: btmrvl: wake system up when receives a wake irq
Johan Hovold (2):
Bluetooth: hci_bcm: add missing tty-device sanity check
Bluetooth: hci_intel: add missing tty-device sanity check
John Keeping (1):
Bluetooth: hci_bcm: Fix clock (un)prepare
Jonas Holmberg (1):
Bluetooth: Change initial min and max interval
Larry Finger (1):
Bluetooth: btrtl: Change message for missing config file
Luiz Augusto von Dentz (10):
6lowpan: Use netdev addr_len to determine lladdr len
6lowpan: Fix IID format for Bluetooth
Bluetooth: 6lowpan: Remove unnecessary peer lookup
Bluetooth: 6lowpan: Print errors during recv_pkt
Bluetooth: L2CAP: Don't return -EAGAIN if out of credits
6lowpan: Don't set IFF_NO_QUEUE
Bluetooth: 6lowpan: Don't drop packets when run out of credits
Bluetooth: 6lowpan: Use netif APIs to flow control
Bluetooth: L2CAP: Add l2cap_le_flowctl_send
Bluetooth: 6lowpan: Set tx_queue_len to DEFAULT_TX_QUEUE_LEN
Marcel Holtmann (1):
Bluetooth: btusb: Add support for Intel Bluetooth devices 9160/9260 [8087:0025]
Marcin Kraglak (1):
Bluetooth: L2CAP: Fix L2CAP_CR_SCID_IN_USE value
Michael Scott (2):
Bluetooth: 6lowpan: fix delay work init in add_peer_chan()
Bluetooth: 6lowpan: fix use after free in chan_suspend/resume
Patrik Flykt (3):
bluetooth: Set 6 byte device addresses
6lowpan: Set MAC address length according to LOWPAN_LLTYPE
bluetooth: Do not set IFF_POINTOPOINT
Rob Herring (5):
Bluetooth: hci_uart: add serdev driver support library
dt-bindings: net: Add TI WiLink shared transport binding
bluetooth: hci_uart: remove unused hci_uart_init_tty
bluetooth: hci_uart: add LL protocol serdev driver support
arm64: dts: hikey: add WL1835 Bluetooth device node
Sebastian Reichel (9):
tty: serial: omap: add UPF_BOOT_AUTOCONF flag for DT init
serdev: add serdev_device_wait_until_sent
serdev: implement get/set tiocm
serdev: add helpers for cts and rts handling
Bluetooth: hci_uart: add support for word alignment
Bluetooth: hci_serdev: do not open device in hci open
Bluetooth: hci_serdev: allow modular drivers
dt-bindings: net: bluetooth: Add nokia-bluetooth
Bluetooth: add nokia driver
Tedd Ho-Jeong An (3):
Bluetooth: Use switch statement for Intel hardware variants
Bluetooth: hci_intel: Fix firmware file name to use hw_variant
Bluetooth: hci_intel: Add support Intel Bluetooth device 9160/9260 for UART
Xinming Hu (2):
Bluetooth: btmrvl: disable platform wakeup interrupt in suspend failure path
Bluetooth: btmrvl: remove unnecessary wakeup interrupt number sanity check
prasanna karthik (1):
Bluetooth: btmrvl: cleanup code in return from btmrvl_sdio_suspend()
.../devicetree/bindings/net/ieee802154/ca8210.txt | 28 +
.../devicetree/bindings/net/nokia-bluetooth.txt | 51 +
.../devicetree/bindings/net/ti,wilink-st.txt | 35 +
.../devicetree/bindings/vendor-prefixes.txt | 1 +
MAINTAINERS | 9 +
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 5 +
drivers/bluetooth/Kconfig | 12 +
drivers/bluetooth/Makefile | 3 +
drivers/bluetooth/bluecard_cs.c | 5 +-
drivers/bluetooth/btmrvl_sdio.c | 32 +-
drivers/bluetooth/btrtl.c | 13 +-
drivers/bluetooth/btusb.c | 15 +-
drivers/bluetooth/hci_bcm.c | 59 +-
drivers/bluetooth/hci_h4.c | 17 +
drivers/bluetooth/hci_intel.c | 47 +-
drivers/bluetooth/hci_ldisc.c | 24 +-
drivers/bluetooth/hci_ll.c | 262 +-
drivers/bluetooth/hci_nokia.c | 820 +++++
drivers/bluetooth/hci_serdev.c | 356 +++
drivers/bluetooth/hci_uart.h | 8 +-
drivers/net/ieee802154/Kconfig | 22 +
drivers/net/ieee802154/Makefile | 1 +
drivers/net/ieee802154/ca8210.c | 3242 ++++++++++++++++++++
drivers/tty/serdev/core.c | 33 +
drivers/tty/serdev/serdev-ttyport.c | 42 +-
drivers/tty/serial/omap-serial.c | 3 +
include/linux/serdev.h | 47 +
include/net/6lowpan.h | 15 +
include/net/bluetooth/l2cap.h | 2 +-
include/net/bluetooth/rfcomm.h | 8 +-
net/6lowpan/core.c | 12 +-
net/6lowpan/iphc.c | 57 +-
net/bluetooth/6lowpan.c | 192 +-
net/bluetooth/af_bluetooth.c | 26 +
net/bluetooth/amp.c | 10 +-
net/bluetooth/hci_core.c | 4 +-
net/bluetooth/l2cap_core.c | 30 +-
net/bluetooth/rfcomm/core.c | 4 +-
net/ipv6/addrconf.c | 23 +-
39 files changed, 5309 insertions(+), 266 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/ieee802154/ca8210.txt
create mode 100644 Documentation/devicetree/bindings/net/nokia-bluetooth.txt
create mode 100644 Documentation/devicetree/bindings/net/ti,wilink-st.txt
create mode 100644 drivers/bluetooth/hci_nokia.c
create mode 100644 drivers/bluetooth/hci_serdev.c
create mode 100644 drivers/net/ieee802154/ca8210.c
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Barry Byford @ 2017-04-14 12:30 UTC (permalink / raw)
To: Olivier MARTIN; +Cc: Bluez mailing list
In-Reply-To: <7e78e5e8a8340ee2b459d0cd2f645712@labapart.com>
Hello Olivier,
On 14 April 2017 at 12:01, Olivier MARTIN <olivier@labapart.com> wrote:
> You are right Barry, `example-advertisement` seems to work well (I installed
> and tried Nordic nRF Connect and I can see the expected advertisemet data).
Excellent!
> But I cannot still manage to get `example-gatt-server` :-(
> I am sure I got it working last year with an older version of Bluez. But I
> cannot make it work with Bluez v5.44.
OK, I've taken a look at "example-gatt-server" and have it working...
>
> My testing procedure:
>
> 1. [Laptop] First terminal: Start `sudo ./src/bluetoothd -E -n -d`
> 2. [Laptop] Second terminal: Start unmodified Bluez
> ./test/example-gatt-server
> 3. [Laptop] Third terminal: Ensure the adapter is "Powered: yes" and
> "Discoverable: yes"
OK, I've done this slightly different (details below). However, the
first thing I did was edit "/etc/bluetooth/main.conf"
I added the following line to the end of the file:
ControllerMode = le
Then I did the following:
1. [SBC1:T1] sudo ./src/bluetoothd -E -n -d
2. [SBC1:T2] ./example-gatt-server
3. [SBC1:T3] ./example-advertisement
>
> 4. [Android] Connect using Nordic nRF Connect (I also tried with "BLE
> Scanner") and check I see the exposed GATT services by `example-gatt-server`
> Unfortunately, I can only see:
> - Generic Access Service (0x1800)
> - Generic Attribute Service (0x1801)
>
I've used bluetoothctl on SBC2 to connect and read the battery values
that the GATT server is counting down.
$ bluetoothctl
[NEW] Controller 00:00:00:00:5A:AD linaro-alip [default]
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:00:00:00:5A:AD Discovering: yes
[NEW] Device B8:27:EB:22:57:E0 BluezeroLight
[bluetooth]# scan off
Discovery stopped
[CHG] Controller 00:00:00:00:5A:AD Discovering: no
[bluetooth]# connect B8:27:EB:22:57:E0
Attempting to connect to B8:27:EB:22:57:E0
[CHG] Device B8:27:EB:22:57:E0 Connected: yes
Connection successful
[...snip...]
[NEW] Primary Service
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a
0000180f-0000-1000-8000-00805f9b34fb
Battery Service
[NEW] Characteristic
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
00002a19-0000-1000-8000-00805f9b34fb
Battery Level
[...snip...]
[CHG] Device B8:27:EB:22:57:E0 ServicesResolved: yes
[BluezeroLight]# select-attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
[BluezeroLight:/service000a/char000b]# read
Attempting to read /org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x46
46 F
[BluezeroLight:/service000a/char000b]# notify on
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
yes
Notify started
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x46
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x44
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x42
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x40
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Value: 0x3e
[BluezeroLight:/service000a/char000b]# notify off
[CHG] Attribute
/org/bluez/hci0/dev_B8_27_EB_22_57_E0/service000a/char000b Notifying:
no
Notify stopped
That seems to be working then. When I didn't have "ControllerMode =
le" set then I did see it be unpredictable if it successfully
connected or not.
This also worked connecting with the nRF app.
Does that work for you?
> If I had to suspect Bluez code, I will guess there is something missing
> around here:
>
> bluetoothd[20429]: src/device.c:gatt_server_init() # gatt_server_init
> bluetoothd[20429]: src/device.c:gatt_debug() Primary services found: 2
> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
> uuid: 00001801-0000-1000-8000-00805f9b34fb
> bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
> uuid: 00001800-0000-1000-8000-00805f9b34fb
> bluetoothd[20429]: src/device.c:gatt_debug() Registered handler for "Service
> Changed": 0
> bluetoothd[20429]: src/device.c:gatt_client_ready_cb() status: success,
> error: 0
>
> As Bluez daemon does not get the GATT services from Buez GATT Database. But
> it might be me who miss a step...
>
>
> On 14.04.2017 12:37, Barry Byford wrote:
>>
>> example-advertisementHello Oliver,
>>
>>
>> On 14 April 2017 at 11:03, Olivier MARTIN <olivier@labapart.com> wrote:
>>>
>>> Thanks for replying my message Barry,
>>>
>>> Sorry, I forgot to mention but I start Bluez daemon with `sudo
>>> ./src/bluetoothd -E -n -d` (after stopping the bluetooth service). So I
>>> already run it with sudo and experimental option.
>>>
>>> I am not sure to understand what you mean by "this kind of error
>>> message".
>>> Because I do not see any error message in the log I provided.
>>
>>
>> OK, that was bad on my part. I read it as complaining that there were
>> too many advertisements. Looking again that wasn't what it was say.
>> Apologies.
>>
>>>
>>> Any other idea?
>>
>>
>> I am by Linux Single Board Computers (SBC) today so I'm able to run
>> what you are running and can show you what I'm seeing. I'll focus on
>> example-advertisement first as example-gatt-server doesn't change the
>> advertisements.
>>
>> I've started the BlueZ daemon with "./src/bluetoothd -E -n -d"
>>
>> In another shell when I start "./example-advertisement" I see the
>> following in the output:
>>
>> bluetoothd[2325]: src/adapter.c:property_set_mode() sending Set
>> Powered command for index 0
>> bluetoothd[2325]: src/adapter.c:property_set_mode_complete() Success
>> (0x00)
>> bluetoothd[2325]: src/adapter.c:new_settings_callback() Settings:
>> 0x00000ad1
>> bluetoothd[2325]: src/adapter.c:settings_changed() Changed settings:
>> 0x00000001
>> bluetoothd[2325]: src/adapter.c:adapter_start() adapter
>> /org/bluez/hci0 has been enabled
>> bluetoothd[2325]: src/adapter.c:trigger_passive_scanning()
>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>> RegisterAdvertisement
>> bluetoothd[2325]: src/advertising.c:client_create() Adding proxy for
>> /org/bluez/example/advertisement0
>> bluetoothd[2325]: src/advertising.c:register_advertisement()
>> Registered advertisement at path /org/bluez/example/advertisement0
>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>> ServiceUUID: 180D
>> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
>> ServiceUUID: 180F
>> bluetoothd[2325]: src/advertising.c:parse_manufacturer_data() Adding
>> ManufacturerData for ffff
>> bluetoothd[2325]: src/advertising.c:parse_service_data() Adding
>> ServiceData for 9999
>> bluetoothd[2325]: src/advertising.c:refresh_advertisement() Refreshing
>> advertisement: /org/bluez/example/advertisement0
>> bluetoothd[2325]: src/advertising.c:add_adv_callback() Advertisement
>> registered: /org/bluez/example/advertisement0
>>
>>
>> On a second SBC, at the command line I run "bluetoothctl" and do "scan
>> on". Once my first SBC is found I do "scan off". I then do "info
>> B8:27:EB:22:57:E0" (this is the address of the first SBC) which gives
>> the following output:
>>
>> [bluetooth]# info B8:27:EB:22:57:E0
>> Device B8:27:EB:22:57:E0
>> Alias: B8-27-EB-22-57-E0
>> Paired: no
>> Trusted: no
>> Blocked: no
>> Connected: no
>> LegacyPairing: no
>> UUID: Heart Rate (0000180d-0000-1000-8000-00805f9b34fb)
>> UUID: Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
>> ManufacturerData Key: 0xffff
>> ManufacturerData Value: 0x00
>> ManufacturerData Value: 0x01
>> ManufacturerData Value: 0x02
>> ManufacturerData Value: 0x03
>> ManufacturerData Value: 0x04
>> ServiceData Key: 00009999-0000-1000-8000-00805f9b34fb
>> ServiceData Value: 0x00
>> ServiceData Value: 0x01
>> ServiceData Value: 0x02
>> ServiceData Value: 0x03
>> ServiceData Value: 0x04
>>
>>
>> I've also done a scan from my Android phone (using the Nordic nRF
>> Connect app) and can see the advertisements also (just hard to share
>> that information on here).
>>
>> Does that help?
>>
>>
>>>
>>>
>>> On 13.04.2017 19:59, Barry Byford wrote:
>>>>
>>>>
>>>> Hello Olivier,
>>>>
>>>>
>>>> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com> wrote:
>>>>>
>>>>>
>>>>> Hi all,
>>>>> I am having issue to advertise/export GATT services exposed through
>>>>> DBus
>>>>> API. I tried `./test/example-gatt-server`. And I also tried to merge
>>>>> `./test/example-advertisement` into `./test/example-gatt-server`. But
>>>>> in
>>>>> both cases I only see the two compulsory GATT services:
>>>>> - Generic Access Service (0x1800)
>>>>> - Generic Attribute Service (0x1801)
>>>>>
>>>>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>>>>
>>>>> GATT Services seem to be discovered by Bluez (note: I added additional
>>>>> debug
>>>>> statement all prefixed with '#'):
>>>>>
>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>>>>> manager_register_app
>>>>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app()
>>>>> Registering
>>>>> application: :1.404:/
>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>> RegisterAdvertisement
>>>>> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy for
>>>>> /org/bluez/example/advertisement0
>>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>>> Registered
>>>>> advertisement at path /org/bluez/example/advertisement0
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service0/char2, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char0/desc0, iface:
>>>>> org.bluez.GattDescriptor1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char2/desc3, iface:
>>>>> org.bluez.GattDescriptor1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char2, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service1/char0, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char1, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service0/char1, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char1/desc3, iface:
>>>>> org.bluez.GattDescriptor1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char1/desc2, iface:
>>>>> org.bluez.GattDescriptor1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service0/char0, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2, iface: org.bluez.GattService1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service1, iface: org.bluez.GattService1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service0, iface: org.bluez.GattService1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char0/desc1, iface:
>>>>> org.bluez.GattDescriptor1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char2/desc2, iface:
>>>>> org.bluez.GattDescriptor1
>>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>>> received:
>>>>> /org/bluez/example/service2/char0, iface: org.bluez.GattCharacteristic1
>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>>>>> client_ready_cb
>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>> create_service
>>>>> from /org/bluez/example/service2
>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>> create_service
>>>>> from /org/bluez/example/service1
>>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>>> create_service
>>>>> from /org/bluez/example/service0
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>>>>> database_add_app
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>> database_add_service
>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value
>>>>> in
>>>>> the database
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>>>> entry
>>>>> for characteristic
>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value
>>>>> in
>>>>> the database
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>>>> entry
>>>>> for characteristic
>>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value
>>>>> in
>>>>> the database
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>>>> entry
>>>>> for characteristic
>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>> gatt_db_service_added: GATT Service added to local database
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>> database_add_service
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>>>>> entry
>>>>> for characteristic
>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>> gatt_db_service_added: GATT Service added to local database
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>>> database_add_service
>>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>>>>> entry
>>>>> for characteristic
>>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>>> gatt_db_service_added: GATT Service added to local database
>>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT
>>>>> application
>>>>> registered: :1.404:/
>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>>> ServiceUUID: 180D
>>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>>> ServiceUUID: 180F
>>>>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data() Adding
>>>>> ManufacturerData for ffff
>>>>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>>>>> ServiceData
>>>>> for 9999
>>>>> bluetoothd[16877]: src/advertising.c:refresh_advertisement() Refreshing
>>>>> advertisement: /org/bluez/example/advertisement0
>>>>> bluetoothd[16877]: src/advertising.c:add_adv_callback() Advertisement
>>>>> registered: /org/bluez/example/advertisement0
>>>>>
>>>>> I start `./test/example-gatt-server` as a normal user. But Bluez does
>>>>> not
>>>>> seem to have any permission issue with it.
>>>>
>>>>
>>>>
>>>> Building from source I've seen something similar if I've used sudo for
>>>> the
>>>> make.
>>>>
>>>> To compile and install I use sudo for the install only:
>>>>
>>>> make -j 4 && sudo make install
>>>>
>>>>
>>>>
>>>>>
>>>>> I am using 'BLE scanner' on Android to discover the GATT services. But
>>>>> I
>>>>> think the problem is coming from Bluez. When I connect the Android
>>>>> device
>>>>> to
>>>>> Bluez, I can see this log:
>>>>>
>>>>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
>>>>> 98:D6:F7:31:7B:0D connected eir_len 14
>>>>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming BR/EDR
>>>>> ATT
>>>>> connection
>>>>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>>>>> g_attrib_ref=1
>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db:
>>>>> Restoring
>>>>> 98:D6:F7:31:7B:0D gatt database from file
>>>>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>>>>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() # load_gatt_db_impl
>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
>>>>> service: 0x0001, end: 0x0005, uuid:
>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
>>>>> service: 0x0014, end: 0xffff, uuid:
>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>> handle:
>>>>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>>>>> 00002a05-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>> handle:
>>>>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>>>>> 00002a00-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>>> handle:
>>>>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>>>>> 00002a01-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries
>>>>> before
>>>>> being free:
>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile accept
>>>>> (98:D6:F7:31:7B:0D)
>>>>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
>>>>> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected ->
>>>>> connected (0)
>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected() Device
>>>>> connected.
>>>>> bluetoothd[16877]: src/device.c:gatt_server_init() # gatt_server_init
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>> 0x0005,
>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>> 0xffff,
>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler for
>>>>> "Service
>>>>> Changed": 0
>>>>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status: success,
>>>>> error: 0
>>>>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>>>>> register_gatt_services
>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>>> bluetoothd[16877]: src/device.c:add_gatt_service() # add_gatt_service:
>>>>> UUID:00001801-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT
>>>>> client
>>>>> ready
>>>>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting
>>>>> objects
>>>>> for
>>>>> GATT services: 98:D6:F7:31:7B:0D
>>>>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported GATT
>>>>> service:
>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>>>>> bluetoothd[16877]: src/gatt-client.c:characteristic_create() Exported
>>>>> GATT
>>>>> characteristic:
>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>>>>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>>>>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP Device
>>>>> Name:
>>>>> Nexus 4
>>>>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>>>>> Appearance:
>>>>> 0x0000
>>>>>
>>>>> I also reduced DBus 'TestAdvertisement' interface to only expose one
>>>>> GATT
>>>>> Service as many BLE adapter got a limitation in the size of the
>>>>> advertisement packet:
>>>>> class TestAdvertisement(Advertisement):
>>>>>
>>>>> def __init__(self, bus, index):
>>>>> Advertisement.__init__(self, bus, index, 'peripheral')
>>>>> #self.add_service_uuid('180D') # HeartRate
>>>>> self.add_service_uuid('180F') # Battery
>>>>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02, 0x03,
>>>>> 0x04])
>>>>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03, 0x04])
>>>>> self.include_tx_power = True
>>>>>
>>>>> My concern is mainly these lines:
>>>>>
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>>> 0x0005,
>>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>>> 0xffff,
>>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>>
>>>>
>>>> I've seen this kind of error message when I've had a failure of a
>>>> previous script and the Bluetooth daemon is in some unknown state. At
>>>> this point it is worth restarting the bluetooth service with:
>>>> sudo service bluetooth restart
>>>>
>>>> You will see in the advertising DBus API documentation that it is
>>>> still in experimental mode in 5.44.
>>>>
>>>>
>>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>>>>
>>>> This means that you need to make sure bluetoothd is started in
>>>> experimental mode. Have you done this?
>>>> You can check with "sudo service bluetooth status"
>>>>
>>>> Experimental can be switched on by default in the bluetooth.service file
>>>>
>>>> Edit /lib/systemd/system/bluetooth.service file to add --experimental
>>>> flag
>>>> e.g:
>>>>
>>>> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
>>>> /lib/systemd/system/bluetooth.service
>>>>
>>>>
>>>>
>>>>
>>>>> I have not found the code that export GATT Services from GATT Database
>>>>> to
>>>>> the BLE central.
>>>>>
>>>>> From my search on Internet, it looks I am not the only one who is
>>>>> having
>>>>> this issue
>>>>> I am happy to share/test anything that could help to make some
>>>>> progress.
>>>>>
>>>>> Thanks,
>>>>> Olivier
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe
>>>>> linux-bluetooth"
>>>>> in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>>
>>>
>
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Olivier MARTIN @ 2017-04-14 11:01 UTC (permalink / raw)
To: Barry Byford; +Cc: Bluez mailing list
In-Reply-To: <CAAu3APYtfEsmu4WREo=V=VtgxCd3tjj0+1J4HcqD0asN8boOxg@mail.gmail.com>
You are right Barry, `example-advertisement` seems to work well (I
installed and tried Nordic nRF Connect and I can see the expected
advertisemet data).
But I cannot still manage to get `example-gatt-server` :-(
I am sure I got it working last year with an older version of Bluez. But
I cannot make it work with Bluez v5.44.
My testing procedure:
1. [Laptop] First terminal: Start `sudo ./src/bluetoothd -E -n -d`
2. [Laptop] Second terminal: Start unmodified Bluez
./test/example-gatt-server
3. [Laptop] Third terminal: Ensure the adapter is "Powered: yes" and
"Discoverable: yes"
4. [Android] Connect using Nordic nRF Connect (I also tried with "BLE
Scanner") and check I see the exposed GATT services by
`example-gatt-server`
Unfortunately, I can only see:
- Generic Access Service (0x1800)
- Generic Attribute Service (0x1801)
If I had to suspect Bluez code, I will guess there is something missing
around here:
bluetoothd[20429]: src/device.c:gatt_server_init() # gatt_server_init
bluetoothd[20429]: src/device.c:gatt_debug() Primary services found: 2
bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
uuid: 00001801-0000-1000-8000-00805f9b34fb
bluetoothd[20429]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
uuid: 00001800-0000-1000-8000-00805f9b34fb
bluetoothd[20429]: src/device.c:gatt_debug() Registered handler for
"Service Changed": 0
bluetoothd[20429]: src/device.c:gatt_client_ready_cb() status: success,
error: 0
As Bluez daemon does not get the GATT services from Buez GATT Database.
But it might be me who miss a step...
On 14.04.2017 12:37, Barry Byford wrote:
> example-advertisementHello Oliver,
>
>
> On 14 April 2017 at 11:03, Olivier MARTIN <olivier@labapart.com> wrote:
>> Thanks for replying my message Barry,
>>
>> Sorry, I forgot to mention but I start Bluez daemon with `sudo
>> ./src/bluetoothd -E -n -d` (after stopping the bluetooth service). So
>> I
>> already run it with sudo and experimental option.
>>
>> I am not sure to understand what you mean by "this kind of error
>> message".
>> Because I do not see any error message in the log I provided.
>
> OK, that was bad on my part. I read it as complaining that there were
> too many advertisements. Looking again that wasn't what it was say.
> Apologies.
>
>>
>> Any other idea?
>
> I am by Linux Single Board Computers (SBC) today so I'm able to run
> what you are running and can show you what I'm seeing. I'll focus on
> example-advertisement first as example-gatt-server doesn't change the
> advertisements.
>
> I've started the BlueZ daemon with "./src/bluetoothd -E -n -d"
>
> In another shell when I start "./example-advertisement" I see the
> following in the output:
>
> bluetoothd[2325]: src/adapter.c:property_set_mode() sending Set
> Powered command for index 0
> bluetoothd[2325]: src/adapter.c:property_set_mode_complete() Success
> (0x00)
> bluetoothd[2325]: src/adapter.c:new_settings_callback() Settings:
> 0x00000ad1
> bluetoothd[2325]: src/adapter.c:settings_changed() Changed settings:
> 0x00000001
> bluetoothd[2325]: src/adapter.c:adapter_start() adapter
> /org/bluez/hci0 has been enabled
> bluetoothd[2325]: src/adapter.c:trigger_passive_scanning()
> bluetoothd[2325]: src/advertising.c:register_advertisement()
> RegisterAdvertisement
> bluetoothd[2325]: src/advertising.c:client_create() Adding proxy for
> /org/bluez/example/advertisement0
> bluetoothd[2325]: src/advertising.c:register_advertisement()
> Registered advertisement at path /org/bluez/example/advertisement0
> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
> ServiceUUID: 180D
> bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
> ServiceUUID: 180F
> bluetoothd[2325]: src/advertising.c:parse_manufacturer_data() Adding
> ManufacturerData for ffff
> bluetoothd[2325]: src/advertising.c:parse_service_data() Adding
> ServiceData for 9999
> bluetoothd[2325]: src/advertising.c:refresh_advertisement() Refreshing
> advertisement: /org/bluez/example/advertisement0
> bluetoothd[2325]: src/advertising.c:add_adv_callback() Advertisement
> registered: /org/bluez/example/advertisement0
>
>
> On a second SBC, at the command line I run "bluetoothctl" and do "scan
> on". Once my first SBC is found I do "scan off". I then do "info
> B8:27:EB:22:57:E0" (this is the address of the first SBC) which gives
> the following output:
>
> [bluetooth]# info B8:27:EB:22:57:E0
> Device B8:27:EB:22:57:E0
> Alias: B8-27-EB-22-57-E0
> Paired: no
> Trusted: no
> Blocked: no
> Connected: no
> LegacyPairing: no
> UUID: Heart Rate (0000180d-0000-1000-8000-00805f9b34fb)
> UUID: Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
> ManufacturerData Key: 0xffff
> ManufacturerData Value: 0x00
> ManufacturerData Value: 0x01
> ManufacturerData Value: 0x02
> ManufacturerData Value: 0x03
> ManufacturerData Value: 0x04
> ServiceData Key: 00009999-0000-1000-8000-00805f9b34fb
> ServiceData Value: 0x00
> ServiceData Value: 0x01
> ServiceData Value: 0x02
> ServiceData Value: 0x03
> ServiceData Value: 0x04
>
>
> I've also done a scan from my Android phone (using the Nordic nRF
> Connect app) and can see the advertisements also (just hard to share
> that information on here).
>
> Does that help?
>
>
>>
>>
>> On 13.04.2017 19:59, Barry Byford wrote:
>>>
>>> Hello Olivier,
>>>
>>>
>>> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com>
>>> wrote:
>>>>
>>>> Hi all,
>>>> I am having issue to advertise/export GATT services exposed through
>>>> DBus
>>>> API. I tried `./test/example-gatt-server`. And I also tried to merge
>>>> `./test/example-advertisement` into `./test/example-gatt-server`.
>>>> But in
>>>> both cases I only see the two compulsory GATT services:
>>>> - Generic Access Service (0x1800)
>>>> - Generic Attribute Service (0x1801)
>>>>
>>>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>>>
>>>> GATT Services seem to be discovered by Bluez (note: I added
>>>> additional
>>>> debug
>>>> statement all prefixed with '#'):
>>>>
>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>>>> manager_register_app
>>>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app()
>>>> Registering
>>>> application: :1.404:/
>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>> RegisterAdvertisement
>>>> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy
>>>> for
>>>> /org/bluez/example/advertisement0
>>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>>> Registered
>>>> advertisement at path /org/bluez/example/advertisement0
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service0/char2, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char0/desc0, iface:
>>>> org.bluez.GattDescriptor1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char2/desc3, iface:
>>>> org.bluez.GattDescriptor1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char2, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service1/char0, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char1, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service0/char1, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char1/desc3, iface:
>>>> org.bluez.GattDescriptor1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char1/desc2, iface:
>>>> org.bluez.GattDescriptor1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service0/char0, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2, iface: org.bluez.GattService1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service1, iface: org.bluez.GattService1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service0, iface: org.bluez.GattService1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char0/desc1, iface:
>>>> org.bluez.GattDescriptor1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char2/desc2, iface:
>>>> org.bluez.GattDescriptor1
>>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>>>> received:
>>>> /org/bluez/example/service2/char0, iface:
>>>> org.bluez.GattCharacteristic1
>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>>>> client_ready_cb
>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>> create_service
>>>> from /org/bluez/example/service2
>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>> create_service
>>>> from /org/bluez/example/service1
>>>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>>>> create_service
>>>> from /org/bluez/example/service0
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>>>> database_add_app
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>> database_add_service
>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>> value in
>>>> the database
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created
>>>> CEP
>>>> entry
>>>> for characteristic
>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>> value in
>>>> the database
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created
>>>> CEP
>>>> entry
>>>> for characteristic
>>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP
>>>> value in
>>>> the database
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created
>>>> CEP
>>>> entry
>>>> for characteristic
>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>> gatt_db_service_added: GATT Service added to local database
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>> database_add_service
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created
>>>> CCC
>>>> entry
>>>> for characteristic
>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>> gatt_db_service_added: GATT Service added to local database
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>>> database_add_service
>>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created
>>>> CCC
>>>> entry
>>>> for characteristic
>>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>>> gatt_db_service_added: GATT Service added to local database
>>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT
>>>> application
>>>> registered: :1.404:/
>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>> ServiceUUID: 180D
>>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>>> ServiceUUID: 180F
>>>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data()
>>>> Adding
>>>> ManufacturerData for ffff
>>>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>>>> ServiceData
>>>> for 9999
>>>> bluetoothd[16877]: src/advertising.c:refresh_advertisement()
>>>> Refreshing
>>>> advertisement: /org/bluez/example/advertisement0
>>>> bluetoothd[16877]: src/advertising.c:add_adv_callback()
>>>> Advertisement
>>>> registered: /org/bluez/example/advertisement0
>>>>
>>>> I start `./test/example-gatt-server` as a normal user. But Bluez
>>>> does not
>>>> seem to have any permission issue with it.
>>>
>>>
>>> Building from source I've seen something similar if I've used sudo
>>> for the
>>> make.
>>>
>>> To compile and install I use sudo for the install only:
>>>
>>> make -j 4 && sudo make install
>>>
>>>
>>>
>>>>
>>>> I am using 'BLE scanner' on Android to discover the GATT services.
>>>> But I
>>>> think the problem is coming from Bluez. When I connect the Android
>>>> device
>>>> to
>>>> Bluez, I can see this log:
>>>>
>>>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
>>>> 98:D6:F7:31:7B:0D connected eir_len 14
>>>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming
>>>> BR/EDR
>>>> ATT
>>>> connection
>>>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>>>> g_attrib_ref=1
>>>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db:
>>>> Restoring
>>>> 98:D6:F7:31:7B:0D gatt database from file
>>>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>>>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() #
>>>> load_gatt_db_impl
>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>> loading
>>>> service: 0x0001, end: 0x0005, uuid:
>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:load_service() # load_service:
>>>> loading
>>>> service: 0x0014, end: 0xffff, uuid:
>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>> handle:
>>>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>>>> 00002a05-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>> handle:
>>>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>>>> 00002a00-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>>> handle:
>>>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>>>> 00002a01-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries
>>>> before
>>>> being free:
>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>> 00001801-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>>> 00001800-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile
>>>> accept
>>>> (98:D6:F7:31:7B:0D)
>>>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
>>>> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected ->
>>>> connected (0)
>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected()
>>>> Device
>>>> connected.
>>>> bluetoothd[16877]: src/device.c:gatt_server_init() #
>>>> gatt_server_init
>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found:
>>>> 2
>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>> 0x0005,
>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>> 0xffff,
>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler for
>>>> "Service
>>>> Changed": 0
>>>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status:
>>>> success,
>>>> error: 0
>>>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>>>> register_gatt_services
>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>>> bluetoothd[16877]: src/device.c:add_gatt_service() #
>>>> add_gatt_service:
>>>> UUID:00001801-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT
>>>> client
>>>> ready
>>>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting
>>>> objects
>>>> for
>>>> GATT services: 98:D6:F7:31:7B:0D
>>>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported GATT
>>>> service:
>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>>>> bluetoothd[16877]: src/gatt-client.c:characteristic_create()
>>>> Exported
>>>> GATT
>>>> characteristic:
>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>>>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>>>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP
>>>> Device
>>>> Name:
>>>> Nexus 4
>>>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>>>> Appearance:
>>>> 0x0000
>>>>
>>>> I also reduced DBus 'TestAdvertisement' interface to only expose one
>>>> GATT
>>>> Service as many BLE adapter got a limitation in the size of the
>>>> advertisement packet:
>>>> class TestAdvertisement(Advertisement):
>>>>
>>>> def __init__(self, bus, index):
>>>> Advertisement.__init__(self, bus, index, 'peripheral')
>>>> #self.add_service_uuid('180D') # HeartRate
>>>> self.add_service_uuid('180F') # Battery
>>>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02, 0x03,
>>>> 0x04])
>>>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03,
>>>> 0x04])
>>>> self.include_tx_power = True
>>>>
>>>> My concern is mainly these lines:
>>>>
>>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found:
>>>> 2
>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>>>> 0x0005,
>>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>>>> 0xffff,
>>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>>
>>>
>>> I've seen this kind of error message when I've had a failure of a
>>> previous script and the Bluetooth daemon is in some unknown state. At
>>> this point it is worth restarting the bluetooth service with:
>>> sudo service bluetooth restart
>>>
>>> You will see in the advertising DBus API documentation that it is
>>> still in experimental mode in 5.44.
>>>
>>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>>>
>>> This means that you need to make sure bluetoothd is started in
>>> experimental mode. Have you done this?
>>> You can check with "sudo service bluetooth status"
>>>
>>> Experimental can be switched on by default in the bluetooth.service
>>> file
>>>
>>> Edit /lib/systemd/system/bluetooth.service file to add --experimental
>>> flag
>>> e.g:
>>>
>>> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
>>> /lib/systemd/system/bluetooth.service
>>>
>>>
>>>
>>>
>>>> I have not found the code that export GATT Services from GATT
>>>> Database to
>>>> the BLE central.
>>>>
>>>> From my search on Internet, it looks I am not the only one who is
>>>> having
>>>> this issue
>>>> I am happy to share/test anything that could help to make some
>>>> progress.
>>>>
>>>> Thanks,
>>>> Olivier
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe
>>>> linux-bluetooth"
>>>> in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>>
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Barry Byford @ 2017-04-14 10:37 UTC (permalink / raw)
To: Olivier MARTIN; +Cc: Bluez mailing list
In-Reply-To: <1c0a0d7a4270d7dcb457523e8fbbc244@labapart.com>
example-advertisementHello Oliver,
On 14 April 2017 at 11:03, Olivier MARTIN <olivier@labapart.com> wrote:
> Thanks for replying my message Barry,
>
> Sorry, I forgot to mention but I start Bluez daemon with `sudo
> ./src/bluetoothd -E -n -d` (after stopping the bluetooth service). So I
> already run it with sudo and experimental option.
>
> I am not sure to understand what you mean by "this kind of error message".
> Because I do not see any error message in the log I provided.
OK, that was bad on my part. I read it as complaining that there were
too many advertisements. Looking again that wasn't what it was say.
Apologies.
>
> Any other idea?
I am by Linux Single Board Computers (SBC) today so I'm able to run
what you are running and can show you what I'm seeing. I'll focus on
example-advertisement first as example-gatt-server doesn't change the
advertisements.
I've started the BlueZ daemon with "./src/bluetoothd -E -n -d"
In another shell when I start "./example-advertisement" I see the
following in the output:
bluetoothd[2325]: src/adapter.c:property_set_mode() sending Set
Powered command for index 0
bluetoothd[2325]: src/adapter.c:property_set_mode_complete() Success (0x00)
bluetoothd[2325]: src/adapter.c:new_settings_callback() Settings: 0x00000ad1
bluetoothd[2325]: src/adapter.c:settings_changed() Changed settings: 0x00000001
bluetoothd[2325]: src/adapter.c:adapter_start() adapter
/org/bluez/hci0 has been enabled
bluetoothd[2325]: src/adapter.c:trigger_passive_scanning()
bluetoothd[2325]: src/advertising.c:register_advertisement()
RegisterAdvertisement
bluetoothd[2325]: src/advertising.c:client_create() Adding proxy for
/org/bluez/example/advertisement0
bluetoothd[2325]: src/advertising.c:register_advertisement()
Registered advertisement at path /org/bluez/example/advertisement0
bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
ServiceUUID: 180D
bluetoothd[2325]: src/advertising.c:parse_service_uuids() Adding
ServiceUUID: 180F
bluetoothd[2325]: src/advertising.c:parse_manufacturer_data() Adding
ManufacturerData for ffff
bluetoothd[2325]: src/advertising.c:parse_service_data() Adding
ServiceData for 9999
bluetoothd[2325]: src/advertising.c:refresh_advertisement() Refreshing
advertisement: /org/bluez/example/advertisement0
bluetoothd[2325]: src/advertising.c:add_adv_callback() Advertisement
registered: /org/bluez/example/advertisement0
On a second SBC, at the command line I run "bluetoothctl" and do "scan
on". Once my first SBC is found I do "scan off". I then do "info
B8:27:EB:22:57:E0" (this is the address of the first SBC) which gives
the following output:
[bluetooth]# info B8:27:EB:22:57:E0
Device B8:27:EB:22:57:E0
Alias: B8-27-EB-22-57-E0
Paired: no
Trusted: no
Blocked: no
Connected: no
LegacyPairing: no
UUID: Heart Rate (0000180d-0000-1000-8000-00805f9b34fb)
UUID: Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
ManufacturerData Key: 0xffff
ManufacturerData Value: 0x00
ManufacturerData Value: 0x01
ManufacturerData Value: 0x02
ManufacturerData Value: 0x03
ManufacturerData Value: 0x04
ServiceData Key: 00009999-0000-1000-8000-00805f9b34fb
ServiceData Value: 0x00
ServiceData Value: 0x01
ServiceData Value: 0x02
ServiceData Value: 0x03
ServiceData Value: 0x04
I've also done a scan from my Android phone (using the Nordic nRF
Connect app) and can see the advertisements also (just hard to share
that information on here).
Does that help?
>
>
> On 13.04.2017 19:59, Barry Byford wrote:
>>
>> Hello Olivier,
>>
>>
>> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com> wrote:
>>>
>>> Hi all,
>>> I am having issue to advertise/export GATT services exposed through DBus
>>> API. I tried `./test/example-gatt-server`. And I also tried to merge
>>> `./test/example-advertisement` into `./test/example-gatt-server`. But in
>>> both cases I only see the two compulsory GATT services:
>>> - Generic Access Service (0x1800)
>>> - Generic Attribute Service (0x1801)
>>>
>>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>>
>>> GATT Services seem to be discovered by Bluez (note: I added additional
>>> debug
>>> statement all prefixed with '#'):
>>>
>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>>> manager_register_app
>>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() Registering
>>> application: :1.404:/
>>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>>> RegisterAdvertisement
>>> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy for
>>> /org/bluez/example/advertisement0
>>> bluetoothd[16877]: src/advertising.c:register_advertisement() Registered
>>> advertisement at path /org/bluez/example/advertisement0
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service0/char2, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char0/desc0, iface: org.bluez.GattDescriptor1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char2/desc3, iface: org.bluez.GattDescriptor1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char2, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service1/char0, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char1, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service0/char1, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char1/desc3, iface: org.bluez.GattDescriptor1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char1/desc2, iface: org.bluez.GattDescriptor1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service0/char0, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2, iface: org.bluez.GattService1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service1, iface: org.bluez.GattService1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service0, iface: org.bluez.GattService1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char0/desc1, iface: org.bluez.GattDescriptor1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char2/desc2, iface: org.bluez.GattDescriptor1
>>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
>>> /org/bluez/example/service2/char0, iface: org.bluez.GattCharacteristic1
>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>>> client_ready_cb
>>> bluetoothd[16877]: src/gatt-database.c:create_service() # create_service
>>> from /org/bluez/example/service2
>>> bluetoothd[16877]: src/gatt-database.c:create_service() # create_service
>>> from /org/bluez/example/service1
>>> bluetoothd[16877]: src/gatt-database.c:create_service() # create_service
>>> from /org/bluez/example/service0
>>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>>> database_add_app
>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>> database_add_service
>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value in
>>> the database
>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>> entry
>>> for characteristic
>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value in
>>> the database
>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>> entry
>>> for characteristic
>>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value in
>>> the database
>>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>>> entry
>>> for characteristic
>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>> gatt_db_service_added: GATT Service added to local database
>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>> database_add_service
>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>>> entry
>>> for characteristic
>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>> gatt_db_service_added: GATT Service added to local database
>>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>>> database_add_service
>>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>>> entry
>>> for characteristic
>>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>>> gatt_db_service_added: GATT Service added to local database
>>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT application
>>> registered: :1.404:/
>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>> ServiceUUID: 180D
>>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>>> ServiceUUID: 180F
>>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data() Adding
>>> ManufacturerData for ffff
>>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>>> ServiceData
>>> for 9999
>>> bluetoothd[16877]: src/advertising.c:refresh_advertisement() Refreshing
>>> advertisement: /org/bluez/example/advertisement0
>>> bluetoothd[16877]: src/advertising.c:add_adv_callback() Advertisement
>>> registered: /org/bluez/example/advertisement0
>>>
>>> I start `./test/example-gatt-server` as a normal user. But Bluez does not
>>> seem to have any permission issue with it.
>>
>>
>> Building from source I've seen something similar if I've used sudo for the
>> make.
>>
>> To compile and install I use sudo for the install only:
>>
>> make -j 4 && sudo make install
>>
>>
>>
>>>
>>> I am using 'BLE scanner' on Android to discover the GATT services. But I
>>> think the problem is coming from Bluez. When I connect the Android device
>>> to
>>> Bluez, I can see this log:
>>>
>>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
>>> 98:D6:F7:31:7B:0D connected eir_len 14
>>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming BR/EDR
>>> ATT
>>> connection
>>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>>> g_attrib_ref=1
>>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db: Restoring
>>> 98:D6:F7:31:7B:0D gatt database from file
>>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() # load_gatt_db_impl
>>> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
>>> service: 0x0001, end: 0x0005, uuid: 00001801-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
>>> service: 0x0014, end: 0xffff, uuid: 00001800-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>> handle:
>>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>>> 00002a05-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>> handle:
>>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>>> 00002a00-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>>> handle:
>>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>>> 00002a01-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries before
>>> being free:
>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>> 00001801-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>>> 00001800-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile accept
>>> (98:D6:F7:31:7B:0D)
>>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
>>> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected ->
>>> connected (0)
>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected() Device
>>> connected.
>>> bluetoothd[16877]: src/device.c:gatt_server_init() # gatt_server_init
>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler for
>>> "Service
>>> Changed": 0
>>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status: success,
>>> error: 0
>>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>>> register_gatt_services
>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>>> bluetoothd[16877]: src/device.c:add_gatt_service() # add_gatt_service:
>>> UUID:00001801-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT client
>>> ready
>>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting objects
>>> for
>>> GATT services: 98:D6:F7:31:7B:0D
>>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported GATT
>>> service:
>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>>> bluetoothd[16877]: src/gatt-client.c:characteristic_create() Exported
>>> GATT
>>> characteristic:
>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>> bluetoothd[16877]: src/device.c:store_service() # store_service
>>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP Device
>>> Name:
>>> Nexus 4
>>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>>> Appearance:
>>> 0x0000
>>>
>>> I also reduced DBus 'TestAdvertisement' interface to only expose one GATT
>>> Service as many BLE adapter got a limitation in the size of the
>>> advertisement packet:
>>> class TestAdvertisement(Advertisement):
>>>
>>> def __init__(self, bus, index):
>>> Advertisement.__init__(self, bus, index, 'peripheral')
>>> #self.add_service_uuid('180D') # HeartRate
>>> self.add_service_uuid('180F') # Battery
>>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02, 0x03,
>>> 0x04])
>>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03, 0x04])
>>> self.include_tx_power = True
>>>
>>> My concern is mainly these lines:
>>>
>>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
>>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
>>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>>
>>
>> I've seen this kind of error message when I've had a failure of a
>> previous script and the Bluetooth daemon is in some unknown state. At
>> this point it is worth restarting the bluetooth service with:
>> sudo service bluetooth restart
>>
>> You will see in the advertising DBus API documentation that it is
>> still in experimental mode in 5.44.
>>
>> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>>
>> This means that you need to make sure bluetoothd is started in
>> experimental mode. Have you done this?
>> You can check with "sudo service bluetooth status"
>>
>> Experimental can be switched on by default in the bluetooth.service file
>>
>> Edit /lib/systemd/system/bluetooth.service file to add --experimental flag
>> e.g:
>>
>> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
>> /lib/systemd/system/bluetooth.service
>>
>>
>>
>>
>>> I have not found the code that export GATT Services from GATT Database to
>>> the BLE central.
>>>
>>> From my search on Internet, it looks I am not the only one who is having
>>> this issue
>>> I am happy to share/test anything that could help to make some progress.
>>>
>>> Thanks,
>>> Olivier
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe
>>> linux-bluetooth"
>>> in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Olivier MARTIN @ 2017-04-14 10:03 UTC (permalink / raw)
To: Barry Byford; +Cc: Bluez mailing list
In-Reply-To: <CAAu3APaR4weHx=63JFbaQNK5kQmCEm3LHg6mPhFe7NQ9aW4Cvg@mail.gmail.com>
Thanks for replying my message Barry,
Sorry, I forgot to mention but I start Bluez daemon with `sudo
./src/bluetoothd -E -n -d` (after stopping the bluetooth service). So I
already run it with sudo and experimental option.
I am not sure to understand what you mean by "this kind of error
message". Because I do not see any error message in the log I provided.
Any other idea?
On 13.04.2017 19:59, Barry Byford wrote:
> Hello Olivier,
>
>
> On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com> wrote:
>> Hi all,
>> I am having issue to advertise/export GATT services exposed through
>> DBus
>> API. I tried `./test/example-gatt-server`. And I also tried to merge
>> `./test/example-advertisement` into `./test/example-gatt-server`. But
>> in
>> both cases I only see the two compulsory GATT services:
>> - Generic Access Service (0x1800)
>> - Generic Attribute Service (0x1801)
>>
>> I am using Bluez v5.44. And I also tried Bluez v5.37.
>>
>> GATT Services seem to be discovered by Bluez (note: I added additional
>> debug
>> statement all prefixed with '#'):
>>
>> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
>> manager_register_app
>> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
>> bluetoothd[16877]: src/gatt-database.c:manager_register_app()
>> Registering
>> application: :1.404:/
>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>> RegisterAdvertisement
>> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy for
>> /org/bluez/example/advertisement0
>> bluetoothd[16877]: src/advertising.c:register_advertisement()
>> Registered
>> advertisement at path /org/bluez/example/advertisement0
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service0/char2, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char0/desc0, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char2/desc3, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char2, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service1/char0, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char1, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service0/char1, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char1/desc3, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char1/desc2, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service0/char0, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2, iface: org.bluez.GattService1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service1, iface: org.bluez.GattService1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service0, iface: org.bluez.GattService1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char0/desc1, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char2/desc2, iface:
>> org.bluez.GattDescriptor1
>> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object
>> received:
>> /org/bluez/example/service2/char0, iface:
>> org.bluez.GattCharacteristic1
>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() #
>> client_ready_cb
>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>> create_service
>> from /org/bluez/example/service2
>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>> create_service
>> from /org/bluez/example/service1
>> bluetoothd[16877]: src/gatt-database.c:create_service() #
>> create_service
>> from /org/bluez/example/service0
>> bluetoothd[16877]: src/gatt-database.c:database_add_app() #
>> database_add_app
>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>> database_add_service
>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value
>> in
>> the database
>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>> entry
>> for characteristic
>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value
>> in
>> the database
>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>> entry
>> for characteristic
>> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value
>> in
>> the database
>> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP
>> entry
>> for characteristic
>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>> gatt_db_service_added: GATT Service added to local database
>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>> database_add_service
>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>> entry
>> for characteristic
>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>> gatt_db_service_added: GATT Service added to local database
>> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
>> database_add_service
>> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC
>> entry
>> for characteristic
>> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
>> gatt_db_service_added: GATT Service added to local database
>> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT
>> application
>> registered: :1.404:/
>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>> ServiceUUID: 180D
>> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
>> ServiceUUID: 180F
>> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data() Adding
>> ManufacturerData for ffff
>> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding
>> ServiceData
>> for 9999
>> bluetoothd[16877]: src/advertising.c:refresh_advertisement()
>> Refreshing
>> advertisement: /org/bluez/example/advertisement0
>> bluetoothd[16877]: src/advertising.c:add_adv_callback() Advertisement
>> registered: /org/bluez/example/advertisement0
>>
>> I start `./test/example-gatt-server` as a normal user. But Bluez does
>> not
>> seem to have any permission issue with it.
>
> Building from source I've seen something similar if I've used sudo for
> the make.
>
> To compile and install I use sudo for the install only:
>
> make -j 4 && sudo make install
>
>
>
>>
>> I am using 'BLE scanner' on Android to discover the GATT services. But
>> I
>> think the problem is coming from Bluez. When I connect the Android
>> device to
>> Bluez, I can see this log:
>>
>> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
>> 98:D6:F7:31:7B:0D connected eir_len 14
>> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming
>> BR/EDR ATT
>> connection
>> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908:
>> g_attrib_ref=1
>> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db:
>> Restoring
>> 98:D6:F7:31:7B:0D gatt database from file
>> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
>> bluetoothd[16877]: src/device.c:load_gatt_db_impl() #
>> load_gatt_db_impl
>> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
>> service: 0x0001, end: 0x0005, uuid:
>> 00001801-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
>> service: 0x0014, end: 0xffff, uuid:
>> 00001800-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>> handle:
>> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
>> 00002a05-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>> handle:
>> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
>> 00002a00-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic
>> handle:
>> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
>> 00002a01-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries
>> before
>> being free:
>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>> 00001801-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
>> 00001800-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile accept
>> (98:D6:F7:31:7B:0D)
>> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
>> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected ->
>> connected (0)
>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected()
>> Device
>> connected.
>> bluetoothd[16877]: src/device.c:gatt_server_init() # gatt_server_init
>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>> 0x0005,
>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>> 0xffff,
>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler for
>> "Service
>> Changed": 0
>> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status:
>> success,
>> error: 0
>> bluetoothd[16877]: src/device.c:register_gatt_services() #
>> register_gatt_services
>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>> bluetoothd[16877]: src/device.c:add_primary() # add_primary
>> bluetoothd[16877]: src/device.c:add_gatt_service() # add_gatt_service:
>> UUID:00001801-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT
>> client
>> ready
>> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting
>> objects for
>> GATT services: 98:D6:F7:31:7B:0D
>> bluetoothd[16877]: src/gatt-client.c:service_create() Exported GATT
>> service:
>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
>> bluetoothd[16877]: src/gatt-client.c:characteristic_create() Exported
>> GATT
>> characteristic:
>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
>> bluetoothd[16877]: src/device.c:device_svc_resolved()
>> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
>> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
>> bluetoothd[16877]: src/device.c:store_service() # store_service
>> bluetoothd[16877]: src/device.c:store_service() # store_service
>> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP Device
>> Name:
>> Nexus 4
>> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP
>> Appearance:
>> 0x0000
>>
>> I also reduced DBus 'TestAdvertisement' interface to only expose one
>> GATT
>> Service as many BLE adapter got a limitation in the size of the
>> advertisement packet:
>> class TestAdvertisement(Advertisement):
>>
>> def __init__(self, bus, index):
>> Advertisement.__init__(self, bus, index, 'peripheral')
>> #self.add_service_uuid('180D') # HeartRate
>> self.add_service_uuid('180F') # Battery
>> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02, 0x03,
>> 0x04])
>> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03, 0x04])
>> self.include_tx_power = True
>>
>> My concern is mainly these lines:
>>
>> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end:
>> 0x0005,
>> uuid: 00001801-0000-1000-8000-00805f9b34fb
>> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end:
>> 0xffff,
>> uuid: 00001800-0000-1000-8000-00805f9b34fb
>>
>
> I've seen this kind of error message when I've had a failure of a
> previous script and the Bluetooth daemon is in some unknown state. At
> this point it is worth restarting the bluetooth service with:
> sudo service bluetooth restart
>
> You will see in the advertising DBus API documentation that it is
> still in experimental mode in 5.44.
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
>
> This means that you need to make sure bluetoothd is started in
> experimental mode. Have you done this?
> You can check with "sudo service bluetooth status"
>
> Experimental can be switched on by default in the bluetooth.service
> file
>
> Edit /lib/systemd/system/bluetooth.service file to add --experimental
> flag e.g:
>
> sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
> /lib/systemd/system/bluetooth.service
>
>
>
>
>> I have not found the code that export GATT Services from GATT Database
>> to
>> the BLE central.
>>
>> From my search on Internet, it looks I am not the only one who is
>> having
>> this issue
>> I am happy to share/test anything that could help to make some
>> progress.
>>
>> Thanks,
>> Olivier
>> --
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-bluetooth"
>> in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCHv4 0/2] Nokia H4+ support
From: Sebastian Reichel @ 2017-04-13 23:19 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Gustavo F. Padovan, Johan Hedberg, Rob Herring, Pavel Machek,
Linux Bluetooth, devicetree, linux-kernel
In-Reply-To: <3CE124E5-09B7-423D-B979-73564EB3BC6C@holtmann.org>
[-- Attachment #1: Type: text/plain, Size: 649 bytes --]
Hi Marcel,
On Thu, Apr 13, 2017 at 10:33:58AM +0200, Marcel Holtmann wrote:
> > Here is the fourth revision of the nokia bluetooth patchset. Compared
> > to the previous one the following things have changed:
> >
> > * Drop patch 1-8 (applied by Marcel) and update Cc/To for patchset
> > * Order includes in the driver alphabetically
> > * Explicitly include <linux/of.h> in the nokia bluetooth driver
> >
> > -- Sebastian
> >
> > Sebastian Reichel (2):
> > dt-bindings: net: bluetooth: Add nokia-bluetooth
> > Bluetooth: add nokia driver
>
> both patches have been applied to bluetooth-next tree.
Thanks.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD
From: kbuild test robot @ 2017-04-13 22:04 UTC (permalink / raw)
To: Felipe F. Tonello
Cc: kbuild-all, linux-bluetooth, linux-kernel, Marcel Holtmann,
Johan Hedberg, Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-5-eu@felipetonello.com>
[-- Attachment #1: Type: text/plain, Size: 17513 bytes --]
Hi Felipe,
[auto build test WARNING on bluetooth/master]
[also build test WARNING on v4.11-rc6 next-20170413]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Felipe-F-Tonello/Connection-Update-improvements/20170414-030326
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All warnings (new ones prefixed by >>):
In file included from include/linux/swab.h:4:0,
from include/uapi/linux/byteorder/big_endian.h:12,
from include/linux/byteorder/big_endian.h:4,
from arch/xtensa/include/uapi/asm/byteorder.h:7,
from arch/xtensa/include/asm/bitops.h:23,
from include/linux/bitops.h:36,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/module.h:9,
from net/bluetooth/mgmt.c:27:
net/bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
(__builtin_constant_p((__u16)(x)) ? \
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0xff00U) >> 8)))
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
__fswab16(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
(__builtin_constant_p((__u16)(x)) ? \
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0xff00U) >> 8)))
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
__fswab16(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
--
In file included from include/linux/swab.h:4:0,
from include/uapi/linux/byteorder/big_endian.h:12,
from include/linux/byteorder/big_endian.h:4,
from arch/xtensa/include/uapi/asm/byteorder.h:7,
from arch/xtensa/include/asm/bitops.h:23,
from include/linux/bitops.h:36,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/module.h:9,
from net//bluetooth/mgmt.c:27:
net//bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
(__builtin_constant_p((__u16)(x)) ? \
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0xff00U) >> 8)))
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
__fswab16(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
(__builtin_constant_p((__u16)(x)) ? \
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
(((__u16)(x) & (__u16)0xff00U) >> 8)))
^
include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
__fswab16(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^
net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^
vim +35 include/uapi/linux/byteorder/big_endian.h
5921e6f8 David Howells 2012-10-13 19 #define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
5921e6f8 David Howells 2012-10-13 20 #define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
5921e6f8 David Howells 2012-10-13 21 #define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
5921e6f8 David Howells 2012-10-13 22 #define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
5921e6f8 David Howells 2012-10-13 23 #define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
5921e6f8 David Howells 2012-10-13 24 #define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
5921e6f8 David Howells 2012-10-13 25 #define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
5921e6f8 David Howells 2012-10-13 26 #define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
5921e6f8 David Howells 2012-10-13 27 #define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
5921e6f8 David Howells 2012-10-13 28 #define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
5921e6f8 David Howells 2012-10-13 29 #define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
5921e6f8 David Howells 2012-10-13 30 #define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
5921e6f8 David Howells 2012-10-13 31 #define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
5921e6f8 David Howells 2012-10-13 32 #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
5921e6f8 David Howells 2012-10-13 33 #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
5921e6f8 David Howells 2012-10-13 34 #define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
5921e6f8 David Howells 2012-10-13 @35 #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
5921e6f8 David Howells 2012-10-13 36 #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
5921e6f8 David Howells 2012-10-13 37 #define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
5921e6f8 David Howells 2012-10-13 38 #define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
5921e6f8 David Howells 2012-10-13 39 #define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
5921e6f8 David Howells 2012-10-13 40 #define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
5921e6f8 David Howells 2012-10-13 41 #define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
5921e6f8 David Howells 2012-10-13 42
bc27fb68 Denys Vlasenko 2016-03-17 43 static __always_inline __le64 __cpu_to_le64p(const __u64 *p)
:::::: The code at line 35 was first introduced by commit
:::::: 5921e6f8809b1616932ca4afd40fe449faa8fd88 UAPI: (Scripted) Disintegrate include/linux/byteorder
:::::: TO: David Howells <dhowells@redhat.com>
:::::: CC: David Howells <dhowells@redhat.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 49076 bytes --]
^ permalink raw reply
* Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD
From: kbuild test robot @ 2017-04-13 20:01 UTC (permalink / raw)
To: Felipe F. Tonello
Cc: kbuild-all, linux-bluetooth, linux-kernel, Marcel Holtmann,
Johan Hedberg, Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-5-eu@felipetonello.com>
[-- Attachment #1: Type: text/plain, Size: 4811 bytes --]
Hi Felipe,
[auto build test WARNING on bluetooth/master]
[also build test WARNING on v4.11-rc6 next-20170413]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Felipe-F-Tonello/Connection-Update-improvements/20170414-030326
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
config: x86_64-randconfig-x011-201715 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from include/linux/byteorder/little_endian.h:4:0,
from arch/x86/include/uapi/asm/byteorder.h:4,
from include/asm-generic/bitops/le.h:5,
from arch/x86/include/asm/bitops.h:517,
from include/linux/bitops.h:36,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/module.h:9,
from net/bluetooth/mgmt.c:27:
net/bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^~~~~~~~~~~
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^~~~~~~~~~~~~
net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^~~~~~~~~~~
--
In file included from include/linux/byteorder/little_endian.h:4:0,
from arch/x86/include/uapi/asm/byteorder.h:4,
from include/asm-generic/bitops/le.h:5,
from arch/x86/include/asm/bitops.h:517,
from include/linux/bitops.h:36,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/module.h:9,
from net//bluetooth/mgmt.c:27:
net//bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^~~~~~~~~~~~~
net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
*min_conn = le16_to_cpu(&data[0]);
^~~~~~~~~~~
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
#define le16_to_cpu __le16_to_cpu
^~~~~~~~~~~~~
net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
*max_conn = le16_to_cpu(&data[2]);
^~~~~~~~~~~
vim +/le16_to_cpu +7474 net/bluetooth/mgmt.c
7458 break;
7459
7460 len += field_len + 1;
7461
7462 /* Do not continue EIR Data parsing if got
7463 * incorrect length
7464 */
7465 if (len > eir_len)
7466 break;
7467
7468 data = &eir_data[2];
7469 data_len = field_len - 1;
7470
7471 if (eir_data[1] == EIR_SLAVE_CONN_INT) {
7472 if (data_len < 4)
7473 break;
> 7474 *min_conn = le16_to_cpu(&data[0]);
7475 *max_conn = le16_to_cpu(&data[2]);
7476 return true;
7477 }
7478
7479 eir_data += field_len + 1;
7480 }
7481
7482 return false;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33493 bytes --]
^ permalink raw reply
* Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD
From: Luiz Augusto von Dentz @ 2017-04-13 18:40 UTC (permalink / raw)
To: Vinicius Costa Gomes
Cc: Felipe F. Tonello, linux-bluetooth@vger.kernel.org,
Linux Kernel Mailing List, Marcel Holtmann, Johan Hedberg
In-Reply-To: <877f2o6u8p.fsf@intel.com>
Hi,
On Thu, Apr 13, 2017 at 9:24 PM, Vinicius Costa Gomes
<vinicius.gomes@intel.com> wrote:
> Hi Felipe,
>
> "Felipe F. Tonello" <eu@felipetonello.com> writes:
>
>> The Slave Connection Interval Range data type contains the Peripheral's
>> preferred connection interval range, for all logical connections.
>>
>> It is useful to parse it in the Kernel so there is no multiple calls to
>> MGMT interface to update the device connection parameters and subsequent
>> connection command call to this device will use proper connection
>> parameters. This saves context-switches and eliminates user-space to
>> update the connection parameters each time a device is found or
>> bluetoothd is restarted and so on. Also, there is no need for the
>> user-space to know care about it because if the slave device wishes to
>> persist with these parameters, it should use the L2CAP connection
>> parameters upade request upon a completed connection.
>
> nitpick: upade -> update
>
>>
>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>> ---
>> net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 53 insertions(+)
>>
>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
>> index 1fba2a03f8ae..ea5d6c85f173 100644
>> --- a/net/bluetooth/mgmt.c
>> +++ b/net/bluetooth/mgmt.c
>> @@ -7442,6 +7442,46 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir,
>> return true;
>> }
>>
>> +static bool has_eir_slave_conn_int(const u8 *eir_data, u8 eir_len,
>> + u16 *min_conn, u16 *max_conn)
>> +{
>> + u16 len = 0;
>> + const u8 EIR_SLAVE_CONN_INT = 0x12; /* Slave Connection Interval Range */
>> +
>> + while (len < eir_len - 1) {
>> + u8 field_len = eir_data[0];
>> + const u8 *data;
>> + u8 data_len;
>> +
>> + /* Check for the end of EIR */
>> + if (field_len == 0)
>> + break;
>> +
>> + len += field_len + 1;
>> +
>> + /* Do not continue EIR Data parsing if got
>> + * incorrect length
>> + */
>> + if (len > eir_len)
>> + break;
>> +
>> + data = &eir_data[2];
>> + data_len = field_len - 1;
>> +
>> + if (eir_data[1] == EIR_SLAVE_CONN_INT) {
>> + if (data_len < 4)
>> + break;
>> + *min_conn = le16_to_cpu(&data[0]);
>> + *max_conn = le16_to_cpu(&data[2]);
>> + return true;
>> + }
>> +
>> + eir_data += field_len + 1;
>> + }
>> +
>> + return false;
>> +}
>> +
>> void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
>> u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
>> u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
>> @@ -7449,6 +7489,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
>> char buf[512];
>> struct mgmt_ev_device_found *ev = (void *)buf;
>> size_t ev_size;
>> + struct hci_conn *hcon;
>>
>> /* Don't send events for a non-kernel initiated discovery. With
>> * LE one exception is if we have pend_le_reports > 0 in which
>> @@ -7521,6 +7562,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
>> ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
>> ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
>>
>> + /* Search for Slave Connection Interval AD */
>> + hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
>> + if (hcon) {
>> + u16 min_conn_int, max_conn_int;
>> +
>> + if (has_eir_slave_conn_int(ev->eir, ev->eir_len,
>> + &min_conn_int, &max_conn_int)) {
>> + hcon->le_conn_min_interval = min_conn_int;
>> + hcon->le_conn_max_interval = max_conn_int;
>> + }
>> + }
>> +
>
> It's been some time that I looked at this code, so I could be missing
> something, but I got the feeling that this part would make more sense if
> it was at process_adv_report(), there's even the check for a pending
> connection, so no need to redo that here.
Actually I would use the AD only in case the device is marked for
auto-connect or there is a connection pending, so the parameters are
only used for the connection alone and are not persisted.
> Apart from this, the series looks good.
>
>
>> mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
>> }
>>
>> --
>> 2.12.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> Cheers,
> --
> Vinicius
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD
From: Vinicius Costa Gomes @ 2017-04-13 18:24 UTC (permalink / raw)
To: Felipe F. Tonello, linux-bluetooth
Cc: linux-kernel, Marcel Holtmann, Johan Hedberg,
Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-5-eu@felipetonello.com>
Hi Felipe,
"Felipe F. Tonello" <eu@felipetonello.com> writes:
> The Slave Connection Interval Range data type contains the Peripheral's
> preferred connection interval range, for all logical connections.
>
> It is useful to parse it in the Kernel so there is no multiple calls to
> MGMT interface to update the device connection parameters and subsequent
> connection command call to this device will use proper connection
> parameters. This saves context-switches and eliminates user-space to
> update the connection parameters each time a device is found or
> bluetoothd is restarted and so on. Also, there is no need for the
> user-space to know care about it because if the slave device wishes to
> persist with these parameters, it should use the L2CAP connection
> parameters upade request upon a completed connection.
nitpick: upade -> update
>
> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
> ---
> net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 1fba2a03f8ae..ea5d6c85f173 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -7442,6 +7442,46 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir,
> return true;
> }
>
> +static bool has_eir_slave_conn_int(const u8 *eir_data, u8 eir_len,
> + u16 *min_conn, u16 *max_conn)
> +{
> + u16 len = 0;
> + const u8 EIR_SLAVE_CONN_INT = 0x12; /* Slave Connection Interval Range */
> +
> + while (len < eir_len - 1) {
> + u8 field_len = eir_data[0];
> + const u8 *data;
> + u8 data_len;
> +
> + /* Check for the end of EIR */
> + if (field_len == 0)
> + break;
> +
> + len += field_len + 1;
> +
> + /* Do not continue EIR Data parsing if got
> + * incorrect length
> + */
> + if (len > eir_len)
> + break;
> +
> + data = &eir_data[2];
> + data_len = field_len - 1;
> +
> + if (eir_data[1] == EIR_SLAVE_CONN_INT) {
> + if (data_len < 4)
> + break;
> + *min_conn = le16_to_cpu(&data[0]);
> + *max_conn = le16_to_cpu(&data[2]);
> + return true;
> + }
> +
> + eir_data += field_len + 1;
> + }
> +
> + return false;
> +}
> +
> void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
> u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
> u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
> @@ -7449,6 +7489,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
> char buf[512];
> struct mgmt_ev_device_found *ev = (void *)buf;
> size_t ev_size;
> + struct hci_conn *hcon;
>
> /* Don't send events for a non-kernel initiated discovery. With
> * LE one exception is if we have pend_le_reports > 0 in which
> @@ -7521,6 +7562,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
> ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
> ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
>
> + /* Search for Slave Connection Interval AD */
> + hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
> + if (hcon) {
> + u16 min_conn_int, max_conn_int;
> +
> + if (has_eir_slave_conn_int(ev->eir, ev->eir_len,
> + &min_conn_int, &max_conn_int)) {
> + hcon->le_conn_min_interval = min_conn_int;
> + hcon->le_conn_max_interval = max_conn_int;
> + }
> + }
> +
It's been some time that I looked at this code, so I could be missing
something, but I got the feeling that this part would make more sense if
it was at process_adv_report(), there's even the check for a pending
connection, so no need to redo that here.
Apart from this, the series looks good.
> mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
> }
>
> --
> 2.12.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
--
Vinicius
^ permalink raw reply
* Re: GATT Server: DBus GATT Services not advertised/exported
From: Barry Byford @ 2017-04-13 17:59 UTC (permalink / raw)
To: Olivier MARTIN; +Cc: Bluez mailing list
In-Reply-To: <1b8c74ef5fafaca3c75fb87249d728f8@labapart.com>
Hello Olivier,
On 13 April 2017 at 12:14, Olivier MARTIN <olivier@labapart.com> wrote:
> Hi all,
> I am having issue to advertise/export GATT services exposed through DBus
> API. I tried `./test/example-gatt-server`. And I also tried to merge
> `./test/example-advertisement` into `./test/example-gatt-server`. But in
> both cases I only see the two compulsory GATT services:
> - Generic Access Service (0x1800)
> - Generic Attribute Service (0x1801)
>
> I am using Bluez v5.44. And I also tried Bluez v5.37.
>
> GATT Services seem to be discovered by Bluez (note: I added additional debug
> statement all prefixed with '#'):
>
> bluetoothd[16877]: src/gatt-database.c:manager_register_app() #
> manager_register_app
> bluetoothd[16877]: src/gatt-database.c:create_app() # create_app
> bluetoothd[16877]: src/gatt-database.c:manager_register_app() Registering
> application: :1.404:/
> bluetoothd[16877]: src/advertising.c:register_advertisement()
> RegisterAdvertisement
> bluetoothd[16877]: src/advertising.c:client_create() Adding proxy for
> /org/bluez/example/advertisement0
> bluetoothd[16877]: src/advertising.c:register_advertisement() Registered
> advertisement at path /org/bluez/example/advertisement0
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service0/char2, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char0/desc0, iface: org.bluez.GattDescriptor1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char2/desc3, iface: org.bluez.GattDescriptor1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char2, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service1/char0, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char1, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service0/char1, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char1/desc3, iface: org.bluez.GattDescriptor1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char1/desc2, iface: org.bluez.GattDescriptor1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service0/char0, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2, iface: org.bluez.GattService1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service1, iface: org.bluez.GattService1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service0, iface: org.bluez.GattService1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char0/desc1, iface: org.bluez.GattDescriptor1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char2/desc2, iface: org.bluez.GattDescriptor1
> bluetoothd[16877]: src/gatt-database.c:proxy_added_cb() Object received:
> /org/bluez/example/service2/char0, iface: org.bluez.GattCharacteristic1
> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() # client_ready_cb
> bluetoothd[16877]: src/gatt-database.c:create_service() # create_service
> from /org/bluez/example/service2
> bluetoothd[16877]: src/gatt-database.c:create_service() # create_service
> from /org/bluez/example/service1
> bluetoothd[16877]: src/gatt-database.c:create_service() # create_service
> from /org/bluez/example/service0
> bluetoothd[16877]: src/gatt-database.c:database_add_app() # database_add_app
> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
> database_add_service
> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value in
> the database
> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP entry
> for characteristic
> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value in
> the database
> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP entry
> for characteristic
> bluetoothd[16877]: src/gatt-database.c:cep_write_cb() Stored CEP value in
> the database
> bluetoothd[16877]: src/gatt-database.c:database_add_cep() Created CEP entry
> for characteristic
> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
> gatt_db_service_added: GATT Service added to local database
> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
> database_add_service
> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC entry
> for characteristic
> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
> gatt_db_service_added: GATT Service added to local database
> bluetoothd[16877]: src/gatt-database.c:database_add_service() #
> database_add_service
> bluetoothd[16877]: src/gatt-database.c:database_add_ccc() Created CCC entry
> for characteristic
> bluetoothd[16877]: src/gatt-database.c:gatt_db_service_added() #
> gatt_db_service_added: GATT Service added to local database
> bluetoothd[16877]: src/gatt-database.c:client_ready_cb() GATT application
> registered: :1.404:/
> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
> ServiceUUID: 180D
> bluetoothd[16877]: src/advertising.c:parse_service_uuids() Adding
> ServiceUUID: 180F
> bluetoothd[16877]: src/advertising.c:parse_manufacturer_data() Adding
> ManufacturerData for ffff
> bluetoothd[16877]: src/advertising.c:parse_service_data() Adding ServiceData
> for 9999
> bluetoothd[16877]: src/advertising.c:refresh_advertisement() Refreshing
> advertisement: /org/bluez/example/advertisement0
> bluetoothd[16877]: src/advertising.c:add_adv_callback() Advertisement
> registered: /org/bluez/example/advertisement0
>
> I start `./test/example-gatt-server` as a normal user. But Bluez does not
> seem to have any permission issue with it.
Building from source I've seen something similar if I've used sudo for the make.
To compile and install I use sudo for the install only:
make -j 4 && sudo make install
>
> I am using 'BLE scanner' on Android to discover the GATT services. But I
> think the problem is coming from Bluez. When I connect the Android device to
> Bluez, I can see this log:
>
> bluetoothd[16877]: src/adapter.c:connected_callback() hci0 device
> 98:D6:F7:31:7B:0D connected eir_len 14
> bluetoothd[16877]: src/gatt-database.c:connect_cb() New incoming BR/EDR ATT
> connection
> bluetoothd[16877]: attrib/gattrib.c:g_attrib_ref() 0x98cd908: g_attrib_ref=1
> bluetoothd[16877]: src/device.c:load_gatt_db() # load_gatt_db: Restoring
> 98:D6:F7:31:7B:0D gatt database from file
> '/var/lib/bluetooth/5C:F3:70:6A:D9:3C/cache/98:D6:F7:31:7B:0D'
> bluetoothd[16877]: src/device.c:load_gatt_db_impl() # load_gatt_db_impl
> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
> service: 0x0001, end: 0x0005, uuid: 00001801-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:load_service() # load_service: loading
> service: 0x0014, end: 0xffff, uuid: 00001800-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic handle:
> 0x0002, value handle: 0x0003, properties 0x0020 uuid:
> 00002a05-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic handle:
> 0x0015, value handle: 0x0016, properties 0x0002 uuid:
> 00002a00-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:load_chrc() loading characteristic handle:
> 0x0017, value handle: 0x0018, properties 0x0002 uuid:
> 00002a01-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:load_gatt_db() List GATT Primaries before
> being free:
> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
> 00001801-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:print_primary() - Primary UUID:
> 00001800-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:add_primary() # add_primary
> bluetoothd[16877]: src/device.c:add_primary() # add_primary
> bluetoothd[16877]: profiles/gap/gas.c:gap_accept() GAP profile accept
> (98:D6:F7:31:7B:0D)
> bluetoothd[16877]: src/service.c:change_state() 0x98c98e0: device
> 98:D6:F7:31:7B:0D profile gap-profile state changed: disconnected ->
> connected (0)
> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_connected() Device
> connected.
> bluetoothd[16877]: src/device.c:gatt_server_init() # gatt_server_init
> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
> uuid: 00001801-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
> uuid: 00001800-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:gatt_debug() Registered handler for "Service
> Changed": 0
> bluetoothd[16877]: src/device.c:gatt_client_ready_cb() status: success,
> error: 0
> bluetoothd[16877]: src/device.c:register_gatt_services() #
> register_gatt_services
> bluetoothd[16877]: src/device.c:add_primary() # add_primary
> bluetoothd[16877]: src/device.c:add_primary() # add_primary
> bluetoothd[16877]: src/device.c:add_gatt_service() # add_gatt_service:
> UUID:00001801-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/gatt-client.c:btd_gatt_client_ready() GATT client
> ready
> bluetoothd[16877]: src/gatt-client.c:create_services() Exporting objects for
> GATT services: 98:D6:F7:31:7B:0D
> bluetoothd[16877]: src/gatt-client.c:service_create() Exported GATT service:
> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001
> bluetoothd[16877]: src/gatt-client.c:characteristic_create() Exported GATT
> characteristic: /org/bluez/hci0/dev_98_D6_F7_31_7B_0D/service0001/char0002
> bluetoothd[16877]: src/device.c:device_svc_resolved()
> /org/bluez/hci0/dev_98_D6_F7_31_7B_0D err 0
> bluetoothd[16877]: src/device.c:store_gatt_db() # store_gatt_db
> bluetoothd[16877]: src/device.c:store_service() # store_service
> bluetoothd[16877]: src/device.c:store_service() # store_service
> bluetoothd[16877]: profiles/gap/gas.c:read_device_name_cb() GAP Device Name:
> Nexus 4
> bluetoothd[16877]: profiles/gap/gas.c:read_appearance_cb() GAP Appearance:
> 0x0000
>
> I also reduced DBus 'TestAdvertisement' interface to only expose one GATT
> Service as many BLE adapter got a limitation in the size of the
> advertisement packet:
> class TestAdvertisement(Advertisement):
>
> def __init__(self, bus, index):
> Advertisement.__init__(self, bus, index, 'peripheral')
> #self.add_service_uuid('180D') # HeartRate
> self.add_service_uuid('180F') # Battery
> #self.add_manufacturer_data(0xffff, [0x00, 0x01, 0x02, 0x03, 0x04])
> #self.add_service_data('9999', [0x00, 0x01, 0x02, 0x03, 0x04])
> self.include_tx_power = True
>
> My concern is mainly these lines:
>
> bluetoothd[16877]: src/device.c:gatt_debug() Primary services found: 2
> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0001, end: 0x0005,
> uuid: 00001801-0000-1000-8000-00805f9b34fb
> bluetoothd[16877]: src/device.c:gatt_debug() start: 0x0014, end: 0xffff,
> uuid: 00001800-0000-1000-8000-00805f9b34fb
>
I've seen this kind of error message when I've had a failure of a
previous script and the Bluetooth daemon is in some unknown state. At
this point it is worth restarting the bluetooth service with:
sudo service bluetooth restart
You will see in the advertising DBus API documentation that it is
still in experimental mode in 5.44.
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt#n78
This means that you need to make sure bluetoothd is started in
experimental mode. Have you done this?
You can check with "sudo service bluetooth status"
Experimental can be switched on by default in the bluetooth.service file
Edit /lib/systemd/system/bluetooth.service file to add --experimental flag e.g:
sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/'
/lib/systemd/system/bluetooth.service
> I have not found the code that export GATT Services from GATT Database to
> the BLE central.
>
> From my search on Internet, it looks I am not the only one who is having
> this issue
> I am happy to share/test anything that could help to make some progress.
>
> Thanks,
> Olivier
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v3 0/4] TI Bluetooth serdev support
From: Marcel Holtmann @ 2017-04-13 17:24 UTC (permalink / raw)
To: Rob Herring
Cc: Linux Bluetooth, linux-arm-kernel, Gustavo F. Padovan,
Johan Hedberg, Mark Rutland, Wei Xu, Eyal Reizer, Satish Patel,
Network Development, devicetree
In-Reply-To: <20170413150353.7389-1-robh@kernel.org>
Hi Rob,
> This series adds serdev support to the HCI LL protocol used on TI BT
> modules and enables support on HiKey board with with the WL1835 module.
> With this the custom TI UIM daemon and btattach are no longer needed.
>
> The series is available on this git branch[1]. This version is rebased on
> bluetooth-next tree containing its dependencies.
>
> Rob
>
> [1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git ti-bluetooth
>
> Rob Herring (4):
> dt-bindings: net: Add TI WiLink shared transport binding
> bluetooth: hci_uart: remove unused hci_uart_init_tty
> bluetooth: hci_uart: add LL protocol serdev driver support
> arm64: dts: hikey: add WL1835 Bluetooth device node
>
> .../devicetree/bindings/net/ti,wilink-st.txt | 35 +++
> arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 5 +
> drivers/bluetooth/hci_ldisc.c | 19 --
> drivers/bluetooth/hci_ll.c | 262 ++++++++++++++++++++-
> drivers/bluetooth/hci_uart.h | 1 -
> 5 files changed, 301 insertions(+), 21 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/net/ti,wilink-st.txt
all 4 patches have been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* [PATCH v3 4/4] arm64: dts: hikey: add WL1835 Bluetooth device node
From: Rob Herring @ 2017-04-13 15:03 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
Cc: linux-arm-kernel, Gustavo Padovan, Johan Hedberg, Mark Rutland,
Wei Xu, Eyal Reizer, Satish Patel, netdev, devicetree
In-Reply-To: <20170413150353.7389-1-robh@kernel.org>
This adds the serial slave device for the WL1835 Bluetooth interface.
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Mark Rutland <mark.rutland@arm.com>
---
v3:
- rebase on bluetooth-next
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
index dba3c131c62c..9b4ba7169210 100644
--- a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
@@ -98,6 +98,11 @@
assigned-clocks = <&sys_ctrl HI6220_UART1_SRC>;
assigned-clock-rates = <150000000>;
status = "ok";
+
+ bluetooth {
+ compatible = "ti,wl1835-st";
+ enable-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+ };
};
uart2: uart@f7112000 {
--
2.11.0
^ permalink raw reply related
* [PATCH v3 3/4] bluetooth: hci_uart: add LL protocol serdev driver support
From: Rob Herring @ 2017-04-13 15:03 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
Cc: linux-arm-kernel, Gustavo Padovan, Johan Hedberg, Mark Rutland,
Wei Xu, Eyal Reizer, Satish Patel, netdev, devicetree
In-Reply-To: <20170413150353.7389-1-robh@kernel.org>
Turns out that the LL protocol and the TI-ST are the same thing AFAICT.
The TI-ST adds firmware loading, GPIO control, and shared access for
NFC, FM radio, etc. For now, we're only implementing what is needed for
BT. This mirrors other drivers like BCM and Intel, but uses the new
serdev bus.
The firmware loading is greatly simplified by using existing
infrastructure to send commands. It may be a bit slower than the
original code using synchronous functions, but the real bottleneck is
likely doing firmware load at 115.2kbps.
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
---
v3:
- rebase on bluetooth-next
- Add explicit of.h include
v2:
- Use IS_ENABLED() to fix module build
drivers/bluetooth/hci_ll.c | 262 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 261 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index 02692fe30279..485e8eb04542 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -34,20 +34,24 @@
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/fcntl.h>
+#include <linux/firmware.h>
#include <linux/interrupt.h>
#include <linux/ptrace.h>
#include <linux/poll.h>
#include <linux/slab.h>
-#include <linux/tty.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/signal.h>
#include <linux/ioctl.h>
+#include <linux/of.h>
+#include <linux/serdev.h>
#include <linux/skbuff.h>
+#include <linux/ti_wilink_st.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
+#include <linux/gpio/consumer.h>
#include "hci_uart.h"
@@ -76,6 +80,12 @@ struct hcill_cmd {
u8 cmd;
} __packed;
+struct ll_device {
+ struct hci_uart hu;
+ struct serdev_device *serdev;
+ struct gpio_desc *enable_gpio;
+};
+
struct ll_struct {
unsigned long rx_state;
unsigned long rx_count;
@@ -136,6 +146,9 @@ static int ll_open(struct hci_uart *hu)
hu->priv = ll;
+ if (hu->serdev)
+ serdev_device_open(hu->serdev);
+
return 0;
}
@@ -164,6 +177,13 @@ static int ll_close(struct hci_uart *hu)
kfree_skb(ll->rx_skb);
+ if (hu->serdev) {
+ struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev);
+ gpiod_set_value_cansleep(lldev->enable_gpio, 0);
+
+ serdev_device_close(hu->serdev);
+ }
+
hu->priv = NULL;
kfree(ll);
@@ -505,9 +525,245 @@ static struct sk_buff *ll_dequeue(struct hci_uart *hu)
return skb_dequeue(&ll->txq);
}
+#if IS_ENABLED(CONFIG_SERIAL_DEV_BUS)
+static int read_local_version(struct hci_dev *hdev)
+{
+ int err = 0;
+ unsigned short version = 0;
+ struct sk_buff *skb;
+ struct hci_rp_read_local_version *ver;
+
+ skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb)) {
+ bt_dev_err(hdev, "Reading TI version information failed (%ld)",
+ PTR_ERR(skb));
+ err = PTR_ERR(skb);
+ goto out;
+ }
+ if (skb->len != sizeof(*ver)) {
+ err = -EILSEQ;
+ goto out;
+ }
+
+ ver = (struct hci_rp_read_local_version *)skb->data;
+ if (le16_to_cpu(ver->manufacturer) != 13) {
+ err = -ENODEV;
+ goto out;
+ }
+
+ version = le16_to_cpu(ver->lmp_subver);
+
+out:
+ if (err) bt_dev_err(hdev, "Failed to read TI version info: %d", err);
+ kfree_skb(skb);
+ return err ? err : version;
+}
+
+/**
+ * download_firmware -
+ * internal function which parses through the .bts firmware
+ * script file intreprets SEND, DELAY actions only as of now
+ */
+static int download_firmware(struct ll_device *lldev)
+{
+ unsigned short chip, min_ver, maj_ver;
+ int version, err, len;
+ unsigned char *ptr, *action_ptr;
+ unsigned char bts_scr_name[40]; /* 40 char long bts scr name? */
+ const struct firmware *fw;
+ struct sk_buff *skb;
+ struct hci_command *cmd;
+
+ version = read_local_version(lldev->hu.hdev);
+ if (version < 0)
+ return version;
+
+ chip = (version & 0x7C00) >> 10;
+ min_ver = (version & 0x007F);
+ maj_ver = (version & 0x0380) >> 7;
+ if (version & 0x8000)
+ maj_ver |= 0x0008;
+
+ snprintf(bts_scr_name, sizeof(bts_scr_name),
+ "ti-connectivity/TIInit_%d.%d.%d.bts",
+ chip, maj_ver, min_ver);
+
+ err = request_firmware(&fw, bts_scr_name, &lldev->serdev->dev);
+ if (err || !fw->data || !fw->size) {
+ bt_dev_err(lldev->hu.hdev, "request_firmware failed(errno %d) for %s",
+ err, bts_scr_name);
+ return -EINVAL;
+ }
+ ptr = (void *)fw->data;
+ len = fw->size;
+ /* bts_header to remove out magic number and
+ * version
+ */
+ ptr += sizeof(struct bts_header);
+ len -= sizeof(struct bts_header);
+
+ while (len > 0 && ptr) {
+ bt_dev_dbg(lldev->hu.hdev, " action size %d, type %d ",
+ ((struct bts_action *)ptr)->size,
+ ((struct bts_action *)ptr)->type);
+
+ action_ptr = &(((struct bts_action *)ptr)->data[0]);
+
+ switch (((struct bts_action *)ptr)->type) {
+ case ACTION_SEND_COMMAND: /* action send */
+ bt_dev_dbg(lldev->hu.hdev, "S");
+ cmd = (struct hci_command *)action_ptr;
+ if (cmd->opcode == 0xff36) {
+ /* ignore remote change
+ * baud rate HCI VS command */
+ bt_dev_warn(lldev->hu.hdev, "change remote baud rate command in firmware");
+ break;
+ }
+ if (cmd->prefix != 1)
+ bt_dev_dbg(lldev->hu.hdev, "command type %d\n", cmd->prefix);
+
+ skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen, &cmd->speed, HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb)) {
+ bt_dev_err(lldev->hu.hdev, "send command failed\n");
+ goto out_rel_fw;
+ }
+ kfree_skb(skb);
+ break;
+ case ACTION_WAIT_EVENT: /* wait */
+ /* no need to wait as command was synchronous */
+ bt_dev_dbg(lldev->hu.hdev, "W");
+ break;
+ case ACTION_DELAY: /* sleep */
+ bt_dev_info(lldev->hu.hdev, "sleep command in scr");
+ mdelay(((struct bts_action_delay *)action_ptr)->msec);
+ break;
+ }
+ len -= (sizeof(struct bts_action) +
+ ((struct bts_action *)ptr)->size);
+ ptr += sizeof(struct bts_action) +
+ ((struct bts_action *)ptr)->size;
+ }
+
+out_rel_fw:
+ /* fw download complete */
+ release_firmware(fw);
+ return err;
+}
+
+static int ll_setup(struct hci_uart *hu)
+{
+ int err, retry = 3;
+ struct ll_device *lldev;
+ struct serdev_device *serdev = hu->serdev;
+ u32 speed;
+
+ if (!serdev)
+ return 0;
+
+ lldev = serdev_device_get_drvdata(serdev);
+
+ serdev_device_set_flow_control(serdev, true);
+
+ do {
+ /* Configure BT_EN to HIGH state */
+ gpiod_set_value_cansleep(lldev->enable_gpio, 0);
+ msleep(5);
+ gpiod_set_value_cansleep(lldev->enable_gpio, 1);
+ msleep(100);
+
+ err = download_firmware(lldev);
+ if (!err)
+ break;
+
+ /* Toggle BT_EN and retry */
+ bt_dev_err(hu->hdev, "download firmware failed, retrying...");
+ } while (retry--);
+
+ if (err)
+ return err;
+
+ /* Operational speed if any */
+ if (hu->oper_speed)
+ speed = hu->oper_speed;
+ else if (hu->proto->oper_speed)
+ speed = hu->proto->oper_speed;
+ else
+ speed = 0;
+
+ if (speed) {
+ struct sk_buff *skb = __hci_cmd_sync(hu->hdev, 0xff36, sizeof(speed), &speed, HCI_INIT_TIMEOUT);
+ if (!IS_ERR(skb)) {
+ kfree_skb(skb);
+ serdev_device_set_baudrate(serdev, speed);
+ }
+ }
+
+ return 0;
+}
+
+static const struct hci_uart_proto llp;
+
+static int hci_ti_probe(struct serdev_device *serdev)
+{
+ struct hci_uart *hu;
+ struct ll_device *lldev;
+ u32 max_speed = 3000000;
+
+ lldev = devm_kzalloc(&serdev->dev, sizeof(struct ll_device), GFP_KERNEL);
+ if (!lldev)
+ return -ENOMEM;
+ hu = &lldev->hu;
+
+ serdev_device_set_drvdata(serdev, lldev);
+ lldev->serdev = hu->serdev = serdev;
+
+ lldev->enable_gpio = devm_gpiod_get_optional(&serdev->dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(lldev->enable_gpio))
+ return PTR_ERR(lldev->enable_gpio);
+
+ of_property_read_u32(serdev->dev.of_node, "max-speed", &max_speed);
+ hci_uart_set_speeds(hu, 115200, max_speed);
+
+ return hci_uart_register_device(hu, &llp);
+}
+
+static void hci_ti_remove(struct serdev_device *serdev)
+{
+ struct ll_device *lldev = serdev_device_get_drvdata(serdev);
+ struct hci_uart *hu = &lldev->hu;
+ struct hci_dev *hdev = hu->hdev;
+
+ cancel_work_sync(&hu->write_work);
+
+ hci_unregister_dev(hdev);
+ hci_free_dev(hdev);
+ hu->proto->close(hu);
+}
+
+static const struct of_device_id hci_ti_of_match[] = {
+ { .compatible = "ti,wl1831-st" },
+ { .compatible = "ti,wl1835-st" },
+ { .compatible = "ti,wl1837-st" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, hci_ti_of_match);
+
+static struct serdev_device_driver hci_ti_drv = {
+ .driver = {
+ .name = "hci-ti",
+ .of_match_table = of_match_ptr(hci_ti_of_match),
+ },
+ .probe = hci_ti_probe,
+ .remove = hci_ti_remove,
+};
+#else
+#define ll_setup NULL
+#endif
+
static const struct hci_uart_proto llp = {
.id = HCI_UART_LL,
.name = "LL",
+ .setup = ll_setup,
.open = ll_open,
.close = ll_close,
.recv = ll_recv,
@@ -518,10 +774,14 @@ static const struct hci_uart_proto llp = {
int __init ll_init(void)
{
+ serdev_device_driver_register(&hci_ti_drv);
+
return hci_uart_register_proto(&llp);
}
int __exit ll_deinit(void)
{
+ serdev_device_driver_unregister(&hci_ti_drv);
+
return hci_uart_unregister_proto(&llp);
}
--
2.11.0
^ permalink raw reply related
* [PATCH v3 2/4] bluetooth: hci_uart: remove unused hci_uart_init_tty
From: Rob Herring @ 2017-04-13 15:03 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
Cc: linux-arm-kernel, Gustavo Padovan, Johan Hedberg, Mark Rutland,
Wei Xu, Eyal Reizer, Satish Patel, netdev, devicetree
In-Reply-To: <20170413150353.7389-1-robh@kernel.org>
There are no users of hci_uart_init_tty, so remove it.
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
---
v3:
- rebase on bluetooth-next
drivers/bluetooth/hci_ldisc.c | 19 -------------------
drivers/bluetooth/hci_uart.h | 1 -
2 files changed, 20 deletions(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 17bcbc13623f..cec4438ede01 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -319,25 +319,6 @@ void hci_uart_set_speeds(struct hci_uart *hu, unsigned int init_speed,
hu->oper_speed = oper_speed;
}
-void hci_uart_init_tty(struct hci_uart *hu)
-{
- struct tty_struct *tty = hu->tty;
- struct ktermios ktermios;
-
- /* Bring the UART into a known 8 bits no parity hw fc state */
- ktermios = tty->termios;
- ktermios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
- INLCR | IGNCR | ICRNL | IXON);
- ktermios.c_oflag &= ~OPOST;
- ktermios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
- ktermios.c_cflag &= ~(CSIZE | PARENB);
- ktermios.c_cflag |= CS8;
- ktermios.c_cflag |= CRTSCTS;
-
- /* tty_set_termios() return not checked as it is always 0 */
- tty_set_termios(tty, &ktermios);
-}
-
void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed)
{
struct tty_struct *tty = hu->tty;
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 1b41c661bbb8..2b05e557fad0 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -114,7 +114,6 @@ int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p
int hci_uart_tx_wakeup(struct hci_uart *hu);
int hci_uart_init_ready(struct hci_uart *hu);
-void hci_uart_init_tty(struct hci_uart *hu);
void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed);
void hci_uart_set_flow_control(struct hci_uart *hu, bool enable);
void hci_uart_set_speeds(struct hci_uart *hu, unsigned int init_speed,
--
2.11.0
^ permalink raw reply related
* [PATCH v3 1/4] dt-bindings: net: Add TI WiLink shared transport binding
From: Rob Herring @ 2017-04-13 15:03 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
Cc: linux-arm-kernel, Gustavo Padovan, Johan Hedberg, Mark Rutland,
Wei Xu, Eyal Reizer, Satish Patel, netdev, devicetree
In-Reply-To: <20170413150353.7389-1-robh@kernel.org>
Add serial slave device binding for the TI WiLink series of Bluetooth/FM/GPS
devices.
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: netdev@vger.kernel.org
Cc: devicetree@vger.kernel.org
---
v3:
- rebase on bluetooth-next
.../devicetree/bindings/net/ti,wilink-st.txt | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/ti,wilink-st.txt
diff --git a/Documentation/devicetree/bindings/net/ti,wilink-st.txt b/Documentation/devicetree/bindings/net/ti,wilink-st.txt
new file mode 100644
index 000000000000..cbad73a84ac4
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/ti,wilink-st.txt
@@ -0,0 +1,35 @@
+TI WiLink 7/8 (wl12xx/wl18xx) Shared Transport BT/FM/GPS devices
+
+TI WiLink devices have a UART interface for providing Bluetooth, FM radio,
+and GPS over what's called "shared transport". The shared transport is
+standard BT HCI protocol with additional channels for the other functions.
+
+These devices also have a separate WiFi interface as described in
+wireless/ti,wlcore.txt.
+
+This bindings follows the UART slave device binding in
+../serial/slave-device.txt.
+
+Required properties:
+ - compatible: should be one of the following:
+ "ti,wl1271-st"
+ "ti,wl1273-st"
+ "ti,wl1831-st"
+ "ti,wl1835-st"
+ "ti,wl1837-st"
+
+Optional properties:
+ - enable-gpios : GPIO signal controlling enabling of BT. Active high.
+ - vio-supply : Vio input supply (1.8V)
+ - vbat-supply : Vbat input supply (2.9-4.8V)
+
+Example:
+
+&serial0 {
+ compatible = "ns16550a";
+ ...
+ bluetooth {
+ compatible = "ti,wl1835-st";
+ enable-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+ };
+};
--
2.11.0
^ permalink raw reply related
* [PATCH v3 0/4] TI Bluetooth serdev support
From: Rob Herring @ 2017-04-13 15:03 UTC (permalink / raw)
To: Marcel Holtmann, linux-bluetooth
Cc: linux-arm-kernel, Gustavo Padovan, Johan Hedberg, Mark Rutland,
Wei Xu, Eyal Reizer, Satish Patel, netdev, devicetree
This series adds serdev support to the HCI LL protocol used on TI BT
modules and enables support on HiKey board with with the WL1835 module.
With this the custom TI UIM daemon and btattach are no longer needed.
The series is available on this git branch[1]. This version is rebased on
bluetooth-next tree containing its dependencies.
Rob
[1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git ti-bluetooth
Rob Herring (4):
dt-bindings: net: Add TI WiLink shared transport binding
bluetooth: hci_uart: remove unused hci_uart_init_tty
bluetooth: hci_uart: add LL protocol serdev driver support
arm64: dts: hikey: add WL1835 Bluetooth device node
.../devicetree/bindings/net/ti,wilink-st.txt | 35 +++
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 5 +
drivers/bluetooth/hci_ldisc.c | 19 --
drivers/bluetooth/hci_ll.c | 262 ++++++++++++++++++++-
drivers/bluetooth/hci_uart.h | 1 -
5 files changed, 301 insertions(+), 21 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/ti,wilink-st.txt
--
2.11.0
^ permalink raw reply
* [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD
From: Felipe F. Tonello @ 2017-04-13 12:22 UTC (permalink / raw)
To: linux-bluetooth
Cc: linux-kernel, Marcel Holtmann, Johan Hedberg,
Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-1-eu@felipetonello.com>
The Slave Connection Interval Range data type contains the Peripheral's
preferred connection interval range, for all logical connections.
It is useful to parse it in the Kernel so there is no multiple calls to
MGMT interface to update the device connection parameters and subsequent
connection command call to this device will use proper connection
parameters. This saves context-switches and eliminates user-space to
update the connection parameters each time a device is found or
bluetoothd is restarted and so on. Also, there is no need for the
user-space to know care about it because if the slave device wishes to
persist with these parameters, it should use the L2CAP connection
parameters upade request upon a completed connection.
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 1fba2a03f8ae..ea5d6c85f173 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7442,6 +7442,46 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir,
return true;
}
+static bool has_eir_slave_conn_int(const u8 *eir_data, u8 eir_len,
+ u16 *min_conn, u16 *max_conn)
+{
+ u16 len = 0;
+ const u8 EIR_SLAVE_CONN_INT = 0x12; /* Slave Connection Interval Range */
+
+ while (len < eir_len - 1) {
+ u8 field_len = eir_data[0];
+ const u8 *data;
+ u8 data_len;
+
+ /* Check for the end of EIR */
+ if (field_len == 0)
+ break;
+
+ len += field_len + 1;
+
+ /* Do not continue EIR Data parsing if got
+ * incorrect length
+ */
+ if (len > eir_len)
+ break;
+
+ data = &eir_data[2];
+ data_len = field_len - 1;
+
+ if (eir_data[1] == EIR_SLAVE_CONN_INT) {
+ if (data_len < 4)
+ break;
+ *min_conn = le16_to_cpu(&data[0]);
+ *max_conn = le16_to_cpu(&data[2]);
+ return true;
+ }
+
+ eir_data += field_len + 1;
+ }
+
+ return false;
+}
+
void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
@@ -7449,6 +7489,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
char buf[512];
struct mgmt_ev_device_found *ev = (void *)buf;
size_t ev_size;
+ struct hci_conn *hcon;
/* Don't send events for a non-kernel initiated discovery. With
* LE one exception is if we have pend_le_reports > 0 in which
@@ -7521,6 +7562,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
+ /* Search for Slave Connection Interval AD */
+ hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
+ if (hcon) {
+ u16 min_conn_int, max_conn_int;
+
+ if (has_eir_slave_conn_int(ev->eir, ev->eir_len,
+ &min_conn_int, &max_conn_int)) {
+ hcon->le_conn_min_interval = min_conn_int;
+ hcon->le_conn_max_interval = max_conn_int;
+ }
+ }
+
mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
}
--
2.12.2
^ permalink raw reply related
* [PATCH v5 BlueZ 3/4] Bluetooth: L2CAP: Add BT_LE_CONN_PARAM socket option
From: Felipe F. Tonello @ 2017-04-13 12:22 UTC (permalink / raw)
To: linux-bluetooth
Cc: linux-kernel, Marcel Holtmann, Johan Hedberg,
Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-1-eu@felipetonello.com>
There is a need for certain LE profiles (MIDI for example) to change the
current connection's parameters. In order to do that, this patch
introduces a new BT_LE_CONN_PARAM socket option for SOL_BLUETOOTH
protocol which allow user-space l2cap sockets to update the current
connection.
It necessary to expose all the connection parameters to user-space
because user-space are exposed to those values anyway, via PPCP
characteristic or particular profile specification.
If ROLE is SLAVE, then it will send a L2CAP_CONN_PARAM_UPDATE_REQ
signaling command to the MASTER, triggering proper LE parameter update
procedure. The connection parameters update will only occur upon a
successful L2CAP_CONN_PARAM_UPDATE_RSP sent by the MASTER.
If ROLE is MASTER, then immediately update the connection parameters.
Once the connection parameters are effective, a MGMT_EV_NEW_CONN_PARAM
event with the store_hint set is sent to user-space so an application
can store the connection parameters for persistence reasons.
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
include/net/bluetooth/bluetooth.h | 8 +++
net/bluetooth/l2cap_sock.c | 110 ++++++++++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 01487192f628..ce5b3abd3b27 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -122,6 +122,14 @@ struct bt_voice {
#define BT_SNDMTU 12
#define BT_RCVMTU 13
+#define BT_LE_CONN_PARAM 14
+struct bt_le_conn_param {
+ __u16 min_interval;
+ __u16 max_interval;
+ __u16 latency;
+ __u16 supervision_timeout;
+};
+
__printf(1, 2)
void bt_info(const char *fmt, ...);
__printf(1, 2)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 507b80d59dec..1e096bd9ddde 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -515,6 +515,47 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
lock_sock(sk);
switch (optname) {
+ case BT_LE_CONN_PARAM: {
+ struct bt_le_conn_param conn_param;
+ struct hci_conn_params *params;
+ struct hci_conn *hcon;
+ struct hci_dev *hdev;
+
+ if (!chan->conn) {
+ err = -ENOTCONN;
+ break;
+ }
+
+ hcon = chan->conn->hcon;
+ hdev = hcon->hdev;
+ hci_dev_lock(hdev);
+
+ params = hci_conn_params_lookup(hdev, &hcon->dst,
+ hcon->dst_type);
+
+ memset(&conn_param, 0, sizeof(conn_param));
+
+ if (params) {
+ conn_param.min_interval = params->conn_min_interval;
+ conn_param.max_interval = params->conn_max_interval;
+ conn_param.latency = params->conn_latency;
+ conn_param.supervision_timeout =
+ params->supervision_timeout;
+ } else {
+ conn_param.min_interval = hdev->le_conn_min_interval;
+ conn_param.max_interval = hdev->le_conn_max_interval;
+ conn_param.latency = hdev->le_conn_latency;
+ conn_param.supervision_timeout = hdev->le_supv_timeout;
+ }
+
+ hci_dev_unlock(hdev);
+
+ len = min_t(unsigned int, len, sizeof(conn_param));
+ if (copy_to_user(optval, (char *)&conn_param, len))
+ err = -EFAULT;
+
+ break;
+ }
case BT_SECURITY:
if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED &&
chan->chan_type != L2CAP_CHAN_FIXED &&
@@ -762,6 +803,75 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
lock_sock(sk);
switch (optname) {
+ case BT_LE_CONN_PARAM: {
+ struct bt_le_conn_param conn_param;
+ struct hci_conn_params *hci_param;
+ struct hci_conn *hcon;
+ struct hci_dev *hdev;
+
+ len = min_t(unsigned int, sizeof(conn_param), optlen);
+ if (copy_from_user((char *)&conn_param, optval, len)) {
+ err = -EFAULT;
+ break;
+ }
+
+ if (!chan->conn) {
+ err = -ENOTCONN;
+ break;
+ }
+
+ err = hci_check_conn_params(conn_param.min_interval,
+ conn_param.max_interval,
+ conn_param.latency,
+ conn_param.supervision_timeout);
+ if (err < 0) {
+ BT_ERR("Ignoring invalid connection parameters");
+ break;
+ }
+
+ hcon = chan->conn->hcon;
+ hdev = hcon->hdev;
+
+ hci_dev_lock(hdev);
+
+ /* we add new param in case it doesn't exist */
+ hci_param = hci_conn_params_add(hdev, &hcon->dst,
+ hcon->dst_type);
+ if (!hci_param) {
+ err = -ENOMEM;
+ BT_ERR("Failed to add connection parameters");
+ hci_dev_unlock(hcon->hdev);
+ break;
+ }
+
+ hci_dev_unlock(hdev);
+
+ /* Send a L2CAP connection parameters update request, if
+ * the host role is slave.
+ */
+ if (hcon->role == HCI_ROLE_SLAVE) {
+ l2cap_le_conn_update_req(chan->conn,
+ conn_param.min_interval,
+ conn_param.max_interval,
+ conn_param.latency,
+ conn_param.supervision_timeout);
+ } else {
+ /* this function also updates the hci_param value */
+ hci_le_conn_update(hcon, conn_param.min_interval,
+ conn_param.max_interval,
+ conn_param.latency,
+ conn_param.supervision_timeout);
+
+ /* don't set the `store' hint */
+ mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type,
+ false, conn_param.min_interval,
+ conn_param.max_interval,
+ conn_param.latency,
+ conn_param.supervision_timeout);
+ }
+ break;
+ }
+
case BT_SECURITY:
if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED &&
chan->chan_type != L2CAP_CHAN_FIXED &&
--
2.12.2
^ permalink raw reply related
* [PATCH v5 BlueZ 2/4] Bluetooth: L2CAP: Add handler for Connection Parameter Update Response
From: Felipe F. Tonello @ 2017-04-13 12:22 UTC (permalink / raw)
To: linux-bluetooth
Cc: linux-kernel, Marcel Holtmann, Johan Hedberg,
Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-1-eu@felipetonello.com>
In case of connected hosts that doesn't support the Connection
Parameters Request Link Layer Control Procedure, we should support this
event response from a slave device.
The slave device will answer based on a previous request done by the
master (BlueZ in this case) and update current connection parameters
accordingly. If the request was rejected, we don't do anything.
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
include/net/bluetooth/l2cap.h | 2 ++
net/bluetooth/l2cap_core.c | 47 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 803a7f4d93a7..eb7ecd5df9a3 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -654,6 +654,8 @@ struct l2cap_conn {
struct mutex chan_lock;
struct kref ref;
struct list_head users;
+
+ struct l2cap_conn_param_update_req conn_param_req;
};
struct l2cap_user {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 585d15ce0a33..1e8539c59cfd 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1489,6 +1489,14 @@ void l2cap_le_conn_update_req(struct l2cap_conn *conn, u8 min_interval,
{
struct l2cap_conn_param_update_req req;
+ /* set temporary parameters in case of a successful
+ * response from the peer device
+ */
+ conn->conn_param_req.min = min_interval;
+ conn->conn_param_req.max = max_interval;
+ conn->conn_param_req.latency = latency;
+ conn->conn_param_req.to_multiplier = supv_timeout;
+
req.min = cpu_to_le16(min_interval);
req.max = cpu_to_le16(max_interval);
req.latency = cpu_to_le16(latency);
@@ -5261,6 +5269,44 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
return 0;
}
+static inline int l2cap_conn_param_update_rsp(struct l2cap_conn *conn,
+ struct l2cap_cmd_hdr *cmd,
+ u16 cmd_len, u8 *data)
+{
+ struct hci_conn *hcon = conn->hcon;
+ struct l2cap_conn_param_update_rsp *rsp;
+ u8 result;
+
+ if (hcon->role != HCI_ROLE_SLAVE)
+ return -EINVAL;
+
+ if (cmd_len != sizeof(struct l2cap_conn_param_update_rsp))
+ return -EPROTO;
+
+ rsp = (struct l2cap_conn_param_update_rsp *)data;
+ result = le16_to_cpu(rsp->result);
+
+ BT_DBG("result 0x%4.4x", result);
+
+ if (result == 0) {
+ u8 store_hint;
+
+ store_hint =
+ hci_le_conn_update(hcon,
+ conn->conn_param_req.min,
+ conn->conn_param_req.max,
+ conn->conn_param_req.latency,
+ conn->conn_param_req.to_multiplier);
+ mgmt_new_conn_param(hcon->hdev, &hcon->dst, hcon->dst_type,
+ store_hint, conn->conn_param_req.min,
+ conn->conn_param_req.max,
+ conn->conn_param_req.latency,
+ conn->conn_param_req.to_multiplier);
+ }
+
+ return 0;
+}
+
static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
struct l2cap_cmd_hdr *cmd, u16 cmd_len,
u8 *data)
@@ -5641,6 +5687,7 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
break;
case L2CAP_CONN_PARAM_UPDATE_RSP:
+ err = l2cap_conn_param_update_rsp(conn, cmd, cmd_len, data);
break;
case L2CAP_LE_CONN_RSP:
--
2.12.2
^ permalink raw reply related
* [PATCH v5 BlueZ 1/4] Bluetooth: L2CAP: Refactor L2CAP_CONN_PARAM_UPDATE_REQ into a function
From: Felipe F. Tonello @ 2017-04-13 12:22 UTC (permalink / raw)
To: linux-bluetooth
Cc: linux-kernel, Marcel Holtmann, Johan Hedberg,
Luiz Augusto von Dentz
In-Reply-To: <20170413122203.4247-1-eu@felipetonello.com>
This signaling command is useful for any connection parameter change
procedure, thus it is important to allow access to it from outside this
translation unit.
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
include/net/bluetooth/l2cap.h | 3 +++
net/bluetooth/l2cap_core.c | 31 ++++++++++++++++++++-----------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 0697fd413087..803a7f4d93a7 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -948,4 +948,7 @@ void l2cap_conn_put(struct l2cap_conn *conn);
int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user);
+void l2cap_le_conn_update_req(struct l2cap_conn *conn, u8 min_interval,
+ u8 max_interval, u8 latency, u8 supv_timeout);
+
#endif /* __L2CAP_H */
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index f88ac99528ce..585d15ce0a33 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1483,6 +1483,21 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
mutex_unlock(&conn->chan_lock);
}
+/* This command shall only be send if the connection role is SLAVE */
+void l2cap_le_conn_update_req(struct l2cap_conn *conn, u8 min_interval,
+ u8 max_interval, u8 latency, u8 supv_timeout)
+{
+ struct l2cap_conn_param_update_req req;
+
+ req.min = cpu_to_le16(min_interval);
+ req.max = cpu_to_le16(max_interval);
+ req.latency = cpu_to_le16(latency);
+ req.to_multiplier = cpu_to_le16(supv_timeout);
+
+ l2cap_send_cmd(conn, l2cap_get_ident(conn),
+ L2CAP_CONN_PARAM_UPDATE_REQ, sizeof(req), &req);
+}
+
static void l2cap_le_conn_ready(struct l2cap_conn *conn)
{
struct hci_conn *hcon = conn->hcon;
@@ -1503,17 +1518,11 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
*/
if (hcon->role == HCI_ROLE_SLAVE &&
(hcon->le_conn_interval < hcon->le_conn_min_interval ||
- hcon->le_conn_interval > hcon->le_conn_max_interval)) {
- struct l2cap_conn_param_update_req req;
-
- req.min = cpu_to_le16(hcon->le_conn_min_interval);
- req.max = cpu_to_le16(hcon->le_conn_max_interval);
- req.latency = cpu_to_le16(hcon->le_conn_latency);
- req.to_multiplier = cpu_to_le16(hcon->le_supv_timeout);
-
- l2cap_send_cmd(conn, l2cap_get_ident(conn),
- L2CAP_CONN_PARAM_UPDATE_REQ, sizeof(req), &req);
- }
+ hcon->le_conn_interval > hcon->le_conn_max_interval))
+ l2cap_le_conn_update_req(conn, hcon->le_conn_min_interval,
+ hcon->le_conn_max_interval,
+ hcon->le_conn_latency,
+ hcon->le_supv_timeout);
}
static void l2cap_conn_ready(struct l2cap_conn *conn)
--
2.12.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox