* How BLE services could be remembered? @ 2016-12-08 14:40 José Bollo 2016-12-09 9:43 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 7+ messages in thread From: José Bollo @ 2016-12-08 14:40 UTC (permalink / raw) To: linux-bluetooth Hello, I observe a strange behaviour of bluez dbus interface. I'm using Cinolink BT 4.0 USB Adapter (CSR BC8510 chipset), Bluez 5.43 on debian and/or on fedora. When I first pair a BLE device, the services are correctly discovered and the GATT endpoints are created (a lot). Then I can use it as expected and it is nice. But when I turn off the computer and restart it, things become different. Because the devices are paired with LT key, they are still paired but the GATT services are not availables. I can connect to the device but it doesn't declares the GATT properties/attributes that I need. Also, the service advertises itself without effect. To be able to restore the attributes, I need to first remove the device using bluetoothctl (CancelPair doesn't seems to work) and to pair a new time. Can you reproduce it? Is it the intended behaviour? How can I setup the system to have GATT properties+attributes present after an advertising? What dbus method should I call (ConnectService doesn't works)? Best regards Jos=C3=A9 Bollo - Senior Software Engineer www.iot.bzh ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How BLE services could be remembered? 2016-12-08 14:40 How BLE services could be remembered? José Bollo @ 2016-12-09 9:43 ` Luiz Augusto von Dentz 2016-12-09 11:14 ` José Bollo 0 siblings, 1 reply; 7+ messages in thread From: Luiz Augusto von Dentz @ 2016-12-09 9:43 UTC (permalink / raw) To: jose.bollo; +Cc: linux-bluetooth@vger.kernel.org Hi Jose, On Thu, Dec 8, 2016 at 4:40 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wrote: > Hello, > > I observe a strange behaviour of bluez dbus interface. > > I'm using Cinolink BT 4.0 USB Adapter (CSR BC8510 chipset), Bluez 5.43 > on debian and/or on fedora. > > When I first pair a BLE device, the services are correctly discovered > and the GATT endpoints are created (a lot). > > Then I can use it as expected and it is nice. But when I turn off the > computer and restart it, things become different. > > Because the devices are paired with LT key, they are still paired but > the GATT services are not availables. I can connect to the device but > it doesn't declares the GATT properties/attributes that I need. Also, > the service advertises itself without effect. The attributes should be saved in cache but they are only reloaded on demand once a connection happens. Also if the database changes the cache can be invalidated removing its attributes, this has been changed so premature disconnections don't cause that anymore but in case the database do actually change their attributes will be invalidated. So if your device is known to cause premature disconnects please try with upstream version. > To be able to restore the attributes, I need to first remove the > device using bluetoothctl (CancelPair doesn't seems to work) and to > pair a new time. CancelPair is for an ongoing pair not to actually remove an existing one, perhaps the device is not reconnecting for some reason. Btw if you are using privacy and the device uses directed advertising using the identity/public address that could cause problems with reconnections. > Can you reproduce it? Is it the intended behaviour? How can I setup > the system to have GATT properties+attributes present after an > advertising? What dbus method should I call (ConnectService doesn't > works)? ConnectService? You mean Connect/ConnectProfile, those can be used in case you want to force an active scanning + connect procedure, otherwise the device shall be reconnected using passive scanning. --=20 Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How BLE services could be remembered? 2016-12-09 9:43 ` Luiz Augusto von Dentz @ 2016-12-09 11:14 ` José Bollo 2016-12-09 13:15 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 7+ messages in thread From: José Bollo @ 2016-12-09 11:14 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: josé bollo, linux-bluetooth@vger.kernel.org Hi Luiz, 2016-12-09 10:43 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>: > Hi Jose, > > On Thu, Dec 8, 2016 at 4:40 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wrot= e: >> Hello, >> >> I observe a strange behaviour of bluez dbus interface. >> >> I'm using Cinolink BT 4.0 USB Adapter (CSR BC8510 chipset), Bluez 5.43 >> on debian and/or on fedora. >> >> When I first pair a BLE device, the services are correctly discovered >> and the GATT endpoints are created (a lot). >> >> Then I can use it as expected and it is nice. But when I turn off the >> computer and restart it, things become different. >> >> Because the devices are paired with LT key, they are still paired but >> the GATT services are not availables. I can connect to the device but >> it doesn't declares the GATT properties/attributes that I need. Also, >> the service advertises itself without effect. > > The attributes should be saved in cache but they are only reloaded on > demand once a connection happens. Also if the database changes the > cache can be invalidated removing its attributes, this has been > changed so premature disconnections don't cause that anymore but in > case the database do actually change their attributes will be > invalidated. So if your device is known to cause premature disconnects > please try with upstream version. That is probably the case, the device disconnects itself after a transaction. Its designer made it to improve battery life. The attribute stay available by DBUS until next restart. I'll try the upstream version and check whether attribute are available after a restart. (snip) > ConnectService? You mean Connect/ConnectProfile, those can be used in > case you want to force an active scanning + connect procedure, > otherwise the device shall be reconnected using passive scanning. Yes I meant ConnectProfile. Is it preferable to use ConnectProfile instead of Connect when only one profile is expected? The device is always advertising. I think that I have to connect explicitly because the connection is not automatic. > Luiz Augusto von Dentz Best regards Jos=C3=A9 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How BLE services could be remembered? 2016-12-09 11:14 ` José Bollo @ 2016-12-09 13:15 ` Luiz Augusto von Dentz 2016-12-12 13:35 ` José Bollo 0 siblings, 1 reply; 7+ messages in thread From: Luiz Augusto von Dentz @ 2016-12-09 13:15 UTC (permalink / raw) To: josé bollo; +Cc: linux-bluetooth@vger.kernel.org Hi Jose, On Fri, Dec 9, 2016 at 1:14 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wrote: > Hi Luiz, > > 2016-12-09 10:43 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>: >> Hi Jose, >> >> On Thu, Dec 8, 2016 at 4:40 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wro= te: >>> Hello, >>> >>> I observe a strange behaviour of bluez dbus interface. >>> >>> I'm using Cinolink BT 4.0 USB Adapter (CSR BC8510 chipset), Bluez 5.43 >>> on debian and/or on fedora. >>> >>> When I first pair a BLE device, the services are correctly discovered >>> and the GATT endpoints are created (a lot). >>> >>> Then I can use it as expected and it is nice. But when I turn off the >>> computer and restart it, things become different. >>> >>> Because the devices are paired with LT key, they are still paired but >>> the GATT services are not availables. I can connect to the device but >>> it doesn't declares the GATT properties/attributes that I need. Also, >>> the service advertises itself without effect. >> >> The attributes should be saved in cache but they are only reloaded on >> demand once a connection happens. Also if the database changes the >> cache can be invalidated removing its attributes, this has been >> changed so premature disconnections don't cause that anymore but in >> case the database do actually change their attributes will be >> invalidated. So if your device is known to cause premature disconnects >> please try with upstream version. > > That is probably the case, the device disconnects itself after a > transaction. Its designer made it to improve battery life. > > The attribute stay available by DBUS until next restart. > > I'll try the upstream version and check whether attribute are > available after a restart. > > (snip) > >> ConnectService? You mean Connect/ConnectProfile, those can be used in >> case you want to force an active scanning + connect procedure, >> otherwise the device shall be reconnected using passive scanning. > > Yes I meant ConnectProfile. > > Is it preferable to use ConnectProfile instead of Connect when only > one profile is expected? > The device is always advertising. I think that I have to connect > explicitly because the connection is not automatic. Actually in this case it should just reconnect if the device is advertising, so you should need to use either ConnectProfile or Connect, actually ConnectProfile doesn't work for LE since the profiles need GATT to be connected first and anyway the way the LE works is that the peripheral would advertise so perhaps what is missing is that you register an application implementing GattProfile1 interface that way bluetoothd can tell there is an application trying to use the profile see: https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt --=20 Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How BLE services could be remembered? 2016-12-09 13:15 ` Luiz Augusto von Dentz @ 2016-12-12 13:35 ` José Bollo 2016-12-12 14:20 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 7+ messages in thread From: José Bollo @ 2016-12-12 13:35 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: josé bollo, linux-bluetooth@vger.kernel.org Hi all, Using the commit c64b4d9e8dc3e36672061f39a9dba19ad0fb1ef1, the issue is sloved. Great! Thank you. But my issue was also related to the fact that 'connected' was received before availability of the attributes/services. The code was disconnecting with the effect that not attributes/services coulded be discovered. Should I that the variable "ServicesResolved" is intended to reflect the service resolution state? How long should I wait after being connected for the ServiceResolved Status? Is there a way to know that service resolution is in progress? Best regards Jos=C3=A9 Bollo Jos=C3=A9 Bollo - Senior Software Engineer www.iot.bzh 2016-12-09 14:15 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>: > Hi Jose, > > On Fri, Dec 9, 2016 at 1:14 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wrot= e: >> Hi Luiz, >> >> 2016-12-09 10:43 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>= : >>> Hi Jose, >>> >>> On Thu, Dec 8, 2016 at 4:40 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wr= ote: >>>> Hello, >>>> >>>> I observe a strange behaviour of bluez dbus interface. >>>> >>>> I'm using Cinolink BT 4.0 USB Adapter (CSR BC8510 chipset), Bluez 5.43 >>>> on debian and/or on fedora. >>>> >>>> When I first pair a BLE device, the services are correctly discovered >>>> and the GATT endpoints are created (a lot). >>>> >>>> Then I can use it as expected and it is nice. But when I turn off the >>>> computer and restart it, things become different. >>>> >>>> Because the devices are paired with LT key, they are still paired but >>>> the GATT services are not availables. I can connect to the device but >>>> it doesn't declares the GATT properties/attributes that I need. Also, >>>> the service advertises itself without effect. >>> >>> The attributes should be saved in cache but they are only reloaded on >>> demand once a connection happens. Also if the database changes the >>> cache can be invalidated removing its attributes, this has been >>> changed so premature disconnections don't cause that anymore but in >>> case the database do actually change their attributes will be >>> invalidated. So if your device is known to cause premature disconnects >>> please try with upstream version. >> >> That is probably the case, the device disconnects itself after a >> transaction. Its designer made it to improve battery life. >> >> The attribute stay available by DBUS until next restart. >> >> I'll try the upstream version and check whether attribute are >> available after a restart. >> >> (snip) >> >>> ConnectService? You mean Connect/ConnectProfile, those can be used in >>> case you want to force an active scanning + connect procedure, >>> otherwise the device shall be reconnected using passive scanning. >> >> Yes I meant ConnectProfile. >> >> Is it preferable to use ConnectProfile instead of Connect when only >> one profile is expected? >> The device is always advertising. I think that I have to connect >> explicitly because the connection is not automatic. > > Actually in this case it should just reconnect if the device is > advertising, so you should need to use either ConnectProfile or > Connect, actually ConnectProfile doesn't work for LE since the > profiles need GATT to be connected first and anyway the way the LE > works is that the peripheral would advertise so perhaps what is > missing is that you register an application implementing GattProfile1 > interface that way bluetoothd can tell there is an application trying > to use the profile see: > https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt > > -- > Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How BLE services could be remembered? 2016-12-12 13:35 ` José Bollo @ 2016-12-12 14:20 ` Luiz Augusto von Dentz 2016-12-15 8:09 ` José Bollo 0 siblings, 1 reply; 7+ messages in thread From: Luiz Augusto von Dentz @ 2016-12-12 14:20 UTC (permalink / raw) To: josé bollo; +Cc: linux-bluetooth@vger.kernel.org Hi Jose, On Mon, Dec 12, 2016 at 3:35 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wrote= : > Hi all, > > Using the commit c64b4d9e8dc3e36672061f39a9dba19ad0fb1ef1, the issue > is sloved. Great! Thank you. > > But my issue was also related to the fact that 'connected' was > received before availability of the attributes/services. The code was > disconnecting with the effect that not attributes/services coulded be > discovered. > > Should I that the variable "ServicesResolved" is intended to reflect > the service resolution state? How long should I wait after being > connected for the ServiceResolved Status? Is there a way to know that > service resolution is in progress? You should use ServicesResolved and wait until it becomes 1/true, while it is false it means it is in progress, when connected, but it should be quite fast to resolve the services once the cache is populated. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How BLE services could be remembered? 2016-12-12 14:20 ` Luiz Augusto von Dentz @ 2016-12-15 8:09 ` José Bollo 0 siblings, 0 replies; 7+ messages in thread From: José Bollo @ 2016-12-15 8:09 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: josé bollo, linux-bluetooth@vger.kernel.org Hi all, Few words, just to tell that it works fine now. Thank you Luiz and Petri Best regards Jos=C3=A9 Bollo Jos=C3=A9 Bollo - Senior Software Engineer www.iot.bzh 2016-12-12 15:20 GMT+01:00 Luiz Augusto von Dentz <luiz.dentz@gmail.com>: > Hi Jose, > > On Mon, Dec 12, 2016 at 3:35 PM, Jos=C3=A9 Bollo <jose.bollo@iot.bzh> wro= te: >> Hi all, >> >> Using the commit c64b4d9e8dc3e36672061f39a9dba19ad0fb1ef1, the issue >> is sloved. Great! Thank you. >> >> But my issue was also related to the fact that 'connected' was >> received before availability of the attributes/services. The code was >> disconnecting with the effect that not attributes/services coulded be >> discovered. >> >> Should I that the variable "ServicesResolved" is intended to reflect >> the service resolution state? How long should I wait after being >> connected for the ServiceResolved Status? Is there a way to know that >> service resolution is in progress? > > You should use ServicesResolved and wait until it becomes 1/true, > while it is false it means it is in progress, when connected, but it > should be quite fast to resolve the services once the cache is > populated. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-12-15 8:09 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-08 14:40 How BLE services could be remembered? José Bollo 2016-12-09 9:43 ` Luiz Augusto von Dentz 2016-12-09 11:14 ` José Bollo 2016-12-09 13:15 ` Luiz Augusto von Dentz 2016-12-12 13:35 ` José Bollo 2016-12-12 14:20 ` Luiz Augusto von Dentz 2016-12-15 8:09 ` José Bollo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).