udp message multiple receiving
Posted: Mon Jun 01, 2015 2:06 pm
Hi All,
Just starting with the esp8266 and C.
Started out with a simple UDP packet receiver to explore the module.
Listen on a port and in case of receiving data print a line on the uart.
The problem is
- sending a packet from the pc to the broadcast address 192.168.2.255 gives 1 printed line
- sending a packet from the pc to the address of the module 192.168.2.2 gives multiple printed lines from 2 upto 5 !
Sending the data I do with a tool called PacketSender (https://packetsender.com/).
Doing the same, sending the data to a rPi, listening to the same port etc gives me 1 printed line every time as expected!
What am I doing wrong ?
code for the esp module
Thanks for any help.
J.
Just starting with the esp8266 and C.
Started out with a simple UDP packet receiver to explore the module.
Listen on a port and in case of receiving data print a line on the uart.
The problem is
- sending a packet from the pc to the broadcast address 192.168.2.255 gives 1 printed line
- sending a packet from the pc to the address of the module 192.168.2.2 gives multiple printed lines from 2 upto 5 !
Sending the data I do with a tool called PacketSender (https://packetsender.com/).
Doing the same, sending the data to a rPi, listening to the same port etc gives me 1 printed line every time as expected!
What am I doing wrong ?
code for the esp module
Code: Select all
// receive callback
static void ICACHE_FLASH_ATTR udp_recv(void *arg, char *pusrdata, unsigned short length)
{
ets_uart_printf("rx data\r\n");
}
// setup the udp port
void udp_init()
{
static struct espconn discover_netconn;
static esp_udp discover_udp;
discover_netconn.type = ESPCONN_UDP;
discover_netconn.state = ESPCONN_NONE;
discover_netconn.proto.udp = &discover_udp;
discover_udp.local_port=50001;
discover_netconn.reverse = NULL;
espconn_regist_recvcb(&discover_netconn, udp_recv);
espconn_create(&discover_netconn);
}
Thanks for any help.
J.