diff --git a/attrib/att-database.h b/attrib/att-database.h
index e022eec..48c50e3 100644
--- a/attrib/att-database.h
+++ b/attrib/att-database.h
struct attribute {
uint16_t handle;
bt_uuid_t uuid;
- size_t read_reqs;
- size_t write_reqs;
+ int read_req; /* Read requirement */
+ int write_req; /* Write requirement */
uint8_t (*read_cb)(struct attribute *a, struct btd_device *device,
gpointer user_data);
uint8_t (*write_cb)(struct attribute *a, struct btd_device *device,
diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index a9de98c..e8788d9 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
ATT_NOT_PERMITTED, atval, len);
}
-static int att_read_reqs(int authorization, int authentication, uint8_t props)
+static int att_read_req(int authorization, int authentication, uint8_t props)
{
if (authorization == GATT_CHR_VALUE_READ ||
authorization == GATT_CHR_VALUE_BOTH)
return ATT_NONE;
}
-static int att_write_reqs(int authorization, int authentication, uint8_t props)
+static int att_write_req(int authorization, int authentication, uint8_t props)
{
if (authorization == GATT_CHR_VALUE_WRITE ||
authorization == GATT_CHR_VALUE_BOTH)
static gboolean add_characteristic(struct btd_adapter *adapter,
uint16_t *handle, struct gatt_info *info)
{
- int read_reqs, write_reqs;
+ int read_req, write_req;
uint16_t h = *handle;
struct attribute *a;
bt_uuid_t bt_uuid;
return FALSE;
}
- read_reqs = att_read_reqs(info->authorization, info->authentication,
+ read_req = att_read_req(info->authorization, info->authentication,
info->props);
- write_reqs = att_write_reqs(info->authorization, info->authentication,
+ write_req = att_write_req(info->authorization, info->authentication,
info->props);
/* TODO: static characteristic values are not supported, therefore a
* callback must be always provided if a read/write property is set */
- if (read_reqs != ATT_NOT_PERMITTED) {
+ if (read_req != ATT_NOT_PERMITTED) {
gpointer reqs = GUINT_TO_POINTER(ATTRIB_READ);
if (!g_slist_find_custom(info->callbacks, reqs,
}
}
- if (write_reqs != ATT_NOT_PERMITTED) {
+ if (write_req != ATT_NOT_PERMITTED) {
gpointer reqs = GUINT_TO_POINTER(ATTRIB_WRITE);
if (!g_slist_find_custom(info->callbacks, reqs,
return FALSE;
/* characteristic value */
- a = attrib_db_add(adapter, h++, &info->uuid, read_reqs, write_reqs,
+ a = attrib_db_add(adapter, h++, &info->uuid, read_req, write_req,
NULL, 0);
if (a == NULL)
return FALSE;
diff --git a/src/attrib-server.c b/src/attrib-server.c
index bbed1a9..145fada 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
static struct attribute *attrib_db_add_new(struct gatt_server *server,
uint16_t handle, bt_uuid_t *uuid,
- size_t read_reqs, size_t write_reqs,
+ int read_req, int write_req,
const uint8_t *value, size_t len)
{
struct attribute *a;
a->data = g_memdup(value, len);
a->handle = handle;
a->uuid = *uuid;
- a->read_reqs = read_reqs;
- a->write_reqs = write_reqs;
+ a->read_req = read_req;
+ a->write_req = write_req;
server->database = g_list_insert_sorted(server->database, a,
attribute_cmp);
break;
status = att_check_reqs(channel, ATT_OP_READ_BY_GROUP_REQ,
- a->read_reqs);
+ a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device,
continue;
status = att_check_reqs(channel, ATT_OP_READ_BY_TYPE_REQ,
- a->read_reqs);
+ a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device,
return enc_read_resp(config, sizeof(config), pdu, len);
}
- status = att_check_reqs(channel, ATT_OP_READ_REQ, a->read_reqs);
+ status = att_check_reqs(channel, ATT_OP_READ_REQ, a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device, a->cb_user_data);
pdu, len);
}
- status = att_check_reqs(channel, ATT_OP_READ_BLOB_REQ, a->read_reqs);
+ status = att_check_reqs(channel, ATT_OP_READ_BLOB_REQ, a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device, a->cb_user_data);
a = l->data;
- status = att_check_reqs(channel, ATT_OP_WRITE_REQ, a->write_reqs);
+ status = att_check_reqs(channel, ATT_OP_WRITE_REQ, a->write_req);
if (status)
return enc_error_resp(ATT_OP_WRITE_REQ, handle, status, pdu,
len);
}
struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
- bt_uuid_t *uuid, size_t read_reqs,
- size_t write_reqs,
- const uint8_t *value, size_t len)
+ bt_uuid_t *uuid, int read_req,
+ int write_req, const uint8_t *value,
+ size_t len)
{
GSList *l;
if (l == NULL)
return NULL;
- return attrib_db_add_new(l->data, handle, uuid, read_reqs, write_reqs,
+ return attrib_db_add_new(l->data, handle, uuid, read_req, write_req,
value, len);
}
diff --git a/src/attrib-server.h b/src/attrib-server.h
index 3ec62ed..2148017 100644
--- a/src/attrib-server.h
+++ b/src/attrib-server.h
uint16_t attrib_db_find_avail(struct btd_adapter *adapter, bt_uuid_t *svc_uuid,
uint16_t nitems);
struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
- bt_uuid_t *uuid, size_t read_reqs,
- size_t write_reqs, const uint8_t *value,
+ bt_uuid_t *uuid, int read_req,
+ int write_req, const uint8_t *value,
size_t len);
int attrib_db_update(struct btd_adapter *adapter, uint16_t handle,
bt_uuid_t *uuid, const uint8_t *value,