diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index 73230f2..3bfa565 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
return cb->event - event;
}
-static gboolean add_characteristic(uint16_t *handle, struct gatt_info *info)
+static gboolean add_characteristic(struct btd_adapter *adapter,
+ uint16_t *handle, struct gatt_info *info)
{
int read_reqs, write_reqs;
uint16_t h = *handle;
atval[0] = info->props;
att_put_u16(h + 1, &atval[1]);
att_put_u16(info->uuid.value.u16, &atval[3]);
- /* FIXME: Provide the adapter in next function */
- attrib_db_add(NULL, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED, atval,
- sizeof(atval));
+ attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED,
+ atval, sizeof(atval));
/* characteristic value */
- /* FIXME: Provide the adapter in next function */
- a = attrib_db_add(NULL, h++, &info->uuid, read_reqs, write_reqs, NULL,
- 0);
+ a = attrib_db_add(adapter, h++, &info->uuid, read_reqs, write_reqs,
+ NULL, 0);
for (l = info->callbacks; l != NULL; l = l->next) {
struct attrib_cb *cb = l->data;
bt_uuid16_create(&bt_uuid, GATT_CLIENT_CHARAC_CFG_UUID);
cfg_val[0] = 0x00;
cfg_val[1] = 0x00;
- /* FIXME: Provide the adapter in next function */
- a = attrib_db_add(NULL, h++, &bt_uuid, ATT_NONE,
+ a = attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE,
ATT_AUTHENTICATION, cfg_val, sizeof(cfg_val));
if (info->ccc_handle != NULL)
g_free(info);
}
-gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...)
+gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
+ uint16_t svc_uuid, gatt_option opt1, ...)
{
uint16_t start_handle, h;
unsigned int size;
size += info->num_attrs;
}
va_end(args);
-
- /* FIXME: Provide the adapter in next function */
- start_handle = attrib_db_find_avail(NULL, size);
+ start_handle = attrib_db_find_avail(adapter, size);
if (start_handle == 0) {
error("Not enough free handles to register service");
g_slist_free_full(chrs, free_gatt_info);
h = start_handle;
bt_uuid16_create(&bt_uuid, uuid);
att_put_u16(svc_uuid, &atval[0]);
- /* FIXME: Provide the adapter in next function */
- attrib_db_add(NULL, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED, atval,
- sizeof(atval));
-
+ attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED,
+ atval, sizeof(atval));
for (l = chrs; l != NULL; l = l->next) {
struct gatt_info *info = l->data;
DBG("New characteristic: handle 0x%04x", h);
- if (!add_characteristic(&h, info)) {
+ if (!add_characteristic(adapter, &h, info)) {
g_slist_free_full(chrs, free_gatt_info);
return FALSE;
}
diff --git a/attrib/gatt-service.h b/attrib/gatt-service.h
index 95064c0..7af2d3e 100644
--- a/attrib/gatt-service.h
+++ b/attrib/gatt-service.h
ATTRIB_WRITE,
} attrib_event_t;
-gboolean gatt_service_add(uint16_t uuid, uint16_t svc_uuid, gatt_option opt1, ...);
+gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
+ uint16_t svc_uuid, gatt_option opt1, ...);
diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index f3f2b3a..27d3d13 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
return 0;
}
-static gboolean register_battery_service(void)
+static gboolean register_battery_service(struct btd_adapter *adapter)
{
- return gatt_service_add(GATT_PRIM_SVC_UUID, BATTERY_STATE_SVC_UUID,
+ return gatt_service_add(adapter, GATT_PRIM_SVC_UUID,
+ BATTERY_STATE_SVC_UUID,
/* battery state characteristic */
GATT_OPT_CHR_UUID, BATTERY_STATE_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
gadapter = g_new0(struct gatt_example_adapter, 1);
gadapter->adapter = btd_adapter_ref(adapter);
- if (!register_battery_service()) {
+ if (!register_battery_service(adapter)) {
DBG("Battery service could not be registered");
gatt_example_adapter_free(gadapter);
return -EIO;
diff --git a/time/server.c b/time/server.c
index 5636cca..839b33a 100644
--- a/time/server.c
+++ b/time/server.c
static void register_current_time_service(void)
{
/* Current Time service */
- gatt_service_add(GATT_PRIM_SVC_UUID, CURRENT_TIME_SVC_UUID,
+ /* FIXME: Provide the adapter in next function */
+ gatt_service_add(NULL, GATT_PRIM_SVC_UUID, CURRENT_TIME_SVC_UUID,
/* CT Time characteristic */
GATT_OPT_CHR_UUID, CT_TIME_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |