1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Pass errors from udp_sendto to WiFiUDP::endPacket (#1696)

This commit is contained in:
Ivan Grokhotkov 2016-03-02 19:58:35 +03:00
parent 33e5ca44df
commit aa67d1c492
2 changed files with 7 additions and 4 deletions

View File

@ -188,8 +188,7 @@ int WiFiUDP::endPacket()
if (!_ctx) if (!_ctx)
return 0; return 0;
_ctx->send(); return (_ctx->send()) ? 1 : 0;
return 1;
} }
size_t WiFiUDP::write(uint8_t byte) size_t WiFiUDP::write(uint8_t byte)

View File

@ -257,7 +257,7 @@ public:
return size; return size;
} }
void send(ip_addr_t* addr = 0, uint16_t port = 0) bool send(ip_addr_t* addr = 0, uint16_t port = 0)
{ {
size_t data_size = _tx_buf_offset; size_t data_size = _tx_buf_offset;
pbuf* tx_copy = pbuf_alloc(PBUF_TRANSPORT, data_size, PBUF_RAM); pbuf* tx_copy = pbuf_alloc(PBUF_TRANSPORT, data_size, PBUF_RAM);
@ -284,9 +284,13 @@ public:
_pcb->ttl = _multicast_ttl; _pcb->ttl = _multicast_ttl;
} }
udp_sendto(_pcb, tx_copy, addr, port); err_t err = udp_sendto(_pcb, tx_copy, addr, port);
if (err != ERR_OK) {
DEBUGV(":ust rc=%d\r\n", err);
}
_pcb->ttl = old_ttl; _pcb->ttl = old_ttl;
pbuf_free(tx_copy); pbuf_free(tx_copy);
return err == ERR_OK;
} }
private: private: