FuDevice: fwupd Reference Manual

## FuDevice FuDevice |

## Functions

gboolean | (*FuDeviceRetryFunc) ()
FuDevice * | fu_device_new ()
FuDevice * | fu_device_new_with_context ()
#define | fu_device_has_flag()
#define | fu_device_has_instance_id()
#define | fu_device_has_vendor_id()
#define | fu_device_has_protocol()
#define | fu_device_add_checksum()
#define | fu_device_add_release()
#define | fu_device_add_icon()
#define | fu_device_has_icon()
#define | fu_device_set_created()
#define | fu_device_set_description()
#define | fu_device_set_flags()
#define | fu_device_set_modified()
#define | fu_device_set_plugin()
#define | fu_device_set_serial()
#define | fu_device_set_summary()
#define | fu_device_set_branch()
#define | fu_device_set_update_message()
#define | fu_device_set_update_image()
#define | fu_device_set_update_error()
#define | fu_device_add_vendor_id()
#define | fu_device_add_protocol()
#define | fu_device_set_version_raw()
#define | fu_device_set_version_lowest_raw()
#define | fu_device_set_version_bootloader_raw()
#define | fu_device_set_version_build_date()
#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_instance_ids()
#define | fu_device_get_icons()
#define | fu_device_get_name()
#define | fu_device_get_serial()
#define | fu_device_get_summary()
#define | fu_device_get_branch()
#define | fu_device_get_id()
#define | fu_device_get_composite_id()
#define | fu_device_get_plugin()
#define | fu_device_get_update_error()
#define | fu_device_get_update_state()
#define | fu_device_get_update_message()
#define | fu_device_get_update_image()
#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_version_format()
#define | fu_device_get_version_raw()
#define | fu_device_get_version_lowest_raw()
#define | fu_device_get_version_bootloader_raw()
#define | fu_device_get_version_build_date()
#define | fu_device_get_vendor_ids()
#define | fu_device_get_protocols()
#define | fu_device_get_flashes_left()
#define | fu_device_get_install_duration()
gchar * | fu_device_to_string ()
void | fu_device_add_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 ()
void | fu_device_add_guid_full ()
gboolean | fu_device_has_guid ()
void | fu_device_add_instance_id ()
void | fu_device_add_instance_id_full ()
FuDevice * | fu_device_get_alternate ()
FuDevice * | fu_device_get_root ()
FuDevice * | fu_device_get_parent ()
GPtrArray * | fu_device_get_children ()
void | fu_device_add_child ()
void | fu_device_remove_child ()
void | fu_device_add_parent_guid ()
void | fu_device_add_parent_physical_id ()
void | fu_device_add_counterpart_guid ()
FuDevice * | fu_device_get_proxy ()
void | fu_device_set_proxy ()
FuDevice * | fu_device_get_proxy_with_fallback ()
const gchar * | fu_device_get_metadata ()
gboolean | fu_device_get_metadata_boolean ()
guint | fu_device_get_metadata_integer ()
void | fu_device_remove_metadata ()
void | fu_device_set_metadata ()
void | fu_device_set_metadata_boolean ()
void | fu_device_set_metadata_integer ()
void | fu_device_set_id ()
void | fu_device_set_version_format ()
void | fu_device_set_version ()
void | fu_device_set_version_lowest ()
void | fu_device_set_version_bootloader ()
void | fu_device_inhibit ()
void | fu_device_uninhibit ()
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_backend_id ()
void | fu_device_set_backend_id ()
const gchar * | fu_device_get_proxy_guid ()
void | fu_device_set_proxy_guid ()
guint | fu_device_get_priority ()
void | fu_device_set_priority ()
void | fu_device_add_flag ()
void | fu_device_remove_flag ()
const gchar * | fu_device_get_custom_flags ()
void | fu_device_set_custom_flags ()
void | fu_device_set_name ()
void | fu_device_set_vendor ()
guint | fu_device_get_remove_delay ()
void | fu_device_set_remove_delay ()
void | fu_device_set_firmware_size ()
void | fu_device_set_firmware_size_min ()
void | fu_device_set_firmware_size_max ()
guint64 | fu_device_get_firmware_size_min ()
guint64 | fu_device_get_firmware_size_max ()
guint | fu_device_get_battery_level ()
void | fu_device_set_battery_level ()
guint | fu_device_get_battery_threshold ()
void | fu_device_set_battery_threshold ()
void | fu_device_set_update_state ()
void | fu_device_set_context ()
FuContext * | fu_device_get_context ()
FwupdRelease * | fu_device_get_release_default ()
GType | fu_device_get_specialized_gtype ()
GType | fu_device_get_firmware_gtype ()
void | fu_device_set_firmware_gtype ()
void | fu_device_add_internal_flag ()
void | fu_device_remove_internal_flag ()
gboolean | fu_device_has_internal_flag ()
gboolean | fu_device_get_results ()
gboolean | fu_device_write_firmware ()
FuFirmware * | fu_device_prepare_firmware ()
FuFirmware * | fu_device_read_firmware ()
GBytes * | fu_device_dump_firmware ()
gboolean | fu_device_attach ()
gboolean | fu_device_detach ()
gboolean | fu_device_attach_full ()
gboolean | fu_device_detach_full ()
gboolean | fu_device_reload ()
gboolean | fu_device_prepare ()
gboolean | fu_device_cleanup ()
void | fu_device_incorporate ()
void | fu_device_incorporate_flag ()
gboolean | fu_device_open ()
gboolean | fu_device_close ()
gboolean | fu_device_probe ()
gboolean | fu_device_setup ()
gboolean | fu_device_rescan ()
gboolean | fu_device_activate ()
void | fu_device_probe_invalidate ()
gboolean | fu_device_poll ()
void | fu_device_set_poll_interval ()
void | fu_device_retry_set_delay ()
void | fu_device_retry_add_recovery ()
gboolean | fu_device_retry ()
gboolean | fu_device_retry_full ()
gboolean | fu_device_bind_driver ()
gboolean | fu_device_unbind_driver ()
GHashTable * | fu_device_report_metadata_pre ()
GHashTable * | fu_device_report_metadata_post ()
void | fu_device_add_security_attrs ()
void | fu_device_register_private_flag ()
void | fu_device_add_private_flag ()
void | fu_device_remove_private_flag ()
gboolean | fu_device_has_private_flag ()
void | fu_device_emit_request ()

