Skip to content

Commit b845d03

Browse files
committed
Merge remote-tracking branch 'remotes/esp8266/master' into httpClient
2 parents d77e605 + 28d1ef3 commit b845d03

File tree

10 files changed

+52
-19
lines changed

10 files changed

+52
-19
lines changed

cores/esp8266/StreamString.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@
2525

2626
size_t StreamString::write(const uint8_t *buffer, size_t size) {
2727
if(reserve(length() + size + 1)) {
28-
for(size_t i = 0; i < size; i++) {
29-
if(write(*buffer)) {
30-
buffer++;
31-
} else {
32-
return i;
33-
}
34-
}
35-
28+
const uint8_t *s = buffer;
29+
const uint8_t *end = buffer + size;
30+
while(write(*s++) && s < end);
31+
return s - buffer;
3632
}
3733
return 0;
3834
}

cores/esp8266/cont.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ void cont_yield(cont_t*);
6060
// return 1 if guard bytes were overwritten.
6161
int cont_check(cont_t* cont);
6262

63+
// Go through stack and check how many bytes are most probably still unchanged
64+
// and thus weren't used by the user code. i.e. that stack space is free. (high water mark)
65+
int cont_get_free_stack(cont_t* cont);
66+
6367
// Check if yield() may be called. Returns true if we are running inside
6468
// continuation stack
6569
bool cont_can_yield(cont_t* cont);

cores/esp8266/cont_util.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ void ICACHE_RAM_ATTR cont_init(cont_t* cont) {
3030
cont->stack_guard2 = CONT_STACKGUARD;
3131
cont->stack_end = cont->stack + (sizeof(cont->stack) / 4);
3232
cont->struct_start = (unsigned*) cont;
33+
34+
// fill stack with magic values to check high water mark
35+
for(int pos = 0; pos < sizeof(cont->stack) / 4; pos++)
36+
{
37+
cont->stack[pos] = CONT_STACKGUARD;
38+
}
3339
}
3440

