## FuDevice FuDevice — a USB device |

## Functions

FuDevice * | fu_device_new ()
#define | fu_device_add_flag()
#define | fu_device_remove_flag()
#define | fu_device_has_flag()
#define | fu_device_add_checksum()
#define | fu_device_add_release()
#define | fu_device_add_icon()
#define | fu_device_set_created()
#define | fu_device_set_description()
#define | fu_device_set_flags()
#define | fu_device_has_guid()
#define | fu_device_set_modified()
#define | fu_device_set_plugin()
#define | fu_device_set_serial()
#define | fu_device_set_summary()
#define | fu_device_set_update_error()
#define | fu_device_set_update_state()
#define | fu_device_set_vendor()
#define | fu_device_set_vendor_id()
#define | fu_device_set_version()
#define | fu_device_set_version_lowest()
#define | fu_device_set_version_bootloader()
#define | fu_device_set_flashes_left()
#define | fu_device_set_install_duration()
#define | fu_device_get_checksums()
#define | fu_device_get_flags()
#define | fu_device_get_created()
#define | fu_device_get_modified()
#define | fu_device_get_guids()
#define | fu_device_get_guid_default()
#define | fu_device_get_icons()
#define | fu_device_get_name()
#define | fu_device_get_serial()
#define | fu_device_get_summary()
#define | fu_device_get_id()
#define | fu_device_get_plugin()
#define | fu_device_get_update_error()
#define | fu_device_get_update_state()
#define | fu_device_get_vendor()
#define | fu_device_get_version()
#define | fu_device_get_version_lowest()
#define | fu_device_get_version_bootloader()
#define | fu_device_get_vendor_id()
#define | fu_device_get_flashes_left()
#define | fu_device_get_install_duration()
gchar * | fu_device_to_string ()
const gchar * | fu_device_get_alternate_id ()
void | fu_device_set_alternate_id ()
const gchar * | fu_device_get_equivalent_id ()
void | fu_device_set_equivalent_id ()
void | fu_device_add_guid ()
gchar * | fu_device_get_guids_as_str ()
FuDevice * | fu_device_get_alternate ()
FuDevice * | fu_device_get_parent ()
GPtrArray * | fu_device_get_children ()
void | fu_device_add_child ()
void | fu_device_add_parent_guid ()
void | fu_device_add_counterpart_guid ()
const gchar * | fu_device_get_metadata ()
gboolean | fu_device_get_metadata_boolean ()
guint | fu_device_get_metadata_integer ()
void | fu_device_set_metadata ()
void | fu_device_set_metadata_boolean ()
void | fu_device_set_metadata_integer ()
void | fu_device_set_id ()
const gchar * | fu_device_get_physical_id ()
void | fu_device_set_physical_id ()
const gchar * | fu_device_get_logical_id ()
void | fu_device_set_logical_id ()
const gchar * | fu_device_get_custom_flags ()
gboolean | fu_device_has_custom_flag ()
void | fu_device_set_custom_flags ()
void | fu_device_set_name ()
guint | fu_device_get_remove_delay ()
void | fu_device_set_remove_delay ()
FwupdStatus | fu_device_get_status ()
void | fu_device_set_status ()
void | fu_device_set_firmware_size_min ()
void | fu_device_set_firmware_size_max ()
guint | fu_device_get_progress ()
void | fu_device_set_progress ()
void | fu_device_set_progress_full ()
void | fu_device_set_quirks ()
FuQuirks * | fu_device_get_quirks ()
FwupdRelease * | fu_device_get_release_default ()
gboolean | fu_device_write_firmware ()
GBytes * | fu_device_prepare_firmware ()
GBytes * | fu_device_read_firmware ()
gboolean | fu_device_attach ()
gboolean | fu_device_detach ()
void | fu_device_incorporate ()
gboolean | fu_device_open ()
gboolean | fu_device_close ()
gboolean | fu_device_probe ()
gboolean | fu_device_setup ()
void | fu_device_probe_invalidate ()
gboolean | fu_device_poll ()
void | fu_device_set_poll_interval ()

