mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-06 05:21:22 +03:00
fix WiFiClient::write(from flash or iram) (#7951)
* fix WiFiClient::write(flash or iram) * fix emulation on host
This commit is contained in:
parent
5ac64ffa27
commit
1c57b3408c
@ -40,6 +40,7 @@ extern "C"
|
|||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#include <include/ClientContext.h>
|
#include <include/ClientContext.h>
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
#include <StreamDev.h>
|
||||||
|
|
||||||
uint16_t WiFiClient::_localPort = 0;
|
uint16_t WiFiClient::_localPort = 0;
|
||||||
|
|
||||||
@ -212,7 +213,8 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_client->setTimeout(_timeout);
|
_client->setTimeout(_timeout);
|
||||||
return _client->write(buf, size);
|
StreamConstPtr ptr(buf, size);
|
||||||
|
return _client->write(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t WiFiClient::write(Stream& stream, size_t unused)
|
size_t WiFiClient::write(Stream& stream, size_t unused)
|
||||||
@ -227,8 +229,12 @@ size_t WiFiClient::write(Stream& stream)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_client->setTimeout(_timeout);
|
if (stream.hasPeekBufferAPI())
|
||||||
return _client->write(stream);
|
{
|
||||||
|
_client->setTimeout(_timeout);
|
||||||
|
return _client->write(stream);
|
||||||
|
}
|
||||||
|
return stream.sendAvailable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t WiFiClient::write_P(PGM_P buf, size_t size)
|
size_t WiFiClient::write_P(PGM_P buf, size_t size)
|
||||||
@ -238,7 +244,8 @@ size_t WiFiClient::write_P(PGM_P buf, size_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_client->setTimeout(_timeout);
|
_client->setTimeout(_timeout);
|
||||||
return _client->write_P(buf, size);
|
StreamConstPtr nopeek(buf, size);
|
||||||
|
return nopeek.sendAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WiFiClient::available()
|
int WiFiClient::available()
|
||||||
|
@ -31,6 +31,7 @@ extern "C" void esp_schedule();
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <StreamDev.h>
|
#include <StreamDev.h>
|
||||||
|
#include <esp_priv.h>
|
||||||
|
|
||||||
bool getDefaultPrivateGlobalSyncValue ();
|
bool getDefaultPrivateGlobalSyncValue ();
|
||||||
|
|
||||||
@ -372,32 +373,15 @@ public:
|
|||||||
return _pcb->state;
|
return _pcb->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write(const uint8_t* data, size_t size)
|
|
||||||
{
|
|
||||||
if (!_pcb) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
StreamConstPtr ptr(data, size);
|
|
||||||
return _write_from_source(&ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t write(Stream& stream)
|
size_t write(Stream& stream)
|
||||||
{
|
{
|
||||||
if (!_pcb) {
|
if (!_pcb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
assert(stream.hasPeekBufferAPI());
|
||||||
return _write_from_source(&stream);
|
return _write_from_source(&stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write_P(PGM_P buf, size_t size)
|
|
||||||
{
|
|
||||||
if (!_pcb) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
StreamConstPtr ptr(buf, size);
|
|
||||||
return _write_from_source(&ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void keepAlive (uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT)
|
void keepAlive (uint16_t idle_sec = TCP_DEFAULT_KEEPALIVE_IDLE_SEC, uint16_t intv_sec = TCP_DEFAULT_KEEPALIVE_INTERVAL_SEC, uint8_t count = TCP_DEFAULT_KEEPALIVE_COUNT)
|
||||||
{
|
{
|
||||||
if (idle_sec && intv_sec && count) {
|
if (idle_sec && intv_sec && count) {
|
||||||
@ -504,7 +488,6 @@ protected:
|
|||||||
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
|
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
|
||||||
delay(1);
|
delay(1);
|
||||||
// will resume on timeout or when _write_some_from_cb or _notify_error fires
|
// will resume on timeout or when _write_some_from_cb or _notify_error fires
|
||||||
|
|
||||||
}
|
}
|
||||||
_send_waiting = false;
|
_send_waiting = false;
|
||||||
} while(true);
|
} while(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user