Languages

Menu
Sites
Language
BTLE - error bt_gatt_client_set_characteristic_value_changed_cb

I'm trying to set a listener to a characteristic and It's returning BT_ERROR_REMOTE_DEVICE_NOT_BONDED : -29359866.

Does anyone know what the problem is?

 

This is my code:

void
__bt_gatt_connection_state_changed_cb_advertise(int result, bool connected,
                                      const char *remote_address, void *user_data)
{

    const char *time_svc_uuid_16 = "xxx";
    const char *time_char_uuid_16 = "xxx";
    bt_gatt_h svc = NULL;


   if (connected){

       ret = bt_device_set_authorization (remote_address, BT_DEVICE_AUTHORIZED);

      ret = bt_adapter_foreach_bonded_device(adapter_bonded_device_cb, remote_address);

      ret = bt_gatt_client_create(remote_address, &client);

      ret = bt_gatt_client_get_service(client, time_svc_uuid_16, &svc);


      ret = bt_gatt_service_get_characteristic(svc, time_char_uuid_16, &chr_android);

      ret = bt_gatt_client_set_characteristic_value_changed_cb(chr_android, __bt_gatt_client_value_changed_cb_android, NULL);

                if (ret == BT_ERROR_NONE)
                      {
                    dlog_print(DLOG_INFO, "BT_CONNECTION", "bt_gatt_client_set_characteristic_value_changed_cb Success!");
                      }
                 if (ret == BT_ERROR_INVALID_PARAMETER)
                        {
                            dlog_print(DLOG_INFO, "BT_CONNECTION", "bt_gatt_client_set_characteristic_value_changed_cb invalid parameter : %d", ret);

                        }
                 else  if (ret == BT_ERROR_NO_DATA)
                        {
                            dlog_print(DLOG_INFO, "BT_CONNECTION", "bt_gatt_client_set_characteristic_value_changed_cb no data : %d", ret);

                        }
                 else  if (ret == BT_ERROR_NOT_SUPPORTED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "bt_gatt_client_set_characteristic_value_changed_cb not supported : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_CANCELLED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_CANCELLED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_NOW_IN_PROGRESS)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_NOW_IN_PROGRESS : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_RESOURCE_BUSY)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_RESOURCE_BUSY : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_PERMISSION_DENIED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_PERMISSION_DENIED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_QUOTA_EXCEEDED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_QUOTA_EXCEEDED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_NOT_INITIALIZED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_NOT_INITIALIZED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_NOT_ENABLED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_NOT_ENABLED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_ALREADY_DONE)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_ALREADY_DONE : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_OPERATION_FAILED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_OPERATION_FAILED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_NOT_IN_PROGRESS)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_NOT_IN_PROGRESS : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_REMOTE_DEVICE_NOT_BONDED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_REMOTE_DEVICE_NOT_BONDED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_AUTH_REJECTED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_AUTH_REJECTED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_AUTH_FAILED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_AUTH_FAILED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_REMOTE_DEVICE_NOT_FOUND)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_REMOTE_DEVICE_NOT_FOUND : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_SERVICE_SEARCH_FAILED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_SERVICE_SEARCH_FAILED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_AGAIN)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_AGAIN : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_SERVICE_NOT_FOUND)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_SERVICE_NOT_FOUND : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_OUT_OF_MEMORY)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_OUT_OF_MEMORY : %d", ret);
                                     }
                 else  if (ret == BT_ERROR_TIMED_OUT)
                      {
                               dlog_print(DLOG_INFO, "BT_CONNECTION", "BT_ERROR_TIMED_OUT : %d", ret);
                                     }

                  else{

                            dlog_print(DLOG_INFO, "BT_CONNECTION", "bt_gatt_client_set_characteristic_value_changed_cb UNKNOWN ERROR 2 is failed : %d", ret);

                  }

 

                send_data_android(60);

 

          }


   else
      dlog_print(DLOG_INFO, LOG_TAG, "LE disconnected");
}

 

 

 

 

 

And this is the log:

