Activation Codes and Methods, Hardware Details, Sniffing
chyiwen
Posts: 16
Joined: 27 Mar 2015, 04:55
Location: Taiwan

Re: Modem D-Link DWM-221

Post by chyiwen » 02 Apr 2015, 14:48

Hi Luiz,

It is really a wow!!! :o

Amazing fortigate config you have done.

I will try it with a Fortigate.

Raspberry pi and Fortigate are the devices i need.

I solved one and you offered me a bonus.

Thanks everyone again.

I wil do more investigate for LOM's input.

I think it probably can be simpler.

lhguanabara
Posts: 8
Joined: 19 Jan 2015, 18:27
Location: Brazil

Re: Modem D-Link DWM-221

Post by lhguanabara » 02 Apr 2015, 15:02

Hi Chyiwen

I'm very glad my information was useful for you, if you need some help about this just ask! :D

I'm also staying here to provide more tests for you guys to make the dongle work at its best.

Best regards,

Luiz

chyiwen
Posts: 16
Joined: 27 Mar 2015, 04:55
Location: Taiwan

Re: Modem D-Link DWM-221

Post by chyiwen » 07 Apr 2015, 05:47

LOM wrote:
chyiwen wrote: - switch mode

Code: Select all

sudo usb_modeswitch -v 2001 -p a401 -W -n -M 555342435b000000000000000001061e000000000000000000000000000000 -2 555342435c000000000000000001061b000000010000000000000000000000 -3 555342435d000000000000000001061b000000020000000000000000000000

The switch sequence above doesn't make sense to me from logical point of view and I wonder what it is that makes the dongle switch now.
The cmds are:
1. Allow media change (unlock media in case it was locked)
2. Start unit
3. Stop unit (also known as eject since stopping a cd-rom automagically makes it eject the caddy)

My questions here are:

Is the allow media change cmd really needed? If it should be included then it should logically come after the Start Unit cmd.
Where does the 01 flag (before length byte 06) in all the msgs come from? This is for selecting the LUN on players with
multi-LUN and should not be needed here. Substitute with 00 and check if it makes any diference!
Hi LOM ,

Here is ther further research as per your input.

##1.-- OK -- The final msg is the combo working with raspberry below:

sudo usb_modeswitch -v 2001 -p a401 -W -n -K

sudo usb_modeswitch -v 2001 -p a401 -W -n -M 555342435b000000000000000001061e000000000000000000000000000000 -2 555342435d000000000000000001061b000000020000000000000000000000

So the msg translation from you would be :

1. Allow media change (unlock media in case it was locked)
2. Stop unit (also known as eject since stopping a cd-rom automagically makes it eject the caddy)

##2-- NG
I tried msg
555342435b000000000000000000061e000000000000000000000000000000
555342435d000000000000000000061b000000020000000000000000000000
it does not work. So without LUN info, the mode switch does not work.

##3-- NG
This also not work -

sudo usb_modeswitch -v 2001 -p a401 -W -n -M 555342435c000000000000000001061b000000010000000000000000000000 -2 555342435d000000000000000001061b000000020000000000000000000000

1. Start unit
2. Stop unit (also known as eject since stopping a cd-rom automagically makes it eject the caddy)

Hope this help.

LOM
Posts: 1404
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: Modem D-Link DWM-221

Post by LOM » 17 Apr 2015, 15:19

chyiwen wrote:
Hi LOM ,

Here is ther further research as per your input.
Thanks for further testing but I can not draw any conclusions from the result.
You do need extra cmds which the other 2 users didn't need and I strongly suspect that the reason
for that is Raspberry Pi, I mentioned before that it behaves unreliable.
The linux kernel maintainer for the usb subsystem had the following to say about Raspberry Pi a few days ago:
Greg Kroah-Hartman wrote:
The RPI's USB controller is horrid, it's amazing it works at all...
Can you please re-test on known good hardware, on your CentOS6.5 system or on the Fortigate.

chyiwen
Posts: 16
Joined: 27 Mar 2015, 04:55
Location: Taiwan

Re: Modem D-Link DWM-221

Post by chyiwen » 05 May 2015, 04:42

LOM wrote:
Can you please re-test on known good hardware, on your CentOS6.5 system or on the Fortigate.

HI LOM ,

FortiGate is working fine with 2 line.

Cent OS is also working.

:)

ilpianista
Posts: 1
Joined: 08 Jul 2015, 19:23
Location: Lecce, Italy

Re: Modem D-Link DWM-221

Post by ilpianista » 08 Jul 2015, 19:26

Hi all,
I'm unable to get this working in Arch Linux.

After installing usb_modeswitch (&& rebooted), lsusb shows the same productId for the D-Link.

The following command change the productId, but still the modem is not shown under NetworkManager/ModemManager. Any idea?

Code: Select all

