浏览代码

Added crap

Aareschluchtje 9 年之前
父节点
当前提交
396eecf3ae
共有 4 个文件被更改,包括 15 次插入3 次删除
  1. 2 2
      main.c
  2. 9 0
      network.c
  3. 1 0
      network.h
  4. 3 1
      ntp.c

+ 2 - 2
main.c

@@ -195,9 +195,9 @@ THREAD(StartupInit, arg)
 
     char* content = httpGet("/getAlarmen.php?radioid=DE370");
     parseAlarmJson(content);
+    free(content);
     isAlarmSyncing = 0;
 
-    free(content);
     NutThreadExit();
 }
 
@@ -247,7 +247,7 @@ int main(void)
     LcdBackLight(LCD_BACKLIGHT_ON);
     NtpInit();
 
-    NutThreadCreate("BackgroundThread", StartupInit, NULL, 1024);
+    NutThreadCreate("BackgroundThread", StartupInit, NULL, 1500);
 
     /** Quick fix for turning off the display after 10 seconds boot */
     start = time(0);

+ 9 - 0
network.c

@@ -90,6 +90,15 @@ char* httpGet(char address[]){
     return content;
 }
 
+int getTimeZone()
+{
+    char* content = httpGet("/gettimezone.php");
+    int timezone = atoi(content);
+    free(content);
+    printf("%d", timezone);
+    return timezone;
+}
+
 void parseAlarmJson(char* content){
     int r;
     int i;

+ 1 - 0
network.h

@@ -8,5 +8,6 @@
 extern void NetworkInit(void);
 char* httpGet(char address[]);
 void parseAlarmJson(char* content);
+int getTimeZone();
 
 #endif /* _Network_H */

+ 3 - 1
ntp.c

@@ -21,7 +21,7 @@
 #include "log.h"
 #include "ntp.h"
 
-#define TIME_ZONE 1
+int TIME_ZONE = 1;
 #define LOG_MODULE  LOG_NTP_MODULE
 
 typedef struct _Eeprom_tm {
@@ -119,6 +119,8 @@ bool NtpTimeIsValid(void){
 void NtpSync(void){
     /* Ophalen van pool.ntp.org */
     isSyncing = true;
+    TIME_ZONE = getTimeZone();
+    NutDelay(100);
     //puts("Tijd ophalen van pool.ntp.org (213.154.229.24)");
     timeserver = inet_addr("213.154.229.24");