newest version

Files at this revision

API Documentation at this revision

Comitter:
Alix955
Date:
Fri Dec 07 13:07:08 2018 +0000
Parent:
8:df979097cc71
Commit message:
updated;

Changed in this revision

Networkbits.cpp Show annotated file Show diff for this revision Revisions of this file
Networkbits.hpp Show annotated file Show diff for this revision Revisions of this file
sample_hardware.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r df979097cc71 -r ca8090c7868e Networkbits.cpp
--- a/Networkbits.cpp	Thu Dec 07 15:28:16 2017 +0000
+++ b/Networkbits.cpp	Fri Dec 07 13:07:08 2018 +0000
@@ -1,11 +1,12 @@
 #include "sample_hardware.hpp"
 #include "Networkbits.hpp"
+#include "ntp-client/NTPClient.h"
 
 //Network thread - responsible for listening for connectinos and responding with updated tempature values
 void networktest()
 {
     //This only runs when BOTH switches are pressed down
-    if ((SW1 == 0) || (SW2 == 0)) return;
+    if (SW2 == 0) return;
     
     lcd.cls();
     lcd.printf("Basic HTTP server example\n");
@@ -16,6 +17,8 @@
     eth.connect();
     lcd.printf("The target IP address is '%s'\n", eth.get_ip_address());
     
+    NTPClient ntp(&eth);
+    
     //Now setup a web server
     TCPServer srv;           //TCP/IP Server
     TCPSocket clt_sock;      //Socket for communication
@@ -31,7 +34,7 @@
     srv.listen(5);
     
     //KEEP RESPONDING WHILE THE SWITCHES ARE PRESSED
-    while ((SW1 == 1) && (SW2 == 1)) {
+    while (SW2 == 1) {
         using namespace std;
         lcd.cls();
         lcd.printf("Open 10.0.0.1 in a browser\n");
@@ -63,6 +66,6 @@
     
     printf("Release BOTH switches\n");
     lcd.printf("Release BOTH switches\n");
-    while ((SW1 != 0) && (SW2 != 0));
+    while (SW2 != 0);
     wait(0.5); //debounce
 }
\ No newline at end of file
diff -r df979097cc71 -r ca8090c7868e Networkbits.hpp
--- a/Networkbits.hpp	Thu Dec 07 15:28:16 2017 +0000
+++ b/Networkbits.hpp	Fri Dec 07 13:07:08 2018 +0000
@@ -3,6 +3,7 @@
 
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "ntp-client/NTPClient.h"
 #include "TCPServer.h"
 #include "TCPSocket.h"
 #include <iostream>
diff -r df979097cc71 -r ca8090c7868e sample_hardware.cpp
--- a/sample_hardware.cpp	Thu Dec 07 15:28:16 2017 +0000
+++ b/sample_hardware.cpp	Fri Dec 07 13:07:08 2018 +0000
@@ -1,10 +1,22 @@
 #include "mbed.h"
+#include "ntp-client/NTPClient.h"
+#include "TCPServer.h"
+#include "TCPSocket.h"
+#include <iostream>
+#include <string> 
+#include "EthernetInterface.h"
 #include "sample_hardware.hpp"
-#include "Networkbits.hpp"
+
+
 
 #define RED_DONE 1
 #define YELLOW_DONE 2
 
+#define IP        "10.0.0.10"
+#define NETMASK   "255.0.0.0"
+#define GATEWAY   "10.0.0.1"
+
+
 //Digital outputs
 DigitalOut onBoardLED(LED1);
 DigitalOut redLED(PE_15);
@@ -13,8 +25,8 @@
 
 //Inputs
 DigitalIn  onBoardSwitch(USER_BUTTON);
-DigitalIn  SW1(PE_12);
 DigitalIn  SW2(PE_14);
+
 //Serial pc(USBTX, USBRX);
 AnalogIn adcIn(PA_0);
 
@@ -31,9 +43,13 @@
 //D7,6,4,2 are the 4 bit for d4-7
 TextLCD lcd(D9, D8, D7, D6, D4, D2); // rs, e, d4-d7
 
+
 //SD Card
 SDBlockDevice sd(PB_5, D12, D13, D10); // mosi, miso, sclk, cs 
 
+
+
+
 //POWER ON SELF TEST
 void post() 
 {
@@ -54,7 +70,7 @@
     } 
     
     //Output the switch states (hold them down to test)
-    printf("SW1: %d\tSW2: %d\n\r", SW1.read(), SW2.read());    
+    printf("SW2: %d\n\r", SW2.read());    
     printf("USER: %d\n\r", onBoardSwitch.read()); 
     
     //Output the ADC
@@ -82,7 +98,7 @@
     redLED = 0;
     
     //Network test (if BOTH switches are held down)
-    networktest();
+ //   networktest();
     
     puts("**********POST END**********");