## DfuTarget DfuTarget — Object representing a DFU-capable target |

## Functions

GPtrArray * | dfu_target_get_sectors ()
guint8 | dfu_target_get_alt_setting ()
const gchar * | dfu_target_get_alt_name ()
const gchar * | dfu_target_get_alt_name_for_display ()
DfuImage * | dfu_target_upload ()
gboolean | dfu_target_download ()
DfuCipherKind | dfu_target_get_cipher_kind ()

## Types and Values

#define | DFU_TYPE_TARGET
struct | DfuTargetClass
enum | DfuTargetTransferFlags
| DfuTarget

## Description

This object allows uploading and downloading an image onto a specific DFU-capable target.

You only need to use this in preference to DfuDevice if you only want to update one target on the device. Most users will want to update all the targets on the device at the same time.

See also: DfuDevice, DfuImage

## Functions

### dfu_target_get_sectors ()

    GPtrArray *
    dfu_target_get_sectors (DfuTarget *target);

Gets the sectors exported by the device.

#### Parameters

target | a GUsbDevice |

#### Returns

sectors.

[transfer none][element-type DfuSector]

Since: 0.5.4

### dfu_target_get_alt_setting ()

    guint8
    dfu_target_get_alt_setting (DfuTarget *target);

Gets the alternate setting to use for this interface.

#### Parameters

target | a DfuTarget |

#### Returns

the alternative setting, typically zero

Since: 0.5.4

### dfu_target_get_alt_name ()

    const gchar *
    dfu_target_get_alt_name (DfuTarget *target,
                             GError **error);

Gets the alternate setting name to use for this interface.

#### Parameters

target | a DfuTarget |
error | a GError, or `NULL` |

#### Returns

the alternative setting name, typically `NULL`

Since: 0.5.4

### dfu_target_get_alt_name_for_display ()

    const gchar *
    dfu_target_get_alt_name_for_display (DfuTarget *target,
                                         GError **error);

Gets the alternate setting name to use for this interface that can be shown on the display.

#### Parameters

target | a DfuTarget |
error | a GError, or `NULL` |

#### Returns

the alternative setting name

Since: 0.7.5

### dfu_target_upload ()

    DfuImage *
    dfu_target_upload (DfuTarget *target,
                       DfuTargetTransferFlags flags,
                       GCancellable *cancellable,
                       GError **error);

Uploads firmware from the target to the host.

#### Parameters

target | a DfuTarget |
flags | flags to use, e.g. `DFU_TARGET_TRANSFER_FLAG_VERIFY` |
cancellable | a GCancellable, or `NULL` |
error | a GError, or `NULL` |

#### Returns

the uploaded image, or `NULL` for error.

[transfer full]

Since: 0.5.4

### dfu_target_download ()

    gboolean
    dfu_target_download (DfuTarget *target,
                         DfuImage *image,
                         DfuTargetTransferFlags flags,
                         GCancellable *cancellable,
                         GError **error);

Downloads firmware from the host to the target, optionally verifying the transfer.

#### Parameters

target | a DfuTarget |
image | a DfuImage |
flags | flags to use, e.g. `DFU_TARGET_TRANSFER_FLAG_VERIFY` |
cancellable | a GCancellable, or `NULL` |
error | a GError, or `NULL` |

#### Returns

`TRUE` for success

Since: 0.5.4

### dfu_target_get_cipher_kind ()

    DfuCipherKind
    dfu_target_get_cipher_kind (DfuTarget *target);

Gets the cipher used for data sent to this interface.

#### Parameters

target | a DfuTarget |

#### Returns

the cipher, typically `DFU_CIPHER_KIND_NONE`

Since: 0.5.4

## Types and Values

### DFU_TYPE_TARGET

    #define DFU_TYPE_TARGET (dfu_target_get_type ())

### struct DfuTargetClass

    struct DfuTargetClass {
    	GUsbDeviceClass		 parent_class;
    	void			(*percentage_changed) (DfuTarget *target,
    							 guint		 percentage);
    	void			(*action_changed) (DfuTarget *target,
    							 DfuAction	 action);
    };

### enum DfuTargetTransferFlags

The optional flags used for transfering firmware.

#### Members

DFU_TARGET_TRANSFER_FLAG_NONE | No flags set |
DFU_TARGET_TRANSFER_FLAG_VERIFY | Verify the download once complete |
DFU_TARGET_TRANSFER_FLAG_DETACH | If required, detach from runtime mode |
DFU_TARGET_TRANSFER_FLAG_ATTACH | Attach the device back to runtime after completion |
DFU_TARGET_TRANSFER_FLAG_WAIT_RUNTIME | Wait for runtime to load after completion |
DFU_TARGET_TRANSFER_FLAG_WILDCARD_VID | Allow downloading images with wildcard VIDs |
DFU_TARGET_TRANSFER_FLAG_WILDCARD_PID | Allow downloading images with wildcard PIDs |
DFU_TARGET_TRANSFER_FLAG_ANY_CIPHER | Allow any cipher kinds to be downloaded |
DFU_TARGET_TRANSFER_FLAG_ADDR_HEURISTIC | Automatically detect the address to use |

### DfuTarget

    typedef struct _DfuTarget DfuTarget;