add rtc function
Change-Id: I30f58c6c2081d02d70f4519370eef12e7a559d8b
diff --git a/mbtk/liblynq_lib/src/lynq_alarm.c b/mbtk/liblynq_lib/src/lynq_alarm.c
index 2722854..461a045 100755
--- a/mbtk/liblynq_lib/src/lynq_alarm.c
+++ b/mbtk/liblynq_lib/src/lynq_alarm.c
@@ -5,47 +5,84 @@
#include "lynq_alarm.h"
#include "mbtk_str.h"
-int lynq_set_wakealarm(unsigned long time_sec)
+
+bool rtc_flag = FALSE;
+int lynq_rtc_service_init(void)
+{
+ int ret = 0;
+ if(!rtc_flag)
+ {
+ rtc_flag = TRUE;
+ ret = 1;
+ }
+ else
+ {
+ ret = -1;
+ }
+ return ret;
+}
+
+int lynq_rtc_service_deinit(void)
+{
+ int ret = 0;
+ if(rtc_flag)
+ {
+ rtc_flag = FALSE;
+ ret = 0;
+ }
+ else{
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int lynq_set_wakealarm(unsigned long time_sec,int src_id,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify )
{
UNUSED(time_sec);
if(time_sec < 1 || time_sec > pow(2, 28)) {
return -1;
}
- return 0;
+ return -1;
}
-int lynq_set_poweralarm(unsigned long time_sec)
+//int lynq_set_poweralarm(unsigned long time_sec)
+int lynq_set_poweralarm(unsigned long time_sec,int src_id)
{
UNUSED(time_sec);
if(time_sec < 1 || time_sec > pow(2, 28)) {
return -1;
}
+ char buf[50] ={0};
+ sprintf(buf, "rtcwake -d rtc0 -s %d -m on &", time_sec);
+ system(buf);
return 0;
}
// min:1 max:2^28
-ssize_t wakealarm(char *buffer)
+ssize_t wakealarm(char *buffer,int src_id,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify )
{
UNUSED(buffer);
if(str_empty(buffer)) {
return -1;
}
- return lynq_set_wakealarm(atol(buffer));
+ return lynq_set_wakealarm(atol(buffer), src_id, rtc_id, wakealarm_notify);
}
// min:1 max:2^28
-ssize_t poweralarm(char *buffer)
+ssize_t poweralarm(char *buffer,int src_id)
{
UNUSED(buffer);
if(str_empty(buffer)) {
return -1;
}
- return lynq_set_poweralarm(atol(buffer));
+ return lynq_set_poweralarm(atol(buffer), 0);
}
-int cancel_wakealarm(void)
+ssize_t cancel_wakealarm(int src_id, int rtc_id)
{
- return 0;
-}
\ No newline at end of file
+ return -1;
+}
+
diff --git a/mbtk/liblynq_lib/src/lynq_time.c b/mbtk/liblynq_lib/src/lynq_time.c
index 55f3ef3..8f432f0 100644
--- a/mbtk/liblynq_lib/src/lynq_time.c
+++ b/mbtk/liblynq_lib/src/lynq_time.c
@@ -303,7 +303,8 @@
// system time set to RTC
int lynq_set_rtc_time(void)
{
- system("hwclock --systohc");
+// system("hwclock --systohc");
+ system("hwclock -w rtc0");
return 0;
}