03-14 16:20:58.900 : ERROR / myapp ( 27527 : 27527 ) : bt_device_set_authorization Success!
03-14 16:20:58.900 : INFO / myapp ( 27527 : 27527 ) : LE connected device:10:30:47:4A:BE:AA
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : Get information about the bonded device(1)
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : remote address = 10:30:47:4A:BE:AA.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : remote name = Tantalum Test (Galaxy S4).
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : service count = 17.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : bonded?? 1.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : connected?? 1.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : authorized?? 1.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : major_device_class 2.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : minor_device_class 12.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : major_service_class_mask 5898240.
03-14 16:20:59.235 : INFO / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3201) > total = 3, index = 1
03-14 16:20:59.235 : INFO / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3209) > uuid : 86c86302-fc10-1399-df43-fceb24618252
03-14 16:20:59.235 : INFO / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3201) > total = 3, index = 2
03-14 16:20:59.235 : INFO / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3209) > uuid : 00001800-0000-1000-8000-00805f9b34fb
03-14 16:20:59.235 : INFO / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3201) > total = 3, index = 3
03-14 16:20:59.235 : INFO / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3209) > uuid : 00001801-0000-1000-8000-00805f9b34fb
03-14 16:20:59.235 : ERROR / WECONN ( 463 : 463 ) : bluetooth.c: __lo_find_device_cb(3234) > LO GM sevice NOT found !!!!!!!!
03-14 16:20:59.590 : INFO / myapp ( 27527 : 27527 ) : add bt_gatt_client_create success
03-14 16:20:59.590 : INFO / myapp ( 27527 : 27527 ) : bt_gatt_client_get_service success
03-14 16:20:59.595 : INFO / myapp ( 27527 : 27527 ) : bt_gatt_service_get_characteristic success
03-14 16:20:59.655 : INFO / BT_CONNECTION ( 27527 : 27527 ) : BT_ERROR_REMOTE_DEVICE_NOT_BONDED : -29359866
03-14 16:20:59.655 : INFO / myapp ( 27527 : 27527 ) : bt_gatt_set_value success
03-14 16:20:59.720 : INFO / myapp ( 27527 : 27527 ) : bt_gatt_client_write_value Android Success

Responses

8 Replies
Gerard

Which device does provide with 'char_android' when you attempt to register '~bt_gatt_client_set_characteristic_value_changed_cb'?

Seemingly current address of bonded device is not matchch with BLE characteristic provider according to the error log '-29359866'.

You should request creating bond to target device using 'bt_device_create_bond(remote_address)' after get bonded device lists.

 

Miguel Benitez

The device is a Samsung s4 which is currently bonded with the watch using the app that is in the play store to start using the watch:

https://play.google.com/store/apps/details?id=com.samsung.android.app.watchmanager

If you see the code and the logs (I didn't add all the code because was mainly call to log), I'm calling 'bt_adapter_foreach_bonded_device()' to know which device is currently bonded and It status.

In the log I've printed out in the log which device I'm connected with:

03-14 16:20:58.900 : INFO / myapp ( 27527 : 27527 ) : LE connected device:10:30:47:4A:BE:AA

And them printed out the status of the bonded devices:

03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : remote address = 10:30:47:4A:BE:AA.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : remote name = Tantalum Test (Galaxy S4).
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : service count = 17.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : bonded?? 1.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : connected?? 1.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : authorized?? 1.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : major_device_class 2.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : minor_device_class 12.
03-14 16:20:59.040 : INFO / myapp ( 27527 : 27527 ) : major_service_class_mask 5898240.

As you can see the address is the same, It's bonded, connected and authorized, and also in the android side, the server said that is bonded.

Also I tried to bonded again using this code:

ret = bt_device_set_bond_created_cb(device_bond_created_cb, remote_address);

      ret = bt_device_create_bond(remote_address);

 

But when It's running this code, the connection between the watch and the mobile phone crash and none app can't comunicate with the watch again until I switch off and on the bluetooth in the mobile phone.

 

 

 

 

 

 

 

Alex Dem

Hi,
just fyi, link at tutorial (and how to create bond with remote device):
https://developer.tizen.org/development/tutorials/native-application/network/bluetooth#find
Alexey.

Miguel Benitez

Hi,

I've followed this tutorial and also this one which is almost the same:

 

https://developer.tizen.org/dev-guide/2.4.0/org.tizen.tutorials/html/native/network/bluetooth_tutorial_n.htm

 

And Also the API:

 

https://developer.tizen.org/dev-guide/2.3.1/org.tizen.native.mobile.apireference/group__CAPI__NETWORK__BLUETOOTH__DEVICE__MODULE.html

 

I'm testing in a Samsung Gear S2 which It's bonded with my Samsung Galasy S4 and if I try to bond again with this device following the tutorial the connection between the watch and the mobile phone crash and none app can't comunicate with the watch again until I switch off and on the bluetooth in the mobile phone.

 

daniel kim

Hi,

I heard from my colleage that same issue was observed and it looks like that it is resolved in latest Gear S2 binary. so I would suggest you to check it once agian. he got new binary today.

Regards

Miguel Benitez

Hi,

I'll check again today and It's happening the same issue. Do I download the latest Gear S2 binary from some website or is it installed automatically?

Cheers,

Miguel.

daniel kim

Hi,

I think that you can update the binary of Gear S2 in following menu of Gear manager.

    Gear S2 --> software update

 

Regards

Miguel Benitez

Hi Daniel,

 

My device has been automatically updated today and It's working!

 

Thank you so much for your help,

 

Cheers,

 

Miguel.