![]() |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
See here: http://wiki.maemo.org/User:Jebba/DBU...d-notification
Replace $1 with your message. But this is the type that does not go automatically. Replace SystemNoteDialog with SystemNoteInfoprint and don't include the last uint32:0 string:'NAO OK!' |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
I've spent some time on this script and refined it a little:
*It now only does anything if there's an active connection. *It logs startup and disconnections to a file in mydocs/tmp *It notifies you onscreen when disconnecting *It distinguishes between wifi/cellular connections I still cannot get it to autostart though - I don't get what I'm doing wrong. I have an entry in /etc/event.d as suggested and have tried everything I can see - to no avail. Ideally it needs to start once the desktop is up and loaded properly... any ideas anyone? Here's my script for anyone who wants it :) Code:
#!/bin/sh |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Add an echo into some file to the event.d file, so you can know if the commands in this file run at startup.
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
appreciate your effort please let us know when your done :D
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
or add the script to /etc/networks/if-pre-up.d/ or /etc/networks/if-up.d/ to start every time a network interface is upped. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Yeah, that'd be ideal to launch it when the network starts but I'm way out of my limited knowledge of linux here...
I took a look in if-up.d and saw there were some scripts in there. I tried to put my own in but it didn't seem to run. The others were named 00_something - maybe my test had a malformed naming for execution within that folder or perhaps I'm misunderstanding how that works... I can't find anything clear on this area on the web... What is there is linux specific - I'm not even sure if thats completely appropriate for all versions of linux, let alone maemo... I'm a Windows programmer so this is all rather unfamiliar to me to say the least! Ideally I'd launch the monitor script with some handle, upon network up and then use the handle to terminate on network down (with the handle - if that's even how linux works?) Any idea how, or does anyone know of any useful guides on this sort of stuff? I sort of got it to auto-run on startup but something is not right and the script seems to freeze up or something, it stops working anyhow. I can see it running in HTOP still just doesn't seem to do anything. Incidentally does anyone know how to use HTOP?... its functions use Fx keys and I'm not sure how you do that in a maemo console... |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
You would probably do better to use transmitted rather than received packets because most networks will have some general chatter on them even if they are only occasional broadcast messages and those packet could keep your network connection up even if you aren't responding to them.
Perhaps the best solution is actually to check if both RX and TX have changed? |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
I'll post it when I have a proper working script here for people to test :) |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Just a couple of other points
1) phonet is interesting, but I am not entirely sure if it is the best device to check for activity. In my experience it handles packets even when there is no connection in place. It may be that it is better to look at something like gprs0 (or whatever device is created when you are connected) as that will definitely relate to genuine traffic. 2) Using ifconfig is ok, but it is probably slightly more demanding than it needs to be. You can get the same result from the file /proc/net/dev, using something like c=`grep wlan0 /proc/net/dev | awk '{ print $10 }'` One of the joys of this option is that if you want to look for something like gprs devices it doesn't matter if they don't exist as you won't get an error. 3) The original script attempted to disconnect even if there was no current connection. I would consequently suggest that you could find out how you are currently connected by doing this ... connection=`tail -1 /proc/net/route | cut -f1` This would set the variable connection to be 'wlan0' or 'gprs0' or whatever you are using, or 'Iface' if you aren't connected. You could use this information to only look at the live connection for new packets. I am assuming in writing this that only one interface will be active at a time, so if you use something like 'openvpn' you would have an issue. Having said that products like openvpn tend to send regular packets anyway so you wouldn't be able to close your connection very easily. Hopefully this information will be of help? |
Why N900 doesn't automatically disconnect when I'm done?
Every phone I used somewhat disconnected from the web/wi-fi when I close the browser, email, or whatever app that was using internet connection but the N900 doesn't. For example, if I used 3g to browse then close the browser it takes hours to disconnect from tmobile 3g by itself. If I used wi-fi to browse or check emails, it doesn't disconnect when I'm done with email app. 3G disconnects after a while I guess but wi-fi never disconnects and drains the battery. Anybody else notice this?
|
All times are GMT. The time now is 22:12. |
vBulletin® Version 3.8.8