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: UIPEthernet mbed FCT_WEB hebergement
Fork of WebSwitch_ENC28J60 by
Revision 5:a46a2512e17e, committed 2015-07-25
- Comitter:
- Fo170
- Date:
- Sat Jul 25 17:43:36 2015 +0000
- Parent:
- 4:d34811deedab
- Child:
- 6:2ce163810c2f
- Commit message:
- petite mise ? jours du code, pour test
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Feb 04 19:27:26 2015 +0000
+++ b/main.cpp Sat Jul 25 17:43:36 2015 +0000
@@ -11,6 +11,9 @@
#include <UIPClient.h>
#include <string>
+DigitalOut myled(LED1);
+AnalogIn a_in(PC_0);
+
using namespace std;
// UIPEthernet is the name of a global instance of UIPEthernetClass.
@@ -44,8 +47,11 @@
// MAC number must be unique within the connected network. Modify as appropriate.
const uint8_t MY_MAC[6] = {0x00,0x01,0x02,0x03,0x04,0x06};
+
// IP address must be also unique and compatible with your network. Change as appropriate.
-const IPAddress MY_IP(192,168,1,181);
+const IPAddress MY_IP(192,168,0,170);
+#define IPAdress_String "192.168.0.170"
+
const uint16_t MY_PORT = 80; // for HTTP connection
EthernetServer myServer = EthernetServer(MY_PORT);
// In this example we are turning on/off LED1.
@@ -112,19 +118,45 @@
string& page(uint8_t status)
{
- httpContent = "<h2>Web Switch</h2>\r\n";
+ char buffer[32];
+ char time_stamp[32];//as our lcd is of 16 character it is so
+ //-------------
+ httpContent = "<h2>Web Switch Nucleo-F411RE & ENC28J60 (RTC et ADC) ";
+ httpContent += IPAdress_String "\r\n";
+
+ // Test d'image en base64 :
+ // http://webcodertools.com/imagetobase64converter/Create
+ httpContent += "<img alt='' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAAUklEQVQ4T2NggIEGMIBzCTDgSh0cHAjrIcFgiGFoGoCWELYQrgLIgGsg4CtkaTibWNfu378fq2tpHx6EbcAMQ8J6iPU3cpIhbCqaisFpCTwVAwB5lit+0ltbrgAAAABJRU5ErkJggg=='>";
+ httpContent += "</h2>\r\n";
if(status == 1) {
- httpContent += "<pre>\r\n <font color=#FF0000>ON</font>";
+ httpContent += "<pre>\r\n <font color=#00FF00>ON</font>";
httpContent += " <a href=\"./?sw=0\">[switch off]</a>\r\n";
} else {
- httpContent += "<pre>\r\n <font color=#00FF00>OFF</font>";
+ httpContent += "<pre>\r\n <font color=#FF0000>OFF</font>";
httpContent += " <a href=\"./?sw=1\">[switch on]</a>\r\n";
}
httpContent += " <a href=\".\">[refresh status]</a>\r\n";
httpContent += "</pre>\r\n";
httpContent += "<hr>\r\n";
+ //-------------
+ time_t seconds = time(NULL)+ 19800; // time(null) gives the GMT time .
+ // printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+ strftime(time_stamp, 32, "%y %m %d, %H:%M:%Ss", localtime(&seconds));
+ // this converts the value in seconds obtained above to human readable format and assigns it to the timestamp
+ sprintf(buffer, "%s", time_stamp);// diplays the human readable time
+ httpContent += buffer;
+ httpContent += "\r\n";
+ httpContent += "<hr>\r\n";
+ //----------------
+ httpContent += "Temperature: ";
+ sprintf(buffer, "%4.3f", a_in * 3.3);
+ httpContent += buffer;
+ httpContent += "°C\r\n";
+ httpContent += "<hr>\r\n";
+ //-----------
+ wait(1);
return httpContent;
}
@@ -144,7 +176,12 @@
}
int main()
-{
+{
+ // RTC
+ set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
+ // Date and time are set.
+
+
UIPEthernet.begin(MY_MAC,MY_IP);
myServer.begin();
while(1) {
