[SOLVED]How do I get a USB modem to connect on startup?

Booting, installing, newbie
Message
Author
april

[SOLVED]How do I get a USB modem to connect on startup?

#1 Post by april »

Puppy Precise 5.7.1 usually connects on startup to the last successful internet connection I think.

I find that when it is set to GPRS it does not do this and you must use either the connect icon or the tray icon to start the negotiation .

Is there a way to get the negotiation to start on boot up ?
Perhaps a script or something .
I would also like the Openvpn program to run thereafter if possible.

EDIT- Turns out the software install script is on the device when first plugged in. Follow the readme on the device and when properly installed it will show as an optical device for about 10 seconds and then that will disappear and the modem will connect as normal. No modeswitching needed these days.
Last edited by april on Sun 24 Apr 2016, 17:50, edited 2 times in total.

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#2 Post by jafadmin »

Hi, April!

I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.

The problem is that there are many steps to get there.

First we would need to look in dmesg to see how the usb device is identified.
Second we would need to "udevadm" to dump the device stack for it.
Third would be to create the udev rule from the info we got in step 2
Fourth, we would write the connect script.

So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.

This kinda demonstrates the end-to-end process to build it. Keep in mind you aren't interested in pppd/pptp, you will use OpenVPN. Near the bottom is all the techie stuff on how we would use udev to automate the proceess:
https://wiki.archlinux.org/index.php/3G ... _with_pppd

How bold do you feel today? :) So what brand of gprs modem is it? Maybe we can find some breadcrumbs on the googles.

april

#3 Post by april »

Its a Huawei E160E
Bus 001 Device 005: ID 12d1:140c Huawei Technologies Co., Ltd.

I take it the udev rule you are pointing to is
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="0612", DEVPATH=="*/ttyACM0", RUN+="pon"
which I should change to
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="140c", DEVPATH=="*/ttyUSB0", RUN+="pon"

Not sure what the last bit is "pon" ?

april

#4 Post by april »

atm when I click connect it comes up as ppp0 connects to ttyUSB0
little script I'm trying gets it connected with

Code: Select all

#! /bin/bash
sleep 10

pgprs-connect
# script to start OpenVPN on startup
openvpn --config /vpnbook-ca1-tcp443.ovpn

THIS GETS CONNECTION UP but no VPN

But not so good . Just wondering why I cant start pgprs-connect in the start menu . Hmm

Certainly first you must setup the Internet connection using GPRS Connect
Then choose "Wireless GPRS Modem" and fill in the details needed.

Then in the Startup folder there must simply be a way to make the "Connect" icon on the desktop, or ,in the tray , run . How to do that?

The desktop icon has " /usr/local/apps/Connect" as a program to run so I tried that in a script and it does not work . I also tried creating a link to it directly in the Startup folder but again no luck. I think I need some delay to give the modem enough time to configure itself on bootup.
Last edited by april on Wed 20 Apr 2016, 09:33, edited 7 times in total.

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#5 Post by nic007 »

Hi, April
My HOWTO here: http://www.murga-linux.com/puppy/viewtopic.php?t=105455 may be of interest to you. To make an automatic connection at startup, you can copy the connection script to your Startup folder in /root. Edit: I see you have already been to that link, it wasn't of any use?

april

#6 Post by april »

It uses the old line modem dialler rather than the newer GPRS dialler nic007 and the GPRS dialler allows you to set the APN for the provider and the dial number in an easier fashion for the less technically minded like me .
Last edited by april on Wed 20 Apr 2016, 10:25, edited 1 time in total.

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#7 Post by nic007 »

april wrote:It uses the modem dialler rather than the GPRS dialler nic007
Can you use dial-up (wvdial) instead?

april

#8 Post by april »

OK got the connect to run OK and probably the vpn with this script in the Startup folder
It runs in the background and I would like it to run in a terminal window so I have to work that bit out yet.

Code: Select all

#! /bin/bash
# script to start pgprs-connect on startup
sleep 05
pgprs-connect
# script to start OpenVPN on startup
openvpn --config /mnt/home/TempSave/OpenVPN/vpnbook-ca1-tcp443.ovpn --auth-user-pass [/mnt/home/Tempsave/OpenVPN/upfile] 
Now the problem becomes VPN has a username "vpnbook" which has to go in and then it asks for a password which is "Suwrav4P" atm see the above line for entry .Those are placed on separate lines in the file "upfile" which is the User/Password file

