1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

1696 Commits

Author SHA1 Message Date
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
Anders
962a23d253 - Make it possible to transfer Strings containing null values via ESP-NOW and FloodingMesh.
- Add uint8ArrayToMultiString and bufferedUint8ArrayToMultiString TypeConversionFunctions to facilitate transfer of Strings containing null values.

- Add HKDF to CryptoInterface.

- Add ChaCha20 + Poly1305 AEAD to CryptoInterface.

- Add customizable nonce generator to CryptoInterface.

- Add ability to automatically encrypt/decrypt ESP-NOW messages via AEAD (ChaCha20 + Poly1305), independent from encrypted ESP-NOW connections.

- Greatly improve performance of incrementSessionKey, espnowGetMessageID, espnowSetMessageID and all non-template TypeConversionFunctions. The average performance increase is roughly a factor 5. Fun fact: Printing a MAC to a HEX String is now over twice as fast when using TypeConversionFunctions compared to using standard functionality like sprintf.

- Add uint64ToUint8Array and uint8ArrayToUint64 TypeConversionFunctions.

- Make it possible to use String values as ESP-NOW and FloodingMesh key seeds, instead of just requiring plain key arrays.

- Add customizable responseTransmittedHook to sendEspnowResponses.

- Add _responsesToSendMutex to make the new responseTransmittedHook safe to use.

- Remove verboseModePrinting from sendPeerRequestConfirmations method to reduce performance variations.

- Fix faulty messageID generation in FloodingMesh.

- Make assert checks more complete and easier to understand in the setMetadataDelimiter method of FloodingMesh.

- Rename EspnowEncryptionKey to EspnowEncryptedConnectionKey since there are now multiple encryption keys.

- Rename acceptsUnencryptedRequests to acceptsUnverifiedRequests, unencryptedMessageID to unsynchronizedMessageID, receivedEncryptedMessage to receivedEncryptedTransmission, since there are now multiple modes of encryption.

- Rename resultArrayLength to outputLength in CryptoInterface and remove its value restrictions in order to match the BearSSL functionality.

- Improve performance of FloodingMesh::encryptedBroadcast.

- Rename FloodingMesh methods maxUnencryptedMessageSize/maxEncryptedMessageSize to maxUnencryptedMessageLength/maxEncryptedMessageLength, so that String length naming is consistent within the library.

- Update examples to illustrate the new features.

- Improve comments.
2019-12-04 02:30:16 +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
Anders
2fef67dcb0 - Generalize CryptoInterface.
- Add more HMAC and hash functions to CryptoInterface.

- Add MeshCryptoInterface as a holder of mesh specific crypto functionality.

