Chibios + LWIP - No broadcast

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
0st3n
Posts: 11
Joined: Tue Aug 25, 2015 11:11 am

Chibios + LWIP - No broadcast

Post by 0st3n »

For 1 week ago, the broadcast worked fine for me with the same code. Then i started adding some code for TCP usage, and know my broadcaster code dosn't work anymore. I have tried with both IP_ADDR_BROADCAST instead of an IP and used 255.255.255.255 as an ip. Still dosn't work. But if i set it to my ip, i can easily receive packets.
Where it fails is at netconn_send(udp_con, buf)

My code:
struct netconn *udp_conn;
struct netbuf *buf;
char *data;
char msg[] = "Broadcast!!!";

struct ip_addr dst;
IP4_ADDR(&dst,255,255,255,255);


debug("ERR_OK = %x", ERR_OK);

err_t err1,err2,err3;


udp_conn = netconn_new( NETCONN_UDP );
err1 = netconn_bind(udp_conn, IP_ADDR_ANY, 5465 ); //local port


debug("err1: %x", err1);

err2 = netconn_connect(udp_conn, &dst, 1515 );
debug("err2: %x", err2);
while(true) {
/* create a new netbuf */
buf = netbuf_new();
data = netbuf_alloc(buf, sizeof(msg));
memcpy(data, msg, sizeof(msg));


err3 = netconn_send(udp_conn, buf);
debug("err3: %x", err3);
netbuf_delete(buf);
chThdSleepMilliseconds(1000);
}
alan5
Posts: 24
Joined: Mon Nov 11, 2013 5:06 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Chibios + LWIP - No broadcast

Post by alan5 »

TCP is connection oriented, and I don't think broadcast TCP makes sense.
Post Reply