Languages

Menu
Sites
Language
No way to discover services of BLE device

I have BLE device (watch). If I connect with the help of LeScan all is ok - all services are discovered by LeScan and I could use them later with bt_gatt_client_get_service. I create bond with watch and all is ok. 

If I reboot tizen phone, find device among bonded - I could see that services (their uuids) in device_info, but method bt_gatt_client_get_service returns error -61 (BT_ERROR_NO_DATA). Method bt_gatt_client_foreach_services returns 0 (Success) but no callbacks called after it - as if there are no services at all. In API there is method bt_gatt_discover_characteristics to discover characteristics but there is no method to discover services.

How could I discover services of bonded device?  For example on Android I use discoverServices for this purpose.

And second question: When I use bt_gatt_connect with flag auto_connect true - device waits for my watch and connects to it when watch is in range. But there are some cases when it does not connect, for example if watch is not in range for an hour after bt_gatt_connect call - and hour later when watch appears in range phone just does not connect to it. Is there a timeout for auto connect feature or something else? Why it does not connect sometimes?

I use Tizen 2.4 on Samsung Z3 phone.

 

Edited by: Leonid Lukyanenko on 11 Feb, 2016

Responses

13 Replies
Alex Dem

Hi,
here is tutorial https://developer.tizen.org/development/tutorials/native-application/network/bluetooth?langredirect=1#find

And as I understand if your device was already bonded (with bt_device_create_bond) your device should be found in bound lis with bt_adapter_foreach_bonded_device (in registered callback)

Does it work? 
Alexey.

Leonid Lukyanenko

Hello,

Thank you for your answer. I have read all that tutorial multiple times. 

Yes the device can be found in callback of bt_adapter_foreach_bonded_device, but that callback does not return BLE service handles.

To get these handles I have to use connect to BLE device and get them with  bt_gatt_client_get_service. So I use bt_gatt_connect and bt_gatt_client_create with address I got from bt_adapter_foreach_bonded_device. After that I use bt_gatt_client_get_service to get handle of service with uuid I got from bt_adapter_foreach_bonded_device. But this method returns BT_ERROR_NO_DATA.

Alex Dem

Hi,
As I understand it works 1st time but it does not work after Tizen phone has been rebooted.  Or bt_gatt_client_get_service does not work all time?
Alexey.

Leonid Lukyanenko

Hello,

Yes, It works after device was LeScanned and connected (bonded) after LeScan (bt_gatt_client_get_service also works). And after disconnect /reconnect also works correctly. But if device was rebooted it does not work until I do unpair (on watch and phone) and repeat LeScan/bonding. I think it works because those handles are cached by OS during LeScan (or bonding), and I could use them, but after reboot this cache dissapears and I have to rediscover that service handles. The only way I have found how I can do it is to unpair devices and repeat LeScan.

 

Leonid Lukyanenko

And my question can be reformulated as: Is there any way to discover services on particular device (with known address, which is bonded and does not advertise scan records by LeScan)? Or Tizen somehow does it (discovering services) automatically (as there is no function discover_services)? If it does it automatically, when does it do discovery?

For example Android has similar case, there is a method getServices, but is works only after services was discovered by LeScan or  btDeviceInstance.discoverServices() and returns only cached values and so will not work after reboot. Is there any similar to btDeviceInstance.discoverServices() function?

Leonid Lukyanenko

I have found out that problem even not in services. It is in connection with gatt. I do bond with watch. All works correctly. After it I reboot Tizen phone.

I can see watch among bonded with values "bonded" "not connected". I use 

ret = bt_gatt_connect(dev_mac_, true);

It returns ok and I just wait for connection.

And see callback on connection gatt_connection_state_changed_cb(int result, bool connected, const char *remote_address, void *data) twice. First is returns connected with watch and secondly in less than second it returns disconnected. If I try to connect_gatt in case of status disconnect - it will be endless loop. It callback will invoked: connect, disconnect, connect, disconnect, connect, disconnect...

I looked at watch - status of connection on watch does not change, which means that Tizen invoke callback connected but no connection really made. And this probably is the reason I can't use services.

Before reboot this code does not cycle. And I have similar code for Android all is ok - so I don't think the reason is in watch. 

Alex Dem

Hi,
Yes in case of endless loop connect/disconnect it looks like error. What mobile device/watch did you use?
Is this loop for any case? Did you try other variants of connection between different Tizen devices?
Alexey.

Paras Kumar

Hi Leonid,

As of now services can be discovered or retrieved only after connection is established, even if device is already bonded.

And there is no such API to discover services explictly like bt_gatt_discover_characteristics so far. So evertime when Application wants to access services, connection has to be established.

1. bt_gatt_connect

2. bt_gatt_client_create

We will check more on this and get back to you. Please provide us the information about the binary version you used.

Regards,

Paras

 

Paras Kumar

Hi Leonid,

Could you please let me know which binary version are you using ? Is this product released binary or TIZEN open source binary ?

Please provide me the link from where you downloaded the binary.

Thanks,

Paras Kumar

Leonid Lukyanenko

Hi,

I am using Samsung Z3 (SM-Z300F) with Tizen 2.4.0.2 (Z300FXXU1BPB1) official.

I have learned information about discovering services, but problem with disconnecting from watch after reboot still remains.

Paras Kumar

Hi,

Could you please share the logs for the same.

Dial the number *#9900#  from the call Application then tap on "Run LOG_DUMP" to generate the logs.

The path would be displayed where the xxx.tar file would be created. You can remove your Application related logs and share the rest modules logs with us.

We would analyze the logs and get back to you.

Thanks & regards,

Paras

 

Leonid Lukyanenko

I am sorry, but I can't share the logs. This phone is not mine, I'm just writing library which should work with Tizen and use this phone to test it. The real owner of phone prohibited sharing the logs. 

Maybe someone else having this issue could share the logs.

Shraddha Shravagi

Hello,

Even I am facing same issue and there. Seems that the BLE API is having some issue with connect. 

 

Regards,

Shraddha