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

66 Commits

Author SHA1 Message Date
drhideg
d92e1edac8
Basic authentication with ESP8266httpUpdate (#7190)
Add ability to use basic access authentication with ESP8266httpUpdate
2020-07-30 08:55:29 -07:00
Earle F. Philhower, III
83166f948b
Deprecate SPIFFS, move examples to LittleFS (#7263)
* Deprecate SPIFFS, move examples to LittleFS

SPIFFS has been a great filesystem, but it has significant problems in
many cases (and it's also pretty slow).  Development seems to have
slowed/stopped on the upstream version, and we're not able to provide
support or fix the known issues with it as-is.

Deprecate SPIFFS variable.

Update all examples to use LittleFS instead of SPIFFS.

Also, minor cleanup on very old examples which has obsolete delays
waiting for the Serial port to come up, or which were stuck at 9600 baud
because of their ancient AVR heritage.

Fixes #7095

* Remove leftover debug code

* Clean up comments in some examples

* Update documentation on SPIFFS deprecation

* Fix host tests to avoid deprecation warnings

* Fix cut-n-paste error

* Restore SpeedTest.ino, adjust to allow custom FSes

Co-authored-by: Develo <deveyes@gmail.com>
2020-05-04 14:22:50 -04:00
Patryk (PsychoX) Ludwikowski
d91f1dac36
Better follow redirection for HTTPClient (#7157)
* Add way to force follow redirections in `HTTPClient`

* Follow other client implementations about `HTTP_CODE_FOUND`; Small rewrite of `sendRequest` function of `HTTPClient`

* Better names for follow redirection modes in `HTTPClient`

Also changed a bit order of the enums (0 element to be DISABLED)

* Rewrite `sendRequest` to remove recursion

Also got rid of unnecessary `redirectCount` field. Now redirect counting and limiting is handled in `sendRequest` directly.

* Use new `setFollowRedirects` of `HTTPClient` instead deprecated one.

* More explanatory comment for `followRedirects_t` in HTTPClient
2020-03-25 23:33:54 +01:00
Tim Stableford
16319da63d
Resolved issue #3359 (#6969)
* Resolved issue #3359

Made severing connections optional as per the patch
in the issue.
Also fixed a minor spacing issue.

* Renamed sever to close and added information to readme

Also my editor automatically removed some odd whitespace at the
end of a few lines.
2020-02-22 16:30:17 -08: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
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
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
Robin Richtsfeld
45d71ae4bd Support FS update in two steps (#6505)
* Support FS update in two steps
2019-10-16 10:11:15 +02:00
Dirk Mueller
8b16d9c1d1 Fix build with -DHTTPCLIENT_1_1_COMPATIBLE=0 (#6597)
We need to disable HTTPUPDATE_1_2 support when HTTPCLIENT_1_1
compatibility is not desired to avoid using methods that are
disabled.
2019-10-07 16:57:18 -07:00
c0degeek
d4897cd216 Added Chip ID into HTTP header (#3877) 2019-10-05 11:28:33 -07:00
Earle F. Philhower, III
8859b818d8
Make CertStore natively use File interface (#6131)
__This is a breaking change, but the header and example did warn
everyone that this API was in flux due to the incompatible SD and SPIFFS
File implementations.__

BearSSL CertStores now simply need a filesystem and the names of the
data (generated on-chip) and archive (uploaded by user) files on it.
No more need to roll your own virtual CertStoreFile class.

Update the library, examples, and device test.
2019-05-30 12:53:03 -07:00
Earle F. Philhower, III
a389a995fb Add LittleFS as an optional filesystem, API compatible w/SPIFFS (but not on-flash-format compatible) (#5511)
* Add LittleFS as internal flash filesystem

Adds a LittleFS object which uses the ARMmbed littlefs embedded filesystem,
https://github.com/ARMmbed/littlefs, to enable a new filesystem for onboard
flash utilizing the exact same API as the existing SPIFFS filesystem.

LittleFS is built for low memory systems that are subject to random power
losses, is actively supported by the ARMmbed community, supports directories,
and seems to be much faster in the large-ish read-mostly applications I use.

LittleFS, however, has a larger minimum file allocation unit and does not do
static wear levelling.  This means that for systems that need many little
files (<4K), have small SPIFFS areas (64K), or which have a large static
set of files covering the majority of flash coupled with a frequently
updated set of other files, it may not perform as well.

Simply replace SPIFFS.begin() with LittleFS.begin() in your sketch,
use LittleFS.open in place of SPIFFS.open to open files, and everything
else just works thanks to the magic of @igrr's File base class.

**LITTLEFS FLASH LAYOUT IS INCOMPATIBLE WITH SPIFFS**
Since it is a completely different filesystem, you will need to reformat
your flash (and lose any data therein) to use it. Tools to build the
flash filesystem and upload are at
https://github.com/earlephilhower/arduino-esp8266littlefs-plugin and
https://github.com/earlephilhower/mklittlefs/ .  The mklittlefs tool
is installed as part of the Arduino platform installation, automatically.

The included example shows a contrived read-mostly example and
demonstrates how the same calls work on either SPIFFS.* or LittleFS.*
Host tests are also included as part of CI.

Directories are fully supported in LittleFS. This means that LittleFS
will have a slight difference vs. SPIFFS when you use
LittleFS.openDir()/Dir.next().  On SPIFFS dir.next()
will return all filesystem entries, including ones in "subdirs"
(because in SPIFFS there are no subdirs and "/" is the same as any
other character in a filename).

On LittleFS, dir.next() will only return entries in the directory
specified, not subdirs.  So to list files in "/subdir/..." you need
to actually openDir("/subdir") and use Dir.next() to parse through
just those elements.  The returned filenames also only have the
filename returned, not full paths.  So on a FS with "/a/1", "/a/2"
when you do openDir("/a"); dir.next().getName(); you get "1" and "2"
and not "/a/1" and "/a/2" like in SPIFFS.  This is consistent with
POSIX ideas about reading directories and more natural for a FS.

Most code will not be affected by this, but if you depend on
openDir/Dir.next() you need to be aware of it.

Corresponding ::mkdir, ::rmdir, ::isDirectory, ::isFile,
::openNextFile, and ::rewind methods added to Filesystem objects.
Documentation has been updated with this and other LittleFS information.

Subdirectories are made silently when they do not exist when you
try and create a file in a subdir.  They are silently removed when
the last file in them is deleted.  This is consistent with what
SPIFFS does but is obviously not normal POSIX behavior.  Since there
has never been a "FS.mkdir()" method this is the only way to be
compatible with legacy SPIFFS code.

SPIFFS code has been refactored to pull out common flash_hal_* ops
and placed in its own namespace, like LittleFS.

* Fix up merge blank line issue

* Merge in the FSConfig changs from SDFS PR

Enable setConfig for LittleFS as well plys merge the SPIFFS changes
done in the SDFS PR.

* Fix merge errors

* Update to use v2-alpha branch

The V2-alpha branch supports small file optimizations which can help
increase the utilization of flash when small files are prevalent.
It also adds support for metadata, which means we can start adding
things like file creation times, if desired (not yet).

* V2 of littlefs is now in upstream/master

* Update test to support non-creation-ordered files

In a directory, the order in which "readNextFile()" will return a name
is undefined.  SPIFFS may return it in order, but LittleFS does not as
of V2.  Update the test to look for files by name when doing
readNextFile() testing.

* Fix LittleFS.truncate implementation

* Fix SDFS tests

SDFS, SPIFFS, and LittleFS now all share the same common set of tests,
greatly increasing the SDFS test coverage.

* Update to point to mklittlefs v2

Upgrade mklittlefs to V2 format support

* Remove extra FS::write(const char *s) method

This was removed in #5861 and erroneously re-introduced here.

* Minimize spurious differences from master

* Dramatically reduce memory usage

Reduce the program and read chunk sizes which impacts performance
minimally but reduces per-file RAM usage of 16KB to <1KB.

* Add @d-a-v's host emulation for LittleFS

* Fix SW Serial library version

* Fix free space reporting

Thanks to @TD-er for discovering the issue

* Update littlefs to latest upstream

* Remove sdfat version included by accident

* Update SDFAT to include MOCK changes required

* Update to include SD.h test of file append
2019-05-25 09:53:24 +02:00
Allman-astyler
eea9999dc5 Revert "Allman now (#6080)" (#6090)
This reverts commit 98125f88605cd7e46e9be4e1b3ad0600dd5d2b51.
2019-05-14 00:09:54 +02:00
Allman-astyler
98125f8860 Allman now (#6080)
* switch restyle script for CI

* remove confirmation

* restyle with allman
2019-05-13 16:41:34 +02:00
david gauchard
e5b4de3633
fix DEBUG macros (#5728)
* fix DEBUG macros

All fmt strings in flash
fix #5658

This also allows to avoid warnings and easy mistakes with (no brace):
    if (something)
        DEBUGV("blah");

* use newlib unaligned-compatible printf for DEBUGV

* remove useless putprintf since ::printf already uses ets_putc
2019-03-14 11:19:21 +01:00
liebman
e46ccae9d5 optionally allow redirects on HTTPClient & OTA updates (#5009)
* optionally allow redirects on http OTA updates

* Refactored HTTPClient::begin(url...) & setURL functions, now only beginInternal parses URL, sets ports
Added HTTPRedirect example.

* fix indentation for style check

* add space after while for style check

* don't use deprecated begin method in redirect example

* moved redirect handling code to HTTPClient.
only GET and HEAD requests are currently handled automatically
Redirects that fail to be automatically handled return the redirect code as before

* added support for POST/303 redirect
added device redirect tests

* add missing getLocation() implementation

* if the new location is only a path then only update the URI
2019-03-13 01:51:17 +01:00
david gauchard
50cbdc0b92 update AddrList and examples (#5422) 2018-12-03 15:15:50 -03:00
Earle F. Philhower, III
d8acfffdb0
Add cryptographically signed update support (#5213)
Using a pluggable architecture, allow updates delivered via the Update
class to be verified as signed by a certificate.  By using plugins, avoid
pulling either axTLS or BearSSL into normal builds.

A signature is appended to a binary image, followed by the size of the
signature as a 32-bit int.  The updater takes a verification function
and checks this signature using whatever method it chooses, and if it
fails the update is not applied.

A SHA256 hash class is presently implemented for the signing hash (since
MD5 is a busted algorithm).

A BearSSLPublicKey based verifier is implemented for RSA keys.  The
application only needs the Public Key, while to sign you can use
OpenSSL and your private key (which should never leave your control
or be deployed on any endpoints).

An example using automatic signing is included.

Update the docs to show the signing steps and how to use it in the
automatic and manual modes.

Also remove one debugging line from the signing tool.

Saves ~600 bytes when in debug mode by moving strings to PMEM

Windows can't run the signing script, nor does it normally have OpenSSL
installed.  When trying to build an automatically signed binary, warn
and don't run the python.
2018-12-02 19:57:47 -08:00
david gauchard
92373a9837 Deprecate axTLS, update examples (#5366)
* update examples

* fix serial<->tcp example, use STASSID instead of SSID (name collision)

* fix HTTPSRequest.ino

* update AxTLS HTTPS examples, update AxTLS API to deprecated

* fixes

* fixes + fix astyle (no preproc directives) + restyling script

* fix HTTPClient library

* fixes

* common.sh: do not reload arduino when already present (for locally CI testing)

* common.sh: do not reload ArduinoJson when already present (for locally CI testing)

* fix

* fix

* fix deprecated example

* fix WiFiHTTPSServer.ino

* reduce footprint

* wipfix

* fix led builtin

* fix example

* finished updating APSSID on all examples

* style

* restyle examples

* helper to run CI test locally

* local CI runner more verbose

* +const

* deprecation deprecation

* deprecation

* Update NTPClient.ino

const char[] => const char *

* Update interactive.ino

const char[] => const char *
2018-11-29 20:49:27 -08:00
Jeroen88
13f374666d Add WiFiClient parameter to HTTPClient (#4980)
Make HTTPClient take a WiFiClient parameter, allowing you to pass in a
simple HTTP WiFiClient or a BearSSL or axTLS WiFiClientSecure with
any desired verification options.  Deprecate the older, TLSTraits methods.
Add basic HttpsClient example.

Add optional LED feedback to the Update class
2018-10-06 07:50:03 -07:00
per1234
4e3af9795b Add missing keywords.txt files to bundled libraries (#5183) 2018-09-29 10:48:23 -07:00
david gauchard
85e68093e9
Automatic stack location selection (SYS or HEAP), enable per library AR-chive in arduino build system (#5018)
Automatic stack location selection (SYS or HEAP), enable per library AR-chive in arduino build system 

* enable dot_a_linkage on internal libraries
* add device tests
* boards generator: deprecate --noextra4k/--allowWPS and fix documentation
2018-08-20 14:35:52 +02:00
klucsik
b126a9c526 https fingerprint clue (#4863)
Adding a clue on the https part that yo will definitely need the fingerprint. 
(My first commit)
2018-07-03 00:40:50 -04:00
Earle F. Philhower, III
e3c970210f
Add BearSSL client and server, support true bidir, lower memory, modern SSL (#4273)
BearSSL (https://www.bearssl.org) is a TLS(SSL) library written by
Thomas Pornin that is optimized for lower-memory embedded systems
like the ESP8266. It supports a wide variety of modern ciphers and
is unique in that it doesn't perform any memory allocations during
operation (which is the unfortunate bane of the current axTLS).

BearSSL is also absolutely focused on security and by default performs
all its security checks on x.509 certificates during the connection
phase (but if you want to be insecure and dangerous, that's possible
too).

While it does support unidirectional SSL buffers, like axTLS,
as implemented the ESP8266 wrappers only support bidirectional
buffers. These bidirectional buffers avoid deadlocks in protocols
which don't have well separated receive and transmit periods.

This patch adds several classes which allow connecting to TLS servers
using this library in almost the same way as axTLS:
BearSSL::WiFiClientSecure - WiFiClient that supports TLS
BearSSL::WiFiServerSecure - WiFiServer supporting TLS and client certs

It also introduces objects for PEM/DER encoded keys and certificates:
BearSSLX509List - x.509 Certificate (list) for general use
BearSSLPrivateKey - RSA or EC private key
BearSSLPublicKey - RSA or EC public key (i.e. from a public website)

Finally, it adds a Certificate Authority store object which lets
BearSSL access a set of trusted CA certificates on SPIFFS to allow it
to verify the identity of any remote site on the Internet, without
requiring RAM except for the single matching certificate.
CertStoreSPIFFSBearSSL - Certificate store utility

Client certificates are supported for the BearSSL::WiFiClientSecure, and
what's more the BearSSL::WiFiServerSecure can also *require* remote clients
to have a trusted certificate signed by a specific CA (or yourself with
self-signing CAs).

Maximum Fragment Length Negotiation probing and usage are supported, but
be aware that most sites on the Internet don't support it yet.  When
available, you can reduce the memory footprint of the SSL client or server
dramatically (i.e. down to 2-8KB vs. the ~22KB required for a full 16K
receive fragment and 512b send fragment).  You can also manually set a
smaller fragment size and guarantee at your protocol level all data will
fit within it.

Examples are included to show the usage of these new features.

axTLS has been moved to its own namespace, "axtls".  A default "using"
clause allows existing apps to run using axTLS without any changes.

The BearSSL::WiFi{client,server}Secure implements the axTLS
client/server API which lets many end user applications take advantage
of BearSSL with few or no changes.

The BearSSL static library used presently is stored at
https://github.com/earlephilhower/bearssl-esp8266 and can be built
using the standard ESP8266 toolchain.
2018-05-14 20:46:47 -07:00
Marian Craciunescu
bd87970aae add http client configurable timeout usefull when download is slow on server side (#4705)
* add http client configurable timeout usefull when download is slow from server side

* member init outside constructor body.

* removed this.
2018-05-04 11:18:15 -03:00
Ivan Grokhotkov
61cd8d8385 examples: format all .ino files
This formats all the example source files using Arduino style rules.
2018-03-08 14:32:06 +08:00
liebman
1cd4a00cff Remove compiler warnings (#4043) 2017-12-29 13:14:56 -03:00
Joey Babcock
a71118caeb Improve error messages (#2800)
I was having trouble understanding what some of the serial output meant so I changed it to the best of my ability
2017-12-29 11:49:29 -03:00
James Stanley
2abbc36da4 Put WiFi into station mode in examples (#3731) 2017-10-22 13:53:01 +08:00
Clemens Kirchgatterer
18297458be allows global object instances be switch off with defines (#2344) 2016-08-01 11:21:50 +08:00
sk1tt1sh
9c36ff9932 Fix example for ESP8266httpUpdate (#2251)
* Fix minor typo in spelling of failed. Removed s from http paths.

* add check if we are just updating spiffs to not reboot. example now works with this change.
2016-07-18 19:33:34 +08:00
Jeroen Vogelpoel
edba2d2829 Exposed sketch MD5 through HTTP headers (#2236)
* Exposed sketch MD5 through HTTP headers

* Updated spacing, docs, example
2016-07-08 10:07:21 +08:00
Andronicus Riyono
46fccac3e5 fix bug #1940 2016-04-20 14:09:41 +08:00
Ivan Grokhotkov
a455f22587 HTTPClient, HTTPUpdate: save some RAM by moving strings into flash 2016-04-09 12:46:29 +03:00
Ivan Grokhotkov
bf7f33d918 Fix code formatting 2016-04-09 12:46:29 +03:00
Ivan Grokhotkov
bbc5e9ba01 Update library versions 2016-04-09 12:46:29 +03:00
Ivan Grokhotkov
c450023a32 ESP8266httpUpdate: decouple HTTPS overloads 2016-04-09 12:46:29 +03:00
Markus Sattler
b2a6ab8059 #1499 2016-01-25 21:05:24 +01:00
Markus Sattler
2b23b005aa allow control of enabling debug and debug level from IDE 2016-01-02 12:25:39 +01:00
Markus Sattler
ef748e369a allow downgrade to HTTP 1.0
use HTTP/1.0 for update since the update handler not support any transfer Encoding
2015-12-31 14:02:00 +01:00
Markus Sattler
5a4ced251d add check for magic header of bin before update is started.
see: #1250
2015-12-19 14:39:07 +01:00
Markus Sattler
02e6b2fc16 setMD5 has now returns bool
handle setMD5 failed in HTTP update
reset UpdaterClass when MD5 check failed
see: #1244
2015-12-18 08:30:35 +01:00
Markus Sattler
28dd31a80f add advanced error handling for HTTP update
see: #1111
2015-12-16 23:05:23 +01:00
Markus Sattler
4dd5d8cf7d allow control of restart on http update
#1202
2015-12-13 23:04:27 +01:00
Markus Sattler
fdadadc787 add default values for updateSpiffs 2015-12-10 12:03:53 +01:00
Markus Sattler
95089b75b9 fix startUpdate always false 2015-12-09 19:56:14 +01:00
Markus Sattler
b1ea7b602e httpUpdate Improve error handling 2015-12-09 16:27:04 +01:00
Markus Sattler
d8e3c766a3 ESP8266HTTPUpdate - improve error displaying 2015-12-06 11:07:25 +01:00
Markus Sattler
95d53c37c3 add httpUpdateSPIFFS.ino example 2015-12-05 20:47:58 +01:00
Markus Sattler
ecce35d240 allow SPIFFS 2015-12-05 20:33:08 +01:00