## Types and Values

#define | FU_TYPE_DEVICE
struct | FuDeviceClass
#define | FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE
#define | FU_DEVICE_REMOVE_DELAY_USER_REPLUG
| FuDevice

## Description

An object that represents a USB device.

See also: FuDevice

## Functions

### fu_device_new ()

    FuDevice *
    fu_device_new (void);

### fu_device_add_flag()

    #define fu_device_add_flag(d,v)			fwupd_device_add_flag(FWUPD_DEVICE(d),v)

### fu_device_remove_flag()

    #define fu_device_remove_flag(d,v)		fwupd_device_remove_flag(FWUPD_DEVICE(d),v)

### fu_device_has_flag()

    #define fu_device_has_flag(d,v)			fwupd_device_has_flag(FWUPD_DEVICE(d),v)

### fu_device_add_checksum()

    #define fu_device_add_checksum(d,v)		fwupd_device_add_checksum(FWUPD_DEVICE(d),v)

### fu_device_add_release()

    #define fu_device_add_release(d,v)		fwupd_device_add_release(FWUPD_DEVICE(d),v)

### fu_device_add_icon()

    #define fu_device_add_icon(d,v)			fwupd_device_add_icon(FWUPD_DEVICE(d),v)

### fu_device_set_created()

    #define fu_device_set_created(d,v)		fwupd_device_set_created(FWUPD_DEVICE(d),v)

### fu_device_set_description()

    #define fu_device_set_description(d,v)		fwupd_device_set_description(FWUPD_DEVICE(d),v)

### fu_device_set_flags()

    #define fu_device_set_flags(d,v)		fwupd_device_set_flags(FWUPD_DEVICE(d),v)

### fu_device_has_guid()

    #define fu_device_has_guid(d,v)			fwupd_device_has_guid(FWUPD_DEVICE(d),v)

### fu_device_set_modified()

    #define fu_device_set_modified(d,v)		fwupd_device_set_modified(FWUPD_DEVICE(d),v)

### fu_device_set_plugin()

    #define fu_device_set_plugin(d,v)		fwupd_device_set_plugin(FWUPD_DEVICE(d),v)

### fu_device_set_serial()

    #define fu_device_set_serial(d,v)		fwupd_device_set_serial(FWUPD_DEVICE(d),v)

### fu_device_set_summary()

    #define fu_device_set_summary(d,v)		fwupd_device_set_summary(FWUPD_DEVICE(d),v)

### fu_device_set_update_error()

    #define fu_device_set_update_error(d,v)		fwupd_device_set_update_error(FWUPD_DEVICE(d),v)

### fu_device_set_update_state()

    #define fu_device_set_update_state(d,v)		fwupd_device_set_update_state(FWUPD_DEVICE(d),v)

### fu_device_set_vendor()

    #define fu_device_set_vendor(d,v)		fwupd_device_set_vendor(FWUPD_DEVICE(d),v)

### fu_device_set_vendor_id()

    #define fu_device_set_vendor_id(d,v)		fwupd_device_set_vendor_id(FWUPD_DEVICE(d),v)

### fu_device_set_version()

    #define fu_device_set_version(d,v)		fwupd_device_set_version(FWUPD_DEVICE(d),v)

### fu_device_set_version_lowest()

    #define fu_device_set_version_lowest(d,v) fwupd_device_set_version_lowest(FWUPD_DEVICE(d),v)

### fu_device_set_version_bootloader()

    #define fu_device_set_version_bootloader(d,v) fwupd_device_set_version_bootloader(FWUPD_DEVICE(d),v)

### fu_device_set_flashes_left()

    #define fu_device_set_flashes_left(d,v)		fwupd_device_set_flashes_left(FWUPD_DEVICE(d),v)