sudo usb_modeswitch -v 2001 -p a401 -W -n -M 555342435b000000000000000001061e000000000000000000000000000000 -2 555342435c000000000000000001061b000000010000000000000000000000 -3 555342435d000000000000000001061b000000020000000000000000000000
usb_modeswitch version is 2.2.3

Thank you!

EDIT: by executing a binary blog 'modemtoatmode' found in the sr0, I got 4 /dev/ttyUSB* devices. Still MM cannot connect, but maybe it's a step forward.

jeanhuveneers
Posts: 2
Joined: 27 Jul 2015, 08:37

Re: Modem D-Link DWM-221

Post by jeanhuveneers » 29 Jul 2015, 10:04

chyiwen wrote:

HI LOM ,

FortiGate is working fine with 2 line.

Cent OS is also working.

:)
I've also trying to get it working on a Fortigate. But look like i'm missing something becaese it is not working for me.
I added the 4 lines to modem_list.conf file. It's detected but not responding to AT commanda (read time out).

Can you please provide your configuration?

Regards,

Jean

aldi7talk
Posts: 5
Joined: 13 Aug 2015, 16:40

Re: Modem D-Link DWM-221

Post by aldi7talk » 13 Aug 2015, 16:51

kubik007 wrote:Hi all,

good news is, that the DWM-221 rev B. I made working on my Arch Linux and Ubuntu, actally it was up 30 minutes after I bought it. Pay attention to USB power, friends told me some 3g sticks take lot of power, my seemd to be dead on notebook, unless I plug it to the port on the rear side of my noteook. Probably port, with stronger USB power.
Bad new is, that I didn't managed to switch it on Open-WRT.

Linux
How did I made it work on Arch and Ubuntu?
- attached USB may appear as cdrom device, check it is not mounted, umount

Code: Select all

mount
umount /dev/...
- switch mode

Code: Select all

sudo usb_modeswitch -v 2001 -p a401 -W -n -M 555342435b000000000000000001061e000000000000000000000000000000 -2 555342435c000000000000000001061b000000010000000000000000000000 -3 555342435d000000000000000001061b000000020000000000000000000000
- you have to see id 2001:7e19 to get next step working

Code: Select all

lsusb | grep 7e19
- now I only have to load the generic driver by:

Code: Select all

sudo modprobe usbserial vendor=0x2001 product=0x7e19
- in my case, 3G came up in my NetworkManager applet, dmesg showes 4 USB devices related to DWM-221

Code: Select all

dmesg
[ 1779.372545] usbcore: registered new interface driver usbserial
[ 1779.372567] usbcore: registered new interface driver usbserial_generic
[ 1779.372584] usbserial: USB Serial support registered for generic
[ 1779.372605] usbserial_generic 2-3:1.0: The "generic" usb-serial driver is only for testing and one-off prototypes.
...
[ 1779.372733] usb 2-3: generic converter now attached to ttyUSB0
....
[ 1779.373134] usb 2-3: generic converter now attached to ttyUSB4

OpenWrt
their 3g hardware page says 'wip'=work in progress, OpenWrt uses lates usb-modeswitch / usbmode , where the messge is in json format, so I have to build json with above mentioned message:
555342435b000000000000000001061e000000000000000000000000000000 555342435c000000000000000001061b000000010000000000000000000000
555342435d000000000000000001061b000000020000000000000000000000

Finally this post makes me crazy: http://lists.freedesktop.org/archives/l ... 00451.html
It is mentioning, that this stick works as QMI, no, I didn't get qmi working ..

Summary:
There is more questions and answers, but since my configuration is workinq, I gave up further experiments ...
How to switch the USB stick without venor-specific installation?
What is in the vendor installation?
How to switch to QMI device?
How to switch on OpenWrt?

PS: my first post on this forum, regards Kubik :D
It took me two weeks to find this forum and make the D-Link DWM-221 work on Lubuntu 14.10. Is there an easy way, so Lubuntu recognizes the DWM-221 without using the LX Terminal every time I want to connect to the 4G network?

LOM
Posts: 1404
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: Modem D-Link DWM-221

Post by LOM » 14 Aug 2015, 04:14

aldi7talk wrote: Is there an easy way, so Lubuntu recognizes the DWM-221 without using the LX Terminal every time I want to connect to the 4G network?

Script your commands.
Add the initial id 2001:a401 in /lib/udev/rules.d/40-usb_modeswitch.rules and call your script from it.

or

download the latest usb_modeswitch executable and data package where support for DWM-221 is included.
You may have to download the source and compile it yourself if your linux distro maintainer hasn't made it available.
Source and data package here:
http://www.draisberghof.de/usb_modeswitch/

aldi7talk
Posts: 5
Joined: 13 Aug 2015, 16:40

Re: Modem D-Link DWM-221

Post by aldi7talk » 24 Aug 2015, 16:24

Script your commands.
Add the initial id 2001:a401 in /lib/udev/rules.d/40-usb_modeswitch.rules and call your script from it./
The commands I have to script are:

Code: Select all

