Thomas Luca
/
Ethernet-Round-Robin
Revision 14:a05e12de308b, committed 2020-11-07
- Comitter:
- thomasluca
- Date:
- Sat Nov 07 15:12:35 2020 +0000
- Parent:
- 13:368c6181b81e
- Commit message:
- Deleted Client class
Changed in this revision
client.cpp | Show diff for this revision Revisions of this file |
--- a/client.cpp Sat Nov 07 15:10:37 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#include "mbed.h" -#include "LM75B.h" -#include "C12832.h" -#include "EthernetInterface.h" - -// Using Arduino pin notation -C12832 lcd(D11, D13, D12, D7, D10); -LM75B sensor(D14,D15); -AnalogIn pot1 (A0); - -int main() -{ - printf("Client example\n\r"); - - EthernetInterface eth; - eth.set_network("192.168.0.20","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.28",4000); - - uint16_t temperature =(sensor.read()); - char upperbyte = (temperature >> 8) & 0x00FF; - char lowerbyte = temperature & 0x00FF; - char pwm = (char)(pot1); - char id = 0x14; - - char data[4]; - data[0] = upperbyte; - data[1] = lowerbyte; - data[2] = pwm; - data[3] = id; - - printf("%d\n", upperbyte); - printf("%d\n", lowerbyte); - - // print hex value of temperature on lcd - lcd.printf("Temp %.1x\n", sensor.read() ); - printf(data); - - socket.send(data, 4); - socket.close(); -}