### fu_device_set_install_duration()

    #define fu_device_set_install_duration(d,v) fwupd_device_set_install_duration(FWUPD_DEVICE(d),v)

### fu_device_get_checksums()

    #define fu_device_get_checksums(d)		fwupd_device_get_checksums(FWUPD_DEVICE(d))

### fu_device_get_flags()

    #define fu_device_get_flags(d)			fwupd_device_get_flags(FWUPD_DEVICE(d))

### fu_device_get_created()

    #define fu_device_get_created(d)		fwupd_device_get_created(FWUPD_DEVICE(d))

### fu_device_get_modified()

    #define fu_device_get_modified(d)		fwupd_device_get_modified(FWUPD_DEVICE(d))

### fu_device_get_guids()

    #define fu_device_get_guids(d)			fwupd_device_get_guids(FWUPD_DEVICE(d))

### fu_device_get_guid_default()

    #define fu_device_get_guid_default(d)		fwupd_device_get_guid_default(FWUPD_DEVICE(d))

### fu_device_get_icons()

    #define fu_device_get_icons(d)			fwupd_device_get_icons(FWUPD_DEVICE(d))

### fu_device_get_name()

    #define fu_device_get_name(d)			fwupd_device_get_name(FWUPD_DEVICE(d))

### fu_device_get_serial()

    #define fu_device_get_serial(d)			fwupd_device_get_serial(FWUPD_DEVICE(d))

### fu_device_get_summary()

    #define fu_device_get_summary(d)		fwupd_device_get_summary(FWUPD_DEVICE(d))

### fu_device_get_id()

    #define fu_device_get_id(d)			fwupd_device_get_id(FWUPD_DEVICE(d))

### fu_device_get_plugin()

    #define fu_device_get_plugin(d)			fwupd_device_get_plugin(FWUPD_DEVICE(d))

### fu_device_get_update_error()

    #define fu_device_get_update_error(d)		fwupd_device_get_update_error(FWUPD_DEVICE(d))

### fu_device_get_update_state()

    #define fu_device_get_update_state(d)		fwupd_device_get_update_state(FWUPD_DEVICE(d))

### fu_device_get_vendor()

    #define fu_device_get_vendor(d)			fwupd_device_get_vendor(FWUPD_DEVICE(d))

### fu_device_get_version()

    #define fu_device_get_version(d)		fwupd_device_get_version(FWUPD_DEVICE(d))

### fu_device_get_version_lowest()

    #define fu_device_get_version_lowest(d)		fwupd_device_get_version_lowest(FWUPD_DEVICE(d))

### fu_device_get_version_bootloader()

    #define fu_device_get_version_bootloader(d) fwupd_device_get_version_bootloader(FWUPD_DEVICE(d))

### fu_device_get_vendor_id()

    #define fu_device_get_vendor_id(d)		fwupd_device_get_vendor_id(FWUPD_DEVICE(d))

### fu_device_get_flashes_left()

    #define fu_device_get_flashes_left(d)		fwupd_device_get_flashes_left(FWUPD_DEVICE(d))

### fu_device_get_install_duration()

    #define fu_device_get_install_duration(d) fwupd_device_get_install_duration(FWUPD_DEVICE(d))

### fu_device_to_string ()

    gchar *
    fu_device_to_string (FuDevice *self);

This allows us to easily print the FwupdDevice, the FwupdRelease and the daemon-specific metadata.

#### Parameters

self | A FuDevice |

#### Returns

a string value, or `NULL` for invalid.

Since: 0.9.8

### fu_device_get_alternate_id ()

    const gchar *
    fu_device_get_alternate_id (FuDevice *self);

### fu_device_set_alternate_id ()

    void
    fu_device_set_alternate_id (FuDevice *self,
                                const gchar *alternate_id);

### fu_device_get_equivalent_id ()

    const gchar *
    fu_device_get_equivalent_id (FuDevice *self);

