summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gatt-database.c109
1 files changed, 69 insertions, 40 deletions
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 4daa2e8f..46be5a87 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1092,23 +1092,20 @@ static void indicate_confirm_free(void *data)
static void indicate_confirm_setup_cb(DBusMessageIter *iter, void *user_data)
{
struct btd_device *device = user_data;
- char dstaddr[18] = { 0 };
- char *addr_value = NULL;
+ char dst_addr[18] = { 0 };
+ char *addr_value = dst_addr;
gboolean complete = FALSE;
if (device_get_rpa_exist(device) == true) {
- ba2str(device_get_rpa(device), dstaddr);
+ ba2str(device_get_rpa(device), dst_addr);
} else {
- ba2str(device_get_address(device), dstaddr);
+ ba2str(device_get_address(device), dst_addr);
}
- addr_value = g_strdup(dstaddr);
- dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
- &addr_value);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_value);
complete = TRUE;
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN,
- &complete);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &complete);
}
static void indicate_confirm_reply_cb(DBusMessage *message, void *user_data)
@@ -1981,21 +1978,14 @@ static struct pending_op *pending_read_new(struct queue *owner_queue,
static void read_setup_cb(DBusMessageIter *iter, void *user_data)
{
struct pending_op *op = user_data;
- char dstaddr[18] = { 0 };
- char *addr_value = NULL;
+ char dst_addr[18] = { 0 };
+ char *addr_value = dst_addr;
uint16_t offset = 0;
- ba2str(&op->bdaddr, dstaddr);
- addr_value = g_strdup(dstaddr);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
- &addr_value);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE,
- &op->id);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16,
- &offset);
+ ba2str(&op->bdaddr, dst_addr);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_value);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &op->id);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &offset);
}
#endif
@@ -2037,23 +2027,16 @@ static void write_setup_cb(DBusMessageIter *iter, void *user_data)
struct pending_op *op = user_data;
DBusMessageIter array;
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
- char dstaddr[18] = { 0 };
- char *addr_value = NULL;
+ char dst_addr[18] = { 0 };
+ char *addr_value = dst_addr;
uint16_t offset = 0;
-#endif
+ gboolean response_needed = TRUE;
-#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
- ba2str(&op->bdaddr, dstaddr);
- addr_value = g_strdup(dstaddr);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
- &addr_value);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE,
- &op->id);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16,
- &offset);
+ ba2str(&op->bdaddr, dst_addr);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_value);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &op->id);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &offset);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &response_needed);
#endif
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "y", &array);
@@ -2513,13 +2496,38 @@ static void chrc_read_cb(struct gatt_db_attribute *attrib,
#endif
}
-#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+struct write_without_response_data {
+ unsigned int id;
+ bdaddr_t dst_addr;
+ uint8_t dst_addr_type;
+ struct iovec *iov;
+};
+#endif
+
static void write_without_response_setup_cb(DBusMessageIter *iter,
void *user_data)
{
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct write_without_response_data *write_data = user_data;
+ struct iovec *iov = write_data->iov;
+ char dst_addr[18];
+ char *addr_str = dst_addr;
+ uint16_t offset = 0;
+ gboolean response_needed = FALSE;
+#else
struct iovec *iov = user_data;
+#endif
DBusMessageIter array;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ ba2str(&write_data->dst_addr, dst_addr);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_str);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &write_data->id);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &offset);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &response_needed);
+#endif
+
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "y", &array);
dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE,
&iov->iov_base, iov->iov_len);
@@ -2527,23 +2535,37 @@ static void write_without_response_setup_cb(DBusMessageIter *iter,
}
static void send_write_without_response(struct gatt_db_attribute *attrib,
+ struct bt_att *att,
GDBusProxy *proxy, unsigned int id,
const uint8_t *value, size_t len)
{
struct iovec iov;
uint8_t ecode = 0;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct write_without_response_data write_data;
+#endif
iov.iov_base = (uint8_t *) value;
iov.iov_len = len;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ write_data.id = id;
+ write_data.iov = &iov;
+ get_dst_info(att, &write_data.dst_addr, &write_data.dst_addr_type);
+
+ if (!g_dbus_proxy_method_call(proxy, "WriteValue",
+ write_without_response_setup_cb,
+ NULL, &write_data, NULL))
+ ecode = BT_ATT_ERROR_UNLIKELY;
+#else
if (!g_dbus_proxy_method_call(proxy, "WriteValue",
write_without_response_setup_cb,
NULL, &iov, NULL))
ecode = BT_ATT_ERROR_UNLIKELY;
+#endif
gatt_db_attribute_write_result(attrib, id, ecode);
}
-#endif
static void chrc_write_cb(struct gatt_db_attribute *attrib,
unsigned int id, uint16_t offset,
@@ -2569,7 +2591,14 @@ static void chrc_write_cb(struct gatt_db_attribute *attrib,
return;
}
- send_write(attrib, att, chrc->proxy, chrc->pending_writes, id, value, len);
+ if (opcode == BT_ATT_OP_WRITE_CMD) {
+ send_write_without_response(attrib, att, chrc->proxy,
+ id, value, len);
+ return;
+ }
+
+ send_write(attrib, att, chrc->proxy, chrc->pending_writes,
+ id, value, len);
#else
if (chrc->props & BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP) {
send_write_without_response(attrib, chrc->proxy, id, value,