/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-qc-s5gen2-ble-struct.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-mem-private.h"
#include "fu-string.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"


/**
 * fu_qc_gaia_v3_cmd_to_string:
 * @val: value, e.g. %FU_QC_GAIA_V3_CMD_GET_API_RESP
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_qc_gaia_v3_cmd_to_string(FuQcGaiaV3Cmd val)
{
    if (val == FU_QC_GAIA_V3_CMD_GET_API_REQ)
        return "get-api-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_API_RESP)
        return "get-api-resp";
    if (val == FU_QC_GAIA_V3_CMD_GET_SUPPORTED_FEATURES_REQ)
        return "get-supported-features-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_SUPPORTED_FEATURES_RESP)
        return "get-supported-features-resp";
    if (val == FU_QC_GAIA_V3_CMD_GET_SUPPORTED_FEATURES_NEXT_REQ)
        return "get-supported-features-next-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_SUPPORTED_FEATURES_NEXT_RESP)
        return "get-supported-features-next-resp";
    if (val == FU_QC_GAIA_V3_CMD_GET_SERIAL_REQ)
        return "get-serial-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_SERIAL_RESP)
        return "get-serial-resp";
    if (val == FU_QC_GAIA_V3_CMD_GET_VARIANT_REQ)
        return "get-variant-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_VARIANT_RESP)
        return "get-variant-resp";
    if (val == FU_QC_GAIA_V3_CMD_REGISTER_NOTIFICATION_CMD)
        return "register-notification-cmd";
    if (val == FU_QC_GAIA_V3_CMD_REGISTER_NOTIFICATION_ACK)
        return "register-notification-ack";
    if (val == FU_QC_GAIA_V3_CMD_GET_TRANSPORT_INFO_REQ)
        return "get-transport-info-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_TRANSPORT_INFO_RESP)
        return "get-transport-info-resp";
    if (val == FU_QC_GAIA_V3_CMD_SET_TRANSPORT_INFO_REQ)
        return "set-transport-info-req";
    if (val == FU_QC_GAIA_V3_CMD_SET_TRANSPORT_INFO_RESP)
        return "set-transport-info-resp";
    if (val == FU_QC_GAIA_V3_CMD_GET_SYSTEM_INFO_REQ)
        return "get-system-info-req";
    if (val == FU_QC_GAIA_V3_CMD_GET_SYSTEM_INFO_RESP)
        return "get-system-info-resp";
    if (val == FU_QC_GAIA_V3_CMD_UPGRADE_CONNECT_CMD)
        return "upgrade-connect-cmd";
    if (val == FU_QC_GAIA_V3_CMD_UPGRADE_CONNECT_ACK)
        return "upgrade-connect-ack";
    if (val == FU_QC_GAIA_V3_CMD_UPGRADE_DISCONNECT_CMD)
        return "upgrade-disconnect-cmd";
    if (val == FU_QC_GAIA_V3_CMD_UPGRADE_DISCONNECT_ACK)
        return "upgrade-disconnect-ack";
    if (val == FU_QC_GAIA_V3_CMD_UPGRADE_CONTROL_CMD)
        return "upgrade-control-cmd";
    if (val == FU_QC_GAIA_V3_CMD_UPGRADE_CONTROL_ACK)
        return "upgrade-control-ack";
    return NULL;
}

/**
 * fu_qc_gaia_cmd_status_to_string:
 * @val: value, e.g. %FU_QC_GAIA_CMD_STATUS_NOT_SUPPORTED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_qc_gaia_cmd_status_to_string(FuQcGaiaCmdStatus val)
{
    if (val == FU_QC_GAIA_CMD_STATUS_SUCCESS)
        return "success";
    if (val == FU_QC_GAIA_CMD_STATUS_NOT_SUPPORTED)
        return "not-supported";
    if (val == FU_QC_GAIA_CMD_STATUS_INSUFFICIENT_RESOURCES)
        return "insufficient-resources";
    if (val == FU_QC_GAIA_CMD_STATUS_INVALID_PARAMETER)
        return "invalid-parameter";
    if (val == FU_QC_GAIA_CMD_STATUS_INCORRECT_STATE)
        return "incorrect-state";
    if (val == FU_QC_GAIA_CMD_STATUS_IN_PROGERSS)
        return "in-progerss";
    return NULL;
}

/**
 * fu_qc_more_to_string:
 * @val: value, e.g. %FU_QC_MORE_LAST
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_qc_more_to_string(FuQcMore val)
{
    if (val == FU_QC_MORE_MORE)
        return "more";
    if (val == FU_QC_MORE_LAST)
        return "last";
    return NULL;
}
/**
 * fu_struct_qc_gaia_v3_api_req_ref: (skip):
 **/
