1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-11 15:22:13 +03:00

Implement remoteIP and remotePort in WiFiUDP

This commit is contained in:
Ivan Grokhotkov
2015-02-17 01:38:35 +03:00
parent ea90d3ce92
commit 71c705a187
3 changed files with 31 additions and 13 deletions

View File

@ -36,6 +36,7 @@ extern "C"
#include "lwip/udp.h"
#include "lwip/inet.h"
#include "lwip/igmp.h"
#include "lwip/mem.h"
#include "include/UdpContext.h"
/* Constructor */
@ -209,23 +210,19 @@ void WiFiUDP::flush()
_ctx->flush();
}
IPAddress WiFiUDP::remoteIP()
IPAddress WiFiUDP::remoteIP()
{
uint8_t _remoteIp[4] = {0};
uint8_t _remotePort[2] = {0};
if (!_ctx)
return IPAddress(0U);
// WiFiDrv::getRemoteData(_sock, _remoteIp, _remotePort);
IPAddress ip(_remoteIp);
return ip;
return IPAddress(_ctx->getRemoteAddress());
}
uint16_t WiFiUDP::remotePort()
uint16_t WiFiUDP::remotePort()
{
uint8_t _remoteIp[4] = {0};
uint8_t _remotePort[2] = {0};
if (!_ctx)
return 0;
// WiFiDrv::getRemoteData(_sock, _remoteIp, _remotePort);
uint16_t port = (_remotePort[0]<<8)+_remotePort[1];
return port;
return _ctx->getRemotePort();
}