sudo usb_modeswitch -v 2001 -p a401 -W -n -M 555342435b000000000000000001061e000000000000000000000000000000 -2 555342435c000000000000000001061b000000010000000000000000000000 -3 555342435d000000000000000001061b000000020000000000000000000000

Code: Select all

lsusb | grep 7e19

Code: Select all

sudo modprobe usbserial vendor=0x2001 product=0x7e19
How do I script them? How do I call the script from /lib/udev/rules.d/40-usb_modeswitch.rules?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Modem D-Link DWM-221

Post by Josh » 24 Aug 2015, 16:36

Just put these commands into a text file, one command per line. Remove the "sudo" part, it will be run with admin privileges anyway.

Also, to be on the safe side, give the full path to the executables, like "/usr/sbin/usb_modeswitch" instead of "usb_modeswitch".

As the first line in the file, use this:

Code: Select all

#!/bin/sh
Call the script file anything you like, but don't forget to make it executable (chmod 755 <scriptfile>).

If you put it into the folder "/lib/udev", you can call it without a path from the "rules" file.
Have a look at the other lines in "40-usb-modeswitch.rules"; you can create a line for your purpose and make your script start simply with

Code: Select all

... RUN+="<scriptfile>"
There is good information available about udev rules. I recommend this:
http://www.reactivated.net/writing_udev_rules.html

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Modem D-Link DWM-221

Post by Josh » 24 Aug 2015, 16:40

For diagnostic reasons - if you're not sure if the rule 'triggers' correctly - include test lines in the script that write to a temporary file.

Example:

Code: Select all

/bin/echo "Triggered!" >/tmp/rule-test

aldi7talk
Posts: 5
Joined: 13 Aug 2015, 16:40

Re: Modem D-Link DWM-221

Post by aldi7talk » 26 Aug 2015, 20:46

Josh wrote:Just put these commands into a text file, one command per line. Remove the "sudo" part, it will be run with admin privileges anyway.

Also, to be on the safe side, give the full path to the executables, like "/usr/sbin/usb_modeswitch" instead of "usb_modeswitch".

As the first line in the file, use this:

Code: Select all

#!/bin/sh
Call the script file anything you like, but don't forget to make it executable (chmod 755 <scriptfile>).

If you put it into the folder "/lib/udev", you can call it without a path from the "rules" file.
Have a look at the other lines in "40-usb-modeswitch.rules"; you can create a line for your purpose and make your script start simply with

Code: Select all

... RUN+="<scriptfile>"
There is good information available about udev rules. I recommend this:
http://www.reactivated.net/writing_udev_rules.html
This is what I did:

step 1:

I made a file called dlink_script in the Documents folder with the following content:

Code: Select all

#!/bin/sh
/lib/udev/usb_modeswitch  -v 2001 -p a401 -W -n -M 555342435b000000000000000001061e000000000000000000000000000000 -2 555342435c000000000000000001061b000000010000000000000000000000 -3 555342435d000000000000000001061b000000020000000000000000000000
lsusb | grep 7e19
modprobe usbserial vendor=0x2001 product=0x7e19
You may notice that I did not use /usr/bin/usb_modeswitch as you suggested, because I could not find such a file. (I tried it with /usr/bin/usb_modeswitch, but it didn't work either.)

Step 2:

Code: Select all

chmod 755 /home/lubuntu/Documents/dlink_script
Step 3

I opened /lib/udev/rules.d/40-usb_modeswitch.rules and added a line like this and saved it:

Code: Select all

 # D-Link DWM-221 (added myself)
ATTR{idVendor}=="2001", ATTR{idProduct}=="7e19", RUN+="/home/lubuntu/Documents/dlink_script"
Step 4:

I restarted the computer with the D-Link 4G modem inserted, but I could not connect to the 4G network.

Step 5:

I added

Code: Select all

/bin/echo "Triggered!" >/home/lubuntu/Documents/rule-test
at the end of the script. When I open rule-test, de page is empty.

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Modem D-Link DWM-221

Post by Josh » 26 Aug 2015, 22:15

You really should be more accurate. Every character counts when writing programs.

The path to usb_modeswitch is /usr/sbin/usb_modeswitch. Check again in that folder.
What you are calling in your script is itself annother little script, a 'wrapper' to start usb_modeswitch (the binary program).

I strongly recommend using a decent file manager to quickly have a look at programs and scripts (so you see which is which).
I'm using Midnight Commander which has largely the same functions (and key commands) as Total Commander for Windows.

It's a terminal program, but if you enlarge your terminal window you'll get a neat interactive surface. I'm using the Fixedsys TTF font with all of my terminals (in Windows too), which delivers excellent readability. YMMV.

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: Modem D-Link DWM-221

Post by Josh » 26 Aug 2015, 22:20

Also, to get the whole path of a program that you can run, append it to the "which" command.

Code: Select all

$ which echo
/usr/bin/echo
As you can see, it's better to double-check a given path, as Linux distributions may differ.

Post Reply