Arthur Coupe
/
tcp-client
.
Diff: main.cpp
- Revision:
- 1:02023a9fd316
- Parent:
- 0:1a75d762a447
- Child:
- 2:095beb50593a
--- a/main.cpp Sat Mar 07 19:29:08 2020 +0000 +++ b/main.cpp Fri Nov 06 17:13:28 2020 +0000 @@ -1,32 +1,34 @@ #include "mbed.h" #include "EthernetInterface.h" - - +#include "C12832.h" +#include "LM75B.h" +// Using Arduino pin notation +C12832 lcd(D11, D13, D12, D7, D10); DigitalOut led(LED1); +LM75B sensor(D14,D15); int main() { - printf("Client example\n\r"); - + lcd.printf("FUCK\n\r"); + lcd.printf("Temp = %.1f\n", sensor.read()); EthernetInterface eth; - eth.set_network("192.168.0.39","255.255.255.0","192.168.0.1"); + eth.set_network("192.168.0.07","255.255.255.0","192.168.0.1"); eth.connect(); printf("The client IP address is '%s'\n\r", eth.get_ip_address()); - - TCPSocket socket; socket.open(ð); - socket.connect("192.168.0.40",4000); - - char rbuffer[64]; - int rcount = socket.recv(rbuffer, sizeof rbuffer); - printf("received: %d\r\n", rcount); - printf(rbuffer); - + socket.connect("192.168.0.19",4000); + + uint16_t temp = sensor.read(); + char upperbyte =(temp>>8) & 0xFF; + char lowerbyte = temp & 0xFF; + char data[2] = {upperbyte, lowerbyte}; + printf("The data is: %c\n", data[0]); + socket.send(data,2); socket.close(); }