receive the data from the source and * turn the data back

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of BroadcastReceive by mbed official

Files at this revision

API Documentation at this revision

Comitter:
emilmont
Date:
Fri Mar 01 16:23:51 2013 +0000
Child:
1:7faf5df9c61b
Commit message:
first commit

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Fri Mar 01 16:23:51 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#9b2d10dc0392
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 01 16:23:51 2013 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+const int BROADCAST_PORT = 58083;
+
+int main() {
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    
+    UDPSocket socket;
+    socket.bind(BROADCAST_PORT);
+    socket.set_broadcasting();
+    
+    Endpoint broadcaster;
+    char buffer[256];
+    while (true) {
+        printf("\nWait for packet...\n");
+        int n = socket.receiveFrom(broadcaster, buffer, sizeof(buffer));
+        buffer[n] = '\0';
+        printf("Packet from \"%s\": %s\n", broadcaster.get_address(), buffer);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Mar 01 16:23:51 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 01 16:23:51 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file