## dfu-common dfu-common — Common functions for DFU |

## Functions

const gchar * | dfu_state_to_string ()
const gchar * | dfu_status_to_string ()
const gchar * | dfu_mode_to_string ()
const gchar * | dfu_cipher_kind_to_string ()
const gchar * | dfu_version_to_string ()
const gchar * | dfu_action_to_string ()

## Types and Values

enum | DfuRequest
enum | DfuStatus
enum | DfuState
enum | DfuMode
enum | DfuCipherKind
enum | DfuVersion
enum | DfuAction
#define | DFU_METADATA_KEY_LICENSE
#define | DFU_METADATA_KEY_COPYRIGHT
#define | DFU_METADATA_KEY_CIPHER_KIND

## Description

These helper objects allow converting from enum values to strings.

## Functions

### dfu_state_to_string ()

    const gchar *
    dfu_state_to_string (DfuState state);

Converts an enumerated value to a string.

#### Parameters

state | a DfuState, e.g. `DFU_STATE_DFU_MANIFEST` |

#### Returns

a string

Since: 0.5.4

### dfu_status_to_string ()

    const gchar *
    dfu_status_to_string (DfuStatus status);

Converts an enumerated value to a string.

#### Parameters

status | a DfuStatus, e.g. `DFU_STATUS_ERR_ERASE` |

#### Returns

a string

Since: 0.5.4

### dfu_mode_to_string ()

    const gchar *
    dfu_mode_to_string (DfuMode mode);

Converts an enumerated value to a string.

#### Parameters

mode | a DfuMode, e.g. `DFU_MODE_RUNTIME` |

#### Returns

a string

Since: 0.5.4

### dfu_cipher_kind_to_string ()

    const gchar *
    dfu_cipher_kind_to_string (DfuCipherKind cipher_kind);

Converts an enumerated value to a string.

#### Parameters

cipher_kind | a DfuCipherKind, e.g. `DFU_CIPHER_KIND_XTEA` |

#### Returns

a string

Since: 0.5.4

### dfu_version_to_string ()

    const gchar *
    dfu_version_to_string (DfuVersion version);

Converts an enumerated value to a string.

#### Parameters

version | a DfuVersion, e.g. `DFU_VERSION_DFU_1_1` |

#### Returns

a string

Since: 0.7.2

### dfu_action_to_string ()

    const gchar *
    dfu_action_to_string (DfuAction action);

Converts an enumerated value to a string.

#### Parameters

action | a DfuAction, e.g. `DFU_ACTION_VERIFY` |

#### Returns

a string

Since: 0.7.5

## Types and Values

### enum DfuRequest

The DFU request kinds.

#### Members

DFU_REQUEST_DETACH | Detach |
DFU_REQUEST_DNLOAD | Download host-to-device |
DFU_REQUEST_UPLOAD | Upload device-to-host |
DFU_REQUEST_GETSTATUS | Get the device status |
DFU_REQUEST_CLRSTATUS | Clear the device status |
DFU_REQUEST_GETSTATE | Get the last set state |
DFU_REQUEST_ABORT | Abort the current transfer |

### enum DfuStatus

The status enumerated kind.

#### Members

DFU_STATUS_OK | No error condition is present |
DFU_STATUS_ERR_TARGET | File is not targeted for use by this device |
DFU_STATUS_ERR_FILE | File is for this device but fails a verification test |
DFU_STATUS_ERR_WRITE | Device is unable to write memory |
DFU_STATUS_ERR_ERASE | Memory erase function failed |
DFU_STATUS_ERR_CHECK_ERASED | Memory erase check failed |
DFU_STATUS_ERR_PROG | Program memory function failed |
DFU_STATUS_ERR_VERIFY | Programmed memory failed verification |
DFU_STATUS_ERR_ADDRESS | Cannot program memory due to received address that isout of range |
DFU_STATUS_ERR_NOTDONE | Received DFU_DNLOAD with wLength = 0 but data is incomplete |
DFU_STATUS_ERR_FIRMWARE | Device firmware is corrupt |
DFU_STATUS_ERR_VENDOR | iString indicates a vendor-specific error |
DFU_STATUS_ERR_USBR | Device detected unexpected USB reset signaling |
DFU_STATUS_ERR_POR | Device detected unexpected power on reset |
DFU_STATUS_ERR_UNKNOWN | Something unexpected went wrong |
DFU_STATUS_ERR_STALLDPKT | Device stalled an unexpected request |

### enum DfuState

The state enumerated kind.

#### Members

DFU_STATE_APP_IDLE | State 0 |
DFU_STATE_APP_DETACH | State 1 |
DFU_STATE_DFU_IDLE | State 2 |
DFU_STATE_DFU_DNLOAD_SYNC | State 3 |
DFU_STATE_DFU_DNBUSY | State 4 |
DFU_STATE_DFU_DNLOAD_IDLE | State 5 |
DFU_STATE_DFU_MANIFEST_SYNC | State 6 |
DFU_STATE_DFU_MANIFEST | State 7 |
DFU_STATE_DFU_MANIFEST_WAIT_RESET | State 8 |
DFU_STATE_DFU_UPLOAD_IDLE | State 9 |
DFU_STATE_DFU_ERROR | State 10 |

### enum DfuMode

The mode enumerated kind.

#### Members

DFU_MODE_UNKNOWN | Unknown mode |
DFU_MODE_RUNTIME | Runtime mode |
DFU_MODE_DFU | Bootloader mode |

### enum DfuCipherKind

The type of cipher used for transfering the firmware.

#### Members

DFU_CIPHER_KIND_NONE | No cipher detected |
DFU_CIPHER_KIND_XTEA | XTEA cipher detected |
DFU_CIPHER_KIND_DEVO | DEVO cipher detected |
DFU_CIPHER_KIND_RSA | RSA cipher detected |

### enum DfuVersion

The known versions of the DFU standard in BCD format.

#### Members

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 |

### enum DfuAction

The device DFU attributes.

#### Members

DFU_ACTION_UNKNOWN | No progress state |
DFU_ACTION_IDLE | Device is idle |
DFU_ACTION_READ | Reading from the device |
DFU_ACTION_WRITE | Writing to the device |
DFU_ACTION_VERIFY | Verifying the write |
DFU_ACTION_ERASE | Erasing the device |
DFU_ACTION_DETACH | Detach into DFU mode |
DFU_ACTION_ATTACH | Attach into APP mode |

### DFU_METADATA_KEY_LICENSE

    #define DFU_METADATA_KEY_LICENSE		"License"

### DFU_METADATA_KEY_COPYRIGHT

    #define DFU_METADATA_KEY_COPYRIGHT		"Copyright"

### DFU_METADATA_KEY_CIPHER_KIND

    #define DFU_METADATA_KEY_CIPHER_KIND		"CipherKind"