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