Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd32e65

Browse files
committed
overload with ::to(ref), missing license, minor details
1 parent 58a6257 commit fd32e65

File tree

8 files changed

+65
-13
lines changed

8 files changed

+65
-13
lines changed

cores/esp8266/Stream.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,19 @@ class Stream: public Print {
196196

197197
using oneShotMs = esp8266::polledTimeout::oneShotFastMs;
198198

199-
virtual size_t to (Print* to,
200-
const ssize_t maxLen = -1,
201-
int readUntilChar = -1,
202-
oneShotMs::timeType timeoutMs = oneShotMs::neverExpires /* =>getTimeout() */) final;
199+
size_t to (Print* to,
200+
const ssize_t maxLen = -1,
201+
int readUntilChar = -1,
202+
oneShotMs::timeType timeoutMs = oneShotMs::neverExpires /* =>getTimeout() */);
203+
204+
size_t to (Print& to,
205+
const ssize_t maxLen = -1,
206+
int readUntilChar = -1,
207+
oneShotMs::timeType timeoutMs = oneShotMs::neverExpires /* =>getTimeout() */)
208+
{
209+
return this->to(&to, maxLen, readUntilChar, timeoutMs);
210+
}
211+
203212
typedef enum
204213
{
205214
STREAMTO_SUCCESS = 0,

cores/esp8266/StreamDev.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
StreamDev.cpp - 1-copy transfer function
3+
Copyright (c) 2019 David Gauchard. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
19+
parsing functions based on TextFinder library by Michael Margolis
20+
*/
21+
122

223
#include <Arduino.h>
324
#include <assert.h>

cores/esp8266/StreamDev.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
StreamDev.h - Stream helpers
3+
Copyright (c) 2019 David Gauchard. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
19+
parsing functions based on TextFinder library by Michael Margolis
20+
*/
121

222
#ifndef __STREAMDEV_H
323
#define __STREAMDEV_H

cores/esp8266/StreamString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "WString.h"
2727

28-
// StreamString has been integrated insite String
28+
// StreamString has been integrated into String
2929

3030
using StreamString = String;
3131

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@
3333
#include <StreamDev.h>
3434
#include <base64.h>
3535

36-
int TO2HTTPC (int streamToError)
36+
static int TO2HTTPC (Stream::toReport_e streamToError)
3737
{
3838
switch (streamToError)
3939
{
4040
case Stream::STREAMTO_TIMED_OUT: return HTTPC_ERROR_READ_TIMEOUT;
4141
case Stream::STREAMTO_READ_ERROR: return HTTPC_ERROR_NO_STREAM;
4242
case Stream::STREAMTO_WRITE_ERROR: return HTTPC_ERROR_STREAM_WRITE;
4343
case Stream::STREAMTO_SHORT: return HTTPC_ERROR_STREAM_WRITE;
44-
default:
4544
case Stream::STREAMTO_SUCCESS: return 0;
4645
}
46+
return 0; // never reached, keep gcc quiet
4747
}
4848

4949
#if HTTPCLIENT_1_1_COMPATIBLE
@@ -1071,8 +1071,8 @@ bool HTTPClient::connect(void)
10711071
} else {
10721072
DEBUG_HTTPCLIENT("[HTTP-Client] connect: already connected, try reuse!\n");
10731073
}
1074-
StreamNull devnull;
1075-
_client->to(&devnull, -1, -1, 0); // clear _client's output (all of it, no timeout)
1074+
StreamNull devNull; // should we have a global one?
1075+
_client->to(devNull); // clear _client's output (all of it, no timeout)
10761076
return true;
10771077
}
10781078

libraries/ESP8266WiFi/examples/WiFiEcho/WiFiEcho.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
WiFiEcho - Echo tester
2+
WiFiEcho - Echo server
33
44
released to public domain
55
*/
@@ -91,8 +91,8 @@ void loop() {
9191

9292
else if (t == 3) {
9393
// stream to print, possibly with only one copy
94-
//client.to(&client); // <=> client.to(&client, -1, -1, client->getTimeout())
95-
client.to(&client, -1, -1, breathMs);
94+
//client.to(client); // <=> client.to(&client, -1, -1, client->getTimeout())
95+
client.to(client, -1, -1, breathMs);
9696

9797
switch (client.getLastTo()) {
9898
case Stream::STREAMTO_SUCCESS: break;

tests/host/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LIBRARIES_PATH := ../../libraries
66
FORCE32 ?= 1
77
OPTZ ?= -Os
88
V ?= 0
9+
R ?= noexec
910

1011
MAKEFILE = $(word 1, $(MAKEFILE_LIST))
1112

@@ -330,6 +331,7 @@ ifeq ($(INO),)
330331
%: %.ino
331332
@# recursive 'make' with paths
332333
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Wextra INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@)
334+
test "$(R)" = noexec || $(BINDIR)/$(notdir $@)/$(notdir $@) $(R)
333335
@# see below the new build rule with fixed output path outside from core location
334336

335337
#####################

tests/host/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Optional 'V=1' enables makefile verbosity
4545
Optional 'D=1' enables core debug (same as IDE's tools menu)
4646
Optional 'OPTZ=-O2' will update gcc -O option (default is -Os, D=1 implies -O0)
4747
Optional 'FORCE32=0' will use native/default gcc (default is FORCE32=1 unless gcc-multilib is not detected)
48-
48+
Optional 'R="<options>"' (ex: R="-b -v") runs the executable with given options after build
4949

5050
Non exhaustive list of working examples:
5151
make D=1 ../../libraries/ESP8266WiFi/examples/udp/udp

0 commit comments

Comments
 (0)