mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-21 17:32:04 +00:00
unifying: Subclass FuDevice like the altos plugin
This commit is contained in:
parent
a4e44ce39b
commit
0de35b058d
@ -6,13 +6,16 @@ AM_CPPFLAGS = \
|
|||||||
-I$(top_srcdir)/libfwupd \
|
-I$(top_srcdir)/libfwupd \
|
||||||
-I$(top_srcdir)/src
|
-I$(top_srcdir)/src
|
||||||
|
|
||||||
|
FWUPD_LIBS = \
|
||||||
|
$(top_builddir)/libfwupd/libfwupd.la
|
||||||
|
|
||||||
plugindir = $(libdir)/fwupd-plugins-2
|
plugindir = $(libdir)/fwupd-plugins-2
|
||||||
plugin_LTLIBRARIES = libfu_plugin_unifying.la
|
plugin_LTLIBRARIES = libfu_plugin_unifying.la
|
||||||
|
|
||||||
libfu_plugin_unifying_la_SOURCES = \
|
libfu_plugin_unifying_la_SOURCES = \
|
||||||
fu-plugin-unifying.c \
|
fu-device-unifying.c \
|
||||||
unifying-dongle.c \
|
fu-device-unifying.h \
|
||||||
unifying-dongle.h
|
fu-plugin-unifying.c
|
||||||
libfu_plugin_unifying_la_LIBADD = $(GUSB_LIBS)
|
libfu_plugin_unifying_la_LIBADD = $(GUSB_LIBS)
|
||||||
libfu_plugin_unifying_la_LDFLAGS = -module -avoid-version
|
libfu_plugin_unifying_la_LDFLAGS = -module -avoid-version
|
||||||
libfu_plugin_unifying_la_CFLAGS = $(WARN_CFLAGS) \
|
libfu_plugin_unifying_la_CFLAGS = $(WARN_CFLAGS) \
|
||||||
@ -21,16 +24,19 @@ libfu_plugin_unifying_la_CFLAGS = $(WARN_CFLAGS) \
|
|||||||
EXTRA_DIST = README.md
|
EXTRA_DIST = README.md
|
||||||
|
|
||||||
noinst_PROGRAMS = \
|
noinst_PROGRAMS = \
|
||||||
unifying-tool
|
fu-unifying-tool
|
||||||
|
|
||||||
unifying_tool_SOURCES = \
|
fu_unifying_tool_SOURCES = \
|
||||||
unifying-dongle.c \
|
fu-device-unifying.c \
|
||||||
unifying-dongle.h \
|
fu-device-unifying.h \
|
||||||
unifying-tool.c
|
../../src/fu-device.c \
|
||||||
|
../../src/fu-device.h \
|
||||||
|
fu-unifying-tool.c
|
||||||
|
|
||||||
unifying_tool_LDADD = \
|
fu_unifying_tool_LDADD = \
|
||||||
$(lib_LTLIBRARIES) \
|
$(lib_LTLIBRARIES) \
|
||||||
$(APPSTREAM_GLIB_LIBS) \
|
$(APPSTREAM_GLIB_LIBS) \
|
||||||
|
$(FWUPD_LIBS) \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(GUSB_LIBS) \
|
$(GUSB_LIBS) \
|
||||||
$(LIBM)
|
$(LIBM)
|
||||||
|
File diff suppressed because it is too large
Load Diff
74
plugins/unifying/fu-device-unifying.h
Normal file
74
plugins/unifying/fu-device-unifying.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
|
||||||
|
*
|
||||||
|
* Licensed under the GNU Lesser General Public License Version 2.1
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FU_DEVICE_UNIFYING_H
|
||||||
|
#define __FU_DEVICE_UNIFYING_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gusb.h>
|
||||||
|
|
||||||
|
#include "fu-plugin.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define FU_TYPE_DEVICE_UNIFYING (fu_device_unifying_get_type ())
|
||||||
|
G_DECLARE_DERIVABLE_TYPE (FuDeviceUnifying, fu_device_unifying, FU, DEVICE_UNIFYING, FuDevice)
|
||||||
|
|
||||||
|
struct _FuDeviceUnifyingClass
|
||||||
|
{
|
||||||
|
FuDeviceClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FU_DEVICE_UNIFYING_KIND_UNKNOWN,
|
||||||
|
FU_DEVICE_UNIFYING_KIND_RUNTIME,
|
||||||
|
FU_DEVICE_UNIFYING_KIND_BOOTLOADER_NORDIC,
|
||||||
|
FU_DEVICE_UNIFYING_KIND_BOOTLOADER_TEXAS,
|
||||||
|
/*< private >*/
|
||||||
|
FU_DEVICE_UNIFYING_KIND_LAST
|
||||||
|
} FuDeviceUnifyingKind;
|
||||||
|
|
||||||
|
FuDeviceUnifying *fu_device_unifying_new (GUsbDevice *usb_device);
|
||||||
|
FuDeviceUnifying *fu_device_unifying_emulated_new (FuDeviceUnifyingKind kind);
|
||||||
|
|
||||||
|
FuDeviceUnifyingKind fu_device_unifying_kind_from_string (const gchar *kind);
|
||||||
|
const gchar *fu_device_unifying_kind_to_string (FuDeviceUnifyingKind kind);
|
||||||
|
|
||||||
|
FuDeviceUnifyingKind fu_device_unifying_get_kind (FuDeviceUnifying *device);
|
||||||
|
GUsbDevice *fu_device_unifying_get_usb_device (FuDeviceUnifying *device);
|
||||||
|
|
||||||
|
gboolean fu_device_unifying_open (FuDeviceUnifying *device,
|
||||||
|
GError **error);
|
||||||
|
gboolean fu_device_unifying_detach (FuDeviceUnifying *device,
|
||||||
|
GError **error);
|
||||||
|
gboolean fu_device_unifying_attach (FuDeviceUnifying *device,
|
||||||
|
GError **error);
|
||||||
|
gboolean fu_device_unifying_close (FuDeviceUnifying *device,
|
||||||
|
GError **error);
|
||||||
|
gboolean fu_device_unifying_write_firmware (FuDeviceUnifying *device,
|
||||||
|
GBytes *fw,
|
||||||
|
GFileProgressCallback progress_cb,
|
||||||
|
gpointer progress_data,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __FU_DEVICE_UNIFYING_H */
|
@ -28,20 +28,18 @@
|
|||||||
#include "fu-plugin.h"
|
#include "fu-plugin.h"
|
||||||
#include "fu-plugin-vfuncs.h"
|
#include "fu-plugin-vfuncs.h"
|
||||||
|
|
||||||
#include "unifying-dongle.h"
|
#include "fu-device-unifying.h"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_unifying_device_added (FuPlugin *plugin,
|
fu_plugin_unifying_device_added (FuPlugin *plugin,
|
||||||
GUsbDevice *usb_device,
|
GUsbDevice *usb_device,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
UnifyingDongleKind fu_unifying_kind;
|
|
||||||
const gchar *platform_id = NULL;
|
const gchar *platform_id = NULL;
|
||||||
g_autofree gchar *name = NULL;
|
g_autofree gchar *name = NULL;
|
||||||
g_autoptr(AsProfile) profile = as_profile_new ();
|
g_autoptr(AsProfile) profile = as_profile_new ();
|
||||||
g_autoptr(AsProfileTask) ptask = NULL;
|
g_autoptr(AsProfileTask) ptask = NULL;
|
||||||
g_autoptr(FuDevice) dev = NULL;
|
g_autoptr(FuDeviceUnifying) dev = NULL;
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
|
||||||
|
|
||||||
/* profile */
|
/* profile */
|
||||||
ptask = as_profile_start (profile, "FuPluginUnifying:added{%04x:%04x}",
|
ptask = as_profile_start (profile, "FuPluginUnifying:added{%04x:%04x}",
|
||||||
@ -51,40 +49,27 @@ fu_plugin_unifying_device_added (FuPlugin *plugin,
|
|||||||
|
|
||||||
/* get version */
|
/* get version */
|
||||||
platform_id = g_usb_device_get_platform_id (usb_device);
|
platform_id = g_usb_device_get_platform_id (usb_device);
|
||||||
dongle = unifying_dongle_new (usb_device);
|
dev = fu_device_unifying_new (usb_device);
|
||||||
if (dongle == NULL ||
|
if (dev == NULL ||
|
||||||
unifying_dongle_get_kind (dongle) == UNIFYING_DONGLE_KIND_UNKNOWN) {
|
fu_device_unifying_get_kind (dev) == FU_DEVICE_UNIFYING_KIND_UNKNOWN) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
"invalid Logitech device type detected");
|
"invalid Logitech device type detected");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
fu_device_set_id (FU_DEVICE (dev), platform_id);
|
||||||
|
|
||||||
/* open the device */
|
/* open the device */
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (dev, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* generate name */
|
|
||||||
fu_unifying_kind = unifying_dongle_get_kind (dongle);
|
|
||||||
name = g_strdup_printf ("Logitech Unifying [%s]",
|
|
||||||
unifying_dongle_kind_to_string (fu_unifying_kind));
|
|
||||||
|
|
||||||
/* create the device */
|
|
||||||
dev = fu_device_new ();
|
|
||||||
fu_device_set_id (dev, platform_id);
|
|
||||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_ONLINE);
|
|
||||||
fu_device_add_guid (dev, unifying_dongle_get_guid (dongle));
|
|
||||||
fu_device_set_version (dev, unifying_dongle_get_version_fw (dongle));
|
|
||||||
fu_device_set_version_bootloader (dev, unifying_dongle_get_version_bl (dongle));
|
|
||||||
fu_device_set_name (dev, name);
|
|
||||||
|
|
||||||
/* close the device */
|
/* close the device */
|
||||||
if (!unifying_dongle_close (dongle, error))
|
if (!fu_device_unifying_close (dev, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* insert to hash */
|
/* insert to hash */
|
||||||
fu_plugin_device_add (plugin, dev);
|
fu_plugin_device_add (plugin, FU_DEVICE (dev));
|
||||||
fu_plugin_cache_add (plugin, platform_id, dev);
|
fu_plugin_cache_add (plugin, platform_id, dev);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -101,7 +86,7 @@ fu_unifying_write_progress_cb (goffset current, goffset total, gpointer user_dat
|
|||||||
fu_plugin_set_percentage (plugin, (guint) percentage);
|
fu_plugin_set_percentage (plugin, (guint) percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnifyingDongle *
|
static FuDeviceUnifying *
|
||||||
fu_plugin_unifying_get_dongle (FuPlugin *plugin,
|
fu_plugin_unifying_get_dongle (FuPlugin *plugin,
|
||||||
FuDevice *dev,
|
FuDevice *dev,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -109,7 +94,7 @@ fu_plugin_unifying_get_dongle (FuPlugin *plugin,
|
|||||||
GUsbContext *usb_ctx = fu_plugin_get_usb_context (plugin);
|
GUsbContext *usb_ctx = fu_plugin_get_usb_context (plugin);
|
||||||
const gchar *platform_id;
|
const gchar *platform_id;
|
||||||
g_autoptr(GUsbDevice) usb_device = NULL;
|
g_autoptr(GUsbDevice) usb_device = NULL;
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
|
|
||||||
/* get version */
|
/* get version */
|
||||||
platform_id = fu_device_get_id (dev);
|
platform_id = fu_device_get_id (dev);
|
||||||
@ -118,32 +103,32 @@ fu_plugin_unifying_get_dongle (FuPlugin *plugin,
|
|||||||
error);
|
error);
|
||||||
if (usb_device == NULL)
|
if (usb_device == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
dongle = unifying_dongle_new (usb_device);
|
device = fu_device_unifying_new (usb_device);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (unifying_dongle_get_kind (dongle) == UNIFYING_DONGLE_KIND_UNKNOWN) {
|
if (fu_device_unifying_get_kind (device) == FU_DEVICE_UNIFYING_KIND_UNKNOWN) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
"invalid Logitech device type detected");
|
"invalid Logitech device type detected");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return g_steal_pointer (&dongle);
|
return g_steal_pointer (&device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_plugin_unifying_detach_cb (gpointer user_data)
|
fu_plugin_unifying_detach_cb (gpointer user_data)
|
||||||
{
|
{
|
||||||
UnifyingDongle *dongle = UNIFYING_DONGLE (user_data);
|
FuDeviceUnifying *device = FU_DEVICE_UNIFYING (user_data);
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
/* ditch this device */
|
/* ditch this device */
|
||||||
g_debug ("detaching");
|
g_debug ("detaching");
|
||||||
if (!unifying_dongle_detach (dongle, &error)) {
|
if (!fu_device_unifying_detach (device, &error)) {
|
||||||
g_warning ("failed to detach: %s", error->message);
|
g_warning ("failed to detach: %s", error->message);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!unifying_dongle_close (dongle, &error)) {
|
if (!fu_device_unifying_close (device, &error)) {
|
||||||
g_warning ("failed to close: %s", error->message);
|
g_warning ("failed to close: %s", error->message);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -159,47 +144,47 @@ fu_plugin_update_online (FuPlugin *plugin,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GUsbContext *usb_ctx = fu_plugin_get_usb_context (plugin);
|
GUsbContext *usb_ctx = fu_plugin_get_usb_context (plugin);
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
|
|
||||||
/* get version */
|
/* get version */
|
||||||
dongle = fu_plugin_unifying_get_dongle (plugin, dev, error);
|
device = fu_plugin_unifying_get_dongle (plugin, dev, error);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* switch to bootloader */
|
/* switch to bootloader */
|
||||||
if (unifying_dongle_get_kind (dongle) == UNIFYING_DONGLE_KIND_RUNTIME) {
|
if (fu_device_unifying_get_kind (device) == FU_DEVICE_UNIFYING_KIND_RUNTIME) {
|
||||||
g_autoptr(GUsbDevice) usb_device = NULL;
|
g_autoptr(GUsbDevice) usb_device = NULL;
|
||||||
|
|
||||||
/* wait for device to come back */
|
/* wait for device to come back */
|
||||||
g_timeout_add (50, fu_plugin_unifying_detach_cb, dongle);
|
g_timeout_add (50, fu_plugin_unifying_detach_cb, device);
|
||||||
usb_device = g_usb_context_wait_for_replug (usb_ctx,
|
usb_device = g_usb_context_wait_for_replug (usb_ctx,
|
||||||
unifying_dongle_get_usb_device (dongle),
|
fu_device_unifying_get_usb_device (device),
|
||||||
2000,
|
2000,
|
||||||
error);
|
error);
|
||||||
if (usb_device == NULL)
|
if (usb_device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* find new device */
|
/* find new device */
|
||||||
g_object_unref (dongle);
|
g_object_unref (device);
|
||||||
dongle = unifying_dongle_new (usb_device);
|
device = fu_device_unifying_new (usb_device);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write the firmware */
|
/* write the firmware */
|
||||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_WRITE);
|
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_WRITE);
|
||||||
if (!unifying_dongle_write_firmware (dongle, blob_fw,
|
if (!fu_device_unifying_write_firmware (device, blob_fw,
|
||||||
fu_unifying_write_progress_cb, plugin,
|
fu_unifying_write_progress_cb, plugin,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART);
|
fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART);
|
||||||
if (!unifying_dongle_attach (dongle, error))
|
if (!fu_device_unifying_attach (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_close (dongle, error))
|
if (!fu_device_unifying_close (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
|
@ -23,16 +23,16 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "unifying-dongle.h"
|
#include "fu-device-unifying.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
GPtrArray *cmd_array;
|
GPtrArray *cmd_array;
|
||||||
UnifyingDongleKind emulation_kind;
|
FuDeviceUnifyingKind emulation_kind;
|
||||||
} UnifyingToolPrivate;
|
} FuUnifyingToolPrivate;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unifying_tool_private_free (UnifyingToolPrivate *priv)
|
fu_unifying_tool_private_free (FuUnifyingToolPrivate *priv)
|
||||||
{
|
{
|
||||||
if (priv == NULL)
|
if (priv == NULL)
|
||||||
return;
|
return;
|
||||||
@ -41,9 +41,9 @@ unifying_tool_private_free (UnifyingToolPrivate *priv)
|
|||||||
g_ptr_array_unref (priv->cmd_array);
|
g_ptr_array_unref (priv->cmd_array);
|
||||||
g_free (priv);
|
g_free (priv);
|
||||||
}
|
}
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(UnifyingToolPrivate, unifying_tool_private_free)
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(FuUnifyingToolPrivate, fu_unifying_tool_private_free)
|
||||||
|
|
||||||
typedef gboolean (*UnifyingToolPrivateCb) (UnifyingToolPrivate *util,
|
typedef gboolean (*FuUnifyingToolPrivateCb) (FuUnifyingToolPrivate *util,
|
||||||
gchar **values,
|
gchar **values,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ typedef struct {
|
|||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *arguments;
|
gchar *arguments;
|
||||||
gchar *description;
|
gchar *description;
|
||||||
UnifyingToolPrivateCb callback;
|
FuUnifyingToolPrivateCb callback;
|
||||||
} UnifyingToolItem;
|
} FuUnifyingToolItem;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unifying_tool_item_free (UnifyingToolItem *item)
|
fu_unifying_tool_item_free (FuUnifyingToolItem *item)
|
||||||
{
|
{
|
||||||
g_free (item->name);
|
g_free (item->name);
|
||||||
g_free (item->arguments);
|
g_free (item->arguments);
|
||||||
@ -64,20 +64,20 @@ unifying_tool_item_free (UnifyingToolItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
unifying_tool_sort_command_name_cb (UnifyingToolItem **item1, UnifyingToolItem **item2)
|
fu_unifying_tool_sort_command_name_cb (FuUnifyingToolItem **item1, FuUnifyingToolItem **item2)
|
||||||
{
|
{
|
||||||
return g_strcmp0 ((*item1)->name, (*item2)->name);
|
return g_strcmp0 ((*item1)->name, (*item2)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unifying_tool_add (GPtrArray *array,
|
fu_unifying_tool_add (GPtrArray *array,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *arguments,
|
const gchar *arguments,
|
||||||
const gchar *description,
|
const gchar *description,
|
||||||
UnifyingToolPrivateCb callback)
|
FuUnifyingToolPrivateCb callback)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
UnifyingToolItem *item;
|
FuUnifyingToolItem *item;
|
||||||
g_auto(GStrv) names = NULL;
|
g_auto(GStrv) names = NULL;
|
||||||
|
|
||||||
g_return_if_fail (name != NULL);
|
g_return_if_fail (name != NULL);
|
||||||
@ -87,7 +87,7 @@ unifying_tool_add (GPtrArray *array,
|
|||||||
/* add each one */
|
/* add each one */
|
||||||
names = g_strsplit (name, ",", -1);
|
names = g_strsplit (name, ",", -1);
|
||||||
for (i = 0; names[i] != NULL; i++) {
|
for (i = 0; names[i] != NULL; i++) {
|
||||||
item = g_new0 (UnifyingToolItem, 1);
|
item = g_new0 (FuUnifyingToolItem, 1);
|
||||||
item->name = g_strdup (names[i]);
|
item->name = g_strdup (names[i]);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
item->description = g_strdup (description);
|
item->description = g_strdup (description);
|
||||||
@ -101,13 +101,13 @@ unifying_tool_add (GPtrArray *array,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
unifying_tool_get_descriptions (GPtrArray *array)
|
fu_unifying_tool_get_descriptions (GPtrArray *array)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
gsize j;
|
gsize j;
|
||||||
gsize len;
|
gsize len;
|
||||||
const gsize max_len = 31;
|
const gsize max_len = 31;
|
||||||
UnifyingToolItem *item;
|
FuUnifyingToolItem *item;
|
||||||
GString *string;
|
GString *string;
|
||||||
|
|
||||||
/* print each command */
|
/* print each command */
|
||||||
@ -144,13 +144,13 @@ unifying_tool_get_descriptions (GPtrArray *array)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
unifying_tool_run (UnifyingToolPrivate *priv,
|
fu_unifying_tool_run (FuUnifyingToolPrivate *priv,
|
||||||
const gchar *command,
|
const gchar *command,
|
||||||
gchar **values,
|
gchar **values,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
UnifyingToolItem *item;
|
FuUnifyingToolItem *item;
|
||||||
|
|
||||||
/* find command */
|
/* find command */
|
||||||
for (i = 0; i < priv->cmd_array->len; i++) {
|
for (i = 0; i < priv->cmd_array->len; i++) {
|
||||||
@ -167,10 +167,10 @@ unifying_tool_run (UnifyingToolPrivate *priv,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnifyingDongle *
|
static FuDeviceUnifying *
|
||||||
fu_unifying_get_default_dongle (UnifyingToolPrivate *priv, GError **error)
|
fu_unifying_get_default_dongle (FuUnifyingToolPrivate *priv, GError **error)
|
||||||
{
|
{
|
||||||
UnifyingDongle *dongle = NULL;
|
FuDeviceUnifying *device = NULL;
|
||||||
g_autoptr(GUsbContext) usb_ctx = NULL;
|
g_autoptr(GUsbContext) usb_ctx = NULL;
|
||||||
g_autoptr(GPtrArray) devices = NULL;
|
g_autoptr(GPtrArray) devices = NULL;
|
||||||
|
|
||||||
@ -184,54 +184,57 @@ fu_unifying_get_default_dongle (UnifyingToolPrivate *priv, GError **error)
|
|||||||
devices = g_usb_context_get_devices (usb_ctx);
|
devices = g_usb_context_get_devices (usb_ctx);
|
||||||
for (guint i = 0; i < devices->len; i++) {
|
for (guint i = 0; i < devices->len; i++) {
|
||||||
GUsbDevice *usb_dev_tmp = g_ptr_array_index (devices, i);
|
GUsbDevice *usb_dev_tmp = g_ptr_array_index (devices, i);
|
||||||
g_autoptr(UnifyingDongle) dev_tmp = unifying_dongle_new (usb_dev_tmp);
|
g_autoptr(FuDeviceUnifying) dev_tmp = fu_device_unifying_new (usb_dev_tmp);
|
||||||
if (dev_tmp == NULL)
|
if (dev_tmp == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (unifying_dongle_get_kind (dev_tmp) != UNIFYING_DONGLE_KIND_UNKNOWN) {
|
if (fu_device_unifying_get_kind (dev_tmp) != FU_DEVICE_UNIFYING_KIND_UNKNOWN) {
|
||||||
dongle = g_object_ref (dev_tmp);
|
device = g_object_ref (dev_tmp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nothing supported */
|
/* nothing supported */
|
||||||
if (dongle == NULL) {
|
if (device == NULL) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
"No supported device plugged in");
|
"No supported device plugged in");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return dongle;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
unifying_tool_info (UnifyingToolPrivate *priv, gchar **values, GError **error)
|
fu_unifying_tool_info (FuUnifyingToolPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
dongle = fu_unifying_get_default_dongle (priv, error);
|
device = fu_unifying_get_default_dongle (priv, error);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* show on console */
|
/* show on console */
|
||||||
g_debug ("Found %s", unifying_dongle_kind_to_string (unifying_dongle_get_kind (dongle)));
|
g_debug ("Found %s", fu_device_unifying_kind_to_string (fu_device_unifying_get_kind (device)));
|
||||||
g_print ("Firmware Ver: %s\n", unifying_dongle_get_version_fw (dongle));
|
g_print ("Firmware Ver: %s\n",
|
||||||
g_print ("Bootloader Ver: %s\n", unifying_dongle_get_version_bl (dongle));
|
fu_device_get_version (FU_DEVICE (device)));
|
||||||
g_print ("GUID: %s\n", unifying_dongle_get_guid (dongle));
|
g_print ("Bootloader Ver: %s\n",
|
||||||
|
fu_device_get_version_bootloader (FU_DEVICE (device)));
|
||||||
|
g_print ("GUID: %s\n",
|
||||||
|
fu_device_get_guid_default (FU_DEVICE (device)));
|
||||||
|
|
||||||
/* close device */
|
/* close device */
|
||||||
return unifying_dongle_close (dongle, error);
|
return fu_device_unifying_close (device, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fu_unifying_write_progress_cb (goffset current, goffset total, gpointer user_data)
|
fu_unifying_write_progress_cb (goffset current, goffset total, gpointer user_data)
|
||||||
{
|
{
|
||||||
UnifyingToolPrivate *priv = (UnifyingToolPrivate *) user_data;
|
FuUnifyingToolPrivate *priv = (FuUnifyingToolPrivate *) user_data;
|
||||||
gdouble percentage = -1.f;
|
gdouble percentage = -1.f;
|
||||||
if (priv->emulation_kind != UNIFYING_DONGLE_KIND_UNKNOWN)
|
if (priv->emulation_kind != FU_DEVICE_UNIFYING_KIND_UNKNOWN)
|
||||||
return;
|
return;
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
percentage = (100.f * (gdouble) current) / (gdouble) total;
|
percentage = (100.f * (gdouble) current) / (gdouble) total;
|
||||||
@ -240,12 +243,12 @@ fu_unifying_write_progress_cb (goffset current, goffset total, gpointer user_dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
unifying_tool_write (UnifyingToolPrivate *priv, gchar **values, GError **error)
|
fu_unifying_tool_write (FuUnifyingToolPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
gsize len;
|
gsize len;
|
||||||
g_autofree guint8 *data = NULL;
|
g_autofree guint8 *data = NULL;
|
||||||
g_autoptr(GBytes) fw = NULL;
|
g_autoptr(GBytes) fw = NULL;
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
|
|
||||||
/* check args */
|
/* check args */
|
||||||
if (g_strv_length (values) != 1) {
|
if (g_strv_length (values) != 1) {
|
||||||
@ -258,19 +261,19 @@ unifying_tool_write (UnifyingToolPrivate *priv, gchar **values, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* open device */
|
/* open device */
|
||||||
if (priv->emulation_kind == UNIFYING_DONGLE_KIND_UNKNOWN) {
|
if (priv->emulation_kind == FU_DEVICE_UNIFYING_KIND_UNKNOWN) {
|
||||||
dongle = fu_unifying_get_default_dongle (priv, error);
|
device = fu_unifying_get_default_dongle (priv, error);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
dongle = unifying_dongle_emulated_new (priv->emulation_kind);
|
device = fu_device_unifying_emulated_new (priv->emulation_kind);
|
||||||
}
|
}
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* do we need to go into bootloader mode */
|
/* do we need to go into bootloader mode */
|
||||||
if (unifying_dongle_get_kind (dongle) == UNIFYING_DONGLE_KIND_RUNTIME) {
|
if (fu_device_unifying_get_kind (device) == FU_DEVICE_UNIFYING_KIND_RUNTIME) {
|
||||||
if (!unifying_dongle_detach (dongle, error))
|
if (!fu_device_unifying_detach (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
g_print ("Switched to bootloader, now run again\n");
|
g_print ("Switched to bootloader, now run again\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -284,54 +287,54 @@ unifying_tool_write (UnifyingToolPrivate *priv, gchar **values, GError **error)
|
|||||||
|
|
||||||
/* update with data blob */
|
/* update with data blob */
|
||||||
fw = g_bytes_new (data, len);
|
fw = g_bytes_new (data, len);
|
||||||
if (!unifying_dongle_write_firmware (dongle, fw,
|
if (!fu_device_unifying_write_firmware (device, fw,
|
||||||
fu_unifying_write_progress_cb, priv,
|
fu_unifying_write_progress_cb, priv,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* detach back into runtime */
|
/* detach back into runtime */
|
||||||
if (!unifying_dongle_attach (dongle, error))
|
if (!fu_device_unifying_attach (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_close (dongle, error))
|
if (!fu_device_unifying_close (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
unifying_tool_attach (UnifyingToolPrivate *priv, gchar **values, GError **error)
|
fu_unifying_tool_attach (FuUnifyingToolPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
dongle = fu_unifying_get_default_dongle (priv, error);
|
device = fu_unifying_get_default_dongle (priv, error);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_attach (dongle, error))
|
if (!fu_device_unifying_attach (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_close (dongle, error))
|
if (!fu_device_unifying_close (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
unifying_tool_detach (UnifyingToolPrivate *priv, gchar **values, GError **error)
|
fu_unifying_tool_detach (FuUnifyingToolPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
dongle = fu_unifying_get_default_dongle (priv, error);
|
device = fu_unifying_get_default_dongle (priv, error);
|
||||||
if (dongle == NULL)
|
if (device == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_open (dongle, error))
|
if (!fu_device_unifying_open (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_detach (dongle, error))
|
if (!fu_device_unifying_detach (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!unifying_dongle_close (dongle, error))
|
if (!fu_device_unifying_close (device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unifying_tool_log_handler_cb (const gchar *log_domain,
|
fu_unifying_tool_log_handler_cb (const gchar *log_domain,
|
||||||
GLogLevelFlags log_level,
|
GLogLevelFlags log_level,
|
||||||
const gchar *message,
|
const gchar *message,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@ -347,8 +350,8 @@ main (int argc, char **argv)
|
|||||||
g_autofree gchar *emulation_kind = NULL;
|
g_autofree gchar *emulation_kind = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(GOptionContext) context = NULL;
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
g_autoptr(UnifyingDongle) dongle = NULL;
|
g_autoptr(FuDeviceUnifying) device = NULL;
|
||||||
g_autoptr(UnifyingToolPrivate) priv = g_new0 (UnifyingToolPrivate, 1);
|
g_autoptr(FuUnifyingToolPrivate) priv = g_new0 (FuUnifyingToolPrivate, 1);
|
||||||
const GOptionEntry options[] = {
|
const GOptionEntry options[] = {
|
||||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||||
"Print verbose debug statements", NULL },
|
"Print verbose debug statements", NULL },
|
||||||
@ -361,32 +364,32 @@ main (int argc, char **argv)
|
|||||||
priv->cancellable = g_cancellable_new ();
|
priv->cancellable = g_cancellable_new ();
|
||||||
|
|
||||||
/* add commands */
|
/* add commands */
|
||||||
priv->cmd_array = g_ptr_array_new_with_free_func ((GDestroyNotify) unifying_tool_item_free);
|
priv->cmd_array = g_ptr_array_new_with_free_func ((GDestroyNotify) fu_unifying_tool_item_free);
|
||||||
unifying_tool_add (priv->cmd_array,
|
fu_unifying_tool_add (priv->cmd_array,
|
||||||
"info", NULL,
|
"info", NULL,
|
||||||
"Show information about the device",
|
"Show information about the device",
|
||||||
unifying_tool_info);
|
fu_unifying_tool_info);
|
||||||
unifying_tool_add (priv->cmd_array,
|
fu_unifying_tool_add (priv->cmd_array,
|
||||||
"write", "FILENAME",
|
"write", "FILENAME",
|
||||||
"Update the firmware",
|
"Update the firmware",
|
||||||
unifying_tool_write);
|
fu_unifying_tool_write);
|
||||||
unifying_tool_add (priv->cmd_array,
|
fu_unifying_tool_add (priv->cmd_array,
|
||||||
"attach", NULL,
|
"attach", NULL,
|
||||||
"Attach to firmware mode",
|
"Attach to firmware mode",
|
||||||
unifying_tool_attach);
|
fu_unifying_tool_attach);
|
||||||
unifying_tool_add (priv->cmd_array,
|
fu_unifying_tool_add (priv->cmd_array,
|
||||||
"detach", NULL,
|
"detach", NULL,
|
||||||
"Detach to bootloader mode",
|
"Detach to bootloader mode",
|
||||||
unifying_tool_detach);
|
fu_unifying_tool_detach);
|
||||||
|
|
||||||
/* sort by command name */
|
/* sort by command name */
|
||||||
g_ptr_array_sort (priv->cmd_array,
|
g_ptr_array_sort (priv->cmd_array,
|
||||||
(GCompareFunc) unifying_tool_sort_command_name_cb);
|
(GCompareFunc) fu_unifying_tool_sort_command_name_cb);
|
||||||
|
|
||||||
|
|
||||||
/* get a list of the commands */
|
/* get a list of the commands */
|
||||||
context = g_option_context_new (NULL);
|
context = g_option_context_new (NULL);
|
||||||
cmd_descriptions = unifying_tool_get_descriptions (priv->cmd_array);
|
cmd_descriptions = fu_unifying_tool_get_descriptions (priv->cmd_array);
|
||||||
g_option_context_set_summary (context, cmd_descriptions);
|
g_option_context_set_summary (context, cmd_descriptions);
|
||||||
g_set_application_name ("Logitech Unifying Debug Tool");
|
g_set_application_name ("Logitech Unifying Debug Tool");
|
||||||
g_option_context_add_main_entries (context, options, NULL);
|
g_option_context_add_main_entries (context, options, NULL);
|
||||||
@ -396,16 +399,16 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* emulate */
|
/* emulate */
|
||||||
priv->emulation_kind = unifying_dongle_kind_from_string (emulation_kind);
|
priv->emulation_kind = fu_device_unifying_kind_from_string (emulation_kind);
|
||||||
if (priv->emulation_kind != UNIFYING_DONGLE_KIND_UNKNOWN)
|
if (priv->emulation_kind != FU_DEVICE_UNIFYING_KIND_UNKNOWN)
|
||||||
g_log_set_default_handler (unifying_tool_log_handler_cb, priv);
|
g_log_set_default_handler (fu_unifying_tool_log_handler_cb, priv);
|
||||||
|
|
||||||
/* set verbose? */
|
/* set verbose? */
|
||||||
if (verbose)
|
if (verbose)
|
||||||
g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
|
g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
|
||||||
|
|
||||||
/* run the specified command */
|
/* run the specified command */
|
||||||
if (!unifying_tool_run (priv, argv[1], (gchar**) &argv[2], &error)) {
|
if (!fu_unifying_tool_run (priv, argv[1], (gchar**) &argv[2], &error)) {
|
||||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
|
||||||
g_autofree gchar *tmp = NULL;
|
g_autofree gchar *tmp = NULL;
|
||||||
tmp = g_option_context_get_help (context, TRUE, NULL);
|
tmp = g_option_context_get_help (context, TRUE, NULL);
|
@ -1,74 +0,0 @@
|
|||||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
|
|
||||||
*
|
|
||||||
* Licensed under the GNU Lesser General Public License Version 2.1
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __UNIFYING_DONGLE_H
|
|
||||||
#define __UNIFYING_DONGLE_H
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
#include <gusb.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define UNIFYING_TYPE_DONGLE (unifying_dongle_get_type ())
|
|
||||||
G_DECLARE_DERIVABLE_TYPE (UnifyingDongle, unifying_dongle, UNIFYING, DONGLE, GObject)
|
|
||||||
|
|
||||||
struct _UnifyingDongleClass
|
|
||||||
{
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
UNIFYING_DONGLE_KIND_UNKNOWN,
|
|
||||||
UNIFYING_DONGLE_KIND_RUNTIME,
|
|
||||||
UNIFYING_DONGLE_KIND_BOOTLOADER_NORDIC,
|
|
||||||
UNIFYING_DONGLE_KIND_BOOTLOADER_TEXAS,
|
|
||||||
UNIFYING_DONGLE_KIND_LAST
|
|
||||||
} UnifyingDongleKind;
|
|
||||||
|
|
||||||
UnifyingDongle *unifying_dongle_new (GUsbDevice *usb_device);
|
|
||||||
UnifyingDongle *unifying_dongle_emulated_new (UnifyingDongleKind kind);
|
|
||||||
|
|
||||||
UnifyingDongleKind unifying_dongle_kind_from_string (const gchar *kind);
|
|
||||||
const gchar *unifying_dongle_kind_to_string (UnifyingDongleKind kind);
|
|
||||||
|
|
||||||
UnifyingDongleKind unifying_dongle_get_kind (UnifyingDongle *dongle);
|
|
||||||
const gchar *unifying_dongle_get_version_fw (UnifyingDongle *dongle);
|
|
||||||
const gchar *unifying_dongle_get_version_bl (UnifyingDongle *dongle);
|
|
||||||
const gchar *unifying_dongle_get_guid (UnifyingDongle *dongle);
|
|
||||||
GUsbDevice *unifying_dongle_get_usb_device (UnifyingDongle *dongle);
|
|
||||||
|
|
||||||
gboolean unifying_dongle_open (UnifyingDongle *dongle,
|
|
||||||
GError **error);
|
|
||||||
gboolean unifying_dongle_detach (UnifyingDongle *dongle,
|
|
||||||
GError **error);
|
|
||||||
gboolean unifying_dongle_attach (UnifyingDongle *dongle,
|
|
||||||
GError **error);
|
|
||||||
gboolean unifying_dongle_close (UnifyingDongle *dongle,
|
|
||||||
GError **error);
|
|
||||||
gboolean unifying_dongle_write_firmware (UnifyingDongle *dongle,
|
|
||||||
GBytes *fw,
|
|
||||||
GFileProgressCallback progress_cb,
|
|
||||||
gpointer progress_data,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __UNIFYING_DONGLE_H */
|
|
Loading…
Reference in New Issue
Block a user