DfuContext

DfuContext — A system context for managing DFU-capable devices

Functions

Types and Values

Description

This object allows discovering and monitoring hotpluggable DFU devices.

When using DfuContext the device is given some time to re-enumerate after a detach or reset. This allows client programs to continue using the DfuDevice without dealing with the device hotplug and the GUsbDevice changing. Using this object may be easier than using GUsbContext directly.

Please be aware that after device detach or reset the number of DfuTarget objects may be different and so need to be re-requested.

See also: DfuDevice, DfuTarget

Functions

dfu_context_new ()

DfuContext *
dfu_context_new (void);

Creates a new DFU context object.

Returns

a new DfuContext

Since: 0.5.4


dfu_context_new_with_context ()

DfuContext *
dfu_context_new_with_context (GUsbContext *usb_ctx);

Creates a new DFU context object.

Parameters

usb_ctx

a DfuContext

 

Returns

a new DfuContext

Since: 0.7.6


dfu_context_enumerate ()

gboolean
dfu_context_enumerate (DfuContext *context,
                       GError **error);

Opens a DFU-capable context.

Parameters

context

a DfuContext

 

error

a GError, or NULL

 

Returns

TRUE for success

Since: 0.5.4


dfu_context_get_devices ()

GPtrArray *
dfu_context_get_devices (DfuContext *context);

Gets all the DFU-capable devices on the system.

Parameters

context

a DfuContext

 

Returns

array of devices.

[element-type DfuDevice][transfer container]

Since: 0.5.4


dfu_context_get_timeout ()

guint
dfu_context_get_timeout (DfuContext *context);

Gets the wait-for-replug timeout.

Parameters

context

a DfuContext

 

Returns

value in milliseconds

Since: 0.5.4


dfu_context_set_timeout ()

void
dfu_context_set_timeout (DfuContext *context,
                         guint timeout);

Sets the wait-for-replug timeout. This is the longest we will wait for a device to re-enumerate after disconnecting. Using longer values will result in any UI not updating in a good time, but using too short values will result in devices being removed and re-added as different DfuDevice's.

Parameters

context

a DfuContext

 

timeout

a timeout in milliseconds

 

Since: 0.5.4


dfu_context_get_device_by_vid_pid ()

DfuDevice *
dfu_context_get_device_by_vid_pid (DfuContext *context,
                                   guint16 vid,
                                   guint16 pid,
                                   GError **error);

Finds a device in the context with a specific vendor:product ID. An error is returned if more than one device matches.

Parameters

context

a DfuContext

 

vid

a vendor ID

 

pid

a product ID

 

error

a GError, or NULL

 

Returns

a DfuDevice for success, or NULL for an error.

[transfer full]

Since: 0.5.4


dfu_context_get_device_by_platform_id ()

DfuDevice *
dfu_context_get_device_by_platform_id (DfuContext *context,
                                       const gchar *platform_id,
                                       GError **error);

Finds a device in the context with a specific platform ID.

Parameters

context

a DfuContext

 

platform_id

a platform ID

 

error

a GError, or NULL

 

Returns

a DfuDevice for success, or NULL for an error.

[transfer full]

Since: 0.5.4


dfu_context_get_device_default ()

DfuDevice *
dfu_context_get_device_default (DfuContext *context,
                                GError **error);

Gets the default device in the context. An error is returned if more than one device exists.

Parameters

context

a DfuContext

 

error

a GError, or NULL

 

Returns

a DfuDevice for success, or NULL for an error.

[transfer full]

Since: 0.5.4

Types and Values

DFU_TYPE_CONTEXT

#define DFU_TYPE_CONTEXT (dfu_context_get_type ())

struct DfuContextClass

struct DfuContextClass {
	GObjectClass		 parent_class;
	void			(*device_added)		(DfuContext *context,
							 DfuDevice *device);
	void			(*device_removed) (DfuContext *context,
							 DfuDevice *device);
	void			(*device_changed) (DfuContext *context,
							 DfuDevice *device);
};

DfuContext

typedef struct _DfuContext DfuContext;