3541
int ICACHE_RAM_ATTR cont_check(cont_t* cont) {
@@ -38,6 +44,19 @@ int ICACHE_RAM_ATTR cont_check(cont_t* cont) {
3844
return 0;
3945
}
4046

47+
int ICACHE_RAM_ATTR cont_get_free_stack(cont_t* cont) {
48+
uint32_t *head = cont->stack;
49+
int freeWords = 0;
50+
51+
while(*head == CONT_STACKGUARD)
52+
{
53+
head++;
54+
freeWords++;
55+
}
56+
57+
return freeWords * 4;
58+
}
59+
4160
bool ICACHE_RAM_ATTR cont_can_yield(cont_t* cont) {
4261
return !ETS_INTR_WITHINISR() &&
4362
cont->pc_ret != 0 && cont->pc_yield == 0;

cores/esp8266/spiffs_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ class SPIFFSImpl : public FSImpl {
6666

6767
bool rename(const char* pathFrom, const char* pathTo) override {
6868
if (!isSpiffsFilenameValid(pathFrom)) {
69-
DEBUGV("SPIFFSImpl::rename: invalid pathFrom=`%s`\r\n", path);
69+
DEBUGV("SPIFFSImpl::rename: invalid pathFrom=`%s`\r\n", pathFrom);
7070
return false;
7171
}
7272
if (!isSpiffsFilenameValid(pathTo)) {
73-
DEBUGV("SPIFFSImpl::rename: invalid pathTo=`%s` \r\n", path);
73+
DEBUGV("SPIFFSImpl::rename: invalid pathTo=`%s` \r\n", pathTo);
7474
return false;
7575
}
7676
auto rc = SPIFFS_rename(&_fs, pathFrom, pathTo);

doc/platformio.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ platformio run --target upload
7171
- [IDE Integration](http://docs.platformio.org/en/latest/ide.html) (Atom, CLion, Eclipse, Qt Creator, Sublime Text, VIM, Visual Studio)
7272
- [Project Examples](http://docs.platformio.org/en/latest/platforms/espressif.html#examples)
7373

74-
## Demo of OTA update
75-
[![PlatformIO and OTA firmware uploading to Espressif ESP8266 ESP-01](http://img.youtube.com/vi/W8wWjvQ8ZQs/0.jpg)](http://www.youtube.com/watch?v=W8wWjvQ8ZQs "PlatformIO and OTA firmware uploading to Espressif ESP8266 ESP-01")
74+
## Demo of Over-the-Air (OTA) ESP8266 programming using PlatformIO
75+
76+
http://www.penninkhof.com/2015/12/1610-over-the-air-esp8266-programming-using-platformio/
77+
78+
[![Over-the-Air ESP8266 programming using PlatformIO](http://img.youtube.com/vi/lXchL3hpDO4/0.jpg)](http://www.youtube.com/watch?v=lXchL3hpDO4 "Over-the-Air ESP8266 programming using PlatformIO")

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,12 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size) {
367367
int c = stream->readBytes(buff, ((s > buff_size) ? buff_size : s));
368368

369369
// write it to Stream
370-
bytesWritten += _tcp->write((const uint8_t *) buff, c);
370+
int w = _tcp->write((const uint8_t *) buff, c);
371+
if(w != c) {
372+
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] short write asked for %d but got %d\n", c, w);
373+
break;
374+
}
375+
bytesWritten += c;
371376

372377
if(len > 0) {
373378
len -= c;
@@ -382,15 +387,15 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size) {
382387
free(buff);
383388

384389
if(size && (int) size != bytesWritten) {
385-
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] Stream payload bytesWritten %d and size %d mismatch!.\n", bytesWritten, _size);
390+
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] Stream payload bytesWritten %d and size %d mismatch!.\n", bytesWritten, size);
386391
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] ERROR SEND PAYLOAD FAILED!");
387392
return HTTPC_ERROR_SEND_PAYLOAD_FAILED;
388393
} else {
389394
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] Stream payload written: %d\n", bytesWritten);
390395
}
391396

392397
} else {
393-
DEBUG_HTTPCLIENT("[HTTP-Client][writeToStream] too less ram! need " HTTP_TCP_BUFFER_SIZE);
398+
DEBUG_HTTPCLIENT("[HTTP-Client][sendRequest] too less ram! need %d\n", HTTP_TCP_BUFFER_SIZE);
394399
return HTTPC_ERROR_TOO_LESS_RAM;
395400
}
396401

@@ -474,7 +479,12 @@ int HTTPClient::writeToStream(Stream * stream) {
474479
int c = _tcp->readBytes(buff, ((size > buff_size) ? buff_size : size));
475480

476481
// write it to Stream
477-
bytesWritten += stream->write(buff, c);
482+
int w = stream->write(buff, c);
483+
if(w != c) {
484+
DEBUG_HTTPCLIENT("[HTTP-Client][writeToStream] short write asked for %d but got %d\n", c, w);
485+
break;
486+
}
487+
bytesWritten += c;
478488

479489
if(len > 0) {
480490
len -= c;
@@ -495,7 +505,7 @@ int HTTPClient::writeToStream(Stream * stream) {
495505
}
496506

497507
} else {
498-
DEBUG_HTTPCLIENT("[HTTP-Client][writeToStream] too less ram! need " HTTP_TCP_BUFFER_SIZE);
508+
DEBUG_HTTPCLIENT("[HTTP-Client][writeToStream] too less ram! need %d\n", HTTP_TCP_BUFFER_SIZE);
499509
return HTTPC_ERROR_TOO_LESS_RAM;
500510
}
501511

libraries/ESP8266WebServer/src/detail/RequestHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
class RequestHandler {
55
public:
6+
virtual ~RequestHandler() { }
67
virtual bool canHandle(HTTPMethod method, String uri) { return false; }
78
virtual bool canUpload(String uri) { return false; }
89
virtual bool handle(ESP8266WebServer& server, HTTPMethod requestMethod, String requestUri) { return false; }

libraries/ESP8266WiFi/src/include/wl_definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ enum wl_enc_type { /* Values map to 802.11 encryption suites... */
6868
ENC_TYPE_AUTO = 8
6969
};
7070

71-
#if !defined(LWIP_INTERNAL)
71+
#if !defined(LWIP_INTERNAL) && !defined(__LWIP_TCP_H__)
7272
enum wl_tcp_state {
7373
CLOSED = 0,
7474
LISTEN = 1,

libraries/GDBStub/src/internal/gdbstub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static void ATTR_GDBFN sendReason() {
299299
} else if (gdbstub_savedRegs.reason&0x80) {
300300
//We stopped because of an exception. Convert exception code to a signal number and send it.
301301
i=gdbstub_savedRegs.reason&0x7f;
302-
if (i<sizeof(exceptionSignal)) return gdbPacketHex(exceptionSignal[i], 8); else gdbPacketHex(11, 8);
302+
if (i<sizeof(exceptionSignal)) gdbPacketHex(exceptionSignal[i], 8); else gdbPacketHex(11, 8);
303303
} else {
304304
//We stopped because of a debugging exception.
305305
gdbPacketHex(5, 8); //sigtrap

tools/sdk/lib/liblwip.a

368 KB
Binary file not shown.

0 commit comments

Comments
 (0)