Diary Api


Pleng

Well-Known Member
Joined
Dec 28, 2006
Messages
3,030
I had an idea for a diary api which could be built in to Pandora's firmware and accessed by games/applications. The idea being that you could schedule events within games, for which the pandora could auto-wakeup and, if avaliable, start the application.

Example:

You are playing a MMO game, racing game, or whatever against an opponent. When in dialogue with another player you arrange to meet up at a specific time. The game then asks if you'd like to set a reminder in your diary.

The diary note is saved to a diary file on the internal NAND, with (for example) the following compulsory and optional fields:
  • Application ID
  • Application Location (last known location)
  • Event Date
  • Event Time
  • Wake Up on Event (Y/N)
  • Run Application?
  • Sound Alarm (Y/N)
  • Remind Before (Y/N)
  • Remind Date
  • Remind Time
  • Reminder Text
  • Additional Info
So, for example, the Pandora could take appropriate actions at the time time, ex
  • Power-up and remind you to run the game at the specified time
  • Power-up and remind you about the event an hour before hand
  • Power-up and load the game (if present on current SD card), passing the event into the game for it to show its own reminders, or take any other action necessary
This could work equally well with productivity applications such as email apps (send email at specific time) and instant messenger clients (arrange to meet with friend online). By using the 'additional info' data to store XML data, it could also be used to integrate with larger PIM applications such as sunbird - the whole information could be stored in the additional info field or, probably more suitable (due to limitations on the size of the NAND) a link to the location of the information in the application's own data file(s).
 
This, or rather the notion of timed wake-up intrigues me. Can the pandora be set to a sleep state from which it wakes up at a certain time? I'm thinking alarm clock, calendar alerts etc. I've read on numerous occasions that the pandora can achieve great battery life when only playing mp3:s using the DSP. Could a similar state be induced, from which the pandora could wake up on its own?
 
B-ZaR said:
Could a similar state be induced, from which the pandora could wake up on its own?
I'm pretty certain it can. I can't think of the source but I'm sure it's possible.
 
Last edited by a moderator:
Yes, but this would also be a firmware / hardware setup that could wake up the Pandora automatically.

Some PCs have this in the BIOS, where you can set the computer to power on automatically at a certain time.

edit: The Wikipedia explains this much more gracefully:
http://en.wikipedia.org/wiki/RTC_Alarm

"In Linux, the real time clock alarm can be set or retrieved using /proc/acpi/alarm."
So does the Pandora have any sort of RTC alarm or ACPI thing going on?

Here's what I'm thinking:

Assume that the Pandora's firmware supports some kind of "power-on at xx:yy time" or "resume at xx:yy time" function. RTC alarm functionality.
Then make the Diary API or Diary daemon or whatever a cron-like program that keeps track of when the system needs to wake up next, and automatically sets the next wake-up time.
As for actually launching a program, you could use a script that runs at startup, checks a text file for tasks that need to start, and starts them. "at" would probably be a good replacement for this, though the Diary daemon will need to wake the system up a minute ahead or so to make sure that at is awake when the application is supposed to start.

Edit: It would be great if somebody could actually find out whether the Pandora's BIOS / firmware is capable of booting at a given time, and whether this can be accessed from software.

more edit: there's a command called rtcwake that sets the RTC alarm. So the diary system would just use that, assuming the Pandora has something along the lines of RTC alarms.
 
Any facts on RTC alarm support? If the hardware supports it, is there a support in the current kernel? If there is a support in the current kernel, should a manager library be made to receive wake-up requests from programs and set the next alarm? This could also be just a text file which would be read before the device is put to sleep.
 
Well, it will probably be a lot like cron, if not partially based on it, so its ability to do notifications / run programs / etc. is only limited by how much a shell command can do.

If you have some of those weird high-level languages like Ruby or Perl installed, that's really anything a regular user can do.

To re-iterate: Does anyone know if the Pandora will have access to an RTC alarm? Does the hardware have one? Are there drivers for it?

*these comments were automatically joined by the forum without telling me, thanks.*

I searched Google for "TI OMAP RTC alarm" and found this driver-looking program:

http://tinyurl.com/dk4ylp

There's some stuff in there about an RTC alarm, so I assume that the Pandora will have one and that this driver will work with it, assuming there's no problems with kernel compatibility. This driver claims to be based on code for a driver for the 2.4.20 kernel. I don't know what's been updated, but at least this means the OMAP has a working RTC alarm, right?
 
Har har! The time for only lurking is over (I have been lurking here since last July or August and have preordered and re-preordered already)!



I like this idea greatly, but I think we could take it one step further by integrating with other existing PIM functionality. If we could tie into the GPE PIM software for example (commonly used in angstrom builds on various PDAs, I have used it on my IPAQ 5450 with Angstrom) it could handle alot of this transparently, while providing great PIM functionality too for many purposes.

It already does have wake-up functionality, which I did have working on an older build of Angstrom on my device.
 
Me being a noob to linux, Cron sounds very good, but a simple/complete calendar and appointment thing with those functions syncing with Google calendar and maybe mail and stuff would be very nice... I thought they provided API to developers to access the data?? edit: hmm, might be another project : )
 
well, cron is used for periodic tasks.
Perhaps I should have thought my comment out more, it would make more sense to use something like at or an autostart script to check for tasks..

