Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added buffered write #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/ESPTelnetStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,19 @@ size_t ESPTelnetStream::write(uint8_t data) {
}
}

/////////////////////////////////////////////////////////////////

size_t ESPTelnetStream::write(const uint8_t* data, size_t size) {
if (client && isConnected()) {
size_t written = client.write(data, size);
if (!written) {
this->disconnectClient();
}

return written;
} else {
return 0;
}
}

/////////////////////////////////////////////////////////////////
3 changes: 2 additions & 1 deletion src/ESPTelnetStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class ESPTelnetStream : public ESPTelnetBase, public Stream {
int peek();
void flush();

size_t write(uint8_t);
size_t write(uint8_t) override;
size_t write(const uint8_t* data, size_t size) override;

protected:
void handleInput();
Expand Down