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: BMP280
Revision 2:5a38ae8459d5, committed 2017-12-18
- Comitter:
- Swaggie
- Date:
- Mon Dec 18 18:10:21 2017 +0000
- Parent:
- 1:76bd6f78cabc
- Child:
- 3:8fa1e77c8a5d
- Commit message:
- Created header file structure
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD.h Mon Dec 18 18:10:21 2017 +0000 @@ -0,0 +1,6 @@ +#ifndef __LCD__ +#define __LCD__ + +//These functions manage writing to the LCD + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Serial.h Mon Dec 18 18:10:21 2017 +0000 @@ -0,0 +1,8 @@ +#ifndef __Serial__ +#define __Serial__ + +//These functions handle the USB serial interface + + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/WebUI.cpp Mon Dec 18 18:10:21 2017 +0000
@@ -0,0 +1,89 @@
+#if !FEATURE_LWIP
+ #error [NOT_SUPPORTED] LWIP not supported for this target
+#endif
+//We need to look into what if statements like the one above do.
+#include "WebUI.h"
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "TCPServer.h"
+#include "TCPSocket.h"
+#include <iostream>
+#include <string>
+
+#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
+#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
+#define HTTP_MESSAGE_BODY1 "" \
+"<html>" "\r\n" \
+" <body style=\"display:flex;text-align:center\">" "\r\n" \
+" <div style=\"margin:auto\">" "\r\n" \
+" <h1>Hello World</h1>" "\r\n" \
+" <p>The LDR value is "
+
+#define HTTP_MESSAGE_BODY2 "" \
+ "</p>" "\r\n" \
+" </div>" "\r\n" \
+" </body>" "\r\n" \
+"</html>"
+
+#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \
+ HTTP_HEADER_FIELDS "\r\n" \
+ "\r\n" \
+ HTTP_MESSAGE_BODY "\r\n"
+
+#define IP "10.0.0.10"
+#define NETMASK "255.0.0.0"
+#define GATEWAY "10.0.0.1"
+
+void WebUISetup(void){
+ printf("Basic HTTP server example\n");
+
+ //Configure an ethernet connection
+ EthernetInterface eth;
+ eth.set_network(IP, NETMASK, GATEWAY);
+ eth.connect();
+ printf("The target IP address is '%s'\n", eth.get_ip_address());
+
+ //Now setup a web server
+ TCPServer srv; //TCP/IP Server
+ TCPSocket clt_sock; //Socket for communication
+ SocketAddress clt_addr; //Address of incoming connection
+
+ /* Open the server on ethernet stack */
+ srv.open(ð);
+
+ /* Bind the HTTP port (TCP 80) to the server */
+ srv.bind(eth.get_ip_address(), 80);
+
+ /* Can handle 5 simultaneous connections */
+ srv.listen(5);
+}
+
+void WebUIUpdate(string& value){
+ while (true) {
+ using namespace std;
+ //Block and wait on an incoming connection
+ srv.accept(&clt_sock, &clt_addr);
+ printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
+
+ //Uses a C++ string to make it easier to concatinate
+ string response;
+ //This is a C string
+ char ldr_str[64];
+
+ //Read the LDR value
+ float u = ldr;
+
+ //Convert to a C String
+ sprintf(ldr_str, "%5.3f", u );
+ printf("LDR: %5.3f\n\r", u);
+
+ //Build the C++ string response
+ response = HTTP_MESSAGE_BODY1;
+ response += ldr_str;
+ response += HTTP_MESSAGE_BODY2;
+
+ //Send static HTML response (as a C string)
+ clt_sock.send(response.c_str(), response.size()+6);
+ }
+}
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebUI.h Mon Dec 18 18:10:21 2017 +0000 @@ -0,0 +1,8 @@ +#ifndef __WebUI__ +#define __WebUI__ + +void WebUISetup(void); //Configures the TCP server + +void WebUIUpdate(string& Value); //Might be called as a string, but does have blocking currently. + +#endif \ No newline at end of file
--- a/main.cpp Tue Nov 21 14:21:48 2017 +0000
+++ b/main.cpp Mon Dec 18 18:10:21 2017 +0000
@@ -1,89 +1,12 @@
-#if !FEATURE_LWIP
- #error [NOT_SUPPORTED] LWIP not supported for this target
-#endif
-
#include "mbed.h"
-#include "EthernetInterface.h"
-#include "TCPServer.h"
-#include "TCPSocket.h"
-#include <iostream>
-#include <string>
-
-#define HTTP_STATUS_LINE "HTTP/1.0 200 OK"
-#define HTTP_HEADER_FIELDS "Content-Type: text/html; charset=utf-8"
-#define HTTP_MESSAGE_BODY1 "" \
-"<html>" "\r\n" \
-" <body style=\"display:flex;text-align:center\">" "\r\n" \
-" <div style=\"margin:auto\">" "\r\n" \
-" <h1>Hello World</h1>" "\r\n" \
-" <p>The LDR value is "
-
-#define HTTP_MESSAGE_BODY2 "" \
- "</p>" "\r\n" \
-" </div>" "\r\n" \
-" </body>" "\r\n" \
-"</html>"
-
-#define HTTP_RESPONSE HTTP_STATUS_LINE "\r\n" \
- HTTP_HEADER_FIELDS "\r\n" \
- "\r\n" \
- HTTP_MESSAGE_BODY "\r\n"
-
-#define IP "10.0.0.10"
-#define NETMASK "255.0.0.0"
-#define GATEWAY "10.0.0.1"
-
-AnalogIn ldr(PA_0);
-
+#include "WebUI.h"
+#include "Serial.h"
int main()
{
- printf("Basic HTTP server example\n");
-
- //Configure an ethernet connection
- EthernetInterface eth;
- eth.set_network(IP, NETMASK, GATEWAY);
- eth.connect();
- printf("The target IP address is '%s'\n", eth.get_ip_address());
-
- //Now setup a web server
- TCPServer srv; //TCP/IP Server
- TCPSocket clt_sock; //Socket for communication
- SocketAddress clt_addr; //Address of incoming connection
-
- /* Open the server on ethernet stack */
- srv.open(ð);
-
- /* Bind the HTTP port (TCP 80) to the server */
- srv.bind(eth.get_ip_address(), 80);
-
- /* Can handle 5 simultaneous connections */
- srv.listen(5);
+ //Initialise devices
- while (true) {
- using namespace std;
- //Block and wait on an incoming connection
- srv.accept(&clt_sock, &clt_addr);
- printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
-
- //Uses a C++ string to make it easier to concatinate
- string response;
- //This is a C string
- char ldr_str[64];
-
- //Read the LDR value
- float u = ldr;
-
- //Convert to a C String
- sprintf(ldr_str, "%5.3f", u );
- printf("LDR: %5.3f\n\r", u);
-
- //Build the C++ string response
- response = HTTP_MESSAGE_BODY1;
- response += ldr_str;
- response += HTTP_MESSAGE_BODY2;
-
- //Send static HTML response (as a C string)
- clt_sock.send(response.c_str(), response.size()+6);
- }
+ //Hardware Self Test
+
+ //Initilaiase interrupts and times
}