Tcp server

Dependencies:   C12832 LM75B

Files at this revision

API Documentation at this revision

Comitter:
jens_c
Date:
Fri Nov 06 13:20:24 2020 +0000
Parent:
1:b658dfbe2a7c
Commit message:
tcp-server

Changed in this revision

C12832.lib Show annotated file Show diff for this revision Revisions of this file
LM75B.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Fri Nov 06 13:20:24 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/chris/code/C12832/#7de323fa46fe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Fri Nov 06 13:20:24 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/chris/code/LM75B/#6a70c9303bbe
--- a/main.cpp	Sat Mar 07 19:26:48 2020 +0000
+++ b/main.cpp	Fri Nov 06 13:20:24 2020 +0000
@@ -1,7 +1,9 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "LM75B.h"
+#include "C12832.h"
 
-
+C12832 lcd(D11, D13, D12, D7, D10);
 DigitalOut led(LED1);
 
 int main()
@@ -9,7 +11,7 @@
     printf("Server example\n\r");
     
     EthernetInterface eth;
-    eth.set_network("192.168.0.40","255.255.255.0","192.168.0.1");
+    eth.set_network("192.168.0.19","255.255.255.0","192.168.0.1");
     eth.connect();
     
     printf("The Server IP address is '%s'\n\r", eth.get_ip_address());
@@ -31,6 +33,17 @@
                     client_addr.get_port());
                     
         client.send(buffer, 256);
+        
+        char data[3];
+        client.recv(data, sizeof data);
+        float temp = float(((data[0]<<8)|data[1]) / 256.0);
+        int pwm = (int)data[2];
+        printf("The temperature is: %f\r\n", temp);
+        printf("The PWM value is: %x\r\n", data[2]);
+        
+        lcd.cls();
+        lcd.locate(0,3);
+        lcd.printf("Temp = %.1f\n", temp);
     
         client.close();