## Types and Values

#define | FU_TYPE_DEVICE
struct | FuDeviceClass
enum | FuDeviceInstanceFlags
#define | FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE
#define | FU_DEVICE_REMOVE_DELAY_USER_REPLUG
typedef | FuDeviceInternalFlags
#define | FU_DEVICE_INTERNAL_FLAG_NONE
#define | FU_DEVICE_INTERNAL_FLAG_UNKNOWN
#define | FU_DEVICE_INTERNAL_FLAG_NO_AUTO_INSTANCE_IDS
#define | FU_DEVICE_INTERNAL_FLAG_ENSURE_SEMVER
#define | FU_DEVICE_INTERNAL_FLAG_ONLY_SUPPORTED
#define | FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME
#define | FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME_CATEGORY
#define | FU_DEVICE_INTERNAL_FLAG_MD_SET_VERFMT
#define | FU_DEVICE_INTERNAL_FLAG_MD_SET_ICON
#define | FU_DEVICE_INTERNAL_FLAG_REPLUG_MATCH_GUID
#define | FU_DEVICE_INTERNAL_FLAG_INHERIT_ACTIVATION
#define | FU_DEVICE_INTERNAL_FLAG_NO_SERIAL_NUMBER
#define | FU_DEVICE_INTERNAL_FLAG_AUTO_PARENT_CHILDREN
#define | FU_DEVICE_INTERNAL_FLAG_ATTACH_EXTRA_RESET
#define | FU_DEVICE_INTERNAL_FLAG_INHIBIT_CHILDREN
#define | FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE_CHILDREN
#define | FU_DEVICE_INTERNAL_FLAG_USE_PARENT_FOR_BATTERY
#define | FU_DEVICE_INTERNAL_FLAG_USE_PROXY_FALLBACK
#define | FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE
#define | FU_DEVICE_INTERNAL_FLAG_MD_SET_VENDOR
#define | FU_DEVICE_INTERNAL_FLAG_NO_LID_CLOSED
| FuDevice

## Description

## Functions

### FuDeviceRetryFunc ()

    gboolean
    (*FuDeviceRetryFunc) (FuDevice *self,
                          gpointer user_data,
                          GError **error);

The device retry iteration callback.

#### Parameters

self | a FuDevice |
user_data | user data |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

### fu_device_new ()

    FuDevice *
    fu_device_new (void);

Creates a new Fudevice

Since: 0.1.0

### fu_device_new_with_context ()

    FuDevice *
    fu_device_new_with_context (FuContext *ctx);

Creates a new Fudevice

Since: 1.6.2

### fu_device_has_flag()

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

### fu_device_has_instance_id()

    #define fu_device_has_instance_id(d, v)	   fwupd_device_has_instance_id(FWUPD_DEVICE(d), v)

### fu_device_has_vendor_id()

    #define fu_device_has_vendor_id(d, v)	   fwupd_device_has_vendor_id(FWUPD_DEVICE(d), v)

### fu_device_has_protocol()

    #define fu_device_has_protocol(d, v)	   fwupd_device_has_protocol(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_has_icon()

    #define fu_device_has_icon(d, v)	   fwupd_device_has_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_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)

### 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_branch()

    #define fu_device_set_branch(d, v)	   fwupd_device_set_branch(FWUPD_DEVICE(d), v)

### fu_device_set_update_message()

    #define fu_device_set_update_message(d, v) fwupd_device_set_update_message(FWUPD_DEVICE(d), v)

### fu_device_set_update_image()

    #define fu_device_set_update_image(d, v)   fwupd_device_set_update_image(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_add_vendor_id()

    #define fu_device_add_vendor_id(d, v)	   fwupd_device_add_vendor_id(FWUPD_DEVICE(d), v)

### fu_device_add_protocol()

    #define fu_device_add_protocol(d, v)	   fwupd_device_add_protocol(FWUPD_DEVICE(d), v)

### fu_device_set_version_raw()

    #define fu_device_set_version_raw(d, v)	   fwupd_device_set_version_raw(FWUPD_DEVICE(d), v)

### fu_device_set_version_lowest_raw()

    #define             fu_device_set_version_lowest_raw(d, v)

### fu_device_set_version_bootloader_raw()

    #define             fu_device_set_version_bootloader_raw(d, v)

### fu_device_set_version_build_date()

    #define             fu_device_set_version_build_date(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_instance_ids()

    #define fu_device_get_instance_ids(d)	     fwupd_device_get_instance_ids(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_branch()

    #define fu_device_get_branch(d)		     fwupd_device_get_branch(FWUPD_DEVICE(d))

### fu_device_get_id()

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

### fu_device_get_composite_id()

    #define fu_device_get_composite_id(d)	     fwupd_device_get_composite_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_update_message()

    #define fu_device_get_update_message(d)	     fwupd_device_get_update_message(FWUPD_DEVICE(d))

### fu_device_get_update_image()

    #define fu_device_get_update_image(d)	     fwupd_device_get_update_image(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_version_format()

    #define fu_device_get_version_format(d)	     fwupd_device_get_version_format(FWUPD_DEVICE(d))

### fu_device_get_version_raw()

    #define fu_device_get_version_raw(d)	     fwupd_device_get_version_raw(FWUPD_DEVICE(d))

