Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
Attila
Posts: 2
Joined: Tue Nov 27, 2018 8:48 pm

D-Link DWA-171

Post by Attila » Tue Nov 27, 2018 10:13 pm

Hi
I tried to configure my wireless adapter to auto unmount and switch but not worked.
Before (manual) switch:

Code: Select all

lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 03f0:134a Hewlett-Packard Optical Mouse
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 006: ID 0bda:1a2b Realtek Semiconductor Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
After (manual) switch:

Code: Select all

~$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 03f0:134a Hewlett-Packard Optical Mouse
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 009: ID 2001:331d D-Link Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
I followed this :

Code: Select all

https://askubuntu.com/questions/43805/help-with-implementing-usb-modeswitch
I made a file with name : 0bda:1a2b
The content of the file :

Code: Select all

# D-Link DWA-171

TargetVendor=   0x2001
TargetProduct=  0x331d
I put it into dir usr/share/usb_modeswitch and tinto dir etc/usb_modeswitch.d too
After reboot the dongle not mounts (at least) but stay on disk mode. When I run this command :

Code: Select all

$ sudo usb_modeswitch -c /etc/usb_modeswitch.conf 
Look for target devices ...
 No devices in target mode or class found
Look for default devices ...
 Found devices in default mode (1)
Access device 010 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Warning: no switching method given. See documentation
-> Run lsusb to note any changes. Bye!
If I use :

Code: Select all

$ sudo usb_modeswitch -KW -v 0bda -p 1a2b
it switched :

Code: Select all

Take all parameters from the command line


 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.5.2 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b

StandardEject=1

Look for default devices ...
  found USB ID 1d6b:0002
  found USB ID 03f0:134a
  found USB ID 1d6b:0001
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 1d6b:0002
  found USB ID 0a12:0001
  found USB ID 1d6b:0001
 Found devices in default mode (1)
Access device 010 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: D-Link Corporation
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active drivers ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes), status 1
Trying to send message 2 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 2 (CSW) ...
 Response successfully read (13 bytes), status 0
Trying to send message 3 to endpoint 0x0b ...
 Device seems to have vanished right after sending. Good.
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!
Pls help where is the mistake?

LOM
Posts: 1306
Joined: Wed Jul 11, 2012 3:14 pm
Location: Koh Samui, TH

Re: D-Link DWA-171

Post by LOM » Wed Nov 28, 2018 1:26 pm

Attila wrote: Pls help where is the mistake?
The log says "Warning: no switching method given."

It worked when you used the -K switch on the cmdline but your device config file
has only the target id and is missing a switch method.
-K on the cmdline is equivalent to StandardEject=1 in a device config file so that is what you have to add.
You'll also have to create an entry for 0bda:1a2b in the 40-usb_modeswitch.rules file so that usb_modeswitch is invoked automatically as soon as the dongle appears on the usb bus.

Attila
Posts: 2
Joined: Tue Nov 27, 2018 8:48 pm

Re: D-Link DWA-171

Post by Attila » Wed Nov 28, 2018 8:11 pm

LOM wrote: StandardEject=1 in a device config file so that is what you have to add.
You'll also have to create an entry for 0bda:1a2b in the 40-usb_modeswitch.rules file so that usb_modeswitch is invoked automatically as soon as the dongle appears on the usb bus.
I followed the instructions , completed the files and it works properly. The problem is solved.
Thanks for your support.
Attila

Post Reply