User:Magick777/My N900 Scheduling

Contents

[edit] What do I need to schedule

[edit] Backups

  • Regular backups to be scheduled from alarmed at such time as I have a suitable backup script.

[edit] Maintenance

  • Perform any software or network updates that may be required
  • Reset GPRS data counters monthly (done via Alarmed)

[edit] Profiles

  • Minimise annoyances overnight (but allow alarms to work)
    • Turn off e-mail checking & notifications overnight

[edit] Optimisations

  • Power management - maximise battery life opportunistically
    • force 2G mode when phone is in pocket/not being actively used
  • Perform updates when on WLAN to minimise transfer via GPRS

[edit] Criteria for scheduling events

[edit] Time-based scheduling

Certain actions need to be scheduled according to time of day, week or month, i.e. as per the scheduling behaviour of the Unix cron daemon. There seem to be two viable ways of achieving this, via fcron and Alarmed. The [fcron] page is well-written and useful, but I think Alarmed is the better tool for the job, partly on the strength of the GUI and partly because it uses an existing daemon rather than adding another one.

[edit] Phone status & event scheduling

[edit] Charger plugged in / removed

When charging starts, it usually means that the phone is at home and therefore that we want to cancel power saving measures, enable WiFi and so forth. However, this may not always be correct and it would be nice to incorporate some sort of test that we actually are at home and that the actions taken are correct. So, what we need is a script that enables WiFi but sets a timer to disable it again after a fixed amount of time, plus a script that reacts to a successful connection to the home WiFi network by disabling the timer and letting WiFi remain.

This way, if I'm charging from an external power pack in the field, it'll trigger and have a look for WiFi, then decide after one minute that it can't reach my home network so it'll turn WiFi off until I explicitly ask for it. We'll handle the WiFi switching in the same way as the existing WiFi Switcher applet (by nicking the scripts from it), meaning that the existing switcher application can also be used as a manual override to our automations.

The end result of all this will be:

  • Using dbus-scripts, when charging commences run the script wifi-enable-home. This will enable the WiFi (if disabled) but also run the script /opt/usr/bin/wifi-kill which, after sleeping for 60 seconds, will disable WiFi again.
  • When we get a connection to my home Wifi, run /opt/usr/bin/wifi-unkill which will kill the script that was set to disable WiFi.

[edit] Device locked / unlocked

[edit] Display on / off

[edit] Specific WLAN connected / disconnected

[edit] Calendar-based scheduling

[edit] Location-based scheduling

  • When not at home, turn WiFi off unless and until explicitly requested
  • When at home, turn WiFi on and autoconnect

[edit] Changelog for scheduled events

This will be moved to the bottom of the page later.

2010-07-15

  • Installed 'alarmed' from extras-devel, had to ln -sf python2.5 to /usr/bin/python
  • Configured alarmed to reset GPRS data at 0000 on 1st of each month

[edit] What have I scheduled?

[edit] Opportunistic power saving

I am working on User:Magick777/OPS.

[edit] CPU frequency scaling

More or less as described in this script, though I implemented it with dbus-scripts-settings. On phone locked we set "kernel-config limits 250 500" and on unlock we set "kernel-config limits 500 850".

[edit] Set 2G radio mode

For battery life, I want the phone to put itself into 2G mode except when I am intensively using the data connection. It would seem sensible to trigger the switch to 2G any time that the phone is locked and remains so for a minute or two, in the assumption that it is in my pocket. But, I would not want this to happen if a) I am on a call b) the phone locked unintentionally and I unlock it again c) the phone is on charge or d) it was in 2G mode in the first place. I do not want it to be constantly switching between the two; it should change when it has good reason.

So, the phone locking should trigger a script that

  • tests whether it should take action and
    • if so, waits a minute to see if I unlock the phone again and
      • if I don't, goes ahead and kills 3G.

This would be achieved by running a script on lock that will sleep for 60 seconds and then switch to 2G mode. On an immediate unlock, we can test if that script is running and kill it thus leaving the dual mode intact.

By what criteria to restore 3G is more difficult; it is by no means automatic that I require 3G because I unlock the phone or plug in a charger. However, as soon as I want to access e-mail, Web or VoIP, 3G will be required. Therefore my options are

  • never automate the switch to dual mode and switch manually when required
  • automate the switch based simply on using the phone
  • automate the switch when I launch any application that requires it
  • automate the switch based on data traffic flow