×
Namespaces

Variants
Actions

How to set an alarm event on Maemo

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


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: lpvalente (14 Apr 2013)

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 (&currentTime);
//Convert time_t to tm as local time
targetTime = localtime (&currentTime);
 
//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

This page was last modified on 14 April 2013, at 00:30.
55 page views in the last 30 days.
×