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