![]() |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
That is up to you.
There are two basic approach to use N900 - use it as ACCESS device then you don't need an access to you from outside. In this case you can just set it "offline" in "Availability" button (not "Offline mode" - it switches of your cellphone totally ... battery lasts weeks). In this mode your batter would last around 48h, I estimate. The second approach - stay connected with net/people as possible. In this case you want receive skype/gtalk/email and think about battery. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
There is another approach - have the device do what the user wants, which in this case is to disconnect from network after a certain period of inactivity. If you do not this behaviour, you don't have to read and comment in this thread, as the title of this thread makes its content very simple. Why come here and try to convince people they don't know what they want?
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Hey all - I suppose this is a similar question (I don't want to start a new thread and couldn't find it elsewhere), but is it also possible for the internet access to be turned off at certain times? I know there's an app to turn off cell data and leave internet on (which is great), and there's this script here to disable internet after no activity, but I really want to disable internet at night time only. I'd still want to receive calls... Think this is possible? A button would of course be handy as with the cellular modem data button...! Any thoughts?
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Well... hello everybody.
I don't know if you are still interested in a workaround for this (and a very simple one at that). But reading the codes previously posted here, and via trial and error, I've managed to get a code that works and starts automatically. Sorry 3g guys, my carrier isn't compatible with the n900 frecuency and therefore I can't see how does 3g behaves, maybe someone can adapt my code. Instructions here: 1) Code:
vim /usr/local/bin/autodisconnect Code:
#!/bin/sh Code:
chmod a+x /usr/local/bin/autodisconnect Code:
vim /etc/event.d/autodisconnect Code:
description "Run a script to disconnect idle wi-fi" 7)Enjoy! Credits to matan for the script in event.d. And to farnwomt for some of the lines there. A few notes here. This script checks every 60 seconds until it finds an established wi-fi connection, it does nothing until then. I'm using grep wlan0 /proc/net/dev | cut -c 8-12 because even when not in use, the wi-fi sends and receives about 1 packet every 30 seconds or so. These are very small packets (most ranging in 30-250 bytes I believe). So what I did was to ignore the last 3-4 digits (depending on how many bytes the device has received since boot-up) in the bytes received and use that as a reference, given that most internet sites are big enough to be about 1-10 kb at least. Not sure how does it behave along with IM (I don't know if IM can receive at least 10kb every 3 mins). For those that decide to test it, it shoud disconnect after 3 mins, but in a bad scenario (unlikely) it should be 6 mins, and in a very bad scenario (very unlikely) it should be 9 mins. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Is anyone willing do thy that? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
@azstunt: i tried your script because thats exactly what I was looking for. Unfortunatly it does not disconnect my wlan.
with "ps" i see 2 instances of the script running and there is "sleep 180" there also. so i think it recognizes the established connection. but it does not disconnect, waited for 30 minutes or so. my messengers are offline and mfe-setting is to check every 60 minutes. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Code:
#!/bin/sh |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
I have to admit I dont fully understand your script. so do I change every sleep 10 to sleep 180 for normal use? what about the sleep 5? change to 60? then erase all echos-lines to surpress output? anything else to delete? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Code:
#!/bin/sh Now test if it works when being autostarted. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Could someone do 3G compatible version of this. Change wlan0>gprs0 etc. and edit cuts?
Maybe this script should run only when connected like this /etc/networks/if-pre-up.d/ or /etc/networks/if-up.d/ to start every time a network interface is upped. And someone should make simple control panel applet to turn this script on/off. Like wifi-switcher check the source code. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Code:
ifconfig wlan0 | grep RX.p | cut -d: -f2 Code:
-sh: ifconfig: not found Get connected again. Now, gain root and type: Code:
ifconfig wlan0 | grep RX.p | cut -d: -f2 If you run the script as root you don't get any errors but you also don't get disconnected. To find out why, open another terminal and run (as root). Code:
ifconfig wlan0 | grep RX.p | cut -d: -f2 |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Code:
#!/bin/sh |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
@azstund,
I tested your modified script and at first after bootup it disconnected me correctly. Then I tested if it leaves a used connection unchanged by listening to internet radio streams. The script did not disconnect, fine. Afterwards i closed all programs causing traffic and waited for a disconnect, but nothing happens. Can you figure out whats wrong? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
I would rather attach it to the cron: http://talk.maemo.org/showthread.php?p=467732 with 3 minutes period instead of global while true...
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
EDIT: Another thing, what time did you set for sleep and how much time did you wait for a disconnection after closing all programs? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
ok, good I was to lazy yesterday to set up the test :)
But is you Script in post #93 affecting packet connection over 3G, GPRS? I just want to disconnect WLAN, hence I don't think I can idle in ICQ when on 3G anymore if I use Script #93. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
I wrote a script for /etc/network/if-up.d/ a number of weeks back to check whether the slide was shut, whether ssh was running (rarely want disconnect in this case) and if so, disconnect. It exited if no route was up. Sorting idled bytes xfered was the missing piece, thanks for this thread! I can post my script if ppl are interested.
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Also, when I connect to a network the email app automatically checks for new emails. If the script could also automatically bring an interface up intermittently (then normal logic to bring it down) would email be checked? This would be perfect - long battery life plus email notifications. I would also like to be able to bring down openvpn when on my home wifi connection. It looks like this thread might make this possible too... |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Just a small battery regarding notice: With a similar script I end the day with about 80% battery. Mails are updated automatically every two hours, I use all kind of widgets like omweather. It's true that I don't speak that much at the telephone.
Before coding that script my battery was almost drained at the end of the day. I didn't expect wlan controller to be _that_ power unfriendly. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Interesting, no wonder so many people are unsatisfied with the battery. It seems that the issue isn't the need for a larger battery but better power management...
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Can we get a "latest and greatest" working version of that script slapped into a fresh thread or somewhere easily accessible in case modifcations/updates are made to it? I am interested in trying this out but would like to know which version is the one people are using with the most success at the moment.
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
well, this is what I'm using - based on a similar idea from his thread. Improvments are welcomed, I'm looking especially for "screen on" info in order to let he connection alive when screen is lit.
#!/bin/sh while true; do a=`tail -1 /proc/net/route | cut -f1` b=`grep wlan0 /proc/net/dev | cut -c 9-18` while [ "$a" = "wlan0" ] do c=`expr $b + 6000` sleep 180 b=`grep wlan0 /proc/net/dev | cut -c 9-18` d=`expr $b + 1` a=`tail -1 /proc/net/route | cut -f1` if [ "$d" -lt "$c" -a "$a" = "wlan0" ]; then echo Disconnecting dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi done sleep 180 done |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
string "on" "on" can also be "dimmed" and "off". I guess you can use dbus-scripts or something similar to have something happen upon the display state changing. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
How to disconnect automatically from idle networks (3g/2g/wi-fi) UPDATED 09/02/10 SECOND UPDATE 09/02/10 - FIXED A FEW TYPOS THIRD UPDATE 09/02/10 - MADE THE INSTRUCTIONS MORE USER FRIENDLY UPDATED 10/02/10 - MADE IT START ONLY WHEN A CONNECTION IS ACTIVE SECOND UPDATE 10/02/10 - FIXED A TYPO... HAD FORGOTTEN A LINE THIRD UPDATE 10/02/10 - NO CHANGE TO THE SCRIPT OR MAIN INSTRUCTIONS, JUST TO THE EXTRA FUNCTIONALLITY INSTRUCTIONS Before you start, you'll need to install vim and rootfsh, both found in the extras repository. 1) In xterminal input Code:
sudo gainroot Code:
vim /usr/local/bin/autodisconnect Code:
#!/bin/sh Code:
chmod a+x /usr/local/bin/autodisconnect Code:
vim /etc/network/if-up.d/00_autodisconnect Code:
!#/bin/sh Code:
chmod a+x /etc/network/if-up.d/00_autodisconnect 9) Enjoy! Extra instructions for those looking specific funcionallity: a) If you want to disconnect only from wi-fi change line 5 Code:
while [ "$a" != "Iface" ] Code:
while [ "$a" == "wlan0" ] i) The constant (1000 in this case) in line 7 is about how many bytes must be receiven in a given period of time (the sleep time in line 9) to consider the connection in use. Anything less than that is considered idle. I also recomend a low number because I still don't know exactly how does it get along with idling in IM (but you still want to stay "Avalaible"). If you get randomly disconnected when idling in IM lower the value. ii) The sleep time in line 8 determines when you'll disconnect automatically. It will almost never be the exact time indicated. If you stop using your connection it should disconnect in a range of x to 2x seconds of the time set (x being the sleep time). Any questions feel free to post here. Hope it works for you. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Is it normal that two instances of the Script are running? I don't know how things in event.d work, so I am just curious.
Code:
Nokia-N900-42-11:~# ps |grep auto |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Hi there. I've been running the following script for now a week and it works pretty good on my device both with 3G and Wifi. Since it's the script I want to use in an application I am currently developping, if I could have some feedbacks, it would be great.
Thx! Code:
#!/bin/sh |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Hello everybody. Just to let you know that I've updated my script (more like the whole instructions). Now, the script only runs when a connection is active and it closes itself after the device is disconnected (instead of running at boot and staying like that). If you had already used my script, please re-read the whole instructions, a couple of things besides the script are different. Please see back here post #107 or click here http://talk.maemo.org/showpost.php?p...&postcount=107
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Thanks for the script! :D
hey Azstunt can you help me with the install? I just finish installing VIM and Rootfs how do I install the script? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
thanks :D
123456789732 |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
I've merged the scripts from azstunt and calvin_42 since they both have great features - I like the visual notification for starting connection monitoring and ending a connection. if-up was a good choice too.
Seems to work quite well - but not when switching connections. For best results disconnect from a connection before connecting to another one. Instructions for install pretty much as azstunt says. Read the comments... /usr/local/bin/autodisconnect: Code:
#!/bin/sh Code:
#!/bin/sh Code:
#!/bin/sh |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
I have got the above script working successfully.
How do I get email to automaticaly connect to network, its set to auto update? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Thanks I had just set mine up to
connection any search 5mins email to update 5mins as you say seems to work, I will see how it goes. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Hey mclarson!
Thanks for the merge! The script begins to be pretty clean now. I will use it in the application. I've got a few questions : 1) Why have you chosen to keep the 2 while instructions ? -> See my script with only 1 while 2) Why have you chosen to read the RX instead of the TX value ? 3) Number of bytes to ignore for each time period : where does it come from in fact ? Broadcast ? I ask because in my tests on my device, neither the 3G nor the WLAN connexion have generated transmitted packets when I was connected with no activity. But in my case I read TX value and not the RX value. Thanks! |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Quote:
Quote:
I would expect there to be a much bigger difference between idle and busy RX than idle and busy TX. More samples should be more accurate. It would take fewer TX packets to affect the measurement considerably. For a bulk download relativey tiny ACKS would be sent, ie tiny sample, but would have lots of rx, ie big sample. My *idle* connection does about 2k per minute - there /must/ be tx in there but I've not checked what that traffic is. I'd be intersted to see how well your tx method works. |
All times are GMT. The time now is 11:35. |
vBulletin® Version 3.8.8