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

521 Commits

Author SHA1 Message Date
david gauchard
1750022601
fix switching to static address with lwip2 (#6026)
fix switching to static address with lwip2

For some reason, ip address is not propagated in a visible way for lwip2
when switching to static address (wifi.config()) *after* wifi.begin().

This patch calls lwip-v1.4's netif_set_addr() with the new ip address to set
all things up, just like it is done and right when wifi.begin() is called
after wifi.config().

Also tested when IPv6 is enabled.

fix documentation: It is more natural to set an IP address before starting WiFi
(.. and not after dhcp has started)
fixes #5839
fixes #6024
2019-05-01 12:35:03 +02:00
david gauchard
cdb549572d
restore proper arduino Client:: & Wire:: API (#5969) 2019-04-26 22:05:46 +02:00
david gauchard
5dd780c571
udp: restore correct address/port when parsing packet (#6011)
do interleave informations on addresses within reception pbuf chain:
before: (data-pbuf) -> (data-pbuf) -> (data-pbuf) -> ... in the receiving order
now: (address+port-info-pbuf -> data-pbuf) -> (address_port-info-pbuf -> data-pbuf) -> ...

address/port informations are updated along with data exposed to user
2019-04-26 20:09:23 +02:00
Earle F. Philhower, III
f6dd826437
Fix MFLN probe and allow returning whether MFLN succeeded or not after a connection. (#6000)
Fixes #5996

* Add extensions to probe message for EC, others

probeMFLN was failing on some connection attempts to servers which only
supported EC based ciphers because it did not include the proper TLS
handshake extensions to list what kinds of ECs it supported.

Add those to the probeMFLN ClientHello message to make probes pass.

* Add client.getMFLNStatus method, returns MFLN state

After a connection it is useful to check whether MFLN negotiation
succeeded.  getMFLNStatus returns a bool (valid only after
client.connect() succeeds, of course) indicating whether the requested
buffer sizes were negotiated successfully.
2019-04-25 12:40:26 -07:00
Earle F. Philhower, III
d9b0480f09
New menu option to minimize BSSL ROM with only RSA (#6006)
* New menu option to minimize BSSL ROM with only RSA

Adds a menu option and define to limit BearSSL to older RSA connection
options.  This saves ~45K program memory and can speed up connections
since EC, while more secure, is significantly slower on the chip.
The supported ciphers are identical to the ones that axTLS supported.

Fixes #6005

* Add default SSLFLAGS(blank) to platform.txt

* Fix unused variable warning

* Add clarifying comment to menu items
2019-04-25 11:13:26 -07:00
Jeroen88
667816ebe0 BearSSL Max Fragment Length Negotation and Node.js server (#5929)
* Minor bug fixes in Maximum Fragment Length Negotation example, mainly giving background processes some time in fetch()

* Minor layout changes to pass travis tests

* Use PolledTimeout for timeout
2019-04-11 14:21:04 +02:00
david gauchard
9a2ed274f3 polledTimeout: add option to use CPU count instead of millis() (#5870)
* polledTimeout: add option to use CPU count instead of millis()

* use more "using" alias

* more c++/clear code, using typename (thanks @devyte)

* rename class name to include unit, introduce timeMax() and check it with assert()

* remove useless defines

* improve api readability, add micro-second unit

* update example

* mock: emulate getCycleCount, add/fix polledTimeout CI test

* + nano-seconds, assert -> message, comments, host test

* allow 0 for timeout (enables immediate timeout, fix division by 0)

* typo, set member instead of local variable

* unify error message

* slight change on checkExpired() allows "never expired"
also removed printed message, add YieldAndDelay, simplify calculations

* remove traces of debug.h/cpp in this PR

* include missing <limits> header

* back to original expired test, introduce boolean _neverExpires, fix reset(), getTimeout() is invalid

* fix expiredOneShot with _timeout==0 check

* reenable getTimeout()

* expose checkExpired with unit conversion

* fix timing comments, move critical code to iram

* add member ::neverExpires and use it where relevant

* improve clarity

* remove exposed checkExpired(), adapt LEAmDNS with equivalent

* add API ::resetToNeverExpires(), use it in LEAmDNS

* remove offending constness from ::flagged() LEAmDNS (due do API fix in PolledTimeout)

* simplify "Fast" base classes

* minor variable rename

* Fix examples

* compliance with good c++ manners

* minor changes for consistency

* add missing const

* expired() and bool() moved to iram

* constexpr compensation computing

* add/update comments

* move neverExpires and alwaysExpired
2019-04-05 10:50:53 -03:00
david gauchard
f0eb5509a0
use static_assert to check on fw structure changes over updates (fix) (#5946) 2019-04-03 23:17:09 +02:00
david gauchard
ca79f2ce39
use static_assert to check on fw structure changes over updates (#5939) 2019-04-02 00:44:27 +02:00
Evgeny Dontsov
68c0a1cc9e sta_config_equal (#5937)
* sta_config_equal

* sta_config_equal bug update
2019-04-01 15:38:09 -03:00
david gauchard
2e75e88c49
bugfix: restore WiFi::setSleepMode functionality with sdk-2.2.x (#5919) 2019-03-26 14:07:49 +01:00
Jiri Bilek
64e30b270b Fix the changed structure of the input file (#5891)
The input file containing certificates has changed.
2019-03-18 15:15:59 -07:00
Earle F. Philhower, III
68bcc41429 Fix SSID reporting for 32-char SSIDs (#5889)
Fixes 5853
2019-03-17 23:06:41 -03:00
david gauchard
a3ea816e65
add optional espressif fw nonos-sdk 2.2.x (19.03.13) (#5873) 2019-03-14 13:35:26 +01: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
Thomas Friedrichsmeier
071eeb8b67 Allow to disable DHCP gateway offer when set up of AP. (#4421) 2019-03-13 00:28:41 +01:00
Earle F. Philhower, III
95cf925719
Add OOM check and debug message in CertStore (#5820)
Fixes #5819
2019-02-26 02:46:25 +00:00
david gauchard
7745e99046
Revert to nonos-sdk 2.2.1, new sdk-switching option in IDE menu for generic board only (#5763)
This commit allows switching SDK firmware:

nonos-sdk-pre-v3 shipped with release 2.5.0 has issues:

    * Some boards show erratic behavior (radio connection is quickly lost), with an unknown cause.
      These boards work well with previous nonos-sdk-2.2.1 firmware (#5736)

    * Overall performances seem to have decreased (#5513)

This PR restores sdk2.2.1 (as in core-2.4.2).

SDK-pre-3.0 - which has brought long awaited fixes (WiFi sleep modes) - is still available through a menu option available only with generic board.

BREAKING

    * new define `-DNONOSDK221=1` or `-DNONOSDK3V0=1`

    * for external build systems: new library directory: `tools/sdk/lib/<version>/lib`

    * PIO: variable `PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3` is needed for sdk-pre-v3.


Fix #5736
2019-02-19 13:10:49 +01:00
david gauchard
6c5269a74b
fix UdpContext::(connect,listen) signature by using IPAddress (#5742)
* fix UdpContext::listen signature by using IPAddress
* fix UdpContext::connect signature by using IPAddress
  by courtesy of @AlfredLamoule
2019-02-11 13:46:40 +01:00
david gauchard
1959311180
UdpContext::setMulticastInterface(): fix for IPv6 (#5743)
Per 'udp_set_multicast_netif_addr()' signature and comments in lwIP sources:
An IPv4 address designating a specific interface must be used.
When an IPv6 address is given, the matching IPv4 in the same interface must be selected.

fix e3bc3c226b (r32235572)
2019-02-08 15:23:08 +01:00
Earle F. Philhower, III
d2a8e8acc2
Add debug messages on BSSL errors (#5723)
Add debugging output when DEBUG_ESP_SSL is defined.
Add dump of actual error when connect fails
2019-02-07 05:18:31 +00:00
Earle F. Philhower, III
56268b166d
Fix memory related issues w/BearSSL server/client (#5706)
Because the constructors of the BSSL client and server add a reference
count to the stack_thunk, if there is no copy constructor defined then
the stack thunk reference count can get out of sync causing the stack
thunk memory to be freed while still in use.  That could cause random
crashes or hangs.

Add a very basic copy constructor to the WiFiClientSecure and
WiFiServerSecure objects, using the default operator= to duplicate
simple types and shared_ptr classes.

The _cipher_list element (used only w/custom ciphers) could be freed
while still in use if copies of the WiFiClientSecure object were made.

Use a shared_ptr which will only free when the last reference is
deleted.

The axTLS compatibility mode calls allocate and store elements needed
for SSL connections (unlike normal BearSSL calls).  These elements could
be freed mistakenly while still in use if copies of the WiFiClientSecure
were made by the app.

Convert to a separately managed shared_ptr to ensure they live as long
as any referencing objects before deletion.

Same done for the axTLS compatability for WiFiServerSecure.
2019-02-02 18:09:19 +00:00
david gauchard
1cacf92ce1 stop lwIP dhcp client when WiFi goes off. (#5703)
* stop lwIP dhcp client with WiFi goes off.

* stop dhcp-client when really unused
2019-02-01 14:33:26 -03:00
Earle F. Philhower, III
3f8cd46dc2
Fix BearSSL Server WDT (#5702)
Fixes #5701 WDTs and other issues with BearSSL::WiFiServerSecure

The BSSL server was creating the client it returns on a connection in a
way that caused the counter for the stack_thunk to get out of sync and
cause it to be freed improperly by having the destructor be called one
more time than the constructor.  Looks like RVO.

Rewrite the ::available() function in order to avoid this issue with
help from @devyte.
2019-02-01 06:47:42 +00:00
david gauchard
f42bfdfc0d
adaptations for lwIP-v1.4 (#5682)
* adaptations for lwIP-v1.4
* add lwIP-v1.4 in CI
2019-01-28 22:31:59 +01:00
SmartBlug
5e4c2e9750 Add capability to have light static DHCP lease (#5594)
* Add capability to have light static DHCP lease

* added ESP8266WiFi StaticLease sample

* Update StaticLease to IPv4
2019-01-25 02:25:04 +00:00
david gauchard
7c5be91430 dynamic WiFi.hostname("newname") (#5652)
* dynamic WiFi.hostname("newname")

* WiFi.hostname() back to String return type

* no silent hostname fix but proceed with debug message and returning false
2019-01-24 17:13:20 -03:00
liebman
049a9eaa5b decorate as override virtual methods in WiFiUDP (#5637)
make WiFiUDP destructor virtual
add empty virtual destructor to Udp
2019-01-20 00:34:21 +01:00
david gauchard
b666435282 WiFiClient::remoteIP: fix nullptr crash (#5634) 2019-01-18 22:08:32 -03:00
david gauchard
cac22e3576
fix dhcp6 in upstream lwIP (#5560) 2018-12-27 19:29:04 +01:00
david gauchard
e3bc3c226b
Fixes for IPv6, added in CI (#5557) 2018-12-27 16:13:48 +01:00
david gauchard
da7ffdaa28
add 1 more IPAddress constructor for IPv6 (#5551) 2018-12-26 15:01:48 +01:00
dav1901
dd6333ee8b Add support for String args to softAP and begin (#5295) 2018-12-22 22:48:31 -03:00
acevest
34e90f3c56 fix bug. in sta mode, empty passphrase should not use secure auth mode (#5516)
* in sta mode, empty passphrase should not use secure auth mode

* use nullptr, camelCase and parenthesis
2018-12-18 10:47:25 -03:00
david gauchard
f8f4b81d60 better compatibility for IPAddress changes with external libraries (#5438) 2018-12-04 23:32:24 -03:00
david gauchard
216680bb57 weak hook preinit() #2111 #2133 #2136 (#5395)
* weak hook early_setup() #2111 #2133 #2136

* rename to early_init (more "c" vs early_setup which is more "c++arduino")

* example

* improve earlyWiFi example, slightly change AddrList interface, move WiFi sketches into WiFi examples

* fix CI

* fix local CI runner

* fix local CI runner

* rename early_init() to preinit()

* + static ESP8266WiFiClass::preinit_wifi_off()

* update early disable wifi example

* example update

* IPv6 example update

* Update ESP8266WiFiGeneric.h

camelCase for static method name

* Update ESP8266WiFiGeneric.cpp

camelCase for static method name

* Update EarlyDisableWiFi.ino

Expand comment, fix static method name

* Update core_esp8266_main.cpp

Expanded comment.

* Update core_esp8266_main.cpp

Expanded comment

* Update EarlyDisableWiFi.ino

Expanded comment
2018-12-03 20:54:27 -08:00
david gauchard
50cbdc0b92 update AddrList and examples (#5422) 2018-12-03 15:15:50 -03:00
Develo
4941711505 Implement for ssid a similar approach as for passphrase (#5411)
* Implement for ssid a similar approach as for passphrase

* Additional fixes for 32-char ssid
2018-12-02 21:25:13 -08: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
773f306ef9 more compatibility fixes to IPAddress, restore INADDR_ANY, INADDR_NONE (#5416) 2018-12-02 22:43:19 -03: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
Earle F. Philhower, III
9ec03ed3f6
Move WiFi debug messages to PMEM (#5388)
Save ~1200 bytes in debug mode by making debug strings into PSTRs().
2018-11-29 12:55:40 -08:00
Earle F. Philhower, III
e7d3cf62b6
Don't clear authentication options on a ::stop (#5386)
Many objects now expect a WiFiClient* object to be passed to them and
potentially re-used multiple times (HTTPClient, others).  Clearing the
authentication options on a ::stop means they can never reconnect.

Remove the option clearing in ::stop

Fixes #5379
2018-11-28 16:12:01 -08:00
dav1901
5fcb8f1dac Check if AP exists before adding it (#5373) 2018-11-27 22:01:15 -03:00
david gauchard
5c4db3acf4
IPv6 on esp8266-nonos-sdk and arduino (#5136) 2018-11-27 23:07:47 +01:00
dav1901
cd05bae0e8 Pass string objects by reference (#5378) 2018-11-25 11:18:44 -03:00
Earle F. Philhower, III
19a0a0b6fd
Remove obsolete BSSL debug print routines (#5368)
Fixes #5356
2018-11-23 12:08:40 -08:00
dav1901
5d573652e4 Check for WEP when setting authmode (#5364)
* check if wep is enabled when setting authmode

* add requested changes
2018-11-22 18:19:37 -02:00
david gauchard
74ca42f829 Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples'

* WIP bufferize tcp input

* WIP Makefile

* WIP network to rework, tcp/udp to factorize, udp addresses broken

* minor changes to the core

* WIP basic udp working

* WIP mdns

* WIP mcast receiving, not sending

* WIP mdns OK

* beta version

* SSL + doc

* update travis host test command

* licenses

* typo

* doc: arduino builder is not around: declare functions before calling them

* fix with latest SSL PR, compile in 32 bits mode

* fix make clean

* make -m32 optional

* 32bits compiler ability tester

* WIP

* WIP (fix 1 vtable error, still another one to hunt with using spiffs)

* example astyle

* fix os_printf_plus

* load / save mock spiffs

* fix style

* fix using spiffs/mock

* don't mess ram

* update doc

* remove leftover

* optimization -Os except for CI, rename ARCH32 to FORCE32

* revert useless cast (not even compiled)

* remove unused function

* use proper type for pointer arithmetics

* makefile: sketch object and cpp file moved to bin/ directories
easier to clean, and IDE don't like them

* changes for review

* make use of %zd

* less verbose makefile by default (option)

* update readme
2018-11-20 18:51:45 -02:00
Earle F. Philhower, III
2f4380777e Move BearSSL from STACK_PROXY to a real, thunked 2nd stack (#5168)
* Update to BearSSL 0.6+ release, add AES_CCM modes

Pull in latest BearSSL head (0.6 + minor additions) release and add AES_CCM
modes to the encryption options.

* Enable the aes_ccm initialization in client/server

* Initial attempt

* Working code with second stack thunking

* Remove #ifdefs in .S file, not needed.

* Clean up thunks and remove separate stack flag

* Fix PIO assembler errors

* Remove #ifdef code changes, ensure same code as PC

Remove "#ifdef ESP8266;...;#else;...;#endif" brackets in BearSSL to
ensure the host-tested code is the same as the ESP8266-run code.

* Move to latest BearSSL w/EC progmem savings

* Merge with master

* Add br_thunk_* calls to do ref counting, painting

Add reference counting br_thunk_add/del_ref() to replace stack handling code
in the class.

Add in stack painting and max usage calculation.

* Add in postmortem stack dump hooks

When a crash occurs while in the second stack, dump the BSSL stack and
then also the stack that it was called from (either cont or sys).

* Update stack dump to match decoder expectations

* Move thunk to code core for linkiage

The thunk code needs to be visible to the core routines, so move it to the
cores/esp8266 directory.  Probably need to refactor the stack setup and the
bearssl portion to avoid dependency on bearssl libs in cores/esp8266

* Add 2nd stack dump utility routine

* Refactor once more, update stack size, add stress

Make stack_thunks generic, remove bearssl include inside of cores/esp8266.

Allocate the stack on a WiFiServerSecure object creation to avoid
fragmentation since we will need to allocate the stack to do any
connected work, anyway.

A stress test is now included which checks the total BearSSL second
stack usage for a variety of TLS handshake and certificate options
from badssl.org.

* Update to latest to-thunks branch

* Add BearSSL device test using stack stress

Run a series of SSL connection and transmission tests that stress
BearSSL and its stack usage to the device tests.

Modify device tests to include a possible SPIFFS generation and
upload when a make_spiffs.py file is present in a test directory.

* Use bearssl/master branch, not /to-thunks branch

Update to use the merged master branch of bearssl.  Should have no code
changes.
2018-11-14 23:29:24 -03:00