### fu_device_get_version_lowest_raw()

    #define fu_device_get_version_lowest_raw(d)  fwupd_device_get_version_lowest_raw(FWUPD_DEVICE(d))

### fu_device_get_version_bootloader_raw()

    #define             fu_device_get_version_bootloader_raw(d)

### fu_device_get_version_build_date()

    #define fu_device_get_version_build_date(d) fwupd_device_get_version_build_date(FWUPD_DEVICE(d))

### fu_device_get_vendor_ids()

    #define fu_device_get_vendor_ids(d)	    fwupd_device_get_vendor_ids(FWUPD_DEVICE(d))

### fu_device_get_protocols()

    #define fu_device_get_protocols(d)	    fwupd_device_get_protocols(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 device, the release and the daemon-specific metadata.

#### Parameters

self | a FuDevice |

#### Returns

a string value, or `NULL` for invalid.

Since: 0.9.8

### fu_device_add_string ()

    void
    fu_device_add_string (FuDevice *self,
                          guint idt,
                          GString *str);

Add daemon-specific device metadata to an existing string.

#### Parameters

self | a FuDevice |
idt | indent level |
str | a string to append to |

Since: 1.7.1

### fu_device_get_alternate_id ()

    const gchar *
    fu_device_get_alternate_id (FuDevice *self);

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

#### Parameters

self | a FuDevice |

#### Returns

a device or `NULL`.

[transfer none]

Since: 1.1.0

### fu_device_set_alternate_id ()

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

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

#### Parameters

self | a FuDevice |
alternate_id | Another FuDevice ID. | [nullable]

Since: 1.1.0

### fu_device_get_equivalent_id ()

    const gchar *
    fu_device_get_equivalent_id (FuDevice *self);

Gets any equivalent ID for a device

#### Parameters

self | a FuDevice |

#### Returns

a gchar or NULL.

[transfer none]

Since: 0.6.1

### fu_device_set_equivalent_id ()

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

Sets any equivalent ID for a device

#### Parameters

self | a FuDevice |
equivalent_id | a string. | [nullable]

Since: 0.6.1

### 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 `fwupd_guid_hash_string()`.

#### Parameters

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

Since: 0.7.2

### fu_device_add_guid_full ()

    void
    fu_device_add_guid_full (FuDevice *self,
                             const gchar *guid,
                             FuDeviceInstanceFlags flags);

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

#### Parameters

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

Since: 1.6.2

### fu_device_has_guid ()

    gboolean
    fu_device_has_guid (FuDevice *self,
                        const gchar *guid);

Finds out if the device has a specific GUID.

#### Parameters

self | a FuDevice |
guid | a GUID, e.g. `WacomAES` |

#### Returns

`TRUE` if the GUID is found

Since: 1.2.2

### fu_device_add_instance_id ()

    void
    fu_device_add_instance_id (FuDevice *self,
                               const gchar *instance_id);

Adds an instance ID to the device. If the `instance_id` argument is already a valid GUID then `fu_device_add_guid()` should be used instead.

#### Parameters

self | a FuDevice |
instance_id | the instance ID, e.g. `PCI\VEN_10EC&amp;DEV_525A` |

Since: 1.2.5

### fu_device_add_instance_id_full ()

    void
    fu_device_add_instance_id_full (FuDevice *self,
                                    const gchar *instance_id,
                                    FuDeviceInstanceFlags flags);

Adds an instance ID with all parameters set

#### Parameters

self | a FuDevice |
instance_id | a instance ID, e.g. `WacomAES` |
flags | instance ID flags |

Since: 1.2.9

### 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 device or `NULL`.

[transfer none]

Since: 0.7.2

### fu_device_get_root ()

    FuDevice *
    fu_device_get_root (FuDevice *self);

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

If there is no parent device defined, then `self` is returned.

#### Parameters

self | a FuDevice |

#### Returns

a device.

[transfer full]

Since: 1.4.0

### 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 device 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_remove_child ()

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

Removes child device.

#### Parameters

self | a FuDevice |
child | Another FuDevice |

Since: 1.6.2

### 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_parent_physical_id ()

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

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

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

#### Parameters

self | a FuDevice |
physical_id | a device physical ID |

Since: 1.6.2

### 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 `fwupd_guid_hash_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_proxy ()

    FuDevice *
    fu_device_get_proxy (FuDevice *self);

Gets any proxy device. A proxy device can be used to perform an action on behalf of another device, for instance `attach()`ing it after a successful update.

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

#### Parameters

self | a FuDevice |

#### Returns

a device or `NULL`.

[transfer none]

Since: 1.4.1

### fu_device_set_proxy ()

    void
    fu_device_set_proxy (FuDevice *self,
                         FuDevice *proxy);

Sets any proxy device. A proxy device can be used to perform an action on behalf of another device, for instance `attach()`ing it after a successful update.

#### Parameters

self | a FuDevice |
proxy | a device |

Since: 1.4.1

### fu_device_get_proxy_with_fallback ()

    FuDevice *
    fu_device_get_proxy_with_fallback (FuDevice *self);

Gets the proxy device if `FU_DEVICE_INTERNAL_FLAG_USE_PROXY_FALLBACK` is set, falling back to the device itself.

#### Parameters

self | a FuDevice |

#### Returns

a device.

[transfer none]

Since: 1.6.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_remove_metadata ()

    void
    fu_device_remove_metadata (FuDevice *self,
                               const gchar *key);

Removes an item of metadata on the device.

#### Parameters

self | a FuDevice |
key | the key |

Since: 1.3.3

### 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 if required 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_set_version_format ()

    void
    fu_device_set_version_format (FuDevice *self,
                                  FwupdVersionFormat fmt);

Sets the device version format.

#### Parameters

