Reply
Thread Tools
Posts: 992 | Thanked: 995 times | Joined on Dec 2009 @ California
#81
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.
 
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#82
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?
__________________
My repository

"N900 community support for the MeeGo-Harmattan" Is the new "Mer is Fremantle for N810".

No more Nokia devices for me.
 

The Following 4 Users Say Thank You to Matan For This Useful Post:
Posts: 284 | Thanked: 75 times | Joined on Nov 2009
#83
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?
 
Posts: 43 | Thanked: 32 times | Joined on Jan 2010
#84
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
2) Contents of /usr/local/bin/autodisconnect:
Code:
#!/bin/sh
while true; do
       sleep 60
       a=`tail -1 /proc/net/route | cut -f1` 
       while [ "$a" == "wlan0" ] 
       do
              b=`grep wlan0 /proc/net/dev | cut -c 8-12` 
              c=$b
              sleep 180
              b=`grep wlan0 /proc/net/dev | cut -c 8-12`
              a=`tail -1 /proc/net/route | cut -1`
              if [ "$b" == "$c" -a "$a" == "wlan0" ]; then
                     dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
              fi
              c=$b
       done
done
3)
Code:
chmod a+x /usr/local/bin/autodisconnect
4)
Code:
vim /etc/event.d/autodisconnect
5) Contents of /etc/event.d/autodisconnect
Code:
description "Run a script to disconnect idle wi-fi"

start on started icd2

console none

script
              /usr/local/bin/autodisconnect
end script
6)Reboot device

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.

Last edited by azstunt; 2010-02-06 at 09:26.
 

The Following 2 Users Say Thank You to azstunt For This Useful Post:
Posts: 31 | Thanked: 44 times | Joined on Nov 2009 @ Czech Republic
#85
It is possible to activate it as icd2 idletimer support is still there in
fremantle but you will need kernel support activated.
This is not tested but should probably work:
- compile idletimer kernel module (IDLETIMER config option is in netfilter
configuration), the idletimer files are found in fremantle kernel sources
- install iptables + ipt_IDLETIMER module (take the sources from diablo and
compile)
- load the kernel module before icd2 starts

There is no UI for setting idletimer value. The idletimer settings are per
network type i.e.,
/system/osso/connectivity/network_type/WLAN_INFRA/idle_timeout for WLAN
(cellular network type is called GPRS) and the value is in seconds.
https://bugs.maemo.org/show_bug.cgi?id=5422#c6

Is anyone willing do thy that?
__________________
OpenWatch - Bluetooth watch support in Maemo
 
Posts: 241 | Thanked: 69 times | Joined on Dec 2009 @ Germany
#86
@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.
 
Posts: 43 | Thanked: 32 times | Joined on Jan 2010
#87
Originally Posted by raily View Post
@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.
I've changed it a bit... try this one, run it from the terminal first... if it doesn't work, paste here the outcomes in terminal

Code:
#!/bin/sh
while true; do
      sleep 10
      a=`tail -1 /proc/net/route | cut -f1`
      echo $a
      b=`grep wlan0 /proc/net/dev | cut -c 8-19`
      echo $b
      while [ "$a" == "wlan0" ]
      do
            c=`expr $b + 1000`
            echo $c
            sleep 10
            b=`grep wlan0 /proc/net/dev | cut -c 8-19`
            echo $b
            d=`expr $b + 1`
            echo $d
            a=`tail -1 /proc/net/route | cut -f1`
            if [ "$d" -lt "$c" -a "$a" == "wlan0" ]; then
                  dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true 
                  a=`tail -1 /proc/net/route | cut -f1`
                  sleep 5
            fi
      done
done
This one is just to test it works. If it works, change the script and erase all the "echo"s around. Also, change the sleep times (I like 180... it means that it should disconnect in 180-360 seconds and it checks every 180 seconds for a connection)

Last edited by azstunt; 2010-02-07 at 21:17.
 
Posts: 241 | Thanked: 69 times | Joined on Dec 2009 @ Germany
#88
Nokia-N900-42-11:/usr/local/bin# ./autodisconnectd
wlan0
125059300
125060300
125059300
125059301
125060300
125059300
125059301
Iface
125059300
Iface
125059300
Iface
125059300
Iface
125059300
Iface
125059300
Iface
125059300
Iface
125059300
Iface
125059300
^CNokia-N900-42-11:/usr/local/bin#
it disconnected correctly. does it idle again or does it send the disconnect command continously?

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?
 
Posts: 43 | Thanked: 32 times | Joined on Jan 2010
#89
Originally Posted by raily View Post
it disconnected correctly. does it idle again or does it send the disconnect command continously?

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?
I forgot about the "sleep 5" one. Leave sleep 5 alone and change the others two to 180. Like this:

Code:
#!/bin/sh
while true; do
      sleep 180
      a=`tail -1 /proc/net/route | cut -f1`
      b=`grep wlan0 /proc/net/dev | cut -c 8-19`
      while [ "$a" == "wlan0" ]
      do
            c=`expr $b + 1000`
            sleep 180
            b=`grep wlan0 /proc/net/dev | cut -c 8-19`
            d=`expr $b + 1`
            a=`tail -1 /proc/net/route | cut -f1`
            if [ "$d" -lt "$c" -a "$a" == "wlan0" ]; then
                  dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true 
                  a=`tail -1 /proc/net/route | cut -f1`
                  sleep 5
            fi
      done
done
Sleep 5 is to give a few seconds to the system to disconnect because if you don't, the system goes back into the while cycle again (just once, though).

Now test if it works when being autostarted.
 
Posts: 144 | Thanked: 21 times | Joined on Mar 2007 @ Finland
#90
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.
 
Reply

Tags
automatic, connect, connect automatically, connect on activity, connect on demand, connect on use, data, data connection, disconnect, disconnect automatically, disconnect when idle, fremantle, gprs, internet, maemo, maemo 5, n900, on demand, on use

Thread Tools

 
Forum Jump


All times are GMT. The time now is 13:00.