Skip to content

Commit 12d53a0

Browse files
committed
Fix UDP send to not temporarily use connect()
1 parent 86e4786 commit 12d53a0

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiUdp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,13 @@ int WiFiUDP::beginPacket(const char *host, uint16_t port)
132132

133133
int WiFiUDP::beginPacket(IPAddress ip, uint16_t port)
134134
{
135-
ip_addr_t addr;
136-
addr.addr = ip;
137-
138135
if (!_ctx) {
139136
_ctx = new UdpContext;
140137
_ctx->ref();
141138
}
142-
return (_ctx->connect(addr, port)) ? 1 : 0;
139+
begunIp_ = ip;
140+
begunPort_= port;
141+
return 1;
143142
}
144143

145144
int WiFiUDP::beginPacketMulticast(IPAddress multicastAddress, uint16_t port,
@@ -167,8 +166,9 @@ int WiFiUDP::endPacket()
167166
if (!_ctx)
168167
return 0;
169168

170-
_ctx->send();
171-
_ctx->disconnect();
169+
ip_addr_t addr;
170+
addr.addr = begunIp_;
171+
_ctx->send(&addr, begunPort_);
172172
return 1;
173173
}
174174

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiUdp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class UdpContext;
3131
class WiFiUDP : public UDP {
3232
private:
3333
UdpContext* _ctx;
34+
IPAddress begunIp_;
35+
uint16_t begunPort_;
3436

3537
public:
3638
WiFiUDP(); // Constructor

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/UdpContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class UdpContext
281281

282282
void _reserve(size_t size)
283283
{
284-
const size_t pbuf_unit_size = 1024;
284+
const size_t pbuf_unit_size = 512;
285285
if (!_tx_buf_head)
286286
{
287287
_tx_buf_head = pbuf_alloc(PBUF_TRANSPORT, pbuf_unit_size, PBUF_RAM);

0 commit comments

Comments
 (0)