1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-25 20:02:37 +03:00

622 Commits

Author SHA1 Message Date
Max Prokhorov
b7c1cfbc45
DHCP custom option (#8582)
* works

* fixup! works

* back to callbacks

* names

* daisy chain

* seconds

* less inline

* fix dns setter

* might as well keep using initlist

/to d-a-v it has automatic storage, here it's the same stack based one
(just one less line for us)

* shift blame

* naming

* fix impl

* revert to ip4 dns

* merge fix

* restyle

* masking done wrong
2022-06-08 23:19:59 +02:00
Max Prokhorov
502d9469fa
Initialize SoftAP DhcpServer object on demand (#8546)
* Initialize SoftAP DhcpServer object on demand

Remove dependency on global ctor, and just construct the object when
someone asks us to do it. Only dependency right now is netif_git, which
is expected to be initialized by the lwip code some time before
dhcps_start happens.

Removing ip_info from begin(), since we never reference later on.
Also removing the specific check for netif id and simplify the ctors.

Update tests and recover old nonos-sdk dhcps functions that were not implemented.

* nonos helpers have a separate header

* wifi ap needs this anyway, simplify sketch includes

* missing example

* existing name :/

* trying to fix header dependency

* restyle

* not a c header

* no need to init

* move dhcp server getter to WiFi

more... arduino'ish? we ahve object as namespace, plus everything else
related to softAP is there
redundant includes, redundant mock impl (out-of-scope here to fix)

* ...move things back, still expose as WiFi method

* review fix

* include -nonos header in wifi lib though

* no more lwip include

* style

* need mock dhcpserver instance
2022-06-01 22:46:04 +02:00
david gauchard
80c0570620
Define lwIP's s32/u32 to int (#8560)
* Define lwIP's s32/u32 to int

s32/u32 were previously defined as long,
but long can be 64 bits in host mode,
so this commit reduces valgrind complaints and increase coherency.

* some lads like to use `unsigned long` for 32 bits IPv4 addresses

* fix lwIP's `sys_now()` return type

* fix C declarations

* merge upstream (lwip2) update on sys_now() definition

* matching lwIP api (2/2)

Co-authored-by: Max Prokhorov <prokhorov.max@outlook.com>
2022-05-15 21:55:56 +02:00
Paulo Cabral Sanz
27827c8c6d
Delete operator=(Self&) when copy constructor is deleted (#8535) 2022-04-11 13:41:21 +03:00
Earle F. Philhower, III
d205a63309
Update sessions example to show speed difference (#8528)
Fixes #8505
2022-04-04 10:48:29 +02:00
Maxim Prokhorov
19b7a29720 Migrate from astyle to clang-format (#8464) 2022-03-04 02:28:47 +03:00
Juraj Andrássy
f401f08aba
WiFiServer - 'rename' available() to accept() (#8419)
* WiFiServer - 'rename' available() to accept()
* use server.accept() instead of available()
* WiFiServer.accept() and ArduinoWiFiServer class doc update
2022-01-03 14:32:02 +01:00
Juraj Andrássy
d0cc3a80f8
WiFiServer - don't inherit from Server class (#8418)
* WiFiServer - don't inherit from Server class
2022-01-03 14:06:31 +01:00
Earle F. Philhower, III
7d971fa45b
Remove warnings, errors during host tests in CI (#8358)
* Remove warnings, errors during host tests in CI

Debug strings often included format parameters which did not exactly match
the passed in format parameters, resulting in warnings in the host test build
process like
````
/home/runner/work/Arduino/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiAP.cpp:107:20: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  107 |         DEBUG_WIFI("[AP] SSID length %u, too long or missing!\n", ssid_len);
      |                                                                   ~~~~~~~~
      |                                                                   |
      |                                                                   size_t {aka long unsigned int}
````

Fix by applying casting or PRxxx macros as appropriate.

Also, fix one debug message which was trying to use a `String` as a `char *`:
````
/home/runner/work/Arduino/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp: In member function ‘wl_status_t ESP8266WiFiMulti::connectWiFiMulti(uint32_t)’:
/home/runner/work/Arduino/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp:331:34: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘String’ [-Wformat=]
  331 |                 DEBUG_WIFI_MULTI("[WIFIM] Connecting %s\n", ssid);
````

* Clean up SpeedTest.ino host build
2021-11-02 22:41:03 +01:00
aWZHY0yQH81uOYvH
f8de3fb464
ESP8266WebServer - Drop inactive connection when another is waiting to improve page load time (#8216)
* ESP8266WebServer - drop current HC_WAIT_READ connection sooner when another has data

Safari sometimes opens two connections when loading a page and only
sends a request over the second one, resulting in a 5 second wait
(HTTP_MAX_DATA_WAIT) before the request is processed. This commit
drops the current connection after 30ms (HTTP_MAX_DATA_AVAILABLE_WAIT)
when there is a new connection with data available or the buffer of
pending TCP clients is full (currently 5).
2021-10-27 22:28:47 +02:00
Max Prokhorov
ac4af38c09
Correctly access WIFI_EVENT_MODE_CHANGE event info (#8343)
Select the specific union member struct fields.

Co-authored-by: Rastislav Hričák <88608954+RastoH@users.noreply.github.com>
2021-10-19 09:47:26 +03:00
Dirk O. Kaar
c312a2eaf1
Implement esp_yield() as a replacement for delay(0)
esp_yield() now also calls esp_schedule(), original esp_yield() function renamed to esp_suspend().

Don't use delay(0) in the Core internals, libraries and examples. Use yield() when the code is
supposed to be called from CONT, use esp_yield() when the code can be called from either CONT or SYS.
Clean-up esp_yield() and esp_schedule() declarations across the code and use coredecls.h instead.

Implement helper functions for libraries that were previously using esp_yield(), esp_schedule() and
esp_delay() directly to wait for certain SYS context tasks to complete. Correctly use esp_delay()
for timeouts, make sure scheduled functions have a chance to run (e.g. LwIP_Ethernet uses recurrent)

Related issues:
- #6107 - discussion about the esp_yield() and esp_delay() usage in ClientContext
- #6212 - discussion about replacing delay() with a blocking loop
- #6680 - pull request introducing LwIP-based Ethernet
- #7146 - discussion that originated UART code changes
- #7969 - proposal to remove delay(0) from the example code
- #8291 - discussion related to the run_scheduled_recurrent_functions() usage in LwIP Ethernet
- #8317 - yieldUntil() implementation, similar to the esp_delay() overload with a timeout and a 0 interval
2021-10-17 00:19:01 +03:00
Max Prokhorov
40b26b769c
Movable HTTPClient and fixing WiFiClient copy (#8237)
- =default for default ctor, destructor, move ctor and the assignment move
- use `std::unique_ptr<WiFiClient>` instead of raw pointer to the client
- implement `virtual std::unique_ptr<WiFiClient> WiFiClient::clone()` to safely copy the WiFiClientSecure instance, without accidentally slicing it (i.e. using the pointer with incorrect type, calling base WiFiClient virtual methods)
- replace headers pointer array with `std::unique_ptr<T[]>` to simplify the move operations
- substitute userAgent with the default one when it is empty
(may be a subject to change though, b/c now there is a global static `String`)

Allow HTTPClient to be placed inside of movable classes (e.g. std::optional, requested in the linked issue) or to be returned from functions. Class logic stays as-is, only the underlying member types are changed.

Notice that WiFiClient connection object is now copied, and the internal ClientContext will be preserved even after the original WiFiClient object was destroyed.

replaces #8236
resolves #8231
and, possibly #5734
2021-10-13 04:19:51 +03:00
david gauchard
9d024d17fd
comments on Arduino flush() method (#8318) 2021-09-29 15:22:30 +02:00
Hasenradball
193043d19b
Update ESP8266WiFiSTA.cpp (#8229)
change return to `WL_WRONG_PASSWORD` if there is an issue with the password!
2021-09-29 09:35:32 +02:00
Juraj Andrássy
64e87f1149
WiFi library ArduinoWiFiServer update (#8238)
* ArduinoWiFiServer - check for clients in write() too
2021-09-22 19:31:07 +02:00
Oxan van Leeuwen
fb5c4a6420
Place deprecated attribute in front of function (#8258) 2021-09-01 09:03:12 -07:00
david gauchard
14c3798d4f
release 3.0.2 (#8242) 2021-07-26 22:27:44 +02:00
david gauchard
69f8cd6934
Certificate and public keys automatic updater (#8218) 2021-07-17 16:29:46 -07:00
M Hightower
40876dc6ba
Fixes failing https connections to HelloServerBearSSL when using the (#8206)
MMU option with 48K IRAM shared. This happended after changes that
increased IRAM code size that caused  free IRAM for Heap to fall
below ~16K, then "new" would OOM out in WiFiClientSecureBearSSL.

Added private function to try IRAM first then switch to DRAM on fail
to WiFiClientSecureBearSSL for iobuff allocations.
2021-07-11 22:22:34 +02:00
Earle F. Philhower, III
45e7976c50
Fix stopAllExcept with WiFiClientSecure (#8136)
Fixes #8079

Because WiFiClientSecure inherits WiFiClient, and WiFiClientSecureCtx also
inherits WiFiClient, they both end up in the list of TCP connections that
are used for WiFiClient::stopAllExcept().  This would cause the underlying
SSL connection to be closed whenever you attempted to
stopAllExcept(WiFiClientSecure)

Fix by adding a "_owned"(by) pointer in the WiFiClient object which points to
nullptr (default case) or to the associated lower-layer connection.
When stopping all connections except one, only look at the lowermost
connections.
2021-06-20 10:43:05 -07:00
Earle F. Philhower, III
60fe7b4ca8
Add code-spell spelling checks to CI (#8067)
Help find and fix silly spelling errors as they are added to the repo.
2021-05-23 08:53:04 -07:00
Dirk O. Kaar
95b06cee0b Explain function of special PolledTimeout to the code reader 2021-05-18 15:43:27 +02:00
Dirk O. Kaar
f382fc9d77 Refactoring to PolledTimeout or optimistic_yield on the grounds that these are not wait loops on slow input. 2021-05-18 15:43:27 +02:00
Juraj Andrássy
3a3d1c693d
added ArduinoWiFiServer with send-to-all-clients functionality (#7612)
and with available() working according to Arduino documentation
plus PagerServer example
2021-05-15 13:50:15 -07:00
Max Prokhorov
4436e32a50
WiFi: clean up AP SSID setter & getter, support 32 chars (#7941) 2021-05-15 12:28:22 -07:00
Dirk O. Kaar
1a455ffd8d
Fix a warning reported by @Tech-TX (#8014) 2021-05-15 10:54:53 -07:00
Max Prokhorov
b0ece8cac4
[BREAKING] wifi: remove pseudo-modes for shutdown, expose ::[resumeFrom]shutdown() (#7956)
* wifi: remove pseudo-modes for shutdown

make shutdown and resumeFromShutdown public
removes extra code from the mode handler and include method description
in the docs

* typo

* dup

* typos

* reference only shutdown() & resumeFromShutdown()

prefer to have some specific function, don't simply chain into sleep
update examples and docs

* safeguard raw sdk config usage
2021-05-15 19:49:35 +02:00
david gauchard
6da2bfb664
simplifying internal code using stream::send api (#7995) 2021-05-15 18:13:05 +02:00
david gauchard
f4178e58dc
fixes for WiFiClient::write(Stream) (#7987)
fixes for WiFiClient::write(Stream) and Stream transfers
- remove deprecated WiFiClient::write(Stream,size)
- fix and deprecate WiFiClient::write(Stream) to use Stream::sendAll instead of ::sendAvailable
- update ESP8266WebServer::streamFile to use file.sendAll(client) instead of client.write(file)
- remove stream dependence in ClientContext
- Stream::send(): honor timeout in all case, avoid short transfer when output is temporarily full
- example WiFiEcho: show sendAll and sendAvailable
2021-04-27 16:02:19 +02:00
Dirk O. Kaar
cfbbd6f22d
enableWiFiAtBootTime() should be declared in ESP8266WiFi.h (#7993) 2021-04-18 22:17:14 +02:00
david gauchard
1cc6960a55
[BREAKING] Disable WiFi at boot by default (#7902)
* Disable WiFi at boot by default

* +define WIFI_IS_OFF_AT_BOOT

* remove now useless example

* mv enableWiFiAtBootTime() to core_esp8266_features.h

* sync with master

* per @earlephilhower review: a file was missing

* doc

* WiFi persistence is now false by default

* fix doc

* ditto

* doc: remove sphinx warnings (fix links and formatting)

* fix link name

* fix doc

* legacy: restore persistence

* undeprecate preinit()

* move force modem up to when mode has changed (per @mcspr review)

* do not wake up from sleep when mode if OFF

* fix doc per review
2021-04-09 23:01:11 +02:00
david gauchard
0049090e48
comments in ClientContext::connect() (#7961)
* add comment
2021-04-05 15:09:27 +02:00
david gauchard
1c57b3408c
fix WiFiClient::write(from flash or iram) (#7951)
* fix WiFiClient::write(flash or iram)

* fix emulation on host
2021-04-04 11:31:45 +02:00
david gauchard
c1118dfce3
Stream::Send fixes: doc + StreamConstPtr byte-by-byte + missing SSL availableForWrite (#7935)
* StreamConstPtr: fix doc + reading flash space byte-by-byte
* add missing availableForWrite wrapper in wificlient-ssl
* WiFiClientSecure-ctx: add missing availableForWrite()
2021-03-25 16:00:41 +01:00
Maxim Prokhorov
3ff573103b Fix WiFi events with 32byte wide SSIDs 2021-03-25 02:38:25 +03:00
virtualmix
edcbdbea45
Update Root Certificate (#7932)
The root certificate used in the example to connect to api.github.com has expired.
A new certificate was issued on March 3, 2021 and should be valid for a year.
2021-03-21 13:35:11 -07:00
david gauchard
3b1e8eab20
rename ClientContext::wait_until_sent() to wait_until_acked() (#7896)
* rename ClientContext::wait_until_sent() to wait_until_acked()

While looking at #6348 and #6369, and after checking into lwIP sources, it
appears that the tests in ClientContext::wait_until_sent() effectively wait
for all acks on current output buffer. Comments are added.

* host tests counterpart
2021-03-21 14:56:20 +01:00
Drzony
1b922edad1
Added broadcastIP method to WiFiSTA class (#7899) 2021-03-16 08:01:04 -07:00
Manuel Domínguez-Dorado
2406fe8fb8
Adds the method setSSLVersions() also to WiFiClientSecure in order to use that new feature. (#7925)
Co-authored-by: Manuel Domínguez Dorado <manuel.dominguez@enzinatec.com>
2021-03-15 13:21:53 -07:00
Earle F. Philhower, III
7475ba7ff3
Add setSSLVersion call to SSL object (#7920)
* Add setSSLVersion call to SSL object

Allow users to only allow specific TLS versions for connections with an
additional call in their app, similar to the setCiphers call.

Fixes #7918

* Add SSL level options to WiFiServerSecure
2021-03-15 12:22:06 -07:00
Drzony
48e1ccbff8
Added ESP32 compatible methods for setting/getting sleep mode (#7901) 2021-03-14 20:48:54 -07:00
david gauchard
c720c0d9e8
Stream::send() (#6979) 2021-03-14 17:36:20 -07:00
david gauchard
807ed51d0f
AP & dhcp-server: fix uninitialized variables (#7905) 2021-03-03 01:12:01 +01:00
Michael Pöttgen
bc3daef76d
WIFI_RESUME improve speed and example (#7877)
Improve resume speed by passing in last known BSSID
Provide a simpler example for WIFI_SHUTDOWN/WIFI_RESUME
Add documentation for WIFI_SHUTDOWN and WIFI_RESUME.
2021-02-15 13:51:37 -08:00
Erriez
d90015e326
Merge branch 'master' into feature/issue-2246-multi-wifi-hidden 2021-01-19 16:12:54 +01:00
Paulo Cabral Sanz
85e2ffffe1
Allow users to inherit and override CertStore (#7827)
Make installCertStore virtual so we can inherit from CertStore and override it
Create CertStoreBase to inherit from
2021-01-18 11:59:20 -08:00
Paulo Cabral Sanz
e938739115
Prevent nullptr dereference on OOM (#7823) 2021-01-12 14:55:57 -08:00
David Luna
a3a7a23a92
Typo error in ESP8266WiFiGeneric.h (#7797)
Error in copyright text about Arduino Wifi library
2020-12-27 22:15:26 +01:00
david gauchard
51c2a1437b
more lwIP physical interfaces (#6680)
This commit adds W5500 W5100 and ENC28j60 drivers from @njh with credits
They are available in libraries/
An example is added in W5500 examples directory

plus:
* Extract dhcp server from lwip2 and add it to the core as a class.
  It must always be present, it is linked and can be called by fw on boot.
  So it cannot be stored in a library.
* ethernet: static or dhcp works
* PPPServer: example
* bring WiFi.config() to the lwIP generic interface (argument reorder common function)
* move hostname() from WiFI-STA to generic interface
* remove non readable characters from dhcp-server comments
* dhcp-server: magic_cookie is part of bootp rfc
* fixes from https://github.com/d-a-v/W5500lwIP/issues/17
* enable lwip_hook_dhcp_parse_option()
* +ethernet tcp client example in w5500 library examples
2020-12-22 22:36:21 +01:00