Page 1 of 1

Chibios + LWIP - No broadcast

Posted: Fri Sep 04, 2015 3:59 pm
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);
}

Re: Chibios + LWIP - No broadcast

Posted: Sun Jul 10, 2016 9:19 pm
by alan5
TCP is connection oriented, and I don't think broadcast TCP makes sense.