mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
Fix UDP send to not temporarily use connect()
This commit is contained in:
parent
5407b064b0
commit
3049d48d56
@ -132,14 +132,13 @@ int WiFiUDP::beginPacket(const char *host, uint16_t port)
|
||||
|
||||
int WiFiUDP::beginPacket(IPAddress ip, uint16_t port)
|
||||
{
|
||||
ip_addr_t addr;
|
||||
addr.addr = ip;
|
||||
|
||||
if (!_ctx) {
|
||||
_ctx = new UdpContext;
|
||||
_ctx->ref();
|
||||
}
|
||||
return (_ctx->connect(addr, port)) ? 1 : 0;
|
||||
begunIp_ = ip;
|
||||
begunPort_= port;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int WiFiUDP::beginPacketMulticast(IPAddress multicastAddress, uint16_t port,
|
||||
@ -167,8 +166,9 @@ int WiFiUDP::endPacket()
|
||||
if (!_ctx)
|
||||
return 0;
|
||||
|
||||
_ctx->send();
|
||||
_ctx->disconnect();
|
||||
ip_addr_t addr;
|
||||
addr.addr = begunIp_;
|
||||
_ctx->send(&addr, begunPort_);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ class UdpContext;
|
||||
class WiFiUDP : public UDP {
|
||||
private:
|
||||
UdpContext* _ctx;
|
||||
IPAddress begunIp_;
|
||||
uint16_t begunPort_;
|
||||
|
||||
public:
|
||||
WiFiUDP(); // Constructor
|
||||
|
@ -281,7 +281,7 @@ private:
|
||||
|
||||
void _reserve(size_t size)
|
||||
{
|
||||
const size_t pbuf_unit_size = 1024;
|
||||
const size_t pbuf_unit_size = 512;
|
||||
if (!_tx_buf_head)
|
||||
{
|
||||
_tx_buf_head = pbuf_alloc(PBUF_TRANSPORT, pbuf_unit_size, PBUF_RAM);
|
||||
|
Loading…
x
Reference in New Issue
Block a user