Netgate m1n1wall

Author Topic: Useful 3G modem 'mode switching' script  (Read 10761 times)

0 Members and 1 Guest are viewing this topic.

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Useful 3G modem 'mode switching' script
« on: February 16, 2012, 09:10:09 am »
Hi all,

One of the problems associated with 3G dongles and pfSense is that pfSense detects the device as a CD/flash drive and not a modem.

For this reason, these devices need to be switched before they can be used, I believe u3g is the driver that takes care of this in FreeBSD but only a limited number of devices are supported.

usb_modeswitch is the other method that can be used and a FreeBSD port for this has been recently made available:

http://www.freshports.org/sysutils/usb_modeswitch/

However, I came across this script which takes care of everything, it just needs a little modification to make it work with pfSense.  Basically, the script just needs to carry out the 'mode switch' and let pfSense handle the ppp dialing.

http://sakis.tel4u.gr/blog/sakis3g/#networks

The script can be downloaded here:

http://www.sakis3g.org/versions/latest/i386/sakis3g.gz

This is way beyond my level of skill so would anyone be willing to take a look?  :)

Cheers,

James

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #1 on: February 16, 2012, 10:00:22 am »
a FreeBSD port for this has been recently made available:

http://www.freshports.org/sysutils/usb_modeswitch/

That's pretty exciting news, that could make a lot more modems usable.

What version of FreeBSD is it available for?

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #2 on: February 16, 2012, 10:04:18 am »
FreeBSD 8.2, i've successfully installed it on pfSense 2.0.1

Now I just need to make it do something useful!

One of the pre-req's is having libusb, I think (but not sure) pfSense already comes with this?

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #3 on: February 16, 2012, 10:10:32 am »
Almost certainly.
If you've installed it that's great news.
Does it have a problem with u3g also running?

Often some libraries might have changed between 8.1 current sufficiently for stuff not to work.

Direct link to the pkg from 8-stable:
Code: [Select]
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8-stable/Latest/usb_modeswitch.tbz

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #4 on: February 16, 2012, 10:21:33 am »
Nope, it doesn't complain about u3g.  The usb_modeswitch command works without any errors.

But how do you stop pfSense from using u3g when it attempts to bring up a modem that requires switching.  For example, I have a ZTE dongle sat here and when I plug it in, u3g tries to do it's thing but it can't because it sees it as a storage device.  I'm guessing when usb_modeswitch is configured with the relevant data package, this will intervene?

I could really do with some help getting the data package on to pfSense to do a bit more testing but there isn't much documentation available and i'm a bit of a noob when it comes to FreeBSD!


Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #5 on: February 16, 2012, 06:40:33 pm »
Is it a problem that u3g tries and fails? Usually it won't try anything on a modem it doesn't recognise.
I'm unfamiliar with usb_modeswitch, though I have used it unwittingly with Unbuntu where it just worked.
The data package instructs it how to handle a modem right?

I would guess you just need to upload it and tell usb_modeswitch where to look for it.
What version of pfSense are you running? (full, embedded, nano)

What OS are you uploading from?

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #6 on: February 17, 2012, 05:06:59 am »
The modem is recognised, i.e the console tells me its a ZTE but its not usable in pfSense.

Yes, the data package contains all the vendor id's and device id's.

Usb modeswitch then knows what to do with the device, i.e switch it to modem mode.

Im using pfSense 2.0.1 full.

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #7 on: February 17, 2012, 08:01:24 am »
Presumably the data packets are cross platform and one already exists for your modem?

You can upload files to pfSense easily enough. Either via the webGUI Diagnostics: Command Prompt: Upload
or using sftp/scp. I use WinSCP from Windows. If you use the web upload it will end up in /tmp which will be lost on reboot so you'll have to move the file afterwards. Also I have found that very small files sometimes refuse to upload via the webGUI.

For testing you can tell usb_modeswitch where to find the file:

Code: [Select]
/usr/share/usb_modeswitch -c /tmp/your_modem.txt

Assuming  usb_modeswitch installs there in FreeBSD since the instructions are all for Linux.

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #8 on: February 17, 2012, 10:33:45 am »
Ah, i probably didnt explain it well. I dont have a problem downloading the package onto pfSense (i use fetch to download it directly before extracting it). The problem is there are a number of components in the package and I dont know where in FreeBSD/pfSense these files need to reside.

As you said, the data package is intended for Linux.

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #9 on: February 17, 2012, 10:44:50 am »
You have a link to the package?

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #11 on: February 17, 2012, 10:56:32 am »
Ah OK, that is a collection of data for all supported modems rather than something specific to yours.
Does that not get installed with the port anyway?
I'm going to have to do some reading/testing.....

Steve

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #12 on: February 17, 2012, 11:19:20 am »
Hmm OK so it looks like under Linux usb_modeswitch ties into the usb subsystem and will automatically recognise devices as they are plugged in and switch them. FreeBSD has a completely different system so none of the automatic part is included in the port.

In FreeBSD you will have to call it manually either with the required parameters in the command line or pointing at a file that contains them.
That's not a problem we can easily make the script run at boot time.

So what is your modem? Specifically what are the VID and PID?

Steve

Offline jamesc

  • Jr. Member
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #13 on: February 17, 2012, 11:33:40 am »
That doesnt sound too painful, the script would need to be called at startup before pfSense did its ppp dial.

My modem is a ZTE 636, i also have a Huawei E220 and vodafone K3565 for further testing. Im away til Sunday so dont have access to my test environment but im still checking the forum via my iPhone :-)

Offline stephenw10

  • Hero Member
  • *****
  • Posts: 8175
  • Karma: +8/-0
    • View Profile
Re: Useful 3G modem 'mode switching' script
« Reply #14 on: February 17, 2012, 12:07:46 pm »
Ok, to confirm we really need the VID and PID but according to the device_reference.txt:
Quote
# ZTE MF622 (aka "Onda MDC502HS")
# ZTE MF626
# ZTE MF628+ (tested version from Telia / Sweden)
# ZTE MF633
# ZTE MF636 (aka "Telstra / BigPond 7.2 Mobile Card")
# ZTE MF637
# and probably others not listed here
#
# Contributor: Joakim Wennergren and others

DefaultVendor=  0x19d2
DefaultProduct= 0x2000

TargetVendor=   0x19d2
TargetProduct=  0x0031

MessageContent="5553424312345678000000000000061e000000000000000000000000000000"
MessageContent2="5553424312345679000000000000061b000000020000000000000000000000"

NeedResponse=1

It says to not use the reference file directly, perhaps because it's quite large, so create a new file with the above lines in. Hope!  ;)

Steve