STM32 Nucleo F207Z ultrasonic radar. TODO: send the data over the net
Dependencies: HC_SR04_Ultrasonic_Library PinDetect
Diff: client.cpp
- Revision:
- 1:b4179d7a5f2c
- Parent:
- 0:23a36e52a5fa
diff -r 23a36e52a5fa -r b4179d7a5f2c client.cpp --- a/client.cpp Thu Jun 28 15:33:29 2018 +0000 +++ b/client.cpp Fri Jun 29 08:52:41 2018 +0000 @@ -42,5 +42,33 @@ // Close the socket to return its memory and bring down the network interface socket.close(); + + return 0; + +} + + +int send_data2(const int distance) { + + // Open a socket on the network interface, and create a TCP connection to mbed.org + TCPSocket socket; + socket.open(&net); + socket.connect("192.168.1.67", 3000); + + // Send a simple http request + char sbuffer[256]; + snprintf(sbuffer, 256, "POST /?distance=%d HTTP/1.1\r\n\r\n\r\n", distance); + int scount = socket.send(sbuffer, sizeof sbuffer); + printf("sent %d [%.*s]\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer); + + // Recieve a simple http response and print out the response line + char rbuffer[64]; + int rcount = socket.recv(rbuffer, sizeof rbuffer); + printf("recv %d [%.*s]\n", rcount, strstr(rbuffer, "\r\n")-rbuffer, rbuffer); + + // Close the socket to return its memory and bring down the network interface + socket.close(); + + return 0; } \ No newline at end of file