blob: 461a04586283f2c06a785344e255d0fcbfdbac6c [file] [log] [blame]
b.liu1c74d692024-08-14 17:43:59 +08001#include <math.h>
2#include <stdlib.h>
3
4#include "mbtk_alarm.h"
5#include "lynq_alarm.h"
6#include "mbtk_str.h"
7
8
9bool rtc_flag = FALSE;
10int lynq_rtc_service_init(void)
11{
12 int ret = 0;
13 if(!rtc_flag)
14 {
15 rtc_flag = TRUE;
16 ret = 1;
17 }
18 else
19 {
20 ret = -1;
21 }
22 return ret;
23}
24
25int lynq_rtc_service_deinit(void)
26{
27 int ret = 0;
28 if(rtc_flag)
29 {
30 rtc_flag = FALSE;
31 ret = 0;
32 }
33 else{
34 ret = -1;
35 }
36
37 return ret;
38}
39
40int lynq_set_wakealarm(unsigned long time_sec,int src_id,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify )
41{
42 UNUSED(time_sec);
43 if(time_sec < 1 || time_sec > pow(2, 28)) {
44 return -1;
45 }
46
47 return -1;
48}
49
50//int lynq_set_poweralarm(unsigned long time_sec)
51int lynq_set_poweralarm(unsigned long time_sec,int src_id)
52{
53 UNUSED(time_sec);
54 if(time_sec < 1 || time_sec > pow(2, 28)) {
55 return -1;
56 }
57 char buf[50] ={0};
58 sprintf(buf, "rtcwake -d rtc0 -s %d -m on &", time_sec);
59 system(buf);
60
61 return 0;
62}
63
64// min:1 max:2^28
65ssize_t wakealarm(char *buffer,int src_id,int rtc_id,lynq_wakealarm_add_cb wakealarm_notify )
66{
67 UNUSED(buffer);
68 if(str_empty(buffer)) {
69 return -1;
70 }
71 return lynq_set_wakealarm(atol(buffer), src_id, rtc_id, wakealarm_notify);
72}
73
74// min:1 max:2^28
75ssize_t poweralarm(char *buffer,int src_id)
76{
77 UNUSED(buffer);
78 if(str_empty(buffer)) {
79 return -1;
80 }
81 return lynq_set_poweralarm(atol(buffer), 0);
82}
83
84ssize_t cancel_wakealarm(int src_id, int rtc_id)
85{
86 return -1;
87}
88