That password changes and the current one is available from the web site http://www.vpnbook.com/ under the OpenVPN tab on that page .
So now how to get that automatically and how to get it into the upfile above?
Last edited by april on Wed 20 Apr 2016, 10:20, edited 3 times in total.

april

#9 Post by april »

nic007 - Your barrow is too heavy . You may push it along as you wish but I look for the easy way .Thanks though Mate!

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#10 Post by nic007 »

april wrote:nic007 - Your barrow is too heavy . You may push it along as you wish but I look for the easy way .Thanks though Mate!
Just trying to help. Good luck.

april

#11 Post by april »

jafadmin wrote:Hi, April!
I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.
So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.
I would like to understand this more . jafadmin
The glaring inadequacy of my above is that the modem must be plugged in already as it wont connect otherwise and must then be done manually anyway..

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#12 Post by jafadmin »

april wrote:
jafadmin wrote:Hi, April!
I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.
So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.
I would like to understand this more . jafadmin
The glaring inadequacy of my above is that the modem must be plugged in already as it wont connect otherwise and must then be done manually anyway..
Once the udev rule is installed, it gets invoked whenever the device is plugged in. So ...

Code: Select all

RUN+="ConnectScript"
... is the part that does the work. Cool, no?

april

#13 Post by april »

Well I f/mucked around with udev rules like this

Code: Select all

ATTR{idVendor}=="12d1", ATTR{idProduct}=="140c", RUN+="/mnt/home/TempSave/Scripts/openvpn.sh"
and could not get it to work whatever.

By placing the script as a link in "/root/Startup" folder the connect part works every time .

Don't see what I have wrong pretty sure the device ID is OK as thats what I get on an "lsusb" but maybe I need the product ID before its switched . ie the default product ID

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#14 Post by jafadmin »

I usually create a test script that will just confirm the udev rule is working first.
Something like:

Code: Select all

date >> /root/mydocuments/ruletest.out
call it "ruletester" or whatever and use that in the RUN+="ruletester"

once you get it to where it adds a time/date stamp every time you plug in the device, you can work with debugging your connect script.

Also: http://cafim.sssup.it/~giulio/other/huawei-E1692.html

april

#15 Post by april »

Thanks . Thats a handy one for any situation . It goes into my script folder .
I am not getting a response however when I plug the modem in and it must be that I have the product ID wrong somehow .

lsusb only gives the product number after modeswitch has done the switch so now I have to find the ID before the switch . It seems to be switching so I assume its being done by a udev rule but perhaps thats not the case in newer hardware.

I'm studying that site you gave me atm.

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#16 Post by nic007 »

Your barrow seems to be extremely heavy and not getting any lighter soon it seems. :cry:

april

#17 Post by april »

We all have our crosses to bear if I follow your meaning . just a bit of fun.

Once the correct modem is found then the answer will be simple . That's why I like bash
Last edited by april on Fri 22 Apr 2016, 09:53, edited 6 times in total.

april

#18 Post by april »

I have a Vodaphone Huawei USB Modem K4203 too.
So I decided to try that one and again looked up the "lsusb" ID's for it and put that ruletester in as below . It did not register a date as it should if the command is executed so I don't know where to turn next on that one?
Running the ruletester directly works every time.

Code: Select all

# Vodafone / Huawei Kxxxx
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f1c", RUN+="usb_modeswitch '%b/%k'"
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f1c", RUN+="/mnt/home/TempSave/Scripts/ruletester.sh"

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#19 Post by nic007 »

Hi, April. Just as a matter of interest. How long does it take to setup your connection using pupdial?

april

#20 Post by april »

nic007 wrote:Hi, April. Just as a matter of interest. How long does it take to setup your connection using pupdial?
Forgive me I don't understand .

I set up under Menu->setup->Internet Connection Wizard . Choose GPRS Connect, and Wireless or wired LAN, and then SNS. it comes up as WWAN0 and I DHCP it and then whenever I hit the connect icon or network icon in tray it does the terminal negotiation thing which only takes 3 or 4 seconds to actually connect. Happens everytime on boot direct from icons now.

I like for that to happen every time on bootup and with the script it does without my involvement . Now I just experiment to have it better when I plug it in . Its not a time problem rather a convenience one

Post Reply