c - How do callback methods for GATT services in bluez look like? -
when adding gatt service using bluez (using 'gatt_service_add()') can specify various callback methods attrib_read, attrib_write, etc. there example 'reading' characteristics given:
static uint8_t battery_state_read(struct attribute *a, struct btd_device *device, gpointer user_data);
how methods other features (eg: write)?
i've been working bluez 4.101 bringing gatt server, you'll want take @ "linkloss.c" located (in bluez 4.101 @ least) in "proximity" directory. or here guess: https://github.com/pauloborges/bluez/blob/master/profiles/proximity/linkloss.c
the link loss service registered writable callbacks like:
svc_added = gatt_service_add(adapter, gatt_prim_svc_uuid, &uuid, /* alert level characteristic */ gatt_opt_chr_uuid16, alert_level_chr_uuid, gatt_opt_chr_props, att_char_proper_read | att_char_proper_write, gatt_opt_chr_value_cb, attrib_read, link_loss_alert_lvl_read, lladapter, gatt_opt_chr_value_cb, attrib_write, link_loss_alert_lvl_write, lladapter, gatt_opt_chr_value_get_handle, &lladapter->alert_lvl_value_handle, gatt_opt_invalid);
where callback structure like:
static uint8_t link_loss_alert_lvl_write(struct attribute *a, struct btd_device *device, gpointer user_data) { /*stuff*/ }
the "attribute" struct contains data passed writable callback.
Comments
Post a Comment