Skip to content

Copy ESP8266 String w/SSO to ESP32 repo #2715

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

Merged
merged 1 commit into from
Apr 26, 2019
Merged
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
25 changes: 10 additions & 15 deletions cores/esp32/StreamString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
StreamString.cpp

Copyright (c) 2015 Markus Sattler. All rights reserved.
This file is part of the esp8266 core for Arduino environment.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -22,31 +23,27 @@
#include <Arduino.h>
#include "StreamString.h"

size_t StreamString::write(const uint8_t *data, size_t size)
{
size_t StreamString::write(const uint8_t *data, size_t size) {
if(size && data) {
if(reserve(length() + size + 1)) {
memcpy((void *) (buffer + len), (const void *) data, size);
len += size;
*(buffer + len) = 0x00; // add null for string end
memcpy((void *) (wbuffer() + len()), (const void *) data, size);
setLen(len() + size);
*(wbuffer() + len()) = 0x00; // add null for string end
return size;
}
}
return 0;
}

size_t StreamString::write(uint8_t data)
{
size_t StreamString::write(uint8_t data) {
return concat((char) data);
}

int StreamString::available()
{
int StreamString::available() {
return length();
}

int StreamString::read()
{
int StreamString::read() {
if(length()) {
char c = charAt(0);
remove(0, 1);
Expand All @@ -56,16 +53,14 @@ int StreamString::read()
return -1;
}

int StreamString::peek()
{
int StreamString::peek() {
if(length()) {
char c = charAt(0);
return c;
}
return -1;
}

void StreamString::flush()
{
void StreamString::flush() {
}

Loading