blob: 4632c63ff02acea1b3133a64746ad554cf1d4870 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
}
}
|