Browse Source

Fixed warnings in alarm.c, alarm.h, network.h, ntp.c, ntp.h

Aareschluchtje 9 năm trước cách đây
mục cha
commit
638f08b304
5 tập tin đã thay đổi với 12 bổ sung32 xóa
  1. 1 0
      alarm.c
  2. 5 7
      alarm.h
  3. 1 1
      network.h
  4. 2 21
      ntp.c
  5. 3 3
      ntp.h

+ 1 - 0
alarm.c

@@ -4,6 +4,7 @@
 #include <string.h>
 #include <time.h>
 #include <assert.h>
+#include <math.h>
 
 #include "log.h"
 #include "rtc.h"

+ 5 - 7
alarm.h

@@ -1,10 +1,7 @@
 /* Alarm get/set status values */
-#define ALARM_1 	5
-#define ALARM_2		6
-
-#define AFLGS		0b11111111
 
 #ifndef _ALARM_DEFINED
+#define _ALARM_DEFINED
 struct _alarm
 {
 	struct _tm time;
@@ -16,8 +13,6 @@ struct _alarm
 	int id;
 	int state;
 };
-#define _ALARM_DEFINED
-#endif
 
 void handleAlarm(int idx);
 int checkAlarms(void);
@@ -27,4 +22,7 @@ void deleteAlarm(int idx);
 int compareTime(tm t1, tm t2);
 void setState(int idx);
 int getState(int idx);
-struct _alarm getAlarm(int idx);
+struct _alarm getAlarm(int idx);
+int maxAlarms(void);
+int isLeapYear(int y);
+#endif

+ 1 - 1
network.h

@@ -9,6 +9,6 @@
 //bool NetworkIsReceiving(void);
 extern void NetworkInit(void);
 extern void httpGet(char address[], void (*parser)(char*));
-char* getMacAdress();
+char* getMacAdress(void);
 
 #endif /* _Network_H */

+ 2 - 21
ntp.c

@@ -21,6 +21,7 @@
 #include "log.h"
 #include "ntp.h"
 #include "contentparser.h"
+#include "alarm.h"
 
 int TIME_ZONE = 1;
 #define LOG_MODULE  LOG_NTP_MODULE
@@ -68,7 +69,7 @@ void NtpCheckValidTime(void){
     tm current_tm;
     X12RtcGetClock(&current_tm);
 
-    validTime = NtpCompareTime(current_tm, stored_tm);
+    validTime = compareTime(current_tm, stored_tm);
     if (validTime){
         puts("NtpCheckValidTime(): Time was valid \n");
     }else {
@@ -76,26 +77,6 @@ void NtpCheckValidTime(void){
     }
 }
 
-//Tests if t1 is after t2.
-bool NtpCompareTime(tm t1, tm t2){
-
-    if (t1.tm_year > t2.tm_year)
-        return true;
-    if (t1.tm_mon > t2.tm_mon)
-        return true;
-    if (t1.tm_mday > t2.tm_mday)
-        return true;
-    if (t1.tm_hour > t2.tm_hour)
-        return true;
-    if (t1.tm_min > t2.tm_min)
-        return true;
-    if (t1.tm_sec > t2.tm_sec)
-        return true;
-
-    //else
-    return false;
-}
-
 bool NtpTimeIsValid(void){
     return validTime;
 }

+ 3 - 3
ntp.h

@@ -6,6 +6,7 @@
 #define _Ntp_H
 
 #include "typedefs.h"
+#include <time.h>
 
 extern bool NtpIsSyncing(void);
 extern void NtpInit(void);
@@ -14,9 +15,8 @@ extern void setTimeZone(int timezone);
 extern bool NtpTimeIsValid(void);
 
 void NtpCheckValidTime(void);
-void NtpWriteTimeToEeprom(tm);
-bool NtpCompareTime(tm, tm);
+void NtpWriteTimeToEeprom(tm time_struct);
 
 void setTimeZone(int timezone);
-int getTimeZone();
+int getTimeZone(void);
 #endif /* _Ntp_H */