KIM YOUNG SEONG / Mbed OS 429_adc_network_adc_16_channel

Dependencies:   MQTT

Revision:
7:02a0635aeeac
Parent:
6:e2d251d535f0
Child:
8:47b0cb4b5b7d
--- a/main.cpp	Tue May 09 06:12:22 2017 +0000
+++ b/main.cpp	Tue Jan 16 08:21:04 2018 +0000
@@ -7,6 +7,11 @@
 
 using namespace     std;
 
+#define IP         "192.168.1.181"
+#define GATEWAY    "192.168.1.1"
+#define MASK       "255.255.255.0"
+
+
 #define PORT        80
 
 EthernetInterface   ethernet;
@@ -106,14 +111,14 @@
  */
 string& showWebPage(uint8_t status) {
     char roomTempStr[5];
-   
+
     //roomTemp = ds1820.read();
     sprintf(roomTempStr, "%3.1f", roomTemp);
 
     // CSS toggle switch
     httpContent  = "<head>";
     httpContent += "<style>";
-    
+
     httpContent += ".switch {";
     httpContent += "position: relative;";
     httpContent += "display: inline-block;";
@@ -167,7 +172,7 @@
     httpContent += "</head>";
 
     httpContent += "<body>";
-    httpContent += "<h2><a href=\".\" title=\"Click to refresh the page\">Smart Home</a></h2>"; 
+    httpContent += "<h2><a href=\".\" title=\"Click to refresh the page\">Smart Home</a></h2>";
     httpContent += "<pre>Temperature:\t" + string(roomTempStr) + "&deg;C</pre>";
     httpContent += "<pre>Heating:\t";
 
@@ -179,11 +184,11 @@
         httpContent += "<a href=\"./?sw=1\" class=\"switch\"> ";
         httpContent += "<input type=\"checkbox\">";
    }
-        
+
     httpContent += "<div class=\"slider\"></div>";
     httpContent += "</a></pre>";
     httpContent += "<hr>";
-    httpContent += "<pre>2017 ARMmbed</pre>";       
+    httpContent += "<pre>2017 armMBED</pre>";
     httpContent += "</body>";
 
     return httpContent;
@@ -218,22 +223,24 @@
  * @retval
  */
 int main(void) {
-    //ethernet.set_network("192.168.1.181","255.255.255.0","192.168.1.1");  // use static IP address, netmask, gateway
+//    ethernet.set_network("192.168.1.181","255.255.255.0","192.168.1.1");  // use static IP address, netmask, gateway
     ethernet.connect();
     printf("Usage: Type %s/%s/ into your web browser and hit ENTER\r\n", ethernet.get_ip_address(), PASSWORD.c_str());
+    const char *mac = ethernet.get_mac_address();
+    printf("MAC address is: %s\n\r", mac ? mac : "No MAC");
 
     /* Open the server on ethernet stack */
     server.open(&ethernet);
-   
+
     /* Bind the HTTP port (TCP 80) to the server */
     server.bind(ethernet.get_ip_address(), 80);
-    
+
     /* Can handle 5 simultaneous connections */
     server.listen(5);
 
     //listening for http GET request
     while(true) {
-        printf("\r\n=========================================\r\n");
+        printf("=========================================\r\n");
         printf("Ready to serve clients.\r\n");
         server.accept(&clientSocket, &clientAddress);
         printf("Connection succeeded!\n\rIP: %s\n\r", clientAddress.get_ip_address());
@@ -241,7 +248,7 @@
         printf("Recieved Data: %d\n\r\n\r%.*s\n\r", strlen(receiveBuf), strlen(receiveBuf), receiveBuf);
 
         string  received(receiveBuf);
-        
+
         if(received.substr(0, 3) != "GET") {
             httpHeader = HTTP_OK;
             httpContent = "<h1>200 OK</h1>";