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

#include "config.h"

#include <glib.h>

#include "fu-blestech-tp-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_blestech_tp_set_hdr_ref: (skip):
 **/
FuBlestechTpSetHdr *
fu_blestech_tp_set_hdr_ref(FuBlestechTpSetHdr *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_set_hdr_unref: (skip):
 **/
void
fu_blestech_tp_set_hdr_unref(FuBlestechTpSetHdr *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpSetHdr refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_set_hdr_new_internal: (skip):
 **/
static FuBlestechTpSetHdr *
fu_blestech_tp_set_hdr_new_internal(void)
{
    FuBlestechTpSetHdr *st = g_new0(FuBlestechTpSetHdr, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_set_hdr_set_report_id: (skip):
 **/
void
fu_blestech_tp_set_hdr_set_report_id(FuBlestechTpSetHdr *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_set_hdr_set_pack_len: (skip):
 **/
void
fu_blestech_tp_set_hdr_set_pack_len(FuBlestechTpSetHdr *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_blestech_tp_set_hdr_set_checksum: (skip):
 **/
void
fu_blestech_tp_set_hdr_set_checksum(FuBlestechTpSetHdr *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_blestech_tp_set_hdr_set_frame_flag: (skip):
 **/
static void
fu_blestech_tp_set_hdr_set_frame_flag(FuBlestechTpSetHdr *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_blestech_tp_set_hdr_set_write_len: (skip):
 **/
void
fu_blestech_tp_set_hdr_set_write_len(FuBlestechTpSetHdr *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 4, value, G_BIG_ENDIAN);
}
/**
 * fu_blestech_tp_set_hdr_set_read_len: (skip):
 **/
void
fu_blestech_tp_set_hdr_set_read_len(FuBlestechTpSetHdr *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 6, value, G_BIG_ENDIAN);
}
/**
 * fu_blestech_tp_set_hdr_set_data: (skip):
 **/
gboolean
fu_blestech_tp_set_hdr_set_data(FuBlestechTpSetHdr *st, const guint8 *buf, gsize bufsz, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    return fu_memcpy_safe(st->buf->data, st->buf->len, 8, buf, bufsz, 0x0, bufsz, error);
}
/**
 * fu_blestech_tp_set_hdr_new: (skip):
 **/
FuBlestechTpSetHdr *
fu_blestech_tp_set_hdr_new(void)
{
    FuBlestechTpSetHdr *st = fu_blestech_tp_set_hdr_new_internal();
    st->buf = g_byte_array_sized_new(33);
    fu_byte_array_set_size(st->buf, 33, 0x0);
    fu_blestech_tp_set_hdr_set_frame_flag(st, 0);
    return st;
}
/**
 * fu_blestech_tp_update_start_req_ref: (skip):
 **/
FuBlestechTpUpdateStartReq *
fu_blestech_tp_update_start_req_ref(FuBlestechTpUpdateStartReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_update_start_req_unref: (skip):
 **/
void
fu_blestech_tp_update_start_req_unref(FuBlestechTpUpdateStartReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpUpdateStartReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_update_start_req_new_internal: (skip):
 **/
static FuBlestechTpUpdateStartReq *
fu_blestech_tp_update_start_req_new_internal(void)
{
    FuBlestechTpUpdateStartReq *st = g_new0(FuBlestechTpUpdateStartReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_update_start_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_update_start_req_set_cmd(FuBlestechTpUpdateStartReq *st, FuBlestechTpCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_update_start_req_set_magic_num: (skip):
 **/
static void
fu_blestech_tp_update_start_req_set_magic_num(FuBlestechTpUpdateStartReq *st, guint64 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint64(st->buf->data + 1, value, G_BIG_ENDIAN);
}
/**
 * fu_blestech_tp_update_start_req_new: (skip):
 **/
FuBlestechTpUpdateStartReq *
fu_blestech_tp_update_start_req_new(void)
{
    FuBlestechTpUpdateStartReq *st = fu_blestech_tp_update_start_req_new_internal();
    st->buf = g_byte_array_sized_new(9);
    fu_byte_array_set_size(st->buf, 9, 0x0);
    fu_blestech_tp_update_start_req_set_cmd(st, FU_BLESTECH_TP_CMD_UPDATE_START_REQ);
    fu_blestech_tp_update_start_req_set_magic_num(st, 0x7565554563756933);
    return st;
}
/**
 * fu_blestech_tp_switch_boot_req_ref: (skip):
 **/
FuBlestechTpSwitchBootReq *
fu_blestech_tp_switch_boot_req_ref(FuBlestechTpSwitchBootReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_switch_boot_req_unref: (skip):
 **/
void
fu_blestech_tp_switch_boot_req_unref(FuBlestechTpSwitchBootReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpSwitchBootReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_switch_boot_req_new_internal: (skip):
 **/
static FuBlestechTpSwitchBootReq *
fu_blestech_tp_switch_boot_req_new_internal(void)
{
    FuBlestechTpSwitchBootReq *st = g_new0(FuBlestechTpSwitchBootReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_switch_boot_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_switch_boot_req_set_cmd(FuBlestechTpSwitchBootReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_blestech_tp_switch_boot_req_new: (skip):
 **/
FuBlestechTpSwitchBootReq *
fu_blestech_tp_switch_boot_req_new(void)
{
    FuBlestechTpSwitchBootReq *st = fu_blestech_tp_switch_boot_req_new_internal();
    st->buf = g_byte_array_sized_new(4);
    fu_byte_array_set_size(st->buf, 4, 0x0);
    fu_blestech_tp_switch_boot_req_set_cmd(st, 0xffff5aa5);
    return st;
}
/**
 * fu_blestech_tp_get_fw_ver_req_ref: (skip):
 **/
FuBlestechTpGetFwVerReq *
fu_blestech_tp_get_fw_ver_req_ref(FuBlestechTpGetFwVerReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_get_fw_ver_req_unref: (skip):
 **/
void
fu_blestech_tp_get_fw_ver_req_unref(FuBlestechTpGetFwVerReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpGetFwVerReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_get_fw_ver_req_new_internal: (skip):
 **/
static FuBlestechTpGetFwVerReq *
fu_blestech_tp_get_fw_ver_req_new_internal(void)
{
    FuBlestechTpGetFwVerReq *st = g_new0(FuBlestechTpGetFwVerReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_get_fw_ver_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_get_fw_ver_req_set_cmd(FuBlestechTpGetFwVerReq *st, FuBlestechTpCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_get_fw_ver_req_new: (skip):
 **/
FuBlestechTpGetFwVerReq *
fu_blestech_tp_get_fw_ver_req_new(void)
{
    FuBlestechTpGetFwVerReq *st = fu_blestech_tp_get_fw_ver_req_new_internal();
    st->buf = g_byte_array_sized_new(1);
    fu_byte_array_set_size(st->buf, 1, 0x0);
    fu_blestech_tp_get_fw_ver_req_set_cmd(st, FU_BLESTECH_TP_CMD_GET_FW_VER);
    return st;
}
/**
 * fu_blestech_tp_get_fw_ver_res_ref: (skip):
 **/
FuBlestechTpGetFwVerRes *
fu_blestech_tp_get_fw_ver_res_ref(FuBlestechTpGetFwVerRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_get_fw_ver_res_unref: (skip):
 **/
void
fu_blestech_tp_get_fw_ver_res_unref(FuBlestechTpGetFwVerRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpGetFwVerRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_get_fw_ver_res_new_internal: (skip):
 **/
static FuBlestechTpGetFwVerRes *
fu_blestech_tp_get_fw_ver_res_new_internal(void)
{
    FuBlestechTpGetFwVerRes *st = g_new0(FuBlestechTpGetFwVerRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_blestech_tp_get_fw_ver_res_get_val: (skip):
 **/
guint16
fu_blestech_tp_get_fw_ver_res_get_val(const FuBlestechTpGetFwVerRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_blestech_tp_get_fw_ver_res_to_string: (skip):
 **/
static gchar *
fu_blestech_tp_get_fw_ver_res_to_string(const FuBlestechTpGetFwVerRes *st)
{
    g_autoptr(GString) str = g_string_new("FuBlestechTpGetFwVerRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  val: 0x%x\n",
                           (guint) fu_blestech_tp_get_fw_ver_res_get_val(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_blestech_tp_get_fw_ver_res_validate_internal(FuBlestechTpGetFwVerRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_blestech_tp_get_fw_ver_res_parse_internal(FuBlestechTpGetFwVerRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_blestech_tp_get_fw_ver_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_blestech_tp_get_fw_ver_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_blestech_tp_get_fw_ver_res_parse: (skip):
 **/
FuBlestechTpGetFwVerRes *
fu_blestech_tp_get_fw_ver_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuBlestechTpGetFwVerRes) st = fu_blestech_tp_get_fw_ver_res_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, 7, error)) {
        g_prefix_error_literal(error, "invalid struct FuBlestechTpGetFwVerRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 7);
    if (!fu_blestech_tp_get_fw_ver_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_blestech_tp_program_end_req_ref: (skip):
 **/
FuBlestechTpProgramEndReq *
fu_blestech_tp_program_end_req_ref(FuBlestechTpProgramEndReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_program_end_req_unref: (skip):
 **/
void
fu_blestech_tp_program_end_req_unref(FuBlestechTpProgramEndReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpProgramEndReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_program_end_req_new_internal: (skip):
 **/
static FuBlestechTpProgramEndReq *
fu_blestech_tp_program_end_req_new_internal(void)
{
    FuBlestechTpProgramEndReq *st = g_new0(FuBlestechTpProgramEndReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_program_end_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_program_end_req_set_cmd(FuBlestechTpProgramEndReq *st, FuBlestechTpCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_program_end_req_new: (skip):
 **/
FuBlestechTpProgramEndReq *
fu_blestech_tp_program_end_req_new(void)
{
    FuBlestechTpProgramEndReq *st = fu_blestech_tp_program_end_req_new_internal();
    st->buf = g_byte_array_sized_new(1);
    fu_byte_array_set_size(st->buf, 1, 0x0);
    fu_blestech_tp_program_end_req_set_cmd(st, FU_BLESTECH_TP_CMD_PROGRAM_END);
    return st;
}
/**
 * fu_blestech_tp_program_checksum_req_ref: (skip):
 **/
FuBlestechTpProgramChecksumReq *
fu_blestech_tp_program_checksum_req_ref(FuBlestechTpProgramChecksumReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_program_checksum_req_unref: (skip):
 **/
void
fu_blestech_tp_program_checksum_req_unref(FuBlestechTpProgramChecksumReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpProgramChecksumReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_program_checksum_req_new_internal: (skip):
 **/
static FuBlestechTpProgramChecksumReq *
fu_blestech_tp_program_checksum_req_new_internal(void)
{
    FuBlestechTpProgramChecksumReq *st = g_new0(FuBlestechTpProgramChecksumReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_program_checksum_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_program_checksum_req_set_cmd(FuBlestechTpProgramChecksumReq *st, FuBlestechTpCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_program_checksum_req_set_val: (skip):
 **/
void
fu_blestech_tp_program_checksum_req_set_val(FuBlestechTpProgramChecksumReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_blestech_tp_program_checksum_req_new: (skip):
 **/
FuBlestechTpProgramChecksumReq *
fu_blestech_tp_program_checksum_req_new(void)
{
    FuBlestechTpProgramChecksumReq *st = fu_blestech_tp_program_checksum_req_new_internal();
    st->buf = g_byte_array_sized_new(3);
    fu_byte_array_set_size(st->buf, 3, 0x0);
    fu_blestech_tp_program_checksum_req_set_cmd(st, FU_BLESTECH_TP_CMD_PROGRAM_CHECKSUM);
    return st;
}
/**
 * fu_blestech_tp_program_checksum_res_ref: (skip):
 **/
FuBlestechTpProgramChecksumRes *
fu_blestech_tp_program_checksum_res_ref(FuBlestechTpProgramChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_program_checksum_res_unref: (skip):
 **/
void
fu_blestech_tp_program_checksum_res_unref(FuBlestechTpProgramChecksumRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpProgramChecksumRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_program_checksum_res_new_internal: (skip):
 **/
static FuBlestechTpProgramChecksumRes *
fu_blestech_tp_program_checksum_res_new_internal(void)
{
    FuBlestechTpProgramChecksumRes *st = g_new0(FuBlestechTpProgramChecksumRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_blestech_tp_program_checksum_res_get_val: (skip):
 **/
guint16
fu_blestech_tp_program_checksum_res_get_val(const FuBlestechTpProgramChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 1, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_blestech_tp_program_checksum_res_to_string: (skip):
 **/
static gchar *
fu_blestech_tp_program_checksum_res_to_string(const FuBlestechTpProgramChecksumRes *st)
{
    g_autoptr(GString) str = g_string_new("FuBlestechTpProgramChecksumRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  val: 0x%x\n",
                           (guint) fu_blestech_tp_program_checksum_res_get_val(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_blestech_tp_program_checksum_res_validate_internal(FuBlestechTpProgramChecksumRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_blestech_tp_program_checksum_res_parse_internal(FuBlestechTpProgramChecksumRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_blestech_tp_program_checksum_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_blestech_tp_program_checksum_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_blestech_tp_program_checksum_res_parse: (skip):
 **/
FuBlestechTpProgramChecksumRes *
fu_blestech_tp_program_checksum_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuBlestechTpProgramChecksumRes) st = fu_blestech_tp_program_checksum_res_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 FuBlestechTpProgramChecksumRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 4);
    if (!fu_blestech_tp_program_checksum_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_blestech_tp_program_page_end_req_ref: (skip):
 **/
FuBlestechTpProgramPageEndReq *
fu_blestech_tp_program_page_end_req_ref(FuBlestechTpProgramPageEndReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_program_page_end_req_unref: (skip):
 **/
void
fu_blestech_tp_program_page_end_req_unref(FuBlestechTpProgramPageEndReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpProgramPageEndReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_program_page_end_req_new_internal: (skip):
 **/
static FuBlestechTpProgramPageEndReq *
fu_blestech_tp_program_page_end_req_new_internal(void)
{
    FuBlestechTpProgramPageEndReq *st = g_new0(FuBlestechTpProgramPageEndReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_program_page_end_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_program_page_end_req_set_cmd(FuBlestechTpProgramPageEndReq *st, FuBlestechTpCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_program_page_end_req_set_page: (skip):
 **/
void
fu_blestech_tp_program_page_end_req_set_page(FuBlestechTpProgramPageEndReq *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_blestech_tp_program_page_end_req_new: (skip):
 **/
FuBlestechTpProgramPageEndReq *
fu_blestech_tp_program_page_end_req_new(void)
{
    FuBlestechTpProgramPageEndReq *st = fu_blestech_tp_program_page_end_req_new_internal();
    st->buf = g_byte_array_sized_new(3);
    fu_byte_array_set_size(st->buf, 3, 0x0);
    fu_blestech_tp_program_page_end_req_set_cmd(st, FU_BLESTECH_TP_CMD_PROGRAM_PAGE_END);
    return st;
}
/**
 * fu_blestech_tp_program_page_end_res_ref: (skip):
 **/
FuBlestechTpProgramPageEndRes *
fu_blestech_tp_program_page_end_res_ref(FuBlestechTpProgramPageEndRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_program_page_end_res_unref: (skip):
 **/
void
fu_blestech_tp_program_page_end_res_unref(FuBlestechTpProgramPageEndRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpProgramPageEndRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_program_page_end_res_new_internal: (skip):
 **/
static FuBlestechTpProgramPageEndRes *
fu_blestech_tp_program_page_end_res_new_internal(void)
{
    FuBlestechTpProgramPageEndRes *st = g_new0(FuBlestechTpProgramPageEndRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_blestech_tp_program_page_end_res_get_checksum: (skip):
 **/
guint8
fu_blestech_tp_program_page_end_res_get_checksum(const FuBlestechTpProgramPageEndRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}

/* setters */
/**
 * fu_blestech_tp_program_page_end_res_to_string: (skip):
 **/
static gchar *
fu_blestech_tp_program_page_end_res_to_string(const FuBlestechTpProgramPageEndRes *st)
{
    g_autoptr(GString) str = g_string_new("FuBlestechTpProgramPageEndRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  checksum: 0x%x\n",
                           (guint) fu_blestech_tp_program_page_end_res_get_checksum(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_blestech_tp_program_page_end_res_validate_internal(FuBlestechTpProgramPageEndRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_blestech_tp_program_page_end_res_parse_internal(FuBlestechTpProgramPageEndRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_blestech_tp_program_page_end_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_blestech_tp_program_page_end_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_blestech_tp_program_page_end_res_parse: (skip):
 **/
FuBlestechTpProgramPageEndRes *
fu_blestech_tp_program_page_end_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuBlestechTpProgramPageEndRes) st = fu_blestech_tp_program_page_end_res_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, 3, error)) {
        g_prefix_error_literal(error, "invalid struct FuBlestechTpProgramPageEndRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 3);
    if (!fu_blestech_tp_program_page_end_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_blestech_tp_program_page_req_ref: (skip):
 **/
FuBlestechTpProgramPageReq *
fu_blestech_tp_program_page_req_ref(FuBlestechTpProgramPageReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_blestech_tp_program_page_req_unref: (skip):
 **/
void
fu_blestech_tp_program_page_req_unref(FuBlestechTpProgramPageReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuBlestechTpProgramPageReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_blestech_tp_program_page_req_new_internal: (skip):
 **/
static FuBlestechTpProgramPageReq *
fu_blestech_tp_program_page_req_new_internal(void)
{
    FuBlestechTpProgramPageReq *st = g_new0(FuBlestechTpProgramPageReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_blestech_tp_program_page_req_set_cmd: (skip):
 **/
static void
fu_blestech_tp_program_page_req_set_cmd(FuBlestechTpProgramPageReq *st, FuBlestechTpCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_blestech_tp_program_page_req_set_data: (skip):
 **/
gboolean
fu_blestech_tp_program_page_req_set_data(FuBlestechTpProgramPageReq *st, const guint8 *buf, gsize bufsz, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    return fu_memcpy_safe(st->buf->data, st->buf->len, 1, buf, bufsz, 0x0, bufsz, error);
}
/**
 * fu_blestech_tp_program_page_req_new: (skip):
 **/
FuBlestechTpProgramPageReq *
fu_blestech_tp_program_page_req_new(void)
{
    FuBlestechTpProgramPageReq *st = fu_blestech_tp_program_page_req_new_internal();
    st->buf = g_byte_array_sized_new(25);
    fu_byte_array_set_size(st->buf, 25, 0x0);
    fu_blestech_tp_program_page_req_set_cmd(st, FU_BLESTECH_TP_CMD_PROGRAM_PAGE);
    return st;
}