### fu_device_set_equivalent_id ()

    void
    fu_device_set_equivalent_id (FuDevice *self,
                                 const gchar *equivalent_id);

### fu_device_add_guid ()

    void
    fu_device_add_guid (FuDevice *self,
                        const gchar *guid);

Adds a GUID to the device. If the `guid` argument is not a valid GUID then it is converted to a GUID using `as_utils_guid_from_string()`.

#### Parameters

self | A FuDevice |
guid | A GUID, e.g. `2082b5e0-7a64-478a-b1b2-e3404fab6dad` |

Since: 0.7.2

### fu_device_get_guids_as_str ()

    gchar *
    fu_device_get_guids_as_str (FuDevice *self);

Gets the device GUIDs as a joined string, which may be useful for error messages.

#### Parameters

self | A FuDevice |

#### Returns

a string, which may be empty length but not `NULL`

Since: 1.0.8

### fu_device_get_alternate ()

    FuDevice *
    fu_device_get_alternate (FuDevice *self);

Gets any alternate device. An alternate device may be linked to the primary device in some way.

The alternate object will be matched from the ID set in `fu_device_set_alternate_id()` and will be assigned by the daemon. This means if the ID is not found as an added device, then this function will return `NULL`.

#### Parameters

self | A FuDevice |

#### Returns

a FuDevice or `NULL`.

[transfer none]

Since: 0.7.2

### fu_device_get_parent ()

    FuDevice *
    fu_device_get_parent (FuDevice *self);

Gets any parent device. An parent device is logically "above" the current device and this may be reflected in client tools.

This information also allows the plugin to optionally verify the parent device, for instance checking the parent device firmware version.

The parent object is not refcounted and if destroyed this function will then return `NULL`.

#### Parameters

self | A FuDevice |

#### Returns

a FuDevice or `NULL`.

[transfer none]

Since: 1.0.8

### fu_device_get_children ()

    GPtrArray *
    fu_device_get_children (FuDevice *self);

Gets any child devices. A child device is logically "below" the current device and this may be reflected in client tools.

#### Parameters

self | A FuDevice |

#### Returns

child devices.

[transfer none][element-type FuDevice]

Since: 1.0.8

### fu_device_add_child ()

    void
    fu_device_add_child (FuDevice *self,
                         FuDevice *child);

Sets any child device. An child device is logically linked to the primary device in some way.

#### Parameters

self | A FuDevice |
child | Another FuDevice |

Since: 1.0.8

### fu_device_add_parent_guid ()

    void
    fu_device_add_parent_guid (FuDevice *self,
                               const gchar *guid);

Sets any parent device using a GUID. An parent device is logically linked to the primary device in some way and can be added before or after `self` .

The GUIDs are searched in order, and so the order of adding GUIDs may be important if more than one parent device might match.

If the parent device is removed, any children logically linked to it will also be removed.

#### Parameters

self | A FuDevice |
guid | a GUID |

Since: 1.0.8

### fu_device_add_counterpart_guid ()

    void
    fu_device_add_counterpart_guid (FuDevice *self,
                                    const gchar *guid);

Adds a GUID to the device. If the `guid` argument is not a valid GUID then it is converted to a GUID using `as_utils_guid_from_string()`.

A counterpart GUID is typically the GUID of the same device in bootloader or runtime mode, if they have a different device PCI or USB ID. Adding this type of GUID does not cause a "cascade" by matching using the quirk database.

#### Parameters

self | A FuDevice |
guid | A GUID, e.g. `2082b5e0-7a64-478a-b1b2-e3404fab6dad` |

Since: 1.1.2

### fu_device_get_metadata ()

    const gchar *
    fu_device_get_metadata (FuDevice *self,
                            const gchar *key);

Gets an item of metadata from the device.

#### Parameters

self | A FuDevice |
key | the key |

#### Returns

a string value, or `NULL` for unfound.

Since: 0.1.0

