我试图将一个int值设置为Tyzen框架中的一个特征,并且我有一个返回值'参数无效'。我已经按照本教程进行了操作:
https://developer.tizen.org/development/tutorials/native-application/network/bluetooth#gatt_setter
这是我的代码:
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);
}
如果我改变了这个:
int data_output = 60;
ret = bt_gatt_set_int_value(chr, BT_DATA_TYPE_SINT32, data_output, 1);
为此:
char char_value[1] = {1 + (rand()%100)};
ret = bt_gatt_set_value(chr, char_value, 1);
我没有任何问题。但我需要发送一个有符号整数
有谁知道这可能是什么问题?
答案 0 :(得分:1)
解决!
我已将偏移值设置为0并且正在运行。
ret = bt_gatt_set_int_value(chr, BT_DATA_TYPE_SINT32, data_output, 0);