ESP8266 Developer Zone The Official ESP8266 Forum 2015-08-15T15:14:36+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=954 2015-08-15T15:14:36+08:00 2015-08-15T15:14:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=954&p=3255#p3255 <![CDATA[Re: transmit UDP from RX callback connection?]]>
Globally define a static bool that keeps track if the buffer has been sent already. If not, don't try to send a new one. Define a callback function for packet sent and clear the flag there.

Also, and that's I think common error #1, don't use endless loops anywhere. Every function that is called from the SDK code should return fairly quickly. If you work isn't done at that point, just return and use posts to have your background work function called frequently. This is NO pre-emptive multitasking, if you don't return, the lwip doesn't get a chance to do it's work.

Statistics: Posted by eriksl — Sat Aug 15, 2015 3:14 pm


]]>
2015-08-15T03:27:58+08:00 2015-08-15T03:27:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=954&p=3251#p3251 <![CDATA[Re: transmit UDP from RX callback connection?]]> Statistics: Posted by stickben — Sat Aug 15, 2015 3:27 am


]]>
2015-08-14T21:49:28+08:00 2015-08-14T21:49:28+08:00 https://bbs.espressif.com:443/viewtopic.php?t=954&p=3246#p3246 <![CDATA[Re: transmit UDP from RX callback connection?]]> Statistics: Posted by kolban — Fri Aug 14, 2015 9:49 pm


]]>
2015-08-14T21:09:25+08:00 2015-08-14T21:09:25+08:00 https://bbs.espressif.com:443/viewtopic.php?t=954&p=3245#p3245 <![CDATA[transmit UDP from RX callback connection?]]>
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:

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);
   }

Statistics: Posted by stickben — Fri Aug 14, 2015 9:09 pm


]]>