diff --git a/libdfu/dfu-common.c b/libdfu/dfu-common.c index fa993a4fc..27b018c13 100644 --- a/libdfu/dfu-common.c +++ b/libdfu/dfu-common.c @@ -155,3 +155,25 @@ dfu_cipher_kind_to_string (DfuCipherKind cipher_kind) return "xtea"; return NULL; } + +/** + * dfu_version_to_string: + * @version: a #DfuVersion, e.g. %DFU_VERSION_DFU_1_1 + * + * Converts an enumerated value to a string. + * + * Return value: a string + * + * Since: 0.7.2 + **/ +const gchar * +dfu_version_to_string (DfuVersion version) +{ + if (version == DFU_VERSION_DFU_1_0) + return "1.0"; + if (version == DFU_VERSION_DFU_1_1) + return "1.1"; + if (version == DFU_VERSION_DFUSE) + return "DfuSe"; + return NULL; +} diff --git a/libdfu/dfu-common.h b/libdfu/dfu-common.h index 9867500ae..a31a663e4 100644 --- a/libdfu/dfu-common.h +++ b/libdfu/dfu-common.h @@ -155,6 +155,24 @@ typedef enum { DFU_CIPHER_KIND_LAST } DfuCipherKind; +/** + * DfuVersion: + * @DFU_VERSION_UNKNOWN: Format unknown + * @DFU_VERSION_DFU_1_0: DFU 1.0 + * @DFU_VERSION_DFU_1_1: DFU 1.1 + * @DFU_VERSION_DFUSE: DfuSe + * + * The known versions of the DFU standard in BCD format. + **/ +typedef enum { + DFU_VERSION_UNKNOWN = 0, + DFU_VERSION_DFU_1_0 = 0x0100, + DFU_VERSION_DFU_1_1 = 0x0110, + DFU_VERSION_DFUSE = 0x011a, + /*< private >*/ + DFU_VERSION_LAST +} DfuVersion; + #define DFU_METADATA_KEY_LICENSE "License" #define DFU_METADATA_KEY_COPYRIGHT "Copyright" #define DFU_METADATA_KEY_CIPHER_KIND "CipherKind" @@ -163,6 +181,7 @@ const gchar *dfu_state_to_string (DfuState state); const gchar *dfu_status_to_string (DfuStatus status); const gchar *dfu_mode_to_string (DfuMode mode); const gchar *dfu_cipher_kind_to_string (DfuCipherKind cipher_kind); +const gchar *dfu_version_to_string (DfuVersion version); G_END_DECLS