1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

1347 Commits

Author SHA1 Message Date
Earle F. Philhower, III
00440cd84a
Remove memory leak on multiple calls to initCertStore (#7021)
In some cases, `initCertStore` may need to be called multiple times
(i.e. to update certs w/oa reboot).  In that case, the saved file names
leaked when the new ones were `malloc()`'d.

Fix by freeing the old strings, if present.
2020-01-17 10:10:17 -08:00
Earle F. Philhower, III
677007f481
Define MAX_SERVOS to 12, like original Servo.h (#6999)
Fixes #6997
2020-01-08 20:30:44 -08:00
LaborEtArs
5e537e5783 Updating _port to really used port and made _port accessible (#7003)
* Updating _port to really used port and made _port accessible

* 2. Try
2020-01-08 21:36:39 -03:00
Earle F. Philhower, III
b4d2ab102b
Fix boolean/logical & mixup in LittleFS open (#6996)
To mimic SPIFFs behavior, we automatically create subdirectories when a
file is opened in a subdir.

The check mixed up a bitmask check with a boolean AND.  Fix it.
2020-01-07 10:55:42 -08:00
JasperHorn
8242d72271 Add LittleFS support to ESP8266WebServer.serveStatic() (#6987)
* Remove trailing whitespace

* Improve "is file" check for LittleFS support

The previous implementation was based on a quirk of SPIFFS (that exists
returns false for directories) so it wouldn't work with LittleFS. This
implementation works with both.

Co-authored-by: Develo <deveyes@gmail.com>
2020-01-04 20:33:05 -08:00
Earle F. Philhower, III
d4d89244bd
Add SDFS::Dir::fileTime callback (#6985)
Forgot to add a Dir->fileTime override, resulting in it always returning
(time_t)0, or Jan 1, 1970.

Add the override, returning the proper lastWriteTime.

Fixes #6981
2020-01-04 11:36:47 -08:00
Earle F. Philhower, III
753b5a581a
Update LittleFS to latest upstream head (#6986) 2020-01-04 09:59:06 -08:00
Dirk Mueller
de307623b2 Move a couple larger strings from rodata to flash (#6976) 2020-01-02 22:26:08 -03:00
Earle F. Philhower, III
fa5040d5da
Only update LittleFS timestamp when opened write (#6956)
Fixes #6955

LittleFS was updating the timestamp on any close, not only for files
when they were opened for writing.  This could lead to excessive writes
to the flash.

Preserve the LFS flags, and only update the timestamp if the file was
opened for writing.
2019-12-30 15:43:26 -08:00
Earle F. Philhower, III
2492043669
Skip . and .. on LittleFS::dir::rewind() (#6959)
Fixes #6958

To match SPIFFS, we get rid of the "." and ".." dirents when we open a
directory on LittleFS.  Do the same on a rewind().
2019-12-30 14:23:14 -08:00
Dirk Mueller
5d5200af41 Reduce temporary string creation in HTTPClient::sendHeader (#6937)
* Reduce temporary string creation/reallocation in HTTPClient

This improves both performance due to fewer memory allocations/copies
as well as reduces code size by ~ 25% (150 bytes)

* Add more correct reservation calculation

Co-authored-by: Develo <deveyes@gmail.com>
2019-12-28 19:48:47 -08:00
Dirk O. Kaar
809e5c967a EspSoftwareSerial, release 6.6.1 (#6943)
* Bug fixes to EspSoftwareSerial, release 6.6.0

Various improvements to the Delegate class template.
Memory footprint reduction of SoftwareSerial instances based on 3rd party contribution by @dirkmueller

* Bug fix EspSoftwareSerial, delegate template programming for > 3 platforms is interesting.

Co-authored-by: Earle F. Philhower, III <earlephilhower@yahoo.com>
Co-authored-by: Develo <deveyes@gmail.com>
2019-12-28 13:26:38 -08:00
Dirk Mueller
bea9cfc3a0 PROGMEM footprint cleanup for responseCodeToString (#6950)
* PROGMEM footprint cleanup for responseCodeToString

Doing returns with String/FlashStringHelper conversion for every
case means that the code for doing that is duplicated, which
is wasteful. doing it only once saves about 250 bytes (50%) of
code size.

* Remove "I'm a teapot" error code

* Add inline code comment to explain rationale
2019-12-27 19:02:57 -03:00
Dirk Mueller
698ffc3498 Various String handling cleanups (#6945)
Use the proper api (::clear(), isEmpty()) instead of doing
comparisons/assignments of empty strings. Also fix mixture
of tabs and spaces in the source code.
2019-12-26 17:03:18 -03:00
Dirk O. Kaar
99aeeadb4d EspSoftwareSerial 6.5.4 (#6932) 2019-12-21 08:24:13 -08:00
Earle F. Philhower, III
52d84b1ead
Add a CRC32 over progmem and ESP.checkFlashCRC (#6566)
* Add a CRC32 over progmem and ESP.checkFlashCRC

Automatically embed a CRC32 of the program memory (including bootloader
but excluding any filesystems) in all images in unused space in the
bootloader block.

Add a call, ESP.checkFlashCRC() which returns false if the calculated
CRC doesn't match the one stored in the image (i.e. flash corruption).

Fixes #4165

* Add example that corrupts itself, comments

Show CRC checking catch a 1-bit error in program code by corrupting a
large array, and then return it to clean and verify the CRC matches once
again.

Add comments to the CRC check routine

Clean up pylint complaints on crc32bin.py

* Check linker script for CRC space in bootsector

Add an assertion in the eboot linker file to guarantee that we have at
least 8 bytes of unused space at the end of the boot sector to patch in
the CRC.  If not, the eboot link will fail.

* Add note about what to do if CRC check fails

Per discussion with @d-a-v.

When the CRC check fails, you could *try* to do certain things (but may
not succeed since there is known flash corruption at that point).  List
a few ideas for application authors.

* Only single, flash/ram friendly crc32() function

* Combine the CRC calc and bin generation in 1 step

Per discussion w/@mcspr, combine the CRC calculation with the binary
generation, removing the additional build step.
2019-12-20 14:38:35 -08:00
Dirk O. Kaar
622baa1659 Bug-fix release EspSoftwareSerial 6.5.3 (#6922)
* EspSoftwareSerial 6.5.0 public release.

* EspSoftwareSerial bug fix public release 6.5.1

* Release 6.5.2, examples changed only, simplified adding WiFi setup etc. by moving logger setup up to the front.

* Parity bug fix: Overflow condition caused data and parity to get out of sync permanently.
2019-12-20 15:37:40 +01:00
Earle F. Philhower, III
1d0bc5efdf
Allow GZIP compressed flash updates (#6820)
* Allow GZIP compressed flash updates

Modified the bootloader to be able to take stored updates in compressed
GZIP format (i.e. the output of "gzip -9 xxx.bin") and decompress them
on-the-fly to their final destination.  This can work for apps and for
filesystems (when used with the 2-step update option).

Allow eboot to be built using -Os/2 optimizations by fixing some portions
which failed when any optimizations were used.  Add -Wall and use data
and function sections to reduce size.  Use -Os to minimize size.

Remove obsolete esptool-ck calls to build a .ROM image, we don't use it.

Move all uninitted variables to RAM from IRAM, allowing 8-bit access.

Hook in @d-a-v and @pfalcon's uzlib port to actually do the
decompression.  Do not use any CRC checking which saves space.  Since we
have overwritten all of flash by the time we know id the CRC matches,
there's nothing we could have done anyway.

Adjust the Updater class to support GZIP files and not attempt to patch
them.

Bootloader builds to 0xd90 out of 0xfff bytes.

* Add @d-a-v's patch for httpupdate

https://github.com/esp8266/Arduino/pull/6820#pullrequestreview-326541014

* Update uzlib to point to pfalcon++

For now, because there are some self-test failures with @d-a-v's esp8266
branch (whose cool new features we don't actually use in eboot now)
start with pfalcon's 2.9 release and add the 2 patches (clcidx to code
from IRAM/RODATA, and the Windows test file renaming) needed to build
and run successfully.

* Add (c) notice for uzlib to README
2019-12-18 09:17:38 -08:00
James Marlowe
eb6418f641 POST http client example (#2704)
* POST http client example

* avoid deprecated api

* Update PostHttpClient.ino

style, comments

* Update PostHttpClient.ino
2019-12-11 14:55:52 -08:00
david gauchard
3e6c25c21b
udp: limit buffer depth (#6895)
This commit avoids OOMs on an udp corner case where a delay() in the main
loop would allow memory filling.

A memory leak has been observed with such semantically forbidden delay,
unsolved yet, and preventing to use a simple counter instead of walking
through a linked list.  The count limit is however small.
2019-12-10 11:04:49 +01:00
jennytoo
70c337001c Fix sending headers in #send_P(int, PGM_P, PGM_P, size_t) (#6881)
The method #send(int, char*, char*[, size_t])) is a virtual method which
calculates the size of the content then calls #send_P(int, PGM_P, PGM_P,
size_t). This particular implementation of #send_P differs from the other
implementations of #send and #send_P in that it uses #sendContent for
headers and always calls #sendContent_P for contents even when the
contents is not specified.

The method #sendContent is intended for body and prepends the chunksize
in chunk mode but this breaks the HTTP protocol which does not expect a
chunksize prior to the headers.

Fix is simply to do the same thing as all the other methods - call
_currentClient.write and only call #sendContent_P if there is content to
send.
2019-12-10 09:47:26 +01:00
Dirk O. Kaar
8a6a7f7480 Non-parity modes save 56 bytes of heap memory. (#6882)
Hardened code in non-parity mode against setting parity case by case.
Waveform generator is back after one release without.
2019-12-05 08:25:44 -03:00
Matthias Hertel
a738884387 Handle HEAD requests for static files correctly (#6837)
* Handle HEAD requests for static files correctly

* Handle HEAD requests for static files correctly
2019-12-04 18:23:25 +01:00
david gauchard
326083044a
webserver: fix sending char* (#6878)
* webserver: fix sending char*

* add missing char*  overload
2019-12-04 00:51:51 +01:00
Earle F. Philhower, III
074a8016bf
Remove user_interface.h from gdbstub includes (#6862)
* Remove user_interface.h from gdbstub includes

Avoid a warning by not including the unneeded "user_interface.h" from
gdbstub.c.  Leftover from original stub code from the SDK, this include
is unnecessary in the Arduino core.

* Add example to ensure gdbstub compiles in CI

Ensure the same user_interface warning doesn't occur in the future by
adding the example shown in the GDB docs to the CI build process.
2019-12-01 15:39:08 -07:00
Develo
32792483cc Fix pointer arithmetic (#6830)
Actually advance position while looping
2019-11-24 11:42:17 +01:00
Earle F. Philhower, III
8f6e0dd339 Allow for POSTs larger than a few 100 bytes (#6800)
This is all @dirkx , whose PR unfortunately got borked when we were
trying to update it to the new format.  As @dirkx said:

When sending POST responses of well over a K - _write() may not sent it
all. Make sure we do -- but cap the individual writes - as somehow large
2-3k blobs seem to cause instability (on my 12F units).

Supercedes #2528
2019-11-24 01:53:29 -03:00
david gauchard
8ec93dcd26 use wificlient.available() where relevant (#6827) 2019-11-23 20:12:37 -03:00
Dirk O. Kaar
a35edca07a EspSoftwareSerial: ctor/begin() compatibility to AVR/ESP8266/ESP32 (#6814)
* EspSoftwareSerial: ctor/begin() compatibility to AVR/ESP8266/ESP32 HW release 6.2.0

* Release 6.2.1: In loopback example, explicit pin settings and for ESP32, realistic max. bps for single stop bit config.

* Loopback example can exploit new invert API in HardwareSerial

* EspSoftwareSerial 6.3.0
2019-11-22 14:26:00 -03:00
Earle F. Philhower, III
ebae47c13a
Expand BSSL stack (#6819)
Fixes #6811 which found an issue where connecting to scripts.google.com
would *occasionally* cause a crash.  On inspection, it was found that up
to 5828 bytes of stack were used once in a while, so expand the stack to
5900 bytes to cover this case plus a little extra.
2019-11-20 18:05:38 -07:00
Earle F. Philhower, III
800794de37 Add callbacks for ESP8266HTTPUpdate (#6796)
Replaces abandoned #1817 and #2694

Add optional std::function callback (so it supports lambdas and normal
functions) via ::onStart, ::onEnd, ::onProgress, and ::onError methods.

Update example with their use.

From @baruch's original pull request:
The callback is called when the upgrade actually starts rather than just
the initial query so that the user can know that it will not take longer
and can also prepare for the upgrade by shutting down other works.

From @karlp's original pull request:
Incomplete: I've not updated any documentation yet. If this style looks
good, I'll happily go and update the documentation (likewise for the
examples)
2019-11-19 16:15:57 -03:00
Earle F. Philhower, III
36f903443b Add const char* content to ESP8266WebServer::send() (#6797)
* Add const char* content to ESP8266WebSerer::send()

Supercedes #3492

Allow sending raw binary data or strings directly without conversion to
a String to reduce memory overhead when possible.

From original @timw1971 PR #3492
Added public functions to allow content to be uploaded using const
char*. For some cases, this can remove the need for content to be copied
into a String, and thus can be considerably more space-efficient.

* Fix example formatting

* Make GIF example use static const array

* Make the example really need to use const char*

Make the generated GIF dynamic in the example and move the original to
PROGMEM (since that's where const arrays like this belong).
2019-11-19 14:46:30 -03:00
Earle F. Philhower, III
919c753563 Terminate the chunked printDirectory (#6808)
Fixes #2481

Send a 0-len chunk when the directory is completed (in a chunked HTTP
transfer) to terminate the HTTP transfer properly.
2019-11-19 10:32:39 +01:00
Earle F. Philhower, III
6768116b8c Only add "l" to XX.htm URLs if XX.html exists (#6794)
Fixes #6792

Only append the "l" to ".htm" when there actually is a ".html" file
present.  If not, fall-thru like before and try .gz through the normal
paths.
2019-11-19 02:43:47 -03:00
Earle F. Philhower, III
344c4492af [SSDP] add schema(Print &) const (#6798)
* [SSDP] add `schema(Print &) const`

Supercedes #2806

Make SSDP::schema(WiFiClient&) use a by-ref (reduce stack use)

Add a SSDP::schema(Print&)

From @Palatis' original PR:
useful when using AsyncWebServer.

* Use ip.toString, only export Print& schema interface

Because WiFiClient inherits a Print interface, replace the
::schema(WiFiClient&) with ::schema(Print&) which is source compatible
with existing code and allows the functionality requested in the initial
PR.

Use ip.toString() in the templates instead of breaking up the octets of
the address.

* Fix compile errors and backwards compatibility
2019-11-19 02:02:54 -03:00
Develo
9b96f53778
Fix typo in mode timeout loop (#6801)
Fix typo to make timeout 1s instead if 1ms, as originally intended.
2019-11-19 01:27:10 -03:00
liebman
bbfe2c2035 remove clear() before beginInternal() so _location is not cleared before its passed to beginInternal() (#6786) 2019-11-18 16:41:24 -03:00
Earle F. Philhower, III
01e9d948c7
Update SdFat to not undefine F() macro (#6787)
Fixes #6767 .  Remove the `undef F` from SysCall.h as it is not needed
nor used in the SD or SDFS libraries.  This puts F() strings back in
flash when using the SD/SDFS libs.
2019-11-16 15:50:02 -07:00
Dirk O. Kaar
240ae5ef26 Add/unify comments for target and source sites of async scheduling via delay()/esp_yield()/esp_schedule() (#6780) 2019-11-15 14:53:43 +01:00
André Futter
05454df164 Root page should be of type text/html (#6776)
In order to be displayed properly by a browser the HTML should be returned as text/html.
2019-11-15 00:29:31 +01:00
Mehdi Beyk Mohamadi
95c740705e Add missing "LittleFS.begin()" in LittleFS_Timestamp example. (#6762)
* Add missing "LittleFS.begin()"

Add missing first LittleFS.begin() call.

* Update LittleFS_Timestamp.ino
2019-11-14 18:25:56 -03:00
Dirk O. Kaar
482516e393 Minimize header use, move Ticker function definitions into cpp file (#6496)
* Backport from ESP32

* Use new library layout (.../src)

* Cleanup test case.

* C++ style cast required.

* Whitespace

* Inlining via header has better baseline ROM footprint.

* Reordered functions for better code-compare to master

* Reduces ROM footprint some more.

* Avoid unnecessary parameter passing - refactoring, same generated footprint.

* Reformat example sources
2019-11-14 10:02:32 -03:00
david gauchard
2f26d94f64 minor: examples: reorder functions for declarations prior to call (#6766)
* minor: reorder functions for declaration prior to call
harmless for arduino, helps with emulation on host or PIO

* fixes per review
2019-11-13 22:35:30 -03:00
Earle F. Philhower, III
d2d0ee3d43
Update to LittleFS 2.1.3 (#6757) 2019-11-12 19:55:50 +01:00
Dirk O. Kaar
8222acedaf EspSoftwareSerial release 6.1.1, "9bit" support (#6761)
* EspSoftwareSerial release 6.1.0:

New feature, a.k.a. "9bit": Supports parity bit on TX and RX and 2 stop bits.

* Fix for local relative #include
2019-11-12 15:57:11 +01:00
Dirk O. Kaar
739bcd3fd5 Updated EspSoftwareSerial brings backward compatibility for ctor/begin() pair (only for the common cases with complete default argument use) (#6746) 2019-11-10 10:48:12 +01:00
Chế Tiệp Chân Khoa
6626b2fb07 add docs: how to get POST body in ESP8266WebSever (#6736) 2019-11-09 08:55:18 +01:00
Dirk O. Kaar
5260b30730 EspSoftwareSerial release 5.4.0 with performance/error rate improvement in TX (#6722)
* EspSoftwareSerial release 5.3.5 with performance/error rate improvement in TX

* EspSoftwareSerial 5.3.6 with CI fix and, tadaaa, reliable tx and rx at 115200bps and beyond.

* Version 5.4.0 stabilized work of past 24h.
2019-11-08 17:53:03 +01:00
Develo
453eb2d064
Add wait loop at the end of mode, refactor can_yield (#6721)
* Add wait loop at the end of mode, refactor can_yield

* fix mock build
2019-11-07 18:25:20 -03:00
david gauchard
6f7eb2828a Make SPIFFS and LittleFS stay out of link when not needed (#6699)
* define two weak functions defaulting to no-op
redefine them to do something useful when either spiffs or littlefs are used

* noop

* single entry point for closing FSes

* rename functions, override when instanciated, add link to explanation

* spiffs: call end on destructor
2019-11-06 21:37:52 -03:00