- Rename broadcastMetadataDelimiter to metadataDelimiter in FloodingMesh since it is not just used for broadcasts, and to save some typing.
2019-11-10 21:50:43 +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
Develo
98785f7cdf
Rollback setContentLength removal (#6715) (#6719)
Apparently I messed up testing #6715 and something broke. This rolls back that PR.
That means #2132 remains closed with no action.
2019-11-06 16:08:28 -03:00
Anders
3132325bf8 - Replace Crypto files with CryptoInterface which uses BearSSL as a cryptographic backend.
- Move cryptographic functions from JsonTranslator to CryptoInterface.

- Make AP activation separate from FloodingMesh::begin().

- Fix English bug.

- Improve comments.
2019-11-06 12:55:34 +01:00
Develo
ffa9e3c7c2
Remove useless call to setContentLength() (#6715)
* Update ESP8266WebServer-impl.h

Remove useless call to setContentLength()

* Fix warning unused param
2019-11-05 21:50:52 -03:00
hreintke
2abcd16efb Implementation of a generic CallBackList (#5710)
* Initial version

Move to experimental namespace

Change namespace
2019-11-05 19:48:04 -03:00
Anders
afc88f2652 - Improve HelloMesh.ino. 2019-11-04 12:59:49 +01:00
Anders
78812a7333 - Add HelloTcpIp.ino example for the TcpIpMeshBackend.
- Update HelloEspnow.ino and HelloMesh.ino examples.

- Fix bug with TransmissionOutcomesUpdateHook not being called when the TCP/IP backend retained WiFi.status() == WL_CONNECTED.
2019-11-03 22:26:52 +01:00
Anders
6b763686de - Add working FloodingMesh. Unencrypted broadcasts should work well, but are untested in large mesh networks. Encrypted broadcast support is currently experimental.
- Add BroadcastTransmissionRedundancy and related functionality to reduce the transmission loss during broadcasts. Broadcast transmissions are now re-transmitted once per default. Broadcast throughput halved per default.

- Add getSenderAPMac method.

- Add FloodingMesh example in the HelloMesh.ino file.

- Improve JSON identifier names.

- Improve comments.

- Improve documentation.
2019-11-03 14:00:05 +01:00
Anders
176f2851e4 Fix space. 2019-11-01 12:55:31 +01:00
Anders
8194197e9d Even better fix of conflict with master branch. 2019-11-01 12:37:09 +01:00
Anders
7ca5a7e5bb Fix conflict with master branch.
- Avoid single character String concatenations done via String literals instead of char literals, as this is inefficient because of temporary String creations (#6571).
2019-11-01 12:17:24 +01:00
Anders
f8ec4f1c72 - Make connectionQueue(), latestTransmissionOutcomes() and latestTransmissionSuccessful() methods static in order to match the underlying data storage.
- Make it possible to transfer elements directly between connectionQueues.

- Add defaultBSSID value.

- Fix bug where encrypted Espnow-connections expired 1 ms too late.

- Add MutexTracker::captureBan() functionality and use it in the espnowReceiveCallbackWrapper method to ensure a consistent mutex environment there.

- Rename acceptRequest to acceptRequests since several requests can be accepted, not just one.

- Reorganize EspnowMeshBackend.cpp.

- Split sendEspnowResponses() method into sendEspnowResponses() and sendPeerRequestConfirmations().

- Add sendStoredEspnowMessages() method to provide the same functionality as the previous version of sendEspnowResponses().

- Add logic for handling peerRequestConfirmations received at the same time as a peer request is being made, to avoid lockups when there are simultaneous cyclic peer requests.

- Add logic for handling simultaneous reciprocal peer requests.

- Include MAC addresses in HMAC calculations for peer requests and use HMAC for all unencrypted peer request messages, to make sure we receive valid MAC combinations.

- Add asserts to ensure ESP-NOW encryption integrity during code changes.

- Add estimatedMaxDuration argument to performEspnowMaintainance and related methods.

- Add methods to EncryptedConnectionData for setting peer MAC.

- Remove createEncryptionRequestMessage function from JsonTranslator since it is not used, to increase clarity.

- Add encryptedConnectionsSoftLimit() and related functionality.

- Add mutex to protect connectionQueue usage during attemptTransmission.

- Add _ongoingPeerRequestMac variable.

- Add reservedEncryptedConnections() method.

- Add TransmissionOutcomesUpdateHook() callback.

- Add constConnectionQueue() method to allow connectionQueue usage while connectionQueue mutex is active.

- Rearrange attemptAutoEncryptingTransmission argument order to increase efficiency.

- Add functionality for serializing the unencrypted ESP-NOW connection.

- Add some constness.

- Improve comments.

- Improve documentation.

- Update keywords.txt.
2019-10-31 22:25:12 +01:00
Dirk Mueller
14262af0d1 Cleanup base64::encode functions (#6607)
* Cleanup base64::encode functions

The implementation choice here using libb64 is generally good as it
is a relatively fast implementation, however the adaptation to
use PROGMEM for the translation function was a bad choice, as reading
randomly PROGMEM with byte-wide access is very very very slow.

Doing a naive if-snake is between 20% and 55% faster and uses less
flash (about 120 bytes less) and also for reasons I don't understand
8 bytes less data RAM (maybe the removal of static?).

In addition the base64::encode function was allocating for larger
input a huge amount of memory (twice the total size). we can reduce
that by doing a chunk-wise conversation to base64.

* Create authorisation base64 encoded string without newlines

Rather than first creating a string with newlines and then
stripping it away in the fast path of constructing the query,
we can call the right method and trust that the result does
not have newlines anymore.
2019-10-31 13:18:36 -07:00
NayanKaran
348c58b644 added public cleanAPlist() function (#4107)
* added public cleanAPlist() function.

* Update ESP8266WiFiMulti.cpp

* Update ESP8266WiFiMulti.cpp

* Add cleanAPlist to object method header
2019-10-31 10:58:35 -07:00
Dirk Mueller
8bc5a10d6d Further const correctness / String by reference passing cleanups (#6571)
There are actually several instances where we pass in read-only
parameters as pass-by-value, where in the case of String() that
is inefficient as it involves copy-constructor/temp string creations.

We can avoid that, similarly to single character string concatenations
done via string literals instead of char literals.
2019-10-31 16:02:39 +01:00
James Marlowe
ba971fe7e9 POST web server example (#2705)
* POST web server example

Should help with the confusion around the plain keyword

* Update WiFi settings vars, use LED_BUILTIN
2019-10-31 14:47:47 +01:00
Earle F. Philhower, III
72dd589599 Add time to filesystem API (#6544)
* Add time to filesystem API

Support the ESP32 File::getLastWrite() call and setting the time on
all filesystems automatically (assuming the system clock has
been set properly and time(NULL) returns the proper time!).

Adds Dir::fileTime() to get the time of a file being listed, similar to
Dir::fileName() and Dir::fileSize().

Adds ::setTimeCallback(time_t (*cb)()) to File, Dir, and FS, allowing
users to override the default timestamp on a per-file, directory, or
filesystem basis. By default, a simple callback returning time(nullptr)
is implemented.

LittleFS uses the 't' attribute and should be backwards compatible.

SD/SDFS work and include wrappers for obsolete SdFat timestamp callbacks
using the MSDOS time.

This PR does not update SPIFFS, due to compatability concerns and a
possible massive rewrite which would make it possible to determine if an
old-style ot metadata enabled FS is present at mount time.

Includes an updated SD/listfiles and LittleFS_time example.

Replaces #6315

* Add links to new mklittlefs w/timestamp support

Include the update mklittlefs which generated 't' metadata on imported
files.
	../tools/sdk/lwip2/include/netif/lowpan6_opts.h

* Add explicit note about timestamp being local time

* Address review concerns

Clean up some awkward object instantiations.

Remove the _enableTime flag/setter from SPIFFS.

Clean up the FSConfig constructors using C++ style init lists.
2019-10-31 14:09:52 +01:00