How to set an alarm event on Maemo
Article Metadata
Tested with
Devices(s): N810
Compatibility
Platform(s): Maemo SDK version 4.x.
Article
Keywords: keywords=Maemo, alarm_event_add,alarm
Created: lming
()
Last edited: hamishwillee
(02 May 2012)
Overview
This snippet demonstrates how to set an alarm on a Maemo device.
Use case
Set an alarm at 7:30 am, tomorrow.
Source file
//necessary header files
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <alarmd/alarm_event.h>
int main (int argc, char *argv[])
{
time_t currentTime;
struct tm *targetTime;
// Get current time
time (¤tTime);
//Convert time_t to tm as local time
targetTime = localtime (¤tTime);
//set alarm time at 7:30 of tomorrow
targetTime->tm_mday = targetTime->tm_mday + 1;
targetTime->tm_hour = 7;
targetTime->tm_min = 30;
alarm_event_t event;
// initializing event object
memset (&event, 0, sizeof (alarm_event_t));
// set event's alarm from targetTime
event.alarm_time = mktime (targetTime);
//add alarm event
cookie_t coo = alarm_event_add (&event);
if (coo == 0)
{
// Error happens
//do someing....
return 1;
}
else
{
//no error happens
return 0;
}
}
Download the source code file: Media:alarm_maemo.zip


(no comments yet)