Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS3231 RHT03 TextLCD mbed
Fork of HomeStatus by
Revision 4:89c52484b4d4, committed 2015-06-01
- Comitter:
- fookies
- Date:
- Mon Jun 01 15:16:52 2015 +0000
- Parent:
- 3:19accdf325fe
- Commit message:
- test
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue May 26 18:00:45 2015 +0000
+++ b/main.cpp Mon Jun 01 15:16:52 2015 +0000
@@ -33,7 +33,7 @@
void sendpage();
void ReadWebData();
-void SendCMD(),getreply(),ReadWebData(),startserver(),sendpage(),SendWEB(),sendcheck();
+void SendCMD(),getreply(),startserver(),SendWEB(),sendcheck();
// Serial Interrupt read ESP data
void callback() {
@@ -50,8 +50,8 @@
lcd.setMode(TextLCD::DispOn);
lcd.setBacklight(TextLCD::LightOff);
lcd.setCursor(TextLCD::CurOff_BlkOff);
- //rtc.setTime(23,04,50);
- //rtc.setDate(2,26,5,2015);
+ //rtc.setTime(21,57,50);
+ //rtc.setDate(1,31,5,2015);
pc.baud(9600);
esp.baud(9600);
startserver();
@@ -130,7 +130,9 @@
if(DataRX==1){
ReadWebData();
- if (servreq == 1 && weberror == 0){sendpage();}
+ lcd.printf("111111");
+ sendpage();
+ lcd.printf("22222");
esp.attach(&callback);
pc.printf(" IPD Data:\r\n\n Link ID = %d,\r\n IPD Header Length = %d \r\n IPD Type = %s\r\n", linkID, ipdLen, type);
pc.printf("\n\n HTTP Packet: \n\n%s\n", webdata);
@@ -159,7 +161,7 @@
timeout=500;getcount=10;
SendCMD();
getreply();
- strcpy(cmdbuff, "AT+CWJAP=""FSE-Wireless"",""1234567890""\r\n"); // set wifi to station
+ strcpy(cmdbuff, "AT+CWJAP=""Fookies-One(m8)"",""12312344""\r\n"); // set wifi to station
timeout=500;getcount=50;
SendCMD();
getreply();
@@ -225,60 +227,65 @@
strcat(webbuff, "<td>Light 1 :</td><td>");
if(p1==1)
{
- strcat(webbuff, "<form action=\"Light1:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light1=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light1:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light1=ON>OFF</a></td></tr>");
}
strcat(webbuff, "<tr>");
strcat(webbuff, "<td>Light 2 :</td><td>");
if(p2==1)
{
- strcat(webbuff, "<form action=\"Light2:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light2=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light2:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light2=ON>OFF</a></td></tr>");
}
strcat(webbuff, "<tr>");
- strcat(webbuff, "<td>Light 2 :</td><td>");
+ strcat(webbuff, "<td>Light 3 :</td><td>");
if(p3==1)
{
- strcat(webbuff, "<form action=\"Light3:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light3=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light3:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
- }strcat(webbuff, "<tr>");
- strcat(webbuff, "<td>Light 2 :</td><td>");
+ strcat(webbuff, "<a href=/?Light3=ON>OFF</a></td></tr>");
+ }
+ strcat(webbuff, "<tr>");
+ strcat(webbuff, "<td>Light 4 :</td><td>");
if(p4==1)
{
- strcat(webbuff, "<form action=\"Light4:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light4=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light4:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
- }strcat(webbuff, "<tr>");
- strcat(webbuff, "<td>Light 2 :</td><td>");
+ strcat(webbuff, "<a href=/?Light4=ON>OFF</a></td></tr>");
+ }
+ strcat(webbuff, "<tr>");
+ strcat(webbuff, "<td>Light 5 :</td><td>");
if(p5==1)
{
- strcat(webbuff, "<form action=\"Light5:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light5=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light5:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
- }strcat(webbuff, "<tr>");
- strcat(webbuff, "<td>Light 2 :</td><td>");
+ strcat(webbuff, "<a href=/?Light5=ON>OFF</a></td></tr>");
+ }
+ strcat(webbuff, "<tr>");
+ strcat(webbuff, "<td>Light 6 :</td><td>");
if(p6==1)
{
- strcat(webbuff, "<form action=\"Light6:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light6=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light6:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
- }strcat(webbuff, "<tr>");
- strcat(webbuff, "<td>Light 2 :</td><td>");
+ strcat(webbuff, "<a href=/?Light6=ON>OFF</a></td></tr>");
+ }
+ strcat(webbuff, "<tr>");
+ strcat(webbuff, "<td>Light 7 :</td><td>");
if(p7==1)
{
- strcat(webbuff, "<form action=\"Light7:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light7=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light7:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
- }strcat(webbuff, "<tr>");
- strcat(webbuff, "<td>Light 2 :</td><td>");
+ strcat(webbuff, "<a href=/?Light7=ON>OFF</a></td></tr>");
+ }
+ strcat(webbuff, "<tr>");
+ strcat(webbuff, "<td>Light 8 :</td><td>");
if(p8==1)
{
- strcat(webbuff, "<form action=\"Light8:OFF\"><input type=\"submit\" value=\"ON\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light8=OFF>ON</a></td></tr>");
}else{
- strcat(webbuff, "<form action=\"Light8:ON\"><input type=\"submit\" value=\"OFF\" /></form></td></tr>");
+ strcat(webbuff, "<a href=/?Light8=ON>OFF</a></td></tr>");
}
@@ -306,22 +313,22 @@
strcpy(webdata, webbuff + x);weberror=0;
int numMatched = sscanf(webdata,"+IPD,%d,%d:%s", &linkID, &ipdLen, type);
- if( strstr(webdata, "Light1:OFF") != NULL ) {p1=0;}
- if( strstr(webdata, "Light1:ON") != NULL ) {p1=1;}
- if( strstr(webdata, "Light2:OFF") != NULL ) {p2=0;}
- if( strstr(webdata, "Light2:ON") != NULL ) {p2=1;}
- if( strstr(webdata, "Light3:OFF") != NULL ) {p3=0;}
- if( strstr(webdata, "Light3:ON") != NULL ) {p3=1;}
- if( strstr(webdata, "Light4:OFF") != NULL ) {p4=0;}
- if( strstr(webdata, "Light4:ON") != NULL ) {p4=1;}
- if( strstr(webdata, "Light5:OFF") != NULL ) {p5=0;}
- if( strstr(webdata, "Light5:ON") != NULL ) {p5=1;}
- if( strstr(webdata, "Light6:OFF") != NULL ) {p6=0;}
- if( strstr(webdata, "Light6:ON") != NULL ) {p6=1;}
- if( strstr(webdata, "Light7:OFF") != NULL ) {p7=0;}
- if( strstr(webdata, "Light7:ON") != NULL ) {p7=1;}
- if( strstr(webdata, "Light8:OFF") != NULL ) {p8=0;}
- if( strstr(webdata, "Light8:ON") != NULL ) {p8=1;}
+ if( strstr(webdata, "Light1=OFF") != NULL ) {p1=0;}
+ if( strstr(webdata, "Light1=ON") != NULL ) {p1=1;}
+ if( strstr(webdata, "Light2=OFF") != NULL ) {p2=0;}
+ if( strstr(webdata, "Light2=ON") != NULL ) {p2=1;}
+ if( strstr(webdata, "Light3=OFF") != NULL ) {p3=0;}
+ if( strstr(webdata, "Light3=ON") != NULL ) {p3=1;}
+ if( strstr(webdata, "Light4=OFF") != NULL ) {p4=0;}
+ if( strstr(webdata, "Light4=ON") != NULL ) {p4=1;}
+ if( strstr(webdata, "Light5=OFF") != NULL ) {p5=0;}
+ if( strstr(webdata, "Light5=ON") != NULL ) {p5=1;}
+ if( strstr(webdata, "Light6=OFF") != NULL ) {p6=0;}
+ if( strstr(webdata, "Light6=ON") != NULL ) {p6=1;}
+ if( strstr(webdata, "Light7=OFF") != NULL ) {p7=0;}
+ if( strstr(webdata, "Light7=ON") != NULL ) {p7=1;}
+ if( strstr(webdata, "Light8=OFF") != NULL ) {p8=0;}
+ if( strstr(webdata, "Light8=ON") != NULL ) {p8=1;}
sprintf(channel, "%d",linkID);
if (strstr(webdata, "GET") != NULL) {servreq=1;}
@@ -332,7 +339,7 @@
else {
memset(webbuff, '\0', sizeof(webbuff));
esp.attach(&callback);weberror=1;
- }
+ }
}
// ESP Command data send
void SendCMD()
