Skip to content

Commit aa67d1c

Browse files
committed
Pass errors from udp_sendto to WiFiUDP::endPacket (#1696)
1 parent 33e5ca4 commit aa67d1c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

libraries/ESP8266WiFi/src/WiFiUdp.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ int WiFiUDP::endPacket()
188188
if (!_ctx)
189189
return 0;
190190

191-
_ctx->send();
192-
return 1;
191+
return (_ctx->send()) ? 1 : 0;
193192
}
194193

195194
size_t WiFiUDP::write(uint8_t byte)

libraries/ESP8266WiFi/src/include/UdpContext.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class UdpContext
257257
return size;
258258
}
259259

260-
void send(ip_addr_t* addr = 0, uint16_t port = 0)
260+
bool send(ip_addr_t* addr = 0, uint16_t port = 0)
261261
{
262262
size_t data_size = _tx_buf_offset;
263263
pbuf* tx_copy = pbuf_alloc(PBUF_TRANSPORT, data_size, PBUF_RAM);
@@ -284,9 +284,13 @@ class UdpContext
284284
_pcb->ttl = _multicast_ttl;
285285
}
286286

287-
udp_sendto(_pcb, tx_copy, addr, port);
287+
err_t err = udp_sendto(_pcb, tx_copy, addr, port);
288+
if (err != ERR_OK) {
289+
DEBUGV(":ust rc=%d\r\n", err);
290+
}
288291
_pcb->ttl = old_ttl;
289292
pbuf_free(tx_copy);
293+
return err == ERR_OK;
290294
}
291295

292296
private:

0 commit comments

Comments
 (0)