maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Looking for a script to enable/disable the connection automatically (https://talk.maemo.org/showthread.php?t=83652)

Crogge 2012-04-15 12:22

Looking for a script to enable/disable the connection automatically
 
I look for a script / application which will automatically enable my internet connection via WiFI or 3G every 2-3 hours and disconnects it after 1-2 minutes.

Reason? Well I want to check my Skype messages every few hours, having it 24/7 enabled takes a lot of power.

misiak 2012-04-15 12:40

Re: Looking for a script to enable/disable the connection automatically
 
About disconnecting, there is package:
http://maemo.org/packages/view/autodisconnect/
You can configure it via control panel, if you want to have this functionality in your program/script, just look into the sources and copy relevant code.

About auto connecting I'm not sure, but you may try https://garage.maemo.org/projects/auto-connect/ , but I don't know if it does exactly what you want (description says that it just tunes the time interval of network search for automatic internet connection, but you may check which gconf keys it checks, etc., so it may be good starting point). Did you attempt to search in Fremantle documetation? I think I've seen somewhere what should be done to connect to the network... The pseudo-code looked like:
1. get "Internet connection" > "allow phone to connect to nerwork by itself?" value from control panel (it is some gconf value afair)
2. set it to "always allow on any connection" (you may set it to "wlan" if you want to check only when wlan is available)
3. run some maemo command to connect to network (there is a library in Fremantle which you should use, normal call to e.g. "wget" or "ping" will fail, because Maemo needs to know you want to open internet connection, so it can actually connect first, see http://wiki.maemo.org/Documentation/...bConIC_Library for more information)
4. Do some stuff you want to do (so, in your case it would be "set skype account to active", "wait a minute", "set skype account to inactive")
5. Disconnect from the Internet
6. set "Internet connection" > "allow phone to connect to nerwork by itself?" value to the one read in point "1."

In fact, points 1 and 6 are optional, as they just guarantee that you don't change user's settings permamently.

vi_ 2012-04-15 12:45

Re: Looking for a script to enable/disable the connection automatically
 
Install 'Alarmed' it will let you run a script/command using a cron like specification without installing any new junk to run in the background.

So set a job that runs once every 3 hours to connect. Then either use 'auto disconnect' program or set another job to run every 3 hours to disconnect.

Easy!

misiak 2012-04-15 12:54

Re: Looking for a script to enable/disable the connection automatically
 
Quote:

Originally Posted by vi_ (Post 1192383)
Install 'Alarmed' it will let you run a script/command using a cron like specification without installing any new junk to run in the background.

So set a job that runs once every 3 hours to connect. Then either use 'auto disconnect' program or set another job to run every 3 hours to disconnect.

Easy!

Didn't know alarmed already had an option to connect to the Internet, my bad.

vi_ 2012-04-15 14:07

Re: Looking for a script to enable/disable the connection automatically
 
It doesn't, however it can run scripts.

Code:

#!/bin/sh
#connect
dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0


Code:

#!/bin/sh
#disconnect
dbus-send --print-reply --system --dest=com.nokia.icd2 /com/nokia/icd2 com.nokia.icd2.disconnect_req uint32:0x8000


figaro 2012-04-15 14:25

Re: Looking for a script to enable/disable the connection automatically
 
Is there a script to disable/enable built-in auto-connect?

I have a terrible signal reception, so auto-connect is not an option (or else, I'll end up with no connection every time it's accidentally disconnected).
But since I don't need internet connection when I'm asleep, I wish I can turn it off during the night and automatically re-enable it in the morning.

bozoid 2012-04-16 15:47

Re: Looking for a script to enable/disable the connection automatically
 
1 Attachment(s)
try these (attached) for auto connect.
make sure you have command line unzip utility.
also make sure you can run sudo gainroot (you need to root your n900).

put the zip file into your n900 in MyDocs folder.
open up an xterm.
type:
sudo gainroot
cd /opt/usr/bin
unzip /home/user/MyDocs/optusrbin.zip
chmod 755 n900netconnections*
chmod 644 n900netconnections*.cfg
chown root:root n900netconnections*
./n900netconnectionslist

the last command should output a long list of things.
if you want to autoconnect your 3G/GPRS, look for type=GPRS among those lines.
then look for the first line above type=GPRS, that starts with the text "/system" & has the text "IAP/".
copy the stuff after "IAP/" and replace line 2 of n900netconnections*.cfg with it.
replace line 1 of n900netconnections*.cfg with your MCC (Mobile Country Code) value.
you can get your MCC from an app called NetMon if i'm not mistaken (it's a GSM network monitoring app).

once done, set alarmed to run command below at times desired:
sh /opt/usr/bin/n900netconnectionsconnect

thanks to all the posts in talk.maemo.org!

bozoid 2012-04-16 15:48

Re: Looking for a script to enable/disable the connection automatically
 
i currently use that script to only auto connect to internet when not roaming & every 20 minutes between 7am to 11pm.
it actually gives me a bit better battery life! :)


All times are GMT. The time now is 10:21.

vBulletin® Version 3.8.8