]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/net/helloworld/broadcast_send/main.cpp
Squashed 'tmk_core/' changes from 57d27a8..08ce4c3
[tmk_keyboard.git] / 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