0

I'm trying to set an int value to a characteristic in Tyzen framework and I have as a return value 'parameter invalid'. I've followed this tutorial:

https://developer.tizen.org/development/tutorials/native-application/network/bluetooth#gatt_setter

And this is my code:

  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);
  ret = bt_gatt_characteristic_set_write_type(chr, BT_GATT_WRITE_TYPE_WRITE);
  int data_output = 60;

  ret = bt_gatt_set_int_value(chr, BT_DATA_TYPE_SINT32, data_output, 1);
  if (ret == BT_ERROR_NONE)
  {
          dlog_print(DLOG_INFO, LOG_TAG, "bt_gatt_set_value success");

  }
  else if (ret == BT_ERROR_INVALID_PARAMETER)
 {
          dlog_print(DLOG_INFO, LOG_TAG, "BT_ERROR_INVALID_PARAMETER is failed : %d", ret);

 }
 else if (ret == BT_ERROR_OPERATION_FAILED)
 {
          dlog_print(DLOG_INFO, LOG_TAG, "BT_ERROR_OPERATION_FAILED is failed : %d", ret);

 }
 else if (ret == BT_ERROR_NOT_SUPPORTED)
{
          dlog_print(DLOG_INFO, LOG_TAG, "BT_ERROR_NOT_SUPPORTED is failed : %d", ret);

}
else{
          dlog_print(DLOG_INFO, LOG_TAG, "UNKNOWN bt_gatt_set_value is failed : %d", ret);

}

if I change this:

  int data_output = 60;

  ret = bt_gatt_set_int_value(chr, BT_DATA_TYPE_SINT32, data_output, 1);

for this:

  char char_value[1] = {1 + (rand()%100)};
   ret = bt_gatt_set_value(chr, char_value, 1);

I don't have any problem. But I need to send a signed integer

does anyone know what It could be the problem?

Miguel Benitez
  • 2,322
  • 10
  • 22

1 Answers1

1

Solved!

I've set the offset value at 0 and is working.

  ret = bt_gatt_set_int_value(chr, BT_DATA_TYPE_SINT32, data_output, 0);
Miguel Benitez
  • 2,322
  • 10
  • 22
  • Hi, I am facing similar issue. I want to write a value greater than 1000. int char_value_v = 10000; ret = bt_gatt_set_int_value(chr, BT_DATA_TYPE_UINT32, char_value_v, 1); This is not writing expected value. If i write 1000 it is giving E8 03. Any suggestions? – Shraddha Shravagi Mar 22 '16 at 07:07
  • Hi, could you open a new question with more explanation about your issue? A little bit of code, devices and framework. Every little detail could be helpful to solve it. Send me the link when you have it. – Miguel Benitez Mar 22 '16 at 09:00