mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-19 09:42:11 +03:00
Adding write(str) and write(buf, size) methods to Print class and Ethernet library Client and Server classes. This allows sending a whole string or buffer at once, reducing the number of ethernet packets.
This commit is contained in:
@ -2,6 +2,7 @@ extern "C" {
|
||||
#include "types.h"
|
||||
#include "w5100.h"
|
||||
#include "socket.h"
|
||||
#include "string.h"
|
||||
}
|
||||
|
||||
#include "Ethernet.h"
|
||||
@ -66,6 +67,16 @@ Client Server::available()
|
||||
}
|
||||
|
||||
void Server::write(uint8_t b)
|
||||
{
|
||||
write(&b, 1);
|
||||
}
|
||||
|
||||
void Server::write(const char *str)
|
||||
{
|
||||
write((const uint8_t *)str, strlen(str));
|
||||
}
|
||||
|
||||
void Server::write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
accept();
|
||||
|
||||
@ -74,7 +85,7 @@ void Server::write(uint8_t b)
|
||||
|
||||
if (EthernetClass::_server_port[sock] == _port &&
|
||||
client.status() == SOCK_ESTABLISHED) {
|
||||
client.write(b);
|
||||
client.write(buffer, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user