self | a FuDevice |
fmt | the version format, e.g. `FWUPD_VERSION_FORMAT_PLAIN` |

Since: 1.4.0

### fu_device_set_version ()

    void
    fu_device_set_version (FuDevice *self,
                           const gchar *version);

Sets the device version, sanitizing the string if required.

#### Parameters

self | a FuDevice |
version | a string, e.g. `1.2.3`. | [nullable]

Since: 1.2.9

### fu_device_set_version_lowest ()

    void
    fu_device_set_version_lowest (FuDevice *self,
                                  const gchar *version);

Sets the device lowest version, sanitizing the string if required.

#### Parameters

self | a FuDevice |
version | a string, e.g. `1.2.3`. | [nullable]

Since: 1.4.0

### fu_device_set_version_bootloader ()

    void
    fu_device_set_version_bootloader (FuDevice *self,
                                      const gchar *version);

Sets the device bootloader version, sanitizing the string if required.

#### Parameters

self | a FuDevice |
version | a string, e.g. `1.2.3`. | [nullable]

Since: 1.4.0

### fu_device_inhibit ()

    void
    fu_device_inhibit (FuDevice *self,
                       const gchar *inhibit_id,
                       const gchar *reason);

Prevent the device from being updated, changing it from `FWUPD_DEVICE_FLAG_UPDATABLE` to `FWUPD_DEVICE_FLAG_UPDATABLE_HIDDEN` if not already inhibited.

If the device already has an inhibit with the same `inhibit_id` then the request is ignored.

#### Parameters

self | a FuDevice |
inhibit_id | an ID used for uninhibiting, e.g. `low-power` |
reason | a string, e.g. `Cannot update as foo [bar] needs reboot`. | [nullable]

Since: 1.6.0

### fu_device_uninhibit ()

    void
    fu_device_uninhibit (FuDevice *self,
                         const gchar *inhibit_id);

Allow the device from being updated if there are no other inhibitors, changing it from `FWUPD_DEVICE_FLAG_UPDATABLE_HIDDEN` to `FWUPD_DEVICE_FLAG_UPDATABLE`.

If the device already has no inhibit with the `inhibit_id` then the request is ignored.

#### Parameters

self | a FuDevice |
inhibit_id | an ID used for uninhibiting, e.g. `low-power` |

Since: 1.6.0

### 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_backend_id ()

    const gchar *
    fu_device_get_backend_id (FuDevice *self);

Gets the ID set for the device as recognized by the backend. This is typically a Linux sysfs path or USB platform ID. If unset, it also falls back to the physical ID as this may be the same value.

#### Parameters

self | a FuDevice |

#### Returns

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

Since: 1.5.8

### fu_device_set_backend_id ()

    void
    fu_device_set_backend_id (FuDevice *self,
                              const gchar *backend_id);

Sets the backend ID on the device. This is designed to disambiguate devices with the same physical ID. This is typically a Linux sysfs path or USB platform ID.

#### Parameters

self | a FuDevice |
backend_id | a string, e.g. `dev2` |

Since: 1.5.8

### fu_device_get_proxy_guid ()

    const gchar *
    fu_device_get_proxy_guid (FuDevice *self);

Gets the proxy GUID device, which which is set to let the engine match up the proxy between plugins.

#### Parameters

self | a FuDevice |

#### Returns

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

Since: 1.4.1

### fu_device_set_proxy_guid ()

    void
    fu_device_set_proxy_guid (FuDevice *self,
                              const gchar *proxy_guid);

Sets the GUID of the proxy device. The proxy device may update `self` .

#### Parameters

self | a FuDevice |
proxy_guid | a string, e.g. `USB\VID_413C&amp;PID_B06E&amp;hub` |

Since: 1.4.1

### fu_device_get_priority ()

    guint
    fu_device_get_priority (FuDevice *self);

Gets the device priority, where higher numbers are better.

#### Parameters

self | a FuPlugin |

#### Returns

the integer value

Since: 1.1.1

### fu_device_set_priority ()

    void
    fu_device_set_priority (FuDevice *self,
                            guint priority);

Sets the device priority, where higher numbers are better.

#### Parameters

self | a FuDevice |
priority | an integer value |

Since: 1.1.1

### fu_device_add_flag ()

    void
    fu_device_add_flag (FuDevice *self,
                        FwupdDeviceFlags flag);

Adds a device flag to the device.

#### Parameters

self | a FuDevice |
flag | a device flag |

Since: 0.1.0

### fu_device_remove_flag ()

    void
    fu_device_remove_flag (FuDevice *self,
                           FwupdDeviceFlags flag);

Removes a device flag from the device.

#### Parameters

self | a FuDevice |
flag | a device flag |

Since: 1.6.0

### 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_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_set_vendor ()

    void
    fu_device_set_vendor (FuDevice *self,
                          const gchar *vendor);

Sets the vendor name on the device.

#### Parameters

self | a FuDevice |
vendor | a device vendor |

Since: 1.6.2

### 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 delay value |

Since: 1.0.2

### fu_device_set_firmware_size ()

    void
    fu_device_set_firmware_size (FuDevice *self,
                                 guint64 size);

Sets the exact allowed size of the firmware blob.

#### Parameters

self | a FuDevice |
size | Size in bytes |

Since: 1.2.6

### 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_firmware_size_min ()

    guint64
    fu_device_get_firmware_size_min (FuDevice *self);

Gets the minimum size of the firmware blob.

#### Parameters

self | a FuDevice |

#### Returns

Size in bytes, or 0 if unset

Since: 1.2.6

### fu_device_get_firmware_size_max ()

    guint64
    fu_device_get_firmware_size_max (FuDevice *self);

Gets the maximum size of the firmware blob.

#### Parameters

self | a FuDevice |

#### Returns

Size in bytes, or 0 if unset

Since: 1.2.6

