/* Register a host attribute with the BLE stack. */
int ble_att_svr_register(const ble_uuid_t *uuid, uint8_t flags, uint8_t min_key_size, uint16_t *handle_id, ble_att_svr_access_fn *cb, void *cb_arg)
/* Register a host attribute with the BLE stack. */
int ble_att_svr_register(const ble_uuid_t *uuid, uint8_t flags, uint8_t min_key_size, uint16_t *handle_id, ble_att_svr_access_fn *cb, void *cb_arg)
{
    struct ble_att_svr_entry *entry;
    entry = ble_att_svr_entry_alloc();
    if (entry == NULL) {
        return BLE_HS_ENOMEM;
    }
    entry->ha_uuid = uuid;
    entry->ha_flags = flags;
    entry->ha_min_key_size = min_key_size;
    entry->ha_handle_id = ble_att_svr_next_id();
    entry->ha_cb = cb;
    entry->ha_cb_arg = cb_arg;
    STAILQ_INSERT_TAIL(&ble_att_svr_list, entry, ha_next);
    if (handle_id != NULL) {
        *handle_id = entry->ha_handle_id;
    }
    return 0;
}