Cron is used for periodic tasks such as system backups. It's probably not appropriate for the 'diary' system.
At is used to delay a command until a specific time. Of course, this only works while the system is on.
The RTC alarm will need to be set sometime before shutdown, probably whenever an earlier task is added to the list.

So there will have to be some sort of sorted list tracking the upcoming events, and every time the earliest one changes, the system needs to update the RTC alarm.

As for actually calling the tasks once the Pandora turns itself on, it would be possible to let at handle this. [Just turn the Pandora on a minute or two before the earliest task needs to start]
Or, add a program that automatically runs at startup or login or whatever and checks for tasks that need to run.

I don't know whether a daemon would need to get involved at any point, but it's possible. I haven't thought this out much yet.
 
@ lulzfish

Ah, i see what you mean. a simple misunderstanding. from the first sentence of your post i thought you were suggesting to use cron itself for day to day use :) but ofcourse the system would need to know when to become active and know when to sound an alarm or connect to a server for a game and stuff so it could be very usefull?

Cheers!
 
No, that was my fault. I said 'cron' without thinking that 'at' was the actual command one should use.

I've tried 'at' out a little bit, and it definitely does all the scheduling stuff needed for the diary API. I believe it will work even after a standby / resume cycle, but we still need a program to wrap 'at' and adjust the RTC alarm in order to make sure the Pandora is awake to run 'at'.

Here's what I've thought of thus far:

The diary will use 'at's task queue, but also its own list, which might be used to track which program owns each event, and store a notification message of some kind.

When a new diary entry is created, it will run a script that calls at and stores the event in the diary's database. It checks the entry's start time against the database, and adjusts the RTC alarm if necessary.

At will call the command automatically when the Pandora is awake. It might make sense to have the diary program add a command to 'at' to also delete the event once it occurs, to keep the diary's database from becoming cluttered.

To remove an event, the diary will check its database, use 'atrm' to clear the event from 'at's task list, and move the RTC alarm back if necessary.

As for notification, I believe there is something like 'gdialog' which can be used for simple pop-up messages. If not, it's pretty easy to write a GTK+ program to do this. The diary program itself doesn't need to handle notifications. A program that wants them should simply tell the diary to open a notification window at the appropriate time.

So, I think that will work. I would get started on a prototype, but I'm not really sure how to use the RTC alarm yet. Maybe I'll do a prototype with something different. Maybe I won't because I'm lazy. We'll find out.

Oh, and my other concerns are as follows:
  • Does the RTC alarm track days or just hours and minutes? If it's days, this could get a little bit more complicated.
  • 'at' doesn't seem to actually return a job ID, which will make it difficult to remove events that have already been set up. I think if I use something like 'sed' or 'awk' to look through the output of 'at', I can find the ID pretty easily. Unfortunately, I don't actually know how to use sed or awk. Please advise.
  • I'm not really sure if the diary needs to store a program name and message for each event, but it seems handy. I dunno. If it does, someone should figure out how to do that.
 
Last edited by a moderator:
Dr.PHP said:
I like this idea greatly, but I think we could take it one step further by integrating with other existing PIM functionality. If we could tie into the GPE PIM software for example (commonly used in angstrom builds on various PDAs, I have used it on my IPAQ 5450 with Angstrom) it could handle alot of this transparently, while providing great PIM functionality too for many purposes.


I think integrating it with existing PIM software could be tricky, as a lot of different standards would need to be built in, and this could end up taking up valuable space in the NAND.

However it would be relatively easy for PIM software to be updated to make use of the in built diary API, by placing any application-specific data (or at least a link to said information) in the Additional Info field. Upon waking up the Pandora would know which PIM to start (Application ID) field, and could feed the data from the additional notes field into the PIM for further processing.
 
Last edited by a moderator:
Pleng said:
I think integrating it with existing PIM software could be tricky, as a lot of different standards would need to be built in, and this could end up taking up valuable space in the NAND.

However it would be relatively easy for PIM software to be updated to make use of the in built diary API, by placing any application-specific data (or at least a link to said information) in the Additional Info field. Upon waking up the Pandora would know which PIM to start (Application ID) field, and could feed the data from the additional notes field into the PIM for further processing.
Depends - I spent some time today looking through the sources and there is an event API that registers the various scheduled events within a mySQL database and various currently running pim apps. You would have to include the event library and then you should be able to schedule things transparently.

I'm just trying to think of things that can benefit the whole entire PDA environment more than just gaming in particular - this concept, if a simple and easy-to-include set of hooks is set up for game developers to be able to add this functionality, could provide a lot of value platform-wide. IE it could tie into IM clients, email, etc.
 
Last edited by a moderator:
Dr.PHP said:
I'm just trying to think of things that can benefit the whole entire PDA environment more than just gaming in particular - this concept, if a simple and easy-to-include set of hooks is set up for game developers to be able to add this functionality, could provide a lot of value platform-wide. IE it could tie into IM clients, email, etc.

Yup. I believe I mentioned that sort of flexibility in my original post :p
 
Last edited by a moderator:
If we get a confirmation that rtc alarm functionality is available, many things can be added on top of that. For now I'd just like to know if this functionality is indeed available. Devs?
 
Back
Top