Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning

Dependencies:   BME280 BMP280 TextLCD

Working Repository

Committer:
thomasmorris
Date:
Sun Jan 07 13:32:54 2018 +0000
Revision:
35:26b0a9b55d82
Child:
36:a0098306fc58
Working Networking

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 35:26b0a9b55d82 1 #if !FEATURE_LWIP
thomasmorris 35:26b0a9b55d82 2 #error [NOT_SUPPORTED] LWIP not supported for this target
thomasmorris 35:26b0a9b55d82 3 #endif
thomasmorris 35:26b0a9b55d82 4
thomasmorris 35:26b0a9b55d82 5 #ifndef _NETWORK_HPP_ //Known as header guards
thomasmorris 35:26b0a9b55d82 6 #define _NETWORK_HPP_
thomasmorris 35:26b0a9b55d82 7
thomasmorris 35:26b0a9b55d82 8 #include "mbed.h"
thomasmorris 35:26b0a9b55d82 9 #include "rtos.h"
thomasmorris 35:26b0a9b55d82 10 #include "EthernetInterface.h"
thomasmorris 35:26b0a9b55d82 11 #include "TCPServer.h"
thomasmorris 35:26b0a9b55d82 12 #include "TCPSocket.h"
thomasmorris 35:26b0a9b55d82 13 #include <iostream>
thomasmorris 35:26b0a9b55d82 14 #include <string>
thomasmorris 35:26b0a9b55d82 15
thomasmorris 35:26b0a9b55d82 16 #define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
thomasmorris 35:26b0a9b55d82 17 #define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
thomasmorris 35:26b0a9b55d82 18 #define HTTP_MESSAGE_BODY1 "" \
thomasmorris 35:26b0a9b55d82 19 "<html>" "\r\n" \
thomasmorris 35:26b0a9b55d82 20 " <body style=\"display:flex;text-align:center\">" "\r\n" \
thomasmorris 35:26b0a9b55d82 21 " <div style=\"margin:auto\">" "\r\n" \
thomasmorris 35:26b0a9b55d82 22 " <h1>Hello World</h1>" "\r\n" \
thomasmorris 35:26b0a9b55d82 23 " <p>The LDR value is "
thomasmorris 35:26b0a9b55d82 24
thomasmorris 35:26b0a9b55d82 25 #define HTTP_MESSAGE_BODY2 "" \
thomasmorris 35:26b0a9b55d82 26 "</p>" "\r\n" \
thomasmorris 35:26b0a9b55d82 27 " </div>" "\r\n" \
thomasmorris 35:26b0a9b55d82 28 " </body>" "\r\n" \
thomasmorris 35:26b0a9b55d82 29 "</html>"
thomasmorris 35:26b0a9b55d82 30
thomasmorris 35:26b0a9b55d82 31 #define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \
thomasmorris 35:26b0a9b55d82 32 HTTP_HEADER_FIELDS "\r\n" \
thomasmorris 35:26b0a9b55d82 33 "\r\n" \
thomasmorris 35:26b0a9b55d82 34 HTTP_MESSAGE_BODY "\r\n"
thomasmorris 35:26b0a9b55d82 35
thomasmorris 35:26b0a9b55d82 36 #define IP "10.0.0.10"
thomasmorris 35:26b0a9b55d82 37 #define NETMASK "255.0.0.0"
thomasmorris 35:26b0a9b55d82 38 #define GATEWAY "10.0.0.1"
thomasmorris 35:26b0a9b55d82 39
thomasmorris 35:26b0a9b55d82 40
thomasmorris 35:26b0a9b55d82 41 void Network_Init();
thomasmorris 35:26b0a9b55d82 42 void Networking();
thomasmorris 35:26b0a9b55d82 43
thomasmorris 35:26b0a9b55d82 44 #endif