### fu_device_get_metadata_boolean ()

    gboolean
    fu_device_get_metadata_boolean (FuDevice *self,
                                    const gchar *key);

Gets an item of metadata from the device.

#### Parameters

self | A FuDevice |
key | the key |

#### Returns

a boolean value, or `FALSE` for unfound or failure to parse.

Since: 0.9.7

### fu_device_get_metadata_integer ()

    guint
    fu_device_get_metadata_integer (FuDevice *self,
                                    const gchar *key);

Gets an item of metadata from the device.

#### Parameters

self | A FuDevice |
key | the key |

#### Returns

a string value, or `G_MAXUINT` for unfound or failure to parse.

Since: 0.9.7

### fu_device_set_metadata ()

    void
    fu_device_set_metadata (FuDevice *self,
                            const gchar *key,
                            const gchar *value);

Sets an item of metadata on the device.

#### Parameters

self | A FuDevice |
key | the key |
value | the string value |

Since: 0.1.0

### fu_device_set_metadata_boolean ()

    void
    fu_device_set_metadata_boolean (FuDevice *self,
                                    const gchar *key,
                                    gboolean value);

Sets an item of metadata on the device. When `value` is set to `TRUE` the actual stored value is "true".

#### Parameters

self | A FuDevice |
key | the key |
value | the boolean value |

Since: 0.9.7

### fu_device_set_metadata_integer ()

    void
    fu_device_set_metadata_integer (FuDevice *self,
                                    const gchar *key,
                                    guint value);

Sets an item of metadata on the device. The integer is stored as a base-10 string internally.

#### Parameters

self | A FuDevice |
key | the key |
value | the unsigned integer value |

Since: 0.9.7

### fu_device_set_id ()

    void
    fu_device_set_id (FuDevice *self,
                      const gchar *id);

Sets the ID on the device. The ID should represent the *connection* of the device, so that any similar device plugged into a different slot will have a different `id` string.

The `id` will be converted to a SHA1 hash before the device is added to the daemon, and plugins should not assume that the ID that is set here is the same as what is returned by `fu_device_get_id()`.

#### Parameters

self | A FuDevice |
id | a string, e.g. `tbt-port1` |

Since: 0.7.1

### fu_device_get_physical_id ()

    const gchar *
    fu_device_get_physical_id (FuDevice *self);

Gets the physical ID set for the device, which represents the electrical connection used to compare devices.

Multiple FuDevices can share a single physical ID.

#### Parameters

self | A FuDevice |

#### Returns

a string value, or `NULL` if never set.

Since: 1.1.2

### fu_device_set_physical_id ()

    void
    fu_device_set_physical_id (FuDevice *self,
                               const gchar *physical_id);

Sets the physical ID on the device which represents the electrical connection of the device to the system. Multiple FuDevices can share a physical ID.

The physical ID is used to remove logical devices when a physical device has been removed from the system.

A sysfs or devpath is not a physical ID, but could be something like `PCI_SLOT_NAME=0000:3e:00.0`.

#### Parameters

self | A FuDevice |
physical_id | a string that identifies the physical device connection |

Since: 1.1.2

### fu_device_get_logical_id ()

    const gchar *
    fu_device_get_logical_id (FuDevice *self);

Gets the logical ID set for the device, which disambiguates devices with the same physical ID.

#### Parameters

self | A FuDevice |

#### Returns

a string value, or `NULL` if never set.

Since: 1.1.2

### fu_device_set_logical_id ()

    void
    fu_device_set_logical_id (FuDevice *self,
                              const gchar *logical_id);

Sets the logical ID on the device. This is designed to disambiguate devices with the same physical ID.

#### Parameters

self | A FuDevice |
logical_id | a string, e.g. `dev2` |

Since: 1.1.2

### fu_device_get_custom_flags ()

    const gchar *
    fu_device_get_custom_flags (FuDevice *self);

Gets the custom flags for the device from the quirk system.

#### Parameters

self | A FuDevice |

#### Returns

