transmit UDP from RX callback connection?

stickben
Posts: 12
Joined: Tue Jun 23, 2015 12:28 pm

transmit UDP from RX callback connection?

Postby stickben » Fri Aug 14, 2015 9:09 pm

Hello,

I am trying to send a udp packet in response to a udp packet that I am receiving. Here is my code in the RX callback. I am not getting any errors, but I dont ever see the packets with my sniffer. Am I doing this right?

Code: Select all

void RxCallback(void *arg, char *data, unsigned short len)
{
   uint32 txlen;
   uint8 *pResponse = (uint8 *)os_malloc(512);
   struct espconn *pConn = (struct espconn *)arg;
 
   ets_uart_printf("\r\n\r\n\r\n************************************************************\r\nRXCallback got data length = %d\r\n", len);
   DebugData(data, len);
   ets_uart_printf("***** RX UDP Local port is %d local IP is %d.%d.%d.%d \r\n remote port is %d remote IP is %d.%d.%d.%d\r\n",
                                                                                       pConn->proto.udp->local_port,
                                                                              pConn->proto.udp->local_ip[0],
                                                                                                                       pConn->proto.udp->local_ip[1],
                                                                              pConn->proto.udp->local_ip[2],
                                                                              pConn->proto.udp->local_ip[3],
                                                                                pConn->proto.udp->remote_port,
                                                                                pConn->proto.udp->remote_ip[0],
                                                                                                                             pConn->proto.udp->remote_ip[1],
                                                                               pConn->proto.udp->remote_ip[2],
                                                                               pConn->proto.udp->remote_ip[3]);
   txlen = BuildAnswer(data, pResponse);
   ets_uart_printf("Response length = %d\r\n", txlen);
   PrintHeader(pResponse);
   DebugData(pResponse, txlen);

   if(espconn_send(pConn, pResponse, txlen) != 0)
   {
      ets_uart_printf(" UDP fail send\r\n");

   }
   os_free(pResponse);
   }

User avatar
kolban
Posts: 131
Joined: Tue Jun 16, 2015 1:09 pm
Location: Fort Worth, Texas, USA

Re: transmit UDP from RX callback connection?

Postby kolban » Fri Aug 14, 2015 9:50 pm

Duplicate post .. primary here.

viewtopic.php?f=7&t=954

Who is online

Users browsing this forum: No registered users and 58 guests