1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-10 04:22:05 +03:00

Pass timeout to optimistic_yield, add cont_can_yield check

This commit is contained in:
Ivan Grokhotkov
2015-07-20 15:48:25 +03:00
parent 01361fc4c8
commit e5d2ba5db8
11 changed files with 193 additions and 177 deletions

View File

@ -22,8 +22,8 @@
#define LWIP_INTERNAL
#include <functional>
extern "C"
extern "C"
{
#include "include/wl_definitions.h"
#include "osapi.h"
@ -45,7 +45,7 @@ template<>
WiFiUDP* SList<WiFiUDP>::_s_first = 0;
/* Constructor */
WiFiUDP::WiFiUDP() : _ctx(0)
WiFiUDP::WiFiUDP() : _ctx(0)
{
WiFiUDP::_add(this);
}
@ -74,7 +74,7 @@ WiFiUDP::~WiFiUDP()
}
/* Start WiFiUDP socket, listening at local port */
uint8_t WiFiUDP::begin(uint16_t port)
uint8_t WiFiUDP::begin(uint16_t port)
{
if (_ctx) {
_ctx->unref();
@ -94,7 +94,7 @@ uint8_t WiFiUDP::beginMulticast(IPAddress interfaceAddr, IPAddress multicast, ui
_ctx->unref();
_ctx = 0;
}
ip_addr_t ifaddr;
ifaddr.addr = (uint32_t) interfaceAddr;
ip_addr_t multicast_addr;
@ -122,10 +122,6 @@ int WiFiUDP::available() {
result = static_cast<int>(_ctx->getSize());
}
if (!result) {
optimistic_yield();
}
return result;
}
@ -161,7 +157,7 @@ int WiFiUDP::beginPacket(IPAddress ip, uint16_t port)
return (_ctx->connect(addr, port)) ? 1 : 0;
}
int WiFiUDP::beginPacketMulticast(IPAddress multicastAddress, uint16_t port,
int WiFiUDP::beginPacketMulticast(IPAddress multicastAddress, uint16_t port,
IPAddress interfaceAddress, int ttl)
{
ip_addr_t mcastAddr;
@ -207,8 +203,12 @@ int WiFiUDP::parsePacket()
{
if (!_ctx)
return 0;
if (!_ctx->next())
if (!_ctx->next()) {
optimistic_yield(100);
return 0;
}
return _ctx->getSize();
}
@ -216,8 +216,8 @@ int WiFiUDP::read()
{
if (!_ctx)
return -1;
return _ctx->read();
return _ctx->read();
}
int WiFiUDP::read(unsigned char* buffer, size_t len)
@ -284,4 +284,3 @@ void WiFiUDP::stopAll()
it->stop();
}
}