pet feeder system ver 0.2 (add timer alert)

Dependencies:   SDFileSystem SNTPClient WIZnetInterface httpServer_ntpsetting mbed

Fork of PetfeederWebServer by justin kim

Files at this revision

API Documentation at this revision

Comitter:
justinkim
Date:
Thu Jul 07 23:53:38 2016 +0000
Parent:
24:08ff0b58ab5f
Child:
26:143e4192ce3e
Commit message:
add function about timer alert

Changed in this revision

SNTPClient.lib Show annotated file Show diff for this revision Revisions of this file
httpServer.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SNTPClient.lib	Thu Jul 07 23:53:38 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/xeon011/code/SNTPClient/#137fc24033c4
--- a/httpServer.lib	Wed May 04 00:44:25 2016 +0000
+++ b/httpServer.lib	Thu Jul 07 23:53:38 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/justinkim/code/httpServer/#3c24e937da61
+https://developer.mbed.org/users/justinkim/code/httpServer/#b33c1a450937
--- a/main.cpp	Wed May 04 00:44:25 2016 +0000
+++ b/main.cpp	Thu Jul 07 23:53:38 2016 +0000
@@ -4,22 +4,38 @@
 #include "HTTPServer.h"
 #include "SDFileSystem.h"
 
-#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
+#define DHCP
+
+#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)||defined(TARGET_WIZWIKI_W7500ECO)
     //Choose one of file system.
     SDFileSystem local(SD_MOSI, SD_MISO, SD_CLK, SD_SEL, "local");//PB_3, PB_2, PB_1, PB_0
     //LocalFileSystem local("local");
 #endif
 
-#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
-    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
+#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)||defined(TARGET_WIZWIKI_W7500ECO)
+    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0xff, 0xff, 0x10};
 #endif
 
 EthernetInterface eth;
 HTTPServer  svr;
+
 char ip_addr[] = "192.168.240.111";
 char subnet_mask[] = "255.255.255.0";
 char gateway_addr[] = "192.168.240.1";
 
+int flag_t = 1;
+int hour_r, min_r, hm_r = 2460, hm_n = 0;
+double duty;
+
+//ymd_buffer[0]~[3] : Year
+//ymd_buffer[4]~[5] : Month
+//ymd_buffer[6]~[7] : Day
+char ymd_buffer[8];
+//hms_buffer[0]~[1] : Hour
+//hms_buffer[2]~[3] : Minute
+//hms_buffer[4]~[5] : Second
+char hms_buffer[6];
+
 //#define DHCP //If uncomment, W7500 runs DHCP
 
 int main()
@@ -28,7 +44,7 @@
     HTTPFsRequestHandler::mount("/local/", "/");
     svr.addHandler<HTTPFsRequestHandler>("/");
 
-#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)
+#if defined(TARGET_WIZWIKI_W7500)||defined(TARGET_WIZWIKI_W7500P)||defined(TARGET_WIZWIKI_W7500ECO)
     
     #ifdef DHCP
         eth.init(mac_addr); //Use DHCP
@@ -55,6 +71,7 @@
     printf("Link up\r\n");
 
     eth.connect();
+    
     printf("Server IP Address is %s\r\n", eth.getIPAddress());
 
     if (!svr.start(80, &eth)) {
@@ -65,7 +82,24 @@
 
     while(1) {
         svr.poll();
+        
+        time_t seconds = time(NULL);
+        strftime(hms_buffer, 6, "%H%M%S\n\r", localtime(&seconds));
+        hm_n = atoi(hms_buffer);
+        hm_n = hm_n / 100;
+        
+        if(hm_r == hm_n)
+        {
+            if(flag_t)
+            {
+                duty = 0.2;
+                myservo = duty;
+                wait(5);
+                duty = 1;
+                myservo = duty;
+                flag_t = 0;
+            }
+        }
     }
-    
 }