jancoow 9 years ago
parent
commit
52ce78b5cd
4 changed files with 13 additions and 4 deletions
  1. 1 1
      contentparser.c
  2. 2 2
      main.c
  3. 7 1
      ntp.c
  4. 3 0
      ntp.h

+ 1 - 1
contentparser.c

@@ -113,5 +113,5 @@ void parseAlarmJson(char* content){
 void parsetimezone(char* content)
 {
     int timezone = atoi(content);
-    printf("%d", timezone);
+    setTimeZone(timezone);
 }

+ 2 - 2
main.c

@@ -221,8 +221,8 @@ THREAD(AlarmSync, arg)
         if((initialized == true) && (hasNetworkConnection() == true))
         {
             isAlarmSyncing = true;
-            char url[43];
-            sprintf(url, "%s%s", "/getAlarmen.php?radiomac=", getMacAdress());
+            char url[49];
+            sprintf(url, "/getAlarmen.php?radiomac=%s&tz=%d", getMacAdress(), getTimeZone());
             httpGet(url, parseAlarmJson);
             isAlarmSyncing = false;
         }

+ 7 - 1
ntp.c

@@ -104,6 +104,7 @@ void NtpSync(void){
     /* Ophalen van pool.ntp.org */
     isSyncing = true;
     httpGet("/gettimezone.php", parsetimezone);
+    _daylight = 0;
     printf(TIME_ZONE);
     NutDelay(100);
     //puts("Tijd ophalen van pool.ntp.org (213.154.229.24)");
@@ -144,5 +145,10 @@ void NtpWriteTimeToEeprom(tm time_struct){
 }
 
 void setTimeZone(int timezone){
-    _timezone = -timezone * 3600;
+    TIME_ZONE = timezone;
+    _timezone = -1*timezone * 3600;
+}
+
+int getTimeZone(){
+    return TIME_ZONE;
 }

+ 3 - 0
ntp.h

@@ -16,4 +16,7 @@ extern bool NtpTimeIsValid(void);
 void NtpCheckValidTime(void);
 void NtpWriteTimeToEeprom(tm);
 bool NtpCompareTime(tm, tm);
+
+void setTimeZone(int timezone);
+int getTimeZone();
 #endif /* _Ntp_H */