### fu_device_get_battery_level ()

    guint
    fu_device_get_battery_level (FuDevice *self);

Returns the battery level.

#### Parameters

self | a FuDevice |

#### Returns

value in percent

Since: 1.5.8

### fu_device_set_battery_level ()

    void
    fu_device_set_battery_level (FuDevice *self,
                                 guint battery_level);

Sets the battery level, or `FU_BATTERY_VALUE_INVALID`.

Setting this allows fwupd to show a warning if the device change is too low to perform the update.

#### Parameters

self | a FuDevice |
battery_level | the percentage value |

Since: 1.5.8

### fu_device_get_battery_threshold ()

    guint
    fu_device_get_battery_threshold (FuDevice *self);

Returns the battery threshold under which a firmware update cannot be performed.

If `fu_device_set_battery_threshold()` has not been used, a default value is used instead.

#### Parameters

self | a FuDevice |

#### Returns

value in percent

Since: 1.6.0

### fu_device_set_battery_threshold ()

    void
    fu_device_set_battery_threshold (FuDevice *self,
                                     guint battery_threshold);

Sets the battery level, or `FU_BATTERY_VALUE_INVALID` for the default.

Setting this allows fwupd to show a warning if the device change is too low to perform the update.

#### Parameters

self | a FuDevice |
battery_threshold | the percentage value |

Since: 1.6.0

### fu_device_set_update_state ()

    void
    fu_device_set_update_state (FuDevice *self,
                                FwupdUpdateState update_state);

Sets the update state, clearing the update error as required.

#### Parameters

self | a FuDevice |
update_state | the state, e.g. `FWUPD_UPDATE_STATE_PENDING` |

Since: 1.6.2

### fu_device_set_context ()

    void
    fu_device_set_context (FuDevice *self,
                           FuContext *ctx);

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

#### Parameters

self | a FuDevice |
ctx | optional FuContext. | [nullable]

Since: 1.6.0

### fu_device_get_context ()

    FuContext *
    fu_device_get_context (FuDevice *self);

Gets the context assigned for this device.

#### Parameters

self | a FuDevice |

#### Returns

the FuContext object, or `NULL`.

[transfer none]

Since: 1.6.0

### 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_get_specialized_gtype ()

    GType
    fu_device_get_specialized_gtype (FuDevice *self);

Gets the specialized type of the device

#### Parameters

self | a FuDevice |

#### Returns

GType

Since: 1.3.3

### fu_device_get_firmware_gtype ()

    GType
    fu_device_get_firmware_gtype (FuDevice *self);

Gets the default firmware type for the device.

#### Parameters

self | a FuDevice |

#### Returns

GType

Since: 1.7.2

### fu_device_set_firmware_gtype ()

    void
    fu_device_set_firmware_gtype (FuDevice *self,
                                  GType firmware_gtype);

Sets the default firmware type for the device.

#### Parameters

self | a FuDevice |
firmware_gtype | a GType |

Since: 1.7.2

### fu_device_add_internal_flag ()

    void
    fu_device_add_internal_flag (FuDevice *self,
                                 FuDeviceInternalFlags flag);

Adds a private flag that stays internal to the engine and is not leaked to the client.

#### Parameters

self | a FuDevice |
flag | an internal device flag, e.g. `FU_DEVICE_INTERNAL_FLAG_MD_SET_ICON` |

Since: 1.5.5

### fu_device_remove_internal_flag ()

    void
    fu_device_remove_internal_flag (FuDevice *self,
                                    FuDeviceInternalFlags flag);

Removes a private flag that stays internal to the engine and is not leaked to the client.

#### Parameters

self | a FuDevice |
flag | an internal device flag, e.g. `FU_DEVICE_INTERNAL_FLAG_MD_SET_ICON` |

Since: 1.5.5

### fu_device_has_internal_flag ()

    gboolean
    fu_device_has_internal_flag (FuDevice *self,
                                 FuDeviceInternalFlags flag);

Tests for a private flag that stays internal to the engine and is not leaked to the client.

#### Parameters

self | a FuDevice |
flag | an internal device flag, e.g. `FU_DEVICE_INTERNAL_FLAG_MD_SET_ICON` |

Since: 1.5.5

### fu_device_get_results ()

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

Gets the results of the last update operation on the device by calling a vfunc.

#### Parameters

self | a FuDevice |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.6.2

### fu_device_write_firmware ()

    gboolean
    fu_device_write_firmware (FuDevice *self,
                              GBytes *fw,
                              FuProgress *progress,
                              FwupdInstallFlags flags,
                              GError **error);

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

#### Parameters

self | a FuDevice |
fw | firmware blob |
progress | a FuProgress |
flags | install flags, e.g. `FWUPD_INSTALL_FLAG_FORCE` |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.0.8

