![]() |
2010-03-17
, 13:09
|
|
Posts: 4,365 |
Thanked: 2,467 times |
Joined on Jan 2010
@ Australia Mate
|
#2
|
![]() |
2010-03-17
, 13:23
|
Posts: 527 |
Thanked: 121 times |
Joined on Feb 2010
|
#4
|
![]() |
2010-03-17
, 13:26
|
Posts: 49 |
Thanked: 6 times |
Joined on Jan 2010
|
#5
|
![]() |
2010-03-17
, 13:33
|
|
Posts: 551 |
Thanked: 507 times |
Joined on Feb 2010
@ North West England
|
#6
|
if wlan0 running if mode is 3G if can ping google set to 2G Notify message endif endif else if mode is 2G set to 3G notify message endif endif
The Following User Says Thank You to JohnLF For This Useful Post: | ||
![]() |
2010-03-17
, 13:39
|
|
Posts: 663 |
Thanked: 282 times |
Joined on Nov 2009
@ London, UK
|
#7
|
![]() |
2010-03-17
, 15:57
|
|
Posts: 551 |
Thanked: 507 times |
Joined on Feb 2010
@ North West England
|
#8
|
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/user/auto2g.sh
![]() |
2010-03-17
, 16:20
|
|
Posts: 2,473 |
Thanked: 12,265 times |
Joined on Oct 2009
@ Jerusalem, PS/IL
|
#10
|
It's nothing new, simply the putting together of snippets of information gleaned from various threads. Took me a few days to gather it all, write it, test it and get it to a point where I was happy it works properly. I've been running it for a while with no problems. This goes to show how open this platform is and the endless possibilities it could provide (and to anyone leaving the party early, you are missing out, I really believe that).
Anyway, the script simply checks for an active WiFi connection, and if one is found, it changes the cellular mode from 3G to 2G. It can be made to automatically revert to 3G upon loss of WiFi if required. A little popup notification briefly appears to indicate a change.
Here it is (there's a file to download at the bottom of this post - Note if you download this file you will need to run a chmod 755 auto2g.sh on it in Xterminal to make it an executable file.)
The reason for the PING is that for some WiFi connections, such as public hotspots, the WiFi can be running but you don't get access until you click an agreement or pay a fee. That line checks the connection is actually working before disabling 3G.
The second IF was required as without it, the N900 set 2G every minute and popped up the notification, which was quite annoying after a while!
The echo near the end is only required if the dbus commands are commented out as there needs to be something between the else and the fi.
I used this with Fcron and scheduled it to run every minute. Fcron instructions can be found here. Note Fcron is in extras-devel only, and you will need to know how to use the Vi editor. Usual warnings apply.
On my N900, the auto2g.sh file is in /home/user. My cron job was set up like so
Thanks to everyone on these forums for the excellent help received, and to Rob1n who showed me the difference between backticks and brackets in shell scripts!
One point to note: This script only deals with 2G and 3G modes, it does not deal with Dual mode as I don't use that myself - I will leave that as an exercise for the reader
Enjoy, and please post back any improvements you make!
Last edited by JohnLF; 2010-03-17 at 22:59. Reason: add chmod note