FuStructQcGaiaV3ApiReq *
fu_struct_qc_gaia_v3_api_req_ref(FuStructQcGaiaV3ApiReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_api_req_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_api_req_unref(FuStructQcGaiaV3ApiReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3ApiReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_api_req_new_internal: (skip):
 **/
static FuStructQcGaiaV3ApiReq *
fu_struct_qc_gaia_v3_api_req_new_internal(void)
{
    FuStructQcGaiaV3ApiReq *st = g_new0(FuStructQcGaiaV3ApiReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_api_req_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_api_req_set_vendor_id(FuStructQcGaiaV3ApiReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_api_req_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_api_req_set_command(FuStructQcGaiaV3ApiReq *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_api_req_new: (skip):
 **/
FuStructQcGaiaV3ApiReq *
fu_struct_qc_gaia_v3_api_req_new(void)
{
    FuStructQcGaiaV3ApiReq *st = fu_struct_qc_gaia_v3_api_req_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_qc_gaia_v3_api_req_set_command(st, FU_QC_GAIA_V3_CMD_GET_API_REQ);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_api_ref: (skip):
 **/
FuStructQcGaiaV3Api *
fu_struct_qc_gaia_v3_api_ref(FuStructQcGaiaV3Api *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_api_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_api_unref(FuStructQcGaiaV3Api *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3Api refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_api_new_internal: (skip):
 **/
static FuStructQcGaiaV3Api *
fu_struct_qc_gaia_v3_api_new_internal(void)
{
    FuStructQcGaiaV3Api *st = g_new0(FuStructQcGaiaV3Api, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_api_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_api_get_vendor_id(const FuStructQcGaiaV3Api *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_api_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_api_get_command(const FuStructQcGaiaV3Api *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_api_get_major: (skip):
 **/
guint8
fu_struct_qc_gaia_v3_api_get_major(const FuStructQcGaiaV3Api *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_qc_gaia_v3_api_get_minor: (skip):
 **/
guint8
fu_struct_qc_gaia_v3_api_get_minor(const FuStructQcGaiaV3Api *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_api_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_api_to_string(const FuStructQcGaiaV3Api *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3Api:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_api_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_api_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_api_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_api_get_command(st));
        }
    }
    g_string_append_printf(str, "  major: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_api_get_major(st));
    g_string_append_printf(str, "  minor: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_api_get_minor(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_api_validate_internal(FuStructQcGaiaV3Api *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_api_get_command(st) != FU_QC_GAIA_V3_CMD_GET_API_RESP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3Api.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_GET_API_RESP' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_api_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_api_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_api_parse_internal(FuStructQcGaiaV3Api *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_api_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_api_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_api_parse: (skip):
 **/
FuStructQcGaiaV3Api *
fu_struct_qc_gaia_v3_api_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3Api) st = fu_struct_qc_gaia_v3_api_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 6, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3Api: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 6);
    if (!fu_struct_qc_gaia_v3_api_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_req_ref: (skip):
 **/
FuStructQcGaiaV3SupportedFeaturesReq *
fu_struct_qc_gaia_v3_supported_features_req_ref(FuStructQcGaiaV3SupportedFeaturesReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_supported_features_req_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_supported_features_req_unref(FuStructQcGaiaV3SupportedFeaturesReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3SupportedFeaturesReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_req_new_internal: (skip):
 **/
static FuStructQcGaiaV3SupportedFeaturesReq *
fu_struct_qc_gaia_v3_supported_features_req_new_internal(void)
{
    FuStructQcGaiaV3SupportedFeaturesReq *st = g_new0(FuStructQcGaiaV3SupportedFeaturesReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_supported_features_req_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_supported_features_req_set_vendor_id(FuStructQcGaiaV3SupportedFeaturesReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_req_set_command: (skip):
 **/
void
fu_struct_qc_gaia_v3_supported_features_req_set_command(FuStructQcGaiaV3SupportedFeaturesReq *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_req_new: (skip):
 **/
FuStructQcGaiaV3SupportedFeaturesReq *
fu_struct_qc_gaia_v3_supported_features_req_new(void)
{
    FuStructQcGaiaV3SupportedFeaturesReq *st = fu_struct_qc_gaia_v3_supported_features_req_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_supported_features_ref: (skip):
 **/
FuStructQcGaiaV3SupportedFeatures *
fu_struct_qc_gaia_v3_supported_features_ref(FuStructQcGaiaV3SupportedFeatures *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_supported_features_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_supported_features_unref(FuStructQcGaiaV3SupportedFeatures *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3SupportedFeatures refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_new_internal: (skip):
 **/
static FuStructQcGaiaV3SupportedFeatures *
fu_struct_qc_gaia_v3_supported_features_new_internal(void)
{
    FuStructQcGaiaV3SupportedFeatures *st = g_new0(FuStructQcGaiaV3SupportedFeatures, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_supported_features_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_supported_features_get_vendor_id(const FuStructQcGaiaV3SupportedFeatures *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_get_command: (skip):
 **/
FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_supported_features_get_command(const FuStructQcGaiaV3SupportedFeatures *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_supported_features_get_more_features: (skip):
 **/
FuQcMore
fu_struct_qc_gaia_v3_supported_features_get_more_features(const FuStructQcGaiaV3SupportedFeatures *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_supported_features_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_supported_features_to_string(const FuStructQcGaiaV3SupportedFeatures *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3SupportedFeatures:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_supported_features_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_supported_features_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_supported_features_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_supported_features_get_command(st));
        }
    }
    {
        const gchar *tmp = fu_qc_more_to_string(fu_struct_qc_gaia_v3_supported_features_get_more_features(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  moreFeatures: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_supported_features_get_more_features(st), tmp);
        } else {
            g_string_append_printf(str, "  moreFeatures: 0x%x\n", (guint) fu_struct_qc_gaia_v3_supported_features_get_more_features(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_supported_features_validate_internal(FuStructQcGaiaV3SupportedFeatures *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_supported_features_parse_internal(FuStructQcGaiaV3SupportedFeatures *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_supported_features_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_supported_features_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_supported_features_parse: (skip):
 **/
FuStructQcGaiaV3SupportedFeatures *
fu_struct_qc_gaia_v3_supported_features_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3SupportedFeatures) st = fu_struct_qc_gaia_v3_supported_features_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 5, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3SupportedFeatures: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 5);
    if (!fu_struct_qc_gaia_v3_supported_features_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_serial_req_ref: (skip):
 **/
FuStructQcGaiaV3SerialReq *
fu_struct_qc_gaia_v3_serial_req_ref(FuStructQcGaiaV3SerialReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_serial_req_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_serial_req_unref(FuStructQcGaiaV3SerialReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3SerialReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_serial_req_new_internal: (skip):
 **/
static FuStructQcGaiaV3SerialReq *
fu_struct_qc_gaia_v3_serial_req_new_internal(void)
{
    FuStructQcGaiaV3SerialReq *st = g_new0(FuStructQcGaiaV3SerialReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_serial_req_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_serial_req_set_vendor_id(FuStructQcGaiaV3SerialReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_serial_req_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_serial_req_set_command(FuStructQcGaiaV3SerialReq *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_serial_req_new: (skip):
 **/
FuStructQcGaiaV3SerialReq *
fu_struct_qc_gaia_v3_serial_req_new(void)
{
    FuStructQcGaiaV3SerialReq *st = fu_struct_qc_gaia_v3_serial_req_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_qc_gaia_v3_serial_req_set_command(st, FU_QC_GAIA_V3_CMD_GET_SERIAL_REQ);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_serial_ref: (skip):
 **/
FuStructQcGaiaV3Serial *
fu_struct_qc_gaia_v3_serial_ref(FuStructQcGaiaV3Serial *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_serial_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_serial_unref(FuStructQcGaiaV3Serial *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3Serial refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_serial_new_internal: (skip):
 **/
static FuStructQcGaiaV3Serial *
fu_struct_qc_gaia_v3_serial_new_internal(void)
{
    FuStructQcGaiaV3Serial *st = g_new0(FuStructQcGaiaV3Serial, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_serial_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_serial_get_vendor_id(const FuStructQcGaiaV3Serial *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_serial_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_serial_get_command(const FuStructQcGaiaV3Serial *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_serial_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_serial_to_string(const FuStructQcGaiaV3Serial *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3Serial:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_serial_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_serial_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_serial_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_serial_get_command(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_serial_validate_internal(FuStructQcGaiaV3Serial *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_serial_get_command(st) != FU_QC_GAIA_V3_CMD_GET_SERIAL_RESP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3Serial.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_GET_SERIAL_RESP' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_serial_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_serial_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_serial_parse_internal(FuStructQcGaiaV3Serial *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_serial_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_serial_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_serial_parse: (skip):
 **/
FuStructQcGaiaV3Serial *
fu_struct_qc_gaia_v3_serial_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3Serial) st = fu_struct_qc_gaia_v3_serial_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3Serial: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_qc_gaia_v3_serial_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_variant_req_ref: (skip):
 **/
FuStructQcGaiaV3VariantReq *
fu_struct_qc_gaia_v3_variant_req_ref(FuStructQcGaiaV3VariantReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_variant_req_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_variant_req_unref(FuStructQcGaiaV3VariantReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3VariantReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_variant_req_new_internal: (skip):
 **/
static FuStructQcGaiaV3VariantReq *
fu_struct_qc_gaia_v3_variant_req_new_internal(void)
{
    FuStructQcGaiaV3VariantReq *st = g_new0(FuStructQcGaiaV3VariantReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_variant_req_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_variant_req_set_vendor_id(FuStructQcGaiaV3VariantReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_variant_req_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_variant_req_set_command(FuStructQcGaiaV3VariantReq *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_variant_req_new: (skip):
 **/
FuStructQcGaiaV3VariantReq *
fu_struct_qc_gaia_v3_variant_req_new(void)
{
    FuStructQcGaiaV3VariantReq *st = fu_struct_qc_gaia_v3_variant_req_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_qc_gaia_v3_variant_req_set_command(st, FU_QC_GAIA_V3_CMD_GET_VARIANT_REQ);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_variant_ref: (skip):
 **/
FuStructQcGaiaV3Variant *
fu_struct_qc_gaia_v3_variant_ref(FuStructQcGaiaV3Variant *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_variant_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_variant_unref(FuStructQcGaiaV3Variant *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3Variant refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_variant_new_internal: (skip):
 **/
static FuStructQcGaiaV3Variant *
fu_struct_qc_gaia_v3_variant_new_internal(void)
{
    FuStructQcGaiaV3Variant *st = g_new0(FuStructQcGaiaV3Variant, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_variant_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_variant_get_vendor_id(const FuStructQcGaiaV3Variant *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_variant_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_variant_get_command(const FuStructQcGaiaV3Variant *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_variant_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_variant_to_string(const FuStructQcGaiaV3Variant *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3Variant:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_variant_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_variant_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_variant_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_variant_get_command(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_variant_validate_internal(FuStructQcGaiaV3Variant *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_variant_get_command(st) != FU_QC_GAIA_V3_CMD_GET_VARIANT_RESP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3Variant.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_GET_VARIANT_RESP' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_variant_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_variant_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_variant_parse_internal(FuStructQcGaiaV3Variant *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_variant_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_variant_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_variant_parse: (skip):
 **/
FuStructQcGaiaV3Variant *
fu_struct_qc_gaia_v3_variant_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3Variant) st = fu_struct_qc_gaia_v3_variant_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3Variant: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_qc_gaia_v3_variant_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_ref: (skip):
 **/
FuStructQcGaiaV3GetTransportInfoReq *
fu_struct_qc_gaia_v3_get_transport_info_req_ref(FuStructQcGaiaV3GetTransportInfoReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_get_transport_info_req_unref(FuStructQcGaiaV3GetTransportInfoReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3GetTransportInfoReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_new_internal: (skip):
 **/
static FuStructQcGaiaV3GetTransportInfoReq *
fu_struct_qc_gaia_v3_get_transport_info_req_new_internal(void)
{
    FuStructQcGaiaV3GetTransportInfoReq *st = g_new0(FuStructQcGaiaV3GetTransportInfoReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_get_transport_info_req_set_vendor_id(FuStructQcGaiaV3GetTransportInfoReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_get_transport_info_req_set_command(FuStructQcGaiaV3GetTransportInfoReq *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_set_key: (skip):
 **/
void
fu_struct_qc_gaia_v3_get_transport_info_req_set_key(FuStructQcGaiaV3GetTransportInfoReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_req_new: (skip):
 **/
FuStructQcGaiaV3GetTransportInfoReq *
fu_struct_qc_gaia_v3_get_transport_info_req_new(void)
{
    FuStructQcGaiaV3GetTransportInfoReq *st = fu_struct_qc_gaia_v3_get_transport_info_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_qc_gaia_v3_get_transport_info_req_set_command(st, FU_QC_GAIA_V3_CMD_GET_TRANSPORT_INFO_REQ);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_ref: (skip):
 **/
FuStructQcGaiaV3GetTransportInfo *
fu_struct_qc_gaia_v3_get_transport_info_ref(FuStructQcGaiaV3GetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_get_transport_info_unref(FuStructQcGaiaV3GetTransportInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3GetTransportInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_new_internal: (skip):
 **/
static FuStructQcGaiaV3GetTransportInfo *
fu_struct_qc_gaia_v3_get_transport_info_new_internal(void)
{
    FuStructQcGaiaV3GetTransportInfo *st = g_new0(FuStructQcGaiaV3GetTransportInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_get_transport_info_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_get_transport_info_get_vendor_id(const FuStructQcGaiaV3GetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_get_transport_info_get_command(const FuStructQcGaiaV3GetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_get_key: (skip):
 **/
guint8
fu_struct_qc_gaia_v3_get_transport_info_get_key(const FuStructQcGaiaV3GetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_qc_gaia_v3_get_transport_info_get_value: (skip):
 **/
guint32
fu_struct_qc_gaia_v3_get_transport_info_get_value(const FuStructQcGaiaV3GetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 5, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_get_transport_info_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_get_transport_info_to_string(const FuStructQcGaiaV3GetTransportInfo *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3GetTransportInfo:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_get_transport_info_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_get_transport_info_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_get_transport_info_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_get_transport_info_get_command(st));
        }
    }
    g_string_append_printf(str, "  key: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_get_transport_info_get_key(st));
    g_string_append_printf(str, "  value: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_get_transport_info_get_value(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_get_transport_info_validate_internal(FuStructQcGaiaV3GetTransportInfo *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_get_transport_info_get_command(st) != FU_QC_GAIA_V3_CMD_GET_TRANSPORT_INFO_RESP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3GetTransportInfo.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_GET_TRANSPORT_INFO_RESP' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_get_transport_info_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_get_transport_info_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_get_transport_info_parse_internal(FuStructQcGaiaV3GetTransportInfo *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_get_transport_info_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_get_transport_info_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_get_transport_info_parse: (skip):
 **/
FuStructQcGaiaV3GetTransportInfo *
fu_struct_qc_gaia_v3_get_transport_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3GetTransportInfo) st = fu_struct_qc_gaia_v3_get_transport_info_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 9, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3GetTransportInfo: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 9);
    if (!fu_struct_qc_gaia_v3_get_transport_info_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_ref: (skip):
 **/
FuStructQcGaiaV3SetTransportInfoReq *
fu_struct_qc_gaia_v3_set_transport_info_req_ref(FuStructQcGaiaV3SetTransportInfoReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_set_transport_info_req_unref(FuStructQcGaiaV3SetTransportInfoReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3SetTransportInfoReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_new_internal: (skip):
 **/
static FuStructQcGaiaV3SetTransportInfoReq *
fu_struct_qc_gaia_v3_set_transport_info_req_new_internal(void)
{
    FuStructQcGaiaV3SetTransportInfoReq *st = g_new0(FuStructQcGaiaV3SetTransportInfoReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_set_transport_info_req_set_vendor_id(FuStructQcGaiaV3SetTransportInfoReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_set_transport_info_req_set_command(FuStructQcGaiaV3SetTransportInfoReq *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_set_key: (skip):
 **/
void
fu_struct_qc_gaia_v3_set_transport_info_req_set_key(FuStructQcGaiaV3SetTransportInfoReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_set_value: (skip):
 **/
void
fu_struct_qc_gaia_v3_set_transport_info_req_set_value(FuStructQcGaiaV3SetTransportInfoReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 5, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_req_new: (skip):
 **/
FuStructQcGaiaV3SetTransportInfoReq *
fu_struct_qc_gaia_v3_set_transport_info_req_new(void)
{
    FuStructQcGaiaV3SetTransportInfoReq *st = fu_struct_qc_gaia_v3_set_transport_info_req_new_internal();
    st->buf = g_byte_array_sized_new(9);
    fu_byte_array_set_size(st->buf, 9, 0x0);
    fu_struct_qc_gaia_v3_set_transport_info_req_set_command(st, FU_QC_GAIA_V3_CMD_SET_TRANSPORT_INFO_REQ);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_ref: (skip):
 **/
FuStructQcGaiaV3SetTransportInfo *
fu_struct_qc_gaia_v3_set_transport_info_ref(FuStructQcGaiaV3SetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_set_transport_info_unref(FuStructQcGaiaV3SetTransportInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3SetTransportInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_new_internal: (skip):
 **/
static FuStructQcGaiaV3SetTransportInfo *
fu_struct_qc_gaia_v3_set_transport_info_new_internal(void)
{
    FuStructQcGaiaV3SetTransportInfo *st = g_new0(FuStructQcGaiaV3SetTransportInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_set_transport_info_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_set_transport_info_get_vendor_id(const FuStructQcGaiaV3SetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_set_transport_info_get_command(const FuStructQcGaiaV3SetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_get_key: (skip):
 **/
guint8
fu_struct_qc_gaia_v3_set_transport_info_get_key(const FuStructQcGaiaV3SetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_qc_gaia_v3_set_transport_info_get_value: (skip):
 **/
guint32
fu_struct_qc_gaia_v3_set_transport_info_get_value(const FuStructQcGaiaV3SetTransportInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 5, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_set_transport_info_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_set_transport_info_to_string(const FuStructQcGaiaV3SetTransportInfo *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3SetTransportInfo:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_set_transport_info_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_set_transport_info_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_set_transport_info_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_set_transport_info_get_command(st));
        }
    }
    g_string_append_printf(str, "  key: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_set_transport_info_get_key(st));
    g_string_append_printf(str, "  value: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_set_transport_info_get_value(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_set_transport_info_validate_internal(FuStructQcGaiaV3SetTransportInfo *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_set_transport_info_get_command(st) != FU_QC_GAIA_V3_CMD_SET_TRANSPORT_INFO_RESP) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3SetTransportInfo.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_SET_TRANSPORT_INFO_RESP' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_set_transport_info_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_set_transport_info_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_set_transport_info_parse_internal(FuStructQcGaiaV3SetTransportInfo *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_set_transport_info_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_set_transport_info_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_set_transport_info_parse: (skip):
 **/
FuStructQcGaiaV3SetTransportInfo *
fu_struct_qc_gaia_v3_set_transport_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3SetTransportInfo) st = fu_struct_qc_gaia_v3_set_transport_info_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 9, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3SetTransportInfo: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 9);
    if (!fu_struct_qc_gaia_v3_set_transport_info_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_cmd_ref: (skip):
 **/
FuStructQcGaiaV3UpgradeConnectCmd *
fu_struct_qc_gaia_v3_upgrade_connect_cmd_ref(FuStructQcGaiaV3UpgradeConnectCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_cmd_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_connect_cmd_unref(FuStructQcGaiaV3UpgradeConnectCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3UpgradeConnectCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_cmd_new_internal: (skip):
 **/
static FuStructQcGaiaV3UpgradeConnectCmd *
fu_struct_qc_gaia_v3_upgrade_connect_cmd_new_internal(void)
{
    FuStructQcGaiaV3UpgradeConnectCmd *st = g_new0(FuStructQcGaiaV3UpgradeConnectCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_cmd_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_connect_cmd_set_vendor_id(FuStructQcGaiaV3UpgradeConnectCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_cmd_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_upgrade_connect_cmd_set_command(FuStructQcGaiaV3UpgradeConnectCmd *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_cmd_new: (skip):
 **/
FuStructQcGaiaV3UpgradeConnectCmd *
fu_struct_qc_gaia_v3_upgrade_connect_cmd_new(void)
{
    FuStructQcGaiaV3UpgradeConnectCmd *st = fu_struct_qc_gaia_v3_upgrade_connect_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_qc_gaia_v3_upgrade_connect_cmd_set_command(st, FU_QC_GAIA_V3_CMD_UPGRADE_CONNECT_CMD);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_ref: (skip):
 **/
FuStructQcGaiaV3UpgradeConnectAck *
fu_struct_qc_gaia_v3_upgrade_connect_ack_ref(FuStructQcGaiaV3UpgradeConnectAck *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_connect_ack_unref(FuStructQcGaiaV3UpgradeConnectAck *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3UpgradeConnectAck refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_new_internal: (skip):
 **/
static FuStructQcGaiaV3UpgradeConnectAck *
fu_struct_qc_gaia_v3_upgrade_connect_ack_new_internal(void)
{
    FuStructQcGaiaV3UpgradeConnectAck *st = g_new0(FuStructQcGaiaV3UpgradeConnectAck, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_upgrade_connect_ack_get_vendor_id(const FuStructQcGaiaV3UpgradeConnectAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(const FuStructQcGaiaV3UpgradeConnectAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_upgrade_connect_ack_to_string(const FuStructQcGaiaV3UpgradeConnectAck *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3UpgradeConnectAck:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_upgrade_connect_ack_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_upgrade_connect_ack_validate_internal(FuStructQcGaiaV3UpgradeConnectAck *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(st) != FU_QC_GAIA_V3_CMD_UPGRADE_CONNECT_ACK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3UpgradeConnectAck.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_UPGRADE_CONNECT_ACK' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_upgrade_connect_ack_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_upgrade_connect_ack_parse_internal(FuStructQcGaiaV3UpgradeConnectAck *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_upgrade_connect_ack_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_upgrade_connect_ack_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_upgrade_connect_ack_parse: (skip):
 **/
FuStructQcGaiaV3UpgradeConnectAck *
fu_struct_qc_gaia_v3_upgrade_connect_ack_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3UpgradeConnectAck) st = fu_struct_qc_gaia_v3_upgrade_connect_ack_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3UpgradeConnectAck: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_qc_gaia_v3_upgrade_connect_ack_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_ref: (skip):
 **/
FuStructQcGaiaV3UpgradeDisconnectCmd *
fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_ref(FuStructQcGaiaV3UpgradeDisconnectCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_unref(FuStructQcGaiaV3UpgradeDisconnectCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3UpgradeDisconnectCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_new_internal: (skip):
 **/
static FuStructQcGaiaV3UpgradeDisconnectCmd *
fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_new_internal(void)
{
    FuStructQcGaiaV3UpgradeDisconnectCmd *st = g_new0(FuStructQcGaiaV3UpgradeDisconnectCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_set_vendor_id(FuStructQcGaiaV3UpgradeDisconnectCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_set_command(FuStructQcGaiaV3UpgradeDisconnectCmd *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_new: (skip):
 **/
FuStructQcGaiaV3UpgradeDisconnectCmd *
fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_new(void)
{
    FuStructQcGaiaV3UpgradeDisconnectCmd *st = fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_qc_gaia_v3_upgrade_disconnect_cmd_set_command(st, FU_QC_GAIA_V3_CMD_UPGRADE_DISCONNECT_CMD);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_ref: (skip):
 **/
FuStructQcGaiaV3UpgradeDisconnectAck *
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_ref(FuStructQcGaiaV3UpgradeDisconnectAck *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_unref(FuStructQcGaiaV3UpgradeDisconnectAck *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3UpgradeDisconnectAck refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_new_internal: (skip):
 **/
static FuStructQcGaiaV3UpgradeDisconnectAck *
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_new_internal(void)
{
    FuStructQcGaiaV3UpgradeDisconnectAck *st = g_new0(FuStructQcGaiaV3UpgradeDisconnectAck, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_vendor_id(const FuStructQcGaiaV3UpgradeDisconnectAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(const FuStructQcGaiaV3UpgradeDisconnectAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_to_string(const FuStructQcGaiaV3UpgradeDisconnectAck *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3UpgradeDisconnectAck:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_validate_internal(FuStructQcGaiaV3UpgradeDisconnectAck *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(st) != FU_QC_GAIA_V3_CMD_UPGRADE_DISCONNECT_ACK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3UpgradeDisconnectAck.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_UPGRADE_DISCONNECT_ACK' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_upgrade_disconnect_ack_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_parse_internal(FuStructQcGaiaV3UpgradeDisconnectAck *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_upgrade_disconnect_ack_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_upgrade_disconnect_ack_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_upgrade_disconnect_ack_parse: (skip):
 **/
FuStructQcGaiaV3UpgradeDisconnectAck *
fu_struct_qc_gaia_v3_upgrade_disconnect_ack_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3UpgradeDisconnectAck) st = fu_struct_qc_gaia_v3_upgrade_disconnect_ack_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3UpgradeDisconnectAck: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_qc_gaia_v3_upgrade_disconnect_ack_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_ref: (skip):
 **/
FuStructQcGaiaV3RegisterNotificationCmd *
fu_struct_qc_gaia_v3_register_notification_cmd_ref(FuStructQcGaiaV3RegisterNotificationCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_register_notification_cmd_unref(FuStructQcGaiaV3RegisterNotificationCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3RegisterNotificationCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_new_internal: (skip):
 **/
static FuStructQcGaiaV3RegisterNotificationCmd *
fu_struct_qc_gaia_v3_register_notification_cmd_new_internal(void)
{
    FuStructQcGaiaV3RegisterNotificationCmd *st = g_new0(FuStructQcGaiaV3RegisterNotificationCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_register_notification_cmd_set_vendor_id(FuStructQcGaiaV3RegisterNotificationCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_register_notification_cmd_set_command(FuStructQcGaiaV3RegisterNotificationCmd *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_set_feature: (skip):
 **/
static void
fu_struct_qc_gaia_v3_register_notification_cmd_set_feature(FuStructQcGaiaV3RegisterNotificationCmd *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_qc_gaia_v3_register_notification_cmd_new: (skip):
 **/
FuStructQcGaiaV3RegisterNotificationCmd *
fu_struct_qc_gaia_v3_register_notification_cmd_new(void)
{
    FuStructQcGaiaV3RegisterNotificationCmd *st = fu_struct_qc_gaia_v3_register_notification_cmd_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_qc_gaia_v3_register_notification_cmd_set_command(st, FU_QC_GAIA_V3_CMD_REGISTER_NOTIFICATION_CMD);
    fu_struct_qc_gaia_v3_register_notification_cmd_set_feature(st, 0x06);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_register_notification_ack_ref: (skip):
 **/
FuStructQcGaiaV3RegisterNotificationAck *
fu_struct_qc_gaia_v3_register_notification_ack_ref(FuStructQcGaiaV3RegisterNotificationAck *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_register_notification_ack_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_register_notification_ack_unref(FuStructQcGaiaV3RegisterNotificationAck *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3RegisterNotificationAck refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_register_notification_ack_new_internal: (skip):
 **/
static FuStructQcGaiaV3RegisterNotificationAck *
fu_struct_qc_gaia_v3_register_notification_ack_new_internal(void)
{
    FuStructQcGaiaV3RegisterNotificationAck *st = g_new0(FuStructQcGaiaV3RegisterNotificationAck, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_register_notification_ack_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_register_notification_ack_get_vendor_id(const FuStructQcGaiaV3RegisterNotificationAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_register_notification_ack_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_register_notification_ack_get_command(const FuStructQcGaiaV3RegisterNotificationAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_register_notification_ack_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_register_notification_ack_to_string(const FuStructQcGaiaV3RegisterNotificationAck *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3RegisterNotificationAck:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_register_notification_ack_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_register_notification_ack_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_register_notification_ack_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_register_notification_ack_get_command(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_register_notification_ack_validate_internal(FuStructQcGaiaV3RegisterNotificationAck *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_register_notification_ack_get_command(st) != FU_QC_GAIA_V3_CMD_REGISTER_NOTIFICATION_ACK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3RegisterNotificationAck.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_REGISTER_NOTIFICATION_ACK' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_register_notification_ack_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_register_notification_ack_get_command(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_register_notification_ack_parse_internal(FuStructQcGaiaV3RegisterNotificationAck *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_register_notification_ack_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_register_notification_ack_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_register_notification_ack_parse: (skip):
 **/
FuStructQcGaiaV3RegisterNotificationAck *
fu_struct_qc_gaia_v3_register_notification_ack_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3RegisterNotificationAck) st = fu_struct_qc_gaia_v3_register_notification_ack_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 4, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3RegisterNotificationAck: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_struct_qc_gaia_v3_register_notification_ack_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_cmd_ref: (skip):
 **/
FuStructQcGaiaV3UpgradeControlCmd *
fu_struct_qc_gaia_v3_upgrade_control_cmd_ref(FuStructQcGaiaV3UpgradeControlCmd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_cmd_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_control_cmd_unref(FuStructQcGaiaV3UpgradeControlCmd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3UpgradeControlCmd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_cmd_new_internal: (skip):
 **/
static FuStructQcGaiaV3UpgradeControlCmd *
fu_struct_qc_gaia_v3_upgrade_control_cmd_new_internal(void)
{
    FuStructQcGaiaV3UpgradeControlCmd *st = g_new0(FuStructQcGaiaV3UpgradeControlCmd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_qc_gaia_v3_upgrade_control_cmd_set_vendor_id: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_control_cmd_set_vendor_id(FuStructQcGaiaV3UpgradeControlCmd *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_cmd_set_command: (skip):
 **/
static void
fu_struct_qc_gaia_v3_upgrade_control_cmd_set_command(FuStructQcGaiaV3UpgradeControlCmd *st, FuQcGaiaV3Cmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_cmd_new: (skip):
 **/
FuStructQcGaiaV3UpgradeControlCmd *
fu_struct_qc_gaia_v3_upgrade_control_cmd_new(void)
{
    FuStructQcGaiaV3UpgradeControlCmd *st = fu_struct_qc_gaia_v3_upgrade_control_cmd_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_struct_qc_gaia_v3_upgrade_control_cmd_set_command(st, FU_QC_GAIA_V3_CMD_UPGRADE_CONTROL_CMD);
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_ref: (skip):
 **/
FuStructQcGaiaV3UpgradeControlAck *
fu_struct_qc_gaia_v3_upgrade_control_ack_ref(FuStructQcGaiaV3UpgradeControlAck *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_unref: (skip):
 **/
void
fu_struct_qc_gaia_v3_upgrade_control_ack_unref(FuStructQcGaiaV3UpgradeControlAck *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructQcGaiaV3UpgradeControlAck refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_new_internal: (skip):
 **/
static FuStructQcGaiaV3UpgradeControlAck *
fu_struct_qc_gaia_v3_upgrade_control_ack_new_internal(void)
{
    FuStructQcGaiaV3UpgradeControlAck *st = g_new0(FuStructQcGaiaV3UpgradeControlAck, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_get_vendor_id: (skip):
 **/
guint16
fu_struct_qc_gaia_v3_upgrade_control_ack_get_vendor_id(const FuStructQcGaiaV3UpgradeControlAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_get_command: (skip):
 **/
static FuQcGaiaV3Cmd
fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(const FuStructQcGaiaV3UpgradeControlAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_get_status: (skip):
 **/
static FuQcGaiaCmdStatus
fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(const FuStructQcGaiaV3UpgradeControlAck *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}

/* setters */
/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_to_string: (skip):
 **/
static gchar *
fu_struct_qc_gaia_v3_upgrade_control_ack_to_string(const FuStructQcGaiaV3UpgradeControlAck *st)
{
    g_autoptr(GString) str = g_string_new("FuStructQcGaiaV3UpgradeControlAck:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  vendorId: 0x%x\n",
                           (guint) fu_struct_qc_gaia_v3_upgrade_control_ack_get_vendor_id(st));
    {
        const gchar *tmp = fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  command: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(st), tmp);
        } else {
            g_string_append_printf(str, "  command: 0x%x\n", (guint) fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(st));
        }
    }
    {
        const gchar *tmp = fu_qc_gaia_cmd_status_to_string(fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  status: 0x%x [%s]\n", (guint) fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(st), tmp);
        } else {
            g_string_append_printf(str, "  status: 0x%x\n", (guint) fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_qc_gaia_v3_upgrade_control_ack_validate_internal(FuStructQcGaiaV3UpgradeControlAck *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(st) != FU_QC_GAIA_V3_CMD_UPGRADE_CONTROL_ACK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3UpgradeControlAck.command was not valid, "
                    "expected 'FU_QC_GAIA_V3_CMD_UPGRADE_CONTROL_ACK' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(st),
                    fu_qc_gaia_v3_cmd_to_string(fu_struct_qc_gaia_v3_upgrade_control_ack_get_command(st)));
        return FALSE;
    }
    if (fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(st) != FU_QC_GAIA_CMD_STATUS_SUCCESS) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructQcGaiaV3UpgradeControlAck.status was not valid, "
                    "expected 'FU_QC_GAIA_CMD_STATUS_SUCCESS' and got 0x%x '%s'",
                    fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(st),
                    fu_qc_gaia_cmd_status_to_string(fu_struct_qc_gaia_v3_upgrade_control_ack_get_status(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_qc_gaia_v3_upgrade_control_ack_parse_internal(FuStructQcGaiaV3UpgradeControlAck *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_qc_gaia_v3_upgrade_control_ack_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_qc_gaia_v3_upgrade_control_ack_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_qc_gaia_v3_upgrade_control_ack_parse: (skip):
 **/
FuStructQcGaiaV3UpgradeControlAck *
fu_struct_qc_gaia_v3_upgrade_control_ack_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructQcGaiaV3UpgradeControlAck) st = fu_struct_qc_gaia_v3_upgrade_control_ack_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 5, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructQcGaiaV3UpgradeControlAck: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 5);
    if (!fu_struct_qc_gaia_v3_upgrade_control_ack_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
