Updated
Networking.hpp@0:9df0dd20731a, 2019-01-05 (annotated)
- Committer:
- Swabey89
- Date:
- Sat Jan 05 15:02:17 2019 +0000
- Revision:
- 0:9df0dd20731a
Updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Swabey89 | 0:9df0dd20731a | 1 | #ifndef MBED_NETWORKING_H |
Swabey89 | 0:9df0dd20731a | 2 | #define MBED_NETWORKING_H |
Swabey89 | 0:9df0dd20731a | 3 | |
Swabey89 | 0:9df0dd20731a | 4 | #include "mbed.h" |
Swabey89 | 0:9df0dd20731a | 5 | #include "main.h" |
Swabey89 | 0:9df0dd20731a | 6 | #include "sample_hardware.hpp" |
Swabey89 | 0:9df0dd20731a | 7 | #include "EthernetInterface.h" |
Swabey89 | 0:9df0dd20731a | 8 | #include "TCPServer.h" |
Swabey89 | 0:9df0dd20731a | 9 | #include "TCPSocket.h" |
Swabey89 | 0:9df0dd20731a | 10 | #include <iostream> |
Swabey89 | 0:9df0dd20731a | 11 | #include <string> |
Swabey89 | 0:9df0dd20731a | 12 | |
Swabey89 | 0:9df0dd20731a | 13 | #define IP "10.0.0.10" |
Swabey89 | 0:9df0dd20731a | 14 | #define NETMASK "255.0.0.0" |
Swabey89 | 0:9df0dd20731a | 15 | #define GATEWAY "10.0.0.1" |
Swabey89 | 0:9df0dd20731a | 16 | |
Swabey89 | 0:9df0dd20731a | 17 | #define HTTP_STATUS_LINE "HTTP/1.0 200 OK" |
Swabey89 | 0:9df0dd20731a | 18 | |
Swabey89 | 0:9df0dd20731a | 19 | #define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8" |
Swabey89 | 0:9df0dd20731a | 20 | |
Swabey89 | 0:9df0dd20731a | 21 | #define HTTP_MESSAGE_BODY "" \ |
Swabey89 | 0:9df0dd20731a | 22 | " <html>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 23 | " <head>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 24 | " <style>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 25 | " .title {" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 26 | " color: dodgerblue;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 27 | " font-family: verdana;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 28 | " text-align: center;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 29 | " padding: 5px;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 30 | " }" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 31 | " </style>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 32 | " <style>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 33 | " .textbox {" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 34 | " background-color: dodgerblue;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 35 | " color: white;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 36 | " font-family: verdana;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 37 | " margin: 20px;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 38 | " padding: 20px;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 39 | " }" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 40 | " </style>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 41 | " <style>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 42 | " .footer {" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 43 | " color: dodgerblue;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 44 | " font-family: verdana;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 45 | " text-align: right;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 46 | " padding: 20px;" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 47 | " }" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 48 | " </style>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 49 | " </head>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 50 | " <body>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 51 | |
Swabey89 | 0:9df0dd20731a | 52 | #define HTTP_MESSAGE_TIME "" \ |
Swabey89 | 0:9df0dd20731a | 53 | " <div class=\"title\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 54 | " <h1>Environmental Sensor</h1>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 55 | " <p> Sample Time: " |
Swabey89 | 0:9df0dd20731a | 56 | |
Swabey89 | 0:9df0dd20731a | 57 | #define HTTP_MESSAGE_TEMP "" \ |
Swabey89 | 0:9df0dd20731a | 58 | " </p>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 59 | " </div>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 60 | " <div style=\"text-align: center\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 61 | " <input type='button' onclick='location.reload();' value='Refresh Data' />" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 62 | " </div>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 63 | " <div class=\"textbox\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 64 | " <h2>Temperature (<sup>o</sup>C)</h2>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 65 | " <p>" |
Swabey89 | 0:9df0dd20731a | 66 | |
Swabey89 | 0:9df0dd20731a | 67 | #define HTTP_MESSAGE_PRESSURE "" \ |
Swabey89 | 0:9df0dd20731a | 68 | " </p>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 69 | " </div>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 70 | " <div class=\"textbox\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 71 | " <h2>Pressure (mbar)</h2>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 72 | " <p>" |
Swabey89 | 0:9df0dd20731a | 73 | |
Swabey89 | 0:9df0dd20731a | 74 | #define HTTP_MESSAGE_LIGHT "" \ |
Swabey89 | 0:9df0dd20731a | 75 | " </p>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 76 | " </div>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 77 | " <div class=\"textbox\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 78 | " <h2>Light Level (%)</h2>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 79 | " <p>" |
Swabey89 | 0:9df0dd20731a | 80 | |
Swabey89 | 0:9df0dd20731a | 81 | #define HTTP_MESSAGE_FOOT "" \ |
Swabey89 | 0:9df0dd20731a | 82 | " </p>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 83 | " </div>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 84 | " <footer class=\"footer\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 85 | " <img src=\"https://cdn-edu.wpmhost.net/53544f/6bf071deb4/A1F4-0FF4-4F67-AE2B-9DAC.png\" width=\"250\" height=\"60\">" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 86 | " <p>ELEC350 - Low Power Environmental Sensor Coursework</p>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 87 | " </footer>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 88 | " </body>" "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 89 | " </html>" |
Swabey89 | 0:9df0dd20731a | 90 | |
Swabey89 | 0:9df0dd20731a | 91 | #define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 92 | HTTP_HEADER_FIELDS "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 93 | "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 94 | HTTP_MESSAGE_BODY "\r\n" \ |
Swabey89 | 0:9df0dd20731a | 95 | |
Swabey89 | 0:9df0dd20731a | 96 | |
Swabey89 | 0:9df0dd20731a | 97 | |
Swabey89 | 0:9df0dd20731a | 98 | extern void network(void); |
Swabey89 | 0:9df0dd20731a | 99 | extern void network_toutISR(void); |
Swabey89 | 0:9df0dd20731a | 100 | |
Swabey89 | 0:9df0dd20731a | 101 | #endif |