### fu_device_prepare_firmware ()

    FuFirmware *
    fu_device_prepare_firmware (FuDevice *self,
                                GBytes *fw,
                                FwupdInstallFlags flags,
                                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 | firmware blob |
flags | install flags, e.g. `FWUPD_INSTALL_FLAG_FORCE` |
error | optional return location for an error. | [nullable]

#### Returns

a new GBytes, or `NULL` for error.

[transfer full]

Since: 1.1.2

### fu_device_read_firmware ()

    FuFirmware *
    fu_device_read_firmware (FuDevice *self,
                             FuProgress *progress,
                             GError **error);

Reads firmware from the device by calling a plugin-specific vfunc. The device subclass should try to ensure the firmware does not contain any serial numbers or user-configuration values and can be used to calculate the device checksum.

The return value can be converted to a blob of memory using `fu_firmware_write()`.

#### Parameters

self | a FuDevice |
progress | a FuProgress |
error | optional return location for an error. | [nullable]

#### Returns

a FuFirmware, or `NULL` for error.

[transfer full]

Since: 1.0.8

### fu_device_dump_firmware ()

    GBytes *
    fu_device_dump_firmware (FuDevice *self,
                             FuProgress *progress,
                             GError **error);

Reads the raw firmware image from the device by calling a plugin-specific vfunc. This raw firmware image may contain serial numbers or device-specific configuration but should be a byte-for-byte match compared to using an external SPI programmer.

#### Parameters

self | a FuDevice |
progress | a FuProgress |
error | optional return location for an error. | [nullable]

#### Returns

a GBytes, or `NULL` for error.

[transfer full]

Since: 1.5.0

### 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 | optional return location for an error. | [nullable]

#### 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 | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.0.8

### fu_device_attach_full ()

    gboolean
    fu_device_attach_full (FuDevice *self,
                           FuProgress *progress,
                           GError **error);

Attaches a device from the bootloader into application mode.

#### Parameters

self | a FuDevice |
progress | a FuProgress |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.7.0

### fu_device_detach_full ()

    gboolean
    fu_device_detach_full (FuDevice *self,
                           FuProgress *progress,
                           GError **error);

Detaches a device from the application into bootloader mode.

#### Parameters

self | a FuDevice |
progress | a FuProgress |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.7.0

### fu_device_reload ()

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

Reloads a device that has just gone from bootloader into application mode.

#### Parameters

self | a FuDevice |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.3.3

### fu_device_prepare ()

    gboolean
    fu_device_prepare (FuDevice *self,
                       FwupdInstallFlags flags,
                       GError **error);

Prepares a device for update. A different plugin can handle each of FuDevice->`prepare()`, FuDevice->`detach()` and FuDevice->`write_firmware()`.

#### Parameters

self | a FuDevice |
flags | install flags |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.3.3

### fu_device_cleanup ()

    gboolean
    fu_device_cleanup (FuDevice *self,
                       FwupdInstallFlags flags,
                       GError **error);

Cleans up a device after an update. A different plugin can handle each of FuDevice->`write_firmware()`, FuDevice->`attach()` and FuDevice->`cleanup()`.

#### Parameters

self | a FuDevice |
flags | install flags |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` on success

Since: 1.3.3

### 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_incorporate_flag ()

    void
    fu_device_incorporate_flag (FuDevice *self,
                                FuDevice *donor,
                                FwupdDeviceFlags flag);

Copy the value of a specific flag from the donor object.

#### Parameters

self | a FuDevice |
donor | another device |
flag | device flags |

Since: 1.3.5

### 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` .

If the `->`probe()``, `->`open()`` and `->`setup()`` actions all complete successfully the internal device flag `FU_DEVICE_INTERNAL_FLAG_IS_OPEN` will be set.

NOTE: It is important to still call `fu_device_close()` even if this function fails as the device may still be partially initialized.

#### Parameters

self | a FuDevice |
error | optional return location for an error. | [nullable]

#### 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.

If the close action completed successfully the internal device flag `FU_DEVICE_INTERNAL_FLAG_IS_OPEN` will be cleared.

#### Parameters

self | a FuDevice |
error | optional return location for an error. | [nullable]

#### 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 | optional return location for an error. | [nullable]

#### 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 | optional return location for an error. | [nullable]

#### Returns

`TRUE` for success

Since: 1.1.2

### fu_device_rescan ()

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

Rescans a device, re-adding GUIDs or flags based on some hardware change.

#### Parameters

self | a FuDevice |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` for success

Since: 1.3.1

### fu_device_activate ()

    gboolean
    fu_device_activate (FuDevice *self,
                        FuProgress *progress,
                        GError **error);

Activates up a device, which normally means the device switches to a new firmware version. This should only be called when data loss cannot occur.

#### Parameters

self | a FuDevice |
progress | a FuProgress |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` for success

Since: 1.2.6

### 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 |

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 | optional return location for an error. | [nullable]

#### 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

### fu_device_retry_set_delay ()

    void
    fu_device_retry_set_delay (FuDevice *self,
                               guint delay);

Sets the recovery delay between failed retries.

#### Parameters

self | a FuDevice |
delay | delay in ms |

Since: 1.4.0

### fu_device_retry_add_recovery ()

    void
    fu_device_retry_add_recovery (FuDevice *self,
                                  GQuark domain,
                                  gint code,
                                  FuDeviceRetryFunc func);

Sets the optional function to be called when `fu_device_retry()` fails, which is possibly a device reset.

If `func` is `NULL` then recovery is not possible and an error is returned straight away.

#### Parameters

self | a FuDevice |
domain | a GQuark, or `0` for all domains |
code | a GError code |
func | a function to recover the device. | [scope async][nullable]

Since: 1.4.0

### fu_device_retry ()

    gboolean
    fu_device_retry (FuDevice *self,
                     FuDeviceRetryFunc func,
                     guint count,
                     gpointer user_data,
                     GError **error);

Calls a specific function a number of times, optionally handling the error with a reset action.

If `fu_device_retry_add_recovery()` has not been used then all errors are considered non-fatal until the last try.

If the reset function returns `FALSE`, then the function returns straight away without processing any pending retries.

#### Parameters

self | a FuDevice |
func | a function to execute. | [scope async]
count | the number of tries to try the function |
user_data | a helper to pass to `func` . | [nullable]
error | optional return location for an error. | [nullable]

Since: 1.4.0

### fu_device_retry_full ()

    gboolean
    fu_device_retry_full (FuDevice *self,
                          FuDeviceRetryFunc func,
                          guint count,
                          guint delay,
                          gpointer user_data,
                          GError **error);

Calls a specific function a number of times, optionally handling the error with a reset action.

If `fu_device_retry_add_recovery()` has not been used then all errors are considered non-fatal until the last try.

If the reset function returns `FALSE`, then the function returns straight away without processing any pending retries.

#### Parameters

self | a FuDevice |
func | a function to execute. | [scope async]
count | the number of tries to try the function |
delay | the delay between each try in ms |
user_data | a helper to pass to `func` . | [nullable]
error | optional return location for an error. | [nullable]

Since: 1.5.5

### fu_device_bind_driver ()

    gboolean
    fu_device_bind_driver (FuDevice *self,
                           const gchar *subsystem,
                           const gchar *driver,
                           GError **error);

Binds a driver to the device, which normally means the kernel driver takes control of the hardware.

#### Parameters

self | a FuDevice |
subsystem | a subsystem string, e.g. `pci` |
driver | a kernel module name, e.g. `tg3` |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` if driver was bound.

Since: 1.5.0

### fu_device_unbind_driver ()

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

Unbinds the driver from the device, which normally means the kernel releases the hardware so it can be used from userspace.

If there is no driver bound then this function will return with success without actually doing anything.

#### Parameters

self | a FuDevice |
error | optional return location for an error. | [nullable]

#### Returns

`TRUE` if driver was unbound.

Since: 1.5.0

### fu_device_report_metadata_pre ()

    GHashTable *
    fu_device_report_metadata_pre (FuDevice *self);

Collects metadata that would be useful for debugging a failed update report.

#### Parameters

self | a FuDevice |

#### Returns

a GHashTable, or `NULL` if there is no data.

[transfer full][nullable]

Since: 1.5.0

### fu_device_report_metadata_post ()

    GHashTable *
    fu_device_report_metadata_post (FuDevice *self);

Collects metadata that would be useful for debugging a failed update report.

#### Parameters

self | a FuDevice |

#### Returns

a GHashTable, or `NULL` if there is no data.

[transfer full][nullable]

Since: 1.5.0

### fu_device_add_security_attrs ()

    void
    fu_device_add_security_attrs (FuDevice *self,
                                  FuSecurityAttrs *attrs);

Adds HSI security attributes.

#### Parameters

self | a FuDevice |
attrs | a security attribute |

Since: 1.6.0

### fu_device_register_private_flag ()

    void
    fu_device_register_private_flag (FuDevice *self,
                                     guint64 value,
                                     const gchar *value_str);

Registers a private device flag so that it can be set from quirk files.

#### Parameters

self | a FuDevice |
value | an integer value |
value_str | a string that represents `value` |

Since: 1.6.2

### fu_device_add_private_flag ()

    void
    fu_device_add_private_flag (FuDevice *self,
                                guint64 flag);

Adds a private flag that can be used by the plugin for any purpose.

#### Parameters

self | a FuDevice |
flag | a device flag |

Since: 1.6.2

### fu_device_remove_private_flag ()

    void
    fu_device_remove_private_flag (FuDevice *self,
                                   guint64 flag);

Removes a private flag that can be used by the plugin for any purpose.

#### Parameters

self | a FuDevice |
flag | a device flag |

Since: 1.6.2

### fu_device_has_private_flag ()

    gboolean
    fu_device_has_private_flag (FuDevice *self,
                                guint64 flag);

Tests for a private flag that can be used by the plugin for any purpose.

#### Parameters

self | a FuDevice |
flag | a device flag |

Since: 1.6.2

### fu_device_emit_request ()

    void
    fu_device_emit_request (FuDevice *self,
                            FwupdRequest *request);

Emit a request from a plugin to the client.

#### Parameters

self | a device |
request | a request |

Since: 1.6.2

## Types and Values

### FU_TYPE_DEVICE

    #define FU_TYPE_DEVICE (fu_device_get_type())

### struct FuDeviceClass

    struct FuDeviceClass {
    	FwupdDeviceClass parent_class;
    #ifndef __GI_SCANNER__
    	void (*to_string)(FuDevice *self, guint indent, GString *str);
    	gboolean (*write_firmware)(FuDevice *self,
    				   FuFirmware *firmware,
    				   FuProgress *progress,
    				   FwupdInstallFlags flags,
    				   GError **error);
    	FuFirmware *(*read_firmware)(FuDevice *self,
    				     FuProgress *progress,
    				     GError **error)G_GNUC_WARN_UNUSED_RESULT;
    	gboolean (*detach)(FuDevice *self,
    			   FuProgress *progress,
    			   GError **error);
    	gboolean (*attach)(FuDevice *self,
    			   FuProgress *progress,
    			   GError **error);
    	gboolean (*open)(FuDevice *self, GError **error);
    	gboolean (*close)(FuDevice *self, GError **error);
    	gboolean (*probe)(FuDevice *self, GError **error);
    	gboolean (*rescan)(FuDevice *self, GError **error);
    	FuFirmware *(*prepare_firmware)(FuDevice *self,
    					GBytes *fw,
    					FwupdInstallFlags flags,
    					GError **error)G_GNUC_WARN_UNUSED_RESULT;
    	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);
    	gboolean (*activate)(FuDevice *self,
    			     FuProgress *progress,
    			     GError **error);
    	gboolean (*reload)(FuDevice *self, GError **error);
    	gboolean (*prepare)(FuDevice *self,
    			    FwupdInstallFlags flags,
    			    GError **error);
    	gboolean (*cleanup)(FuDevice *self,
    			    FwupdInstallFlags flags,
    			    GError **error);
    	void (*report_metadata_pre)(FuDevice *self, GHashTable *metadata);
    	void (*report_metadata_post)(FuDevice *self, GHashTable *metadata);
    	gboolean (*bind_driver)(FuDevice *self,
    				const gchar *subsystem,
    				const gchar *driver,
    				GError **error);
    	gboolean (*unbind_driver)(FuDevice *self, GError **error);
    	GBytes *(*dump_firmware)(FuDevice *self,
    				 FuProgress *progress,
    				 GError **error)G_GNUC_WARN_UNUSED_RESULT;
    	void (*add_security_attrs)(FuDevice *self, FuSecurityAttrs *attrs);
    	gboolean (*ready)(FuDevice *self, GError **error);
    	void (*child_added)(FuDevice *self, /* signal */
    			    FuDevice *child);
    	void (*child_removed)(FuDevice *self, /* signal */
    			      FuDevice *child);
    	void (*request)(FuDevice *self, /* signal */
    			FwupdRequest *request);
    	gboolean (*get_results)(FuDevice *self, GError **error);
    	void (*set_progress)(FuDevice *self, FuProgress *progress);
    };

### enum FuDeviceInstanceFlags

The flags to use when interacting with a device instance

#### Members

FU_DEVICE_INSTANCE_FLAG_NONE | No flags set |
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS | Only use instance ID for quirk matching |
FU_DEVICE_INSTANCE_FLAG_NO_QUIRKS | Do no quirk matching |

### 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.

### FuDeviceInternalFlags

    typedef guint64 FuDeviceInternalFlags;

The device internal flags.

### FU_DEVICE_INTERNAL_FLAG_NONE

    #define FU_DEVICE_INTERNAL_FLAG_NONE (0)

No flags set.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_UNKNOWN

    #define FU_DEVICE_INTERNAL_FLAG_UNKNOWN G_MAXUINT64

Unknown flag value.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_NO_AUTO_INSTANCE_IDS

    #define FU_DEVICE_INTERNAL_FLAG_NO_AUTO_INSTANCE_IDS (1ull << 0)

Do not add instance IDs from the device baseclass.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_ENSURE_SEMVER

    #define FU_DEVICE_INTERNAL_FLAG_ENSURE_SEMVER (1ull << 1)

Ensure the version is a valid semantic version, e.g. numbers separated with dots.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_ONLY_SUPPORTED

    #define FU_DEVICE_INTERNAL_FLAG_ONLY_SUPPORTED (1ull << 2)

Only devices supported in the metadata will be opened

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME

    #define FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME (1ull << 3)

Set the device name from the metadata `name` if available.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME_CATEGORY

    #define FU_DEVICE_INTERNAL_FLAG_MD_SET_NAME_CATEGORY (1ull << 4)

Set the device name from the metadata `category` if available.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_MD_SET_VERFMT

    #define FU_DEVICE_INTERNAL_FLAG_MD_SET_VERFMT (1ull << 5)

Set the device version format from the metadata if available.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_MD_SET_ICON

    #define FU_DEVICE_INTERNAL_FLAG_MD_SET_ICON (1ull << 6)

Set the device icon from the metadata if available.

Since: 1.5.5

### FU_DEVICE_INTERNAL_FLAG_REPLUG_MATCH_GUID

    #define FU_DEVICE_INTERNAL_FLAG_REPLUG_MATCH_GUID (1ull << 8)

Match GUIDs on device replug where the physical and logical IDs will be different.

Since: 1.5.8

### FU_DEVICE_INTERNAL_FLAG_INHERIT_ACTIVATION

    #define FU_DEVICE_INTERNAL_FLAG_INHERIT_ACTIVATION (1ull << 9)

Inherit activation status from the history database on startup.

Since: 1.5.9

### FU_DEVICE_INTERNAL_FLAG_NO_SERIAL_NUMBER

    #define FU_DEVICE_INTERNAL_FLAG_NO_SERIAL_NUMBER (1ull << 11)

Do not attempt to read the device serial number.

Since: 1.6.2

### FU_DEVICE_INTERNAL_FLAG_AUTO_PARENT_CHILDREN

    #define FU_DEVICE_INTERNAL_FLAG_AUTO_PARENT_CHILDREN (1ull << 12)

Automatically assign the parent for children of this device.

Since: 1.6.2

### FU_DEVICE_INTERNAL_FLAG_ATTACH_EXTRA_RESET

    #define FU_DEVICE_INTERNAL_FLAG_ATTACH_EXTRA_RESET (1ull << 13)

Device needs resetting twice for attach after the firmware update.

Since: 1.6.2

### FU_DEVICE_INTERNAL_FLAG_INHIBIT_CHILDREN

    #define FU_DEVICE_INTERNAL_FLAG_INHIBIT_CHILDREN (1ull << 14)

Children of the device are inhibited by the parent.

Since: 1.6.2

### FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE_CHILDREN

    #define FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE_CHILDREN (1ull << 15)

Do not auto-remove clildren in the device list.

Since: 1.6.2

### FU_DEVICE_INTERNAL_FLAG_USE_PARENT_FOR_BATTERY

    #define FU_DEVICE_INTERNAL_FLAG_USE_PARENT_FOR_BATTERY (1ull << 17)

Use parent for the battery level and threshold.

Since: 1.6.3

### FU_DEVICE_INTERNAL_FLAG_USE_PROXY_FALLBACK

    #define FU_DEVICE_INTERNAL_FLAG_USE_PROXY_FALLBACK (1ull << 18)

Use parent for the battery level and threshold.

Since: 1.6.4

### FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE

    #define FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE (1llu << 19)

The device is not auto removed.

Since 1.7.3

### FU_DEVICE_INTERNAL_FLAG_MD_SET_VENDOR

    #define FU_DEVICE_INTERNAL_FLAG_MD_SET_VENDOR (1ull << 20)

Set the device vendor from the metadata `developer_name` if available.

Since: 1.7.4

### FU_DEVICE_INTERNAL_FLAG_NO_LID_CLOSED

    #define FU_DEVICE_INTERNAL_FLAG_NO_LID_CLOSED (1ull << 21)

Do not allow updating when the laptop lid is closed.

Since: 1.7.4

### FuDevice

    typedef struct _FuDevice FuDevice;

A physical or logical device that is exported to the daemon.

See also: [class`FuDeviceLocker` ], [class`Fwupd.Device` ]