aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp')
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp b/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp
new file mode 100644
index 000000000..4632c63ff
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp
@@ -0,0 +1,25 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+const int BROADCAST_PORT = 58083;
+
+int main() {
+ EthernetInterface eth;
+ eth.init(); //Use DHCP
+ eth.connect();
+
+ UDPSocket sock;
+ sock.init();
+ sock.set_broadcasting();
+
+ Endpoint broadcast;
+ broadcast.set_address("255.255.255.255", BROADCAST_PORT);
+
+ char out_buffer[] = "very important data";
+
+ while (true) {
+ printf("Broadcasting...\n");
+ sock.sendTo(broadcast, out_buffer, sizeof(out_buffer));
+ Thread::wait(1000);
+ }
+}