/* Simple read/write access callback for the alert level characteristic.  */
static int ble_svc_lls_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg)
/* Simple read/write access callback for the alert level characteristic.  */
static int ble_svc_lls_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg)
{
    assert(ctxt->chr == &ble_svc_lls_defs[0].characteristics[0]);
    int rc;
    switch (ctxt->op) {
    case BLE_GATT_ACCESS_OP_READ_CHR:
        rc = os_mbuf_append(ctxt->om, &ble_svc_lls_alert_level,
                            sizeof ble_svc_lls_alert_level);
        return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
    case BLE_GATT_ACCESS_OP_WRITE_CHR:
        rc = ble_svc_lls_chr_write(ctxt->om,
                                   sizeof ble_svc_lls_alert_level,
                                   sizeof ble_svc_lls_alert_level,
                                   &ble_svc_lls_alert_level, NULL);
        return rc;
    default:
        assert(0);
        return BLE_ATT_ERR_UNLIKELY;
    }
    return 0;
}