/****************************************************************************** * FunctionName : espconn_sendto * Description : send data for UDP * Parameters : espconn -- espconn to set for UDP * psent -- data to send * length -- length of data to send * Returns : error *******************************************************************************/ sint16 ICACHE_FLASH_ATTR espconn_sendto(struct espconn *espconn, uint8 *psent, uint16 length) { espconn_msg *pnode = NULL; bool value = false; // err_t error = ESPCONN_OK; if (espconn == NULL || psent == NULL || length == 0) { return ESPCONN_ARG; } /*Find the node depend on the espconn message*/ value = espconn_find_connection(espconn, &pnode); if (value && espconn->type == ESPCONN_UDP) return espconn_udp_sendto(pnode, psent, length); else return ESPCONN_ARG; }
static void ICACHE_FLASH_ATTR espconn_data_sent(void *arg, enum send_opt opt) { espconn_msg *psent = arg; if (psent == NULL) { return; } if (psent->pcommon.cntr == 0) { psent->pespconn->state = ESPCONN_CONNECT; if (psent->pcommon.err == 0) espconn_data_sentcb(psent->pespconn); } else { if (opt == ESPCONN_SEND){ espconn_udp_sent(arg, psent->pcommon.ptrbuf, psent->pcommon.cntr); } else { espconn_udp_sendto(arg, psent->pcommon.ptrbuf, psent->pcommon.cntr); } } }