Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to set an alarm event on Maemo

From 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 (13 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 13 April 2013, at 21:30.
33 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×