]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / tests / net / helloworld / broadcast_send / main.cpp
1 #include "mbed.h"
2 #include "EthernetInterface.h"
3
4 const int BROADCAST_PORT = 58083;
5
6 int main() {
7 EthernetInterface eth;
8 eth.init(); //Use DHCP
9 eth.connect();
10
11 UDPSocket sock;
12 sock.init();
13 sock.set_broadcasting();
14
15 Endpoint broadcast;
16 broadcast.set_address("255.255.255.255", BROADCAST_PORT);
17
18 char out_buffer[] = "very important data";
19
20 while (true) {
21 printf("Broadcasting...\n");
22 sock.sendTo(broadcast, out_buffer, sizeof(out_buffer));
23 Thread::wait(1000);
24 }
25 }
Imprint / Impressum