diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-03-27 14:41:35 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-09-29 15:41:21 +0200 |
commit | 1f813c4e9691f22017802278ab6f5b1475185113 (patch) | |
tree | 8c354cd3053d7837bc575e6f1c793fda0c2ba3e1 /src/mm-device.h | |
parent | e5fa0233bb73a8374cf35e9170c66c580255815a (diff) |
core: allow identifying devices by a user-provided 'uid'
All ports of the same modem reported by the kernel will all be associated with
a common 'uid' (unique id), which uniquely identifies the physical device. This
logic was already in place, what we do now is avoid calling it the 'sysfs
path' of the physical device, because we may not want to use that to identify
a device.
This logic now also enables the possibility of "naming" the modems in a unique
way by setting the "ID_MM_PHYSDEV_UID" property in the "usb_device" that owns
all the ports.
E.g. a custom device has 4 modems in 4 different USB ports. The device path of
each USB device will always be the same, so the naming rules could go like this:
$ vim /usr/lib/udev/rules.d/78-mm-naming.rules
ACTION!="add|change|move", GOTO="mm_naming_rules_end"
DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.1", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-1"
DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.2", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-2"
DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.3", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-3"
DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.4", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-4"
LABEL="mm_naming_rules_end"
Each of the modems found will have a unique UID retrieved from the previous list
of rules. Then, "mmcli" has also been updated to allow using the UID instead of
the modem DBus path or index, e.g.:
$ sudo mmcli -m USB-MODEM-1
/org/freedesktop/ModemManager1/Modem/0 (device id '988d83252c0598f670c2d69d5f41e077204a92fd')
-------------------------
Hardware | manufacturer: 'ZTE CORPORATION'
| model: 'MF637'
| revision: 'BD_W7P673A3F3V1.0.0B04'
| supported: 'gsm-umts'
| current: 'gsm-umts'
| equipment id: '356516027657837'
-------------------------
System | device: 'USB-MODEM-1'
| drivers: 'option'
| plugin: 'ZTE'
| primary port: 'ttyUSB5'
| ports: 'ttyUSB5 (at)'
...
$ sudo mmcli -m USB-MODEM-1 --enable
...
Diffstat (limited to 'src/mm-device.h')
-rw-r--r-- | src/mm-device.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mm-device.h b/src/mm-device.h index 2da82223..57726e6c 100644 --- a/src/mm-device.h +++ b/src/mm-device.h @@ -34,7 +34,7 @@ typedef struct _MMDevice MMDevice; typedef struct _MMDeviceClass MMDeviceClass; typedef struct _MMDevicePrivate MMDevicePrivate; -#define MM_DEVICE_PATH "path" +#define MM_DEVICE_UID "uid" #define MM_DEVICE_UDEV_DEVICE "udev-device" #define MM_DEVICE_PLUGIN "plugin" #define MM_DEVICE_MODEM "modem" @@ -78,7 +78,7 @@ gboolean mm_device_create_modem (MMDevice *self, GError **error); void mm_device_remove_modem (MMDevice *self); -const gchar *mm_device_get_path (MMDevice *self); +const gchar *mm_device_get_uid (MMDevice *self); const gchar **mm_device_get_drivers (MMDevice *self); guint16 mm_device_get_vendor (MMDevice *self); guint16 mm_device_get_product (MMDevice *self); @@ -104,7 +104,7 @@ gboolean mm_device_get_hotplugged (MMDevice *self); /* For testing purposes */ -MMDevice *mm_device_virtual_new (const gchar *path, +MMDevice *mm_device_virtual_new (const gchar *uid, gboolean hotplugged); void mm_device_virtual_grab_ports (MMDevice *self, const gchar **ports); |