Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: UsaClient
Diff: main.cpp
- Revision:
- 0:4d6a8970674c
- Child:
- 1:c050a4297deb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Oct 24 15:18:12 2021 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "UsaClient.hpp"
+
+EthernetInterface net;
+DigitalIn button(PC_13);
+
+int main()
+{
+ SocketAddress sockAddr;
+ if (net.connect() != 0)
+ {
+ printf("a");
+ return -1;
+ }
+ net.get_ip_address(&sockAddr);
+ printf("IP: %s\r\n", sockAddr.get_ip_address() ? sockAddr.get_ip_address() : "No IP");
+
+
+ UsaClient udp(&net, "192.168.10.104", 10000); // server IP address, Port number
+ uint8_t send[6] = {1, 4, 9, 16, 25, 0};
+ uint8_t recv[6];
+
+ while (1)
+ {
+ if (button)
+ {
+ send[5] += 1;
+ udp.Write(2, send, 6);
+ }
+ udp.Read(2, recv, 6);
+ printf("%3d, %3d, %3d, %3d, %3d, %3d\r\n", recv[0], recv[1], recv[2], recv[3], recv[4], recv[5]);
+ thread_sleep_for(100);
+ }
+}
+
\ No newline at end of file