const char *bt_uuid_str(const struct bt_uuid *uuid) { static char str[37]; bt_uuid_to_str(uuid, str, sizeof(str)); return str; }
static uint8_t discover_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, struct bt_gatt_discover_params *params) { struct bt_gatt_service *gatt_service; struct bt_gatt_chrc *gatt_chrc; struct bt_gatt_include *gatt_include; char uuid[37]; if (!attr) { printk("Discover complete\n"); memset(params, 0, sizeof(*params)); return BT_GATT_ITER_STOP; } switch (params->type) { case BT_GATT_DISCOVER_SECONDARY: case BT_GATT_DISCOVER_PRIMARY: gatt_service = attr->user_data; bt_uuid_to_str(gatt_service->uuid, uuid, sizeof(uuid)); printk("Service %s found: start handle %x, end_handle %x\n", uuid, attr->handle, gatt_service->end_handle); break; case BT_GATT_DISCOVER_CHARACTERISTIC: gatt_chrc = attr->user_data; bt_uuid_to_str(gatt_chrc->uuid, uuid, sizeof(uuid)); printk("Characteristic %s found: handle %x\n", uuid, attr->handle); print_chrc_props(gatt_chrc->properties); break; case BT_GATT_DISCOVER_INCLUDE: gatt_include = attr->user_data; bt_uuid_to_str(gatt_include->uuid, uuid, sizeof(uuid)); printk("Include %s found: handle %x, start %x, end %x\n", uuid, attr->handle, gatt_include->start_handle, gatt_include->end_handle); break; default: bt_uuid_to_str(attr->uuid, uuid, sizeof(uuid)); printk("Descriptor %s found: handle %x\n", uuid, attr->handle); break; } return BT_GATT_ITER_CONTINUE; }