a string value, or `NULL` if never set.

Since: 1.1.0

### fu_device_has_custom_flag ()

    gboolean
    fu_device_has_custom_flag (FuDevice *self,
                               const gchar *hint);

Checks if the custom flag exists for the device from the quirk system.

It may be more efficient to call `fu_device_get_custom_flags()` and split the string locally if checking for lots of different flags.

#### Parameters

self | A FuDevice |
hint | A string, e.g. "bootloader" |

#### Returns

`TRUE` if the hint exists

Since: 1.1.0

### fu_device_set_custom_flags ()

    void
    fu_device_set_custom_flags (FuDevice *self,
                                const gchar *custom_flags);

Sets the custom flags from the quirk system that can be used to affect device matching. The actual string format is defined by the plugin.

#### Parameters

self | A FuDevice |
custom_flags | a string |

Since: 1.1.0

### fu_device_set_name ()

    void
    fu_device_set_name (FuDevice *self,
                        const gchar *value);

Sets the name on the device. Any invalid parts will be converted or removed.

#### Parameters

self | A FuDevice |
value | a device name |

Since: 0.7.1

### fu_device_get_remove_delay ()

    guint
    fu_device_get_remove_delay (FuDevice *self);

Returns the maximum delay expected when replugging the device going into bootloader mode.

#### Parameters

self | A FuDevice |

#### Returns

time in milliseconds

Since: 1.0.2

### fu_device_set_remove_delay ()

    void
    fu_device_set_remove_delay (FuDevice *self,
                                guint remove_delay);

Sets the amount of time a device is allowed to return in bootloader mode.

NOTE: this should be less than 3000ms for devices that just have to reset and automatically re-enumerate, but significantly longer if it involves a user removing a cable, pressing several buttons and removing a cable. A suggested value for this would be 10,000ms.

#### Parameters

self | A FuDevice |
remove_delay | the remove_delay value |

Since: 1.0.2

### fu_device_get_status ()

    FwupdStatus
    fu_device_get_status (FuDevice *self);

Returns what the device is currently doing.

#### Parameters

self | A FuDevice |

#### Returns

the status value, e.g. `FWUPD_STATUS_DEVICE_WRITE`

Since: 1.0.3

### fu_device_set_status ()

    void
    fu_device_set_status (FuDevice *self,
                          FwupdStatus status);

Sets what the device is currently doing.

#### Parameters

self | A FuDevice |
status | the status value, e.g. `FWUPD_STATUS_DEVICE_WRITE` |

Since: 1.0.3

### fu_device_set_firmware_size_min ()

    void
    fu_device_set_firmware_size_min (FuDevice *self,
                                     guint64 size_min);

Sets the minimum allowed size of the firmware blob.

#### Parameters

self | A FuDevice |
size_min | Size in bytes |

Since: 1.1.2

### fu_device_set_firmware_size_max ()

    void
    fu_device_set_firmware_size_max (FuDevice *self,
                                     guint64 size_max);

Sets the maximum allowed size of the firmware blob.

#### Parameters

self | A FuDevice |
size_max | Size in bytes |

Since: 1.1.2

### fu_device_get_progress ()

    guint
    fu_device_get_progress (FuDevice *self);

Returns the progress completion.

#### Parameters

self | A FuDevice |

#### Returns

value in percent

Since: 1.0.3

### fu_device_set_progress ()

    void
    fu_device_set_progress (FuDevice *self,
                            guint progress);

Sets the progress completion.

#### Parameters

self | A FuDevice |
progress | the progress percentage value |

Since: 1.0.3

### fu_device_set_progress_full ()

    void
    fu_device_set_progress_full (FuDevice *self,
                                 gsize progress_done,
                                 gsize progress_total);

Sets the progress completion using the raw progress values.

#### Parameters

self | A FuDevice |
progress_done | the bytes already done |
progress_total | the total number of bytes |

Since: 1.0.3

### fu_device_set_quirks ()

    void
    fu_device_set_quirks (FuDevice *self,
                          FuQuirks *quirks);

Sets the optional quirk information which may be useful to this device. This is typically set after the FuDevice has been created, but before the device has been opened or probed.

#### Parameters

self | A FuDevice |
quirks | A FuQuirks, or `NULL` |

Since: 1.0.3

### fu_device_get_quirks ()

    FuQuirks *
    fu_device_get_quirks (FuDevice *self);

Gets the quirk information which may be useful to this device.

#### Parameters

self | A FuDevice |

#### Returns

the FuQuirks object, or `NULL`.

[transfer none]

Since: 1.0.3

### fu_device_get_release_default ()

    FwupdRelease *
    fu_device_get_release_default (FuDevice *self);

Gets the default release for the device, creating one if not found.

#### Parameters

self | A FuDevice |

#### Returns

the FwupdRelease object.

[transfer none]

Since: 1.0.5

### fu_device_write_firmware ()

    gboolean
    fu_device_write_firmware (FuDevice *self,
                              GBytes *fw,
                              GError **error);

Writes firmware to the device by calling a plugin-specific vfunc.

#### Parameters

self | A FuDevice |
fw | A GBytes |
error | A GError |

#### Returns

`TRUE` on success

Since: 1.0.8

### fu_device_prepare_firmware ()

    GBytes *
    fu_device_prepare_firmware (FuDevice *self,
                                GBytes *fw,
                                GError **error);

Prepares the firmware by calling an optional device-specific vfunc for the device, which can do things like decompressing or parsing of the firmware data.

For all firmware, this checks the size of the firmware if limits have been set using `fu_device_set_firmware_size_min()`, `fu_device_set_firmware_size_max()` or using a quirk entry.

#### Parameters

self | A FuDevice |
fw | A GBytes |
error | A GError |

#### Returns

A new GBytes, or `NULL` for error.

[transfer full]

Since: 1.1.2

### fu_device_read_firmware ()

    GBytes *
    fu_device_read_firmware (FuDevice *self,
                             GError **error);

Reads firmware from the device by calling a plugin-specific vfunc.

#### Parameters

self | A FuDevice |
error | A GError |

#### Returns

A GBytes, or `NULL` for error.

[transfer full]

Since: 1.0.8

### fu_device_attach ()

    gboolean
    fu_device_attach (FuDevice *self,
                      GError **error);

Attaches a device from the bootloader into application mode.

#### Parameters

self | A FuDevice |
error | A GError |

#### Returns

`TRUE` on success

Since: 1.0.8

### fu_device_detach ()

    gboolean
    fu_device_detach (FuDevice *self,
                      GError **error);

Detaches a device from the application into bootloader mode.

#### Parameters

self | A FuDevice |
error | A GError |

#### Returns

`TRUE` on success

Since: 1.0.8

### fu_device_incorporate ()

    void
    fu_device_incorporate (FuDevice *self,
                           FuDevice *donor);

Copy all properties from the donor object if they have not already been set.

#### Parameters

self | A FuDevice |
donor | Another FuDevice |

Since: 1.1.0

### fu_device_open ()

    gboolean
    fu_device_open (FuDevice *self,
                    GError **error);

Opens a device, optionally running a object-specific vfunc.

Plugins can call `fu_device_open()` multiple times without calling `fu_device_close()`, but only the first call will actually invoke the vfunc.

It is expected that plugins issue the same number of `fu_device_open()` and `fu_device_close()` methods when using a specific `self` .

#### Parameters

self | A FuDevice |
error | A GError, or `NULL` |

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_close ()

    gboolean
    fu_device_close (FuDevice *self,
                     GError **error);

Closes a device, optionally running a object-specific vfunc.

Plugins can call `fu_device_close()` multiple times without calling `fu_device_open()`, but only the last call will actually invoke the vfunc.

It is expected that plugins issue the same number of `fu_device_open()` and `fu_device_close()` methods when using a specific `self` .

An error is returned if this method is called without having used the `fu_device_open()` method beforehand.

#### Parameters

self | A FuDevice |
error | A GError, or `NULL` |

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_probe ()

    gboolean
    fu_device_probe (FuDevice *self,
                     GError **error);

Probes a device, setting parameters on the object that does not need the device open or the interface claimed. If the device is not compatible then an error should be returned.

#### Parameters

self | A FuDevice |
error | A GError, or `NULL` |

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_setup ()

    gboolean
    fu_device_setup (FuDevice *self,
                     GError **error);

Sets up a device, setting parameters on the object that requires the device to be open and have the interface claimed. If the device is not compatible then an error should be returned.

#### Parameters

self | A FuDevice |
error | A GError, or `NULL` |

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_probe_invalidate ()

    void
    fu_device_probe_invalidate (FuDevice *self);

Normally when calling `fu_device_probe()` multiple times it is only done once. Calling this method causes the next requests to `fu_device_probe()` and `fu_device_setup()` actually probe the hardware.

This should be done in case the backing device has changed, for instance if a USB device has been replugged.

#### Parameters

self | A FuDevice |

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_poll ()

    gboolean
    fu_device_poll (FuDevice *self,
                    GError **error);

Polls a device, typically querying the hardware for status.

#### Parameters

self | A FuDevice |
error | A GError, or `NULL` |

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_set_poll_interval ()

    void
    fu_device_set_poll_interval (FuDevice *self,
                                 guint interval);

Polls the hardware every interval period. If the subclassed `->`poll()`` method returns `FALSE` then a warning is printed to the console and the poll is disabled until the next call to `fu_device_set_poll_interval()`.

#### Parameters

self | a FuPlugin |
interval | duration in ms, or 0 to disable |

Since: 1.1.2

## Types and Values

### FU_TYPE_DEVICE

    #define FU_TYPE_DEVICE (fu_device_get_type ())

### struct FuDeviceClass

    struct FuDeviceClass {
    	FwupdDeviceClass	 parent_class;
    	void			 (*to_string)		(FuDevice *self,
    							 GString *str);
    	gboolean		 (*write_firmware) (FuDevice *self,
    							 GBytes		*fw,
    							 GError		**error);
    	GBytes			*(*read_firmware) (FuDevice *self,
    							 GError		**error);
    	gboolean		 (*detach)		(FuDevice *self,
    							 GError		**error);
    	gboolean		 (*attach)		(FuDevice *self,
    							 GError		**error);
    	gboolean		 (*open)		(FuDevice *self,
    							 GError		**error);
    	gboolean		 (*close)		(FuDevice *self,
    							 GError		**error);
    	gboolean		 (*probe)		(FuDevice *self,
    							 GError		**error);
    	GBytes			*(*prepare_firmware) (FuDevice *self,
    							 GBytes		*fw,
    							 GError		**error);
    	gboolean		 (*set_quirk_kv) (FuDevice *self,
    							 const gchar *key,
    							 const gchar *value,
    							 GError		**error);
    	gboolean		 (*setup)		(FuDevice *self,
    							 GError		**error);
    	void			 (*incorporate)		(FuDevice *self,
    							 FuDevice *donor);
    	gboolean		 (*poll)		(FuDevice *self,
    							 GError		**error);
    };

### FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE

    #define FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE		10000

The default removal delay for device re-enumeration taking into account a chain of slow USB hubs. This should be used when the device is able to reset itself between bootloader->runtime->bootloader.

### FU_DEVICE_REMOVE_DELAY_USER_REPLUG

    #define FU_DEVICE_REMOVE_DELAY_USER_REPLUG		40000

The default removal delay for device re-plug taking into account humans being slow and clumsy. This should be used when the user has to do something, e.g. unplug, press a magic button and then replug.

### FuDevice

    typedef struct _FuDevice FuDevice;