Commit Graph

627 Commits

Author SHA1 Message Date
Mark
9eea85f9ff
Check if m_pServerCallbacks is not null before calling method. (#5603)
Fixes: https://github.com/espressif/arduino-esp32/issues/5573

To reproduce:
1. Run any sample code that starts a BLE server, and does not call `setCallbacks`.
2. Connect to the device using the "LightBlue" app on iOS.
3. Observe crash shown in the issue linked above.
2021-08-31 09:20:02 +03:00
beamholder
0730e0ec93
Include nvs_commit() on three methods (#5309)
* Include nvs_commit() on three methods

In [Preferences.cpp](https://github.com/espressif/arduino-esp32/blob/master/libraries/Preferences/src/Preferences.cpp),  the functions:
```
Preferences::clear()
Preferences::remove()
Preferences::end()
```
should be revised to include a call to 
`nvs_commit()`
as required per 
[Non-volatile storage library](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/nvs_flash.html)
when using 
```
nvs_erase_all()
nvs_erase_key()
nvs_close()
```
2021-08-23 21:23:42 +03:00
Me No Dev
c45cff5f83
Implement USB HID Device Support for ESP32-S2 (#5538)
* Add support and example for USB HID Devices
* Add support and example for USB Vendor
2021-08-23 17:27:34 +03:00
Tim
29455a0447
Fix issue #5507 "Constructor WebServer::WebServer(IPAddress addr, int… (#5509)
* Fix issue #5507 "Constructor WebServer::WebServer(IPAddress addr, int port) produces an unexpected result"

"The class Webserver is declared with two explicit constructors, one with signature:
WebServer::WebServer(IPAddress addr, int port)
Using this results in a server listening on the port number obtained by converting the value of the IPAddress addr argument (in host byte order) to a uint32_t and then to a uint16_t, which is manifestly not the result that would be expected.
...
As for a fix, we can assume from these results that this constructor is not being used and therefore could simply be deleted."

* Issue 5507
Reverse changes in commit bee1e7088cef913391155f096b42cd4bb89c5c6f after discussion.
Alternative fix to be done.

* Fix issue #5507 "Constructor WebServer::WebServer(IPAddress addr, int port) produces an unexpected result"

This change adds support for multi-homed servers to libraries/WiFi.  It was assumed to be there already by libraries/WebServer, but was not.
This led to unexpected results when the IP address-specific constructor of class WebServer was used (see issue 5507).

This change was tested using three concurrent instances of WebServer, one bound to the WiFi station address, one bound to the WiFi soft AP address,
and one bound to INADDR_ANY.  See libraries/WebServer/examples/MultiHomedServers for the test method.

* Fix issue #5507 "Constructor WebServer::WebServer(IPAddress addr, int port) produces an unexpected result" (cont.)
This fixes what I think might be the cause of CI failures on GitHub for the previous commit, namely the absence of an include file
in examples/MultiHomedServers.

* Fix issue #5507 "Constructor WebServer::WebServer(IPAddress addr, int port) produces an unexpected result" (cont.)

Change port numbers in examples/MultiHomedServers per pull-request comment from me-no-dev ...
"for this test to be valid, both servers should be on the same port. That is how you can make sure that the functionality works."
2021-08-23 15:51:06 +03:00
Tim
c4fcab28e4
Fix issue #5506 "WebServer serveStatic () can cause LoadProhibited exception in _svfprintf_r" (#5508)
"Using a Core Debug Level of Verbose and the WebServer serveStatic() function with the default value of nullptr for its cache_header argument, results in a LoadProhibited exception in _svfprintf_r().
This is because serveStatic() calls log_v() with cache_header corresponding to a "%s" in its format but without checking that cache_header is not nullptr, and then logv() (indirectly) calls _svfprintf_r().
On the other hand, with a Core Debug Level other than Verbose, this does not occur."

Changed serveStatic() to the check value of cache_header and if it is nullptr, instead pass an empty string to log_v().
2021-08-11 14:31:07 +03:00
Drzony
0acbe781f5
Increase default timeout for WiFiClient from 3ms to 3s (#5496)
## Summary
https://github.com/espressif/arduino-esp32/pull/5487 introduced a default timeout for WiFiClient, however the default was specified in milliseconds instead of seconds, see be84c8219c (commitcomment-54358731)
This 3ms timeout breaks OTA when the processor is busy.

## Impact
Sets the default to a saner value, fixes OTA.
2021-08-11 14:17:38 +03:00
Me No Dev
5bb8177aa1
Add initial support for USB MSC (#5466)
* Add initial support for USB MSC

* Add Firmware Upload/Download With MSC

Current running firmware is available as file inside the MSC Disk. To update the firmware on the ESP, just copy a regular firmware bin into the drive

* Support overwriting of the firmware file

Overwriting a file is done totally differently on MacOS, Windows and Linux. This change supports it on all of them.

* Allow CDC, FirmwareMSC and DFU to be enabled on boot

* Add example ESP32-S2 USB-ONLY board

* Various device code optimizations

Added `end()` methods to MSC classes
Made begin() methods safe to be called multiple times
Optimized CDC class

* Fix CDC Connect/Disconnect detection in Arduino IDE on Windows

* Rework cdc_write

* Update ESP32-S2 board configs
2021-08-02 15:35:13 +03:00
Krzysiek S
be84c8219c
[WiFiClient] Default connection timeout, when no timeout provided (#5487)
## The problem
WiFiClient's connect method variant where no timeout is passed can block esp32 MCU and may then cause watchdog to kick in and reset the device. This behavior is different from that, what is in arduino-esp8266 core.

## Summary
Some cross-esp libraries (working both on esp32 and 8266), like PubSubClient simply call connect method on WiFiClient, to get connected to remote server. However, connect behavior varies betwen esp arduino 8266 and esp arduino 32 cores. This pull request tries introduce same behavior - to make connect method non-blocking on esp32, like it is with 8266 arduino core.

## Proposed solution
Introduce default fixed timeout that can be changed by #define - by default set to 3 seconds.

### Affected components: 
WiFiClient

### Affected methods:
```c++ 
int connect(IPAddress ip, uint16_t port);
int connect(const char *host, uint16_t port);
```

### Impact
May impact projects or libraries using connect method variant without specified timeout, where:
- remote is located far away or
- connection is heavily limited, or
- remote is slow, when it comes to accept the connection
2021-08-02 15:05:44 +03:00
t-oot
31127f4260
Support for Transfer-Encoding headers that specify "identify" (#5486)
In [HTTPClient](https://github.com/espressif/arduino-esp32/tree/master/libraries/HTTPClient), if the `Transfer-Encoding` header is set to `identity`, an error (Transfer-Encoding not supported) will occur.

HTTPClient will consider the request as `identity` if the `Transfer-Encoding` header is not set. But it is also defined a response with `identity` explicitly set in the `Transfer-Encoding` header (ref:[MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding)).

This pull request will allow the request to be processed normally even when `identity` is explicitly set.
2021-08-02 15:04:48 +03:00
me-no-dev
4365a45401 Fix WiFi Deinit bug
Fixes: https://github.com/espressif/arduino-esp32/issues/4842
2021-08-02 14:57:55 +03:00
pulquero
c5a1f3efd7
Corrected CLASSIC_BT_ENABLED to CONFIG_BT_CLASSIC_ENABLED. (#5471)
CLASSIC_BT_ENABLED never worked as was incorrectly named, e.g. see
https://github.com/nkolban/esp32-snippets/issues/890#issuecomment-521520934
Now corrected to the update-to-date name CONFIG_BT_CLASSIC_ENABLED.
2021-07-29 15:06:43 +03:00
vortigont
34125cee1d
Examples update, add a note for configTime() that only one ntp server is supported by lwip (#5343)
lwip lib bundled with esp32 Arduino supports only one ntp server. Any additional servers set are just silently ignored.
This default is different from esp8266 Arduino core and very confusing. Most of the examples provided uses 3 different ntp servers for redundancy while only the first one is used actually.
Addressing issue #4964
2021-07-22 20:09:28 +03:00
Vlasta Hajek
e12d8c8ff1
fix: WiFiClientSecure connection timeout (#5398) (#5418)
Closes #5398

Using the same non-blocking socket connect pattern for respecting connection timeout, copied from WiFiClient::connect.

WiFiClient::connect uses lwip_connect_r, whereas start_ssl_client uses lwip_connect. I haven't found what is the difference between them. I tested both, both work ok, so I kept lwip_connect.
2021-07-21 13:20:23 +03:00
Me No Dev
268595c743
Various USB fixes (#5422)
* Fix compile archive arguments for the new toolchain

* Add menu to S2 for picking through which port to upload

Internal USB CDC requires to reset and wait for the new port (because persistence is not yet stable)

* USB CDC should also be started in main

* Fix URL and USB version for WebUSB

* Update vendor callback API

* Update CDC::write to use TX_DONE semaphore

* Update USB_Serial example
2021-07-20 11:59:13 +03:00
Rodrigo Garcia
4a0305a05e
Fixes SD begin() end() memory leak #2897 (#5419) 2021-07-19 19:08:51 +03:00
Jayantajit Gogoi
db4e7667af
add callback to HTTPUpdate (#5408)
- add callback function to HTTPUpdate
- update example to print httpupdate progress
- fix ArduinoIDE syntax coloring

Signed-off-by: Jayantajit Gogoi <jayanta.gogoi525@gmail.com>
2021-07-19 14:28:17 +03:00
Sagar
f64ca2e084
Fixed typo in comments. (#5407)
A typographical error is corrected in the 2nd line of the comment. 
From = " This is un example howto use Touch Intrrerupts "
To = " This is an example of how to use Touch Intrrerupts "
2021-07-19 13:38:40 +03:00
xBiohazardx
0aafa05e8f
Added function to retrieve the amount of data received from an BLECharacteristic (#5339) 2021-07-17 02:03:44 +03:00
Me No Dev
16f4b0f5ba
IDF master d93887f9f (#5336)
* Update toolchain

* Update package_esp32_index.template.json

* add optional component dependencies after Kconfig options are known (#5404)

Until this commit, Kconfig options (e.g. CONFIG_TINYUSB_ENABLED) were
used in conditions preceding idf_component_register to determine which
components need to be added to `arduino` component requirements.
However the Kconfig options aren't known at the early expansion stage,
when the component CMakeLists.txt files are expanded the first time
and requirements are evaluated. So all the conditions evaluated as if
the options were not set.
This commit changes the logic to only add these components as
dependencies when the Kconfig options are known. Dependencies become
"weak", which means that if one of the components isn't included into
the build for some reason, it is not added as a dependency.
This may happen, for example, if the component is not present in the
`components` directory or is excluded by setting `COMPONENTS` variable
in the project CMakeLists.txt file.
This also ensures that if the component is not present, it will not be
added as a dependency, and this will allow the build to proceed.

Follow-up to https://github.com/espressif/arduino-esp32/pull/5391.
Closes https://github.com/espressif/arduino-esp32/issues/5319.

* IDF master d93887f9f

* PlatformIO updates for CI (#5387)

* Update PlatformIO CI build script

- Switch to the latest toolchains 8.4.0 for ESP32, ESP32S2, ESP32C3
- Use PlatformIO from master branch for better robustness

* Update package.json for PlatformIO

Co-authored-by: Ivan Grokhotkov <ivan@espressif.com>
Co-authored-by: Valerii Koval <valeros@users.noreply.github.com>
2021-07-17 01:57:49 +03:00
rtrbt
780588dce3
Remove undocumented and uncontrollable WiFI RSSI filter. (#5393)
Commit d15e1b0e [1] in the 2.0.0 pull request #4996 introduced a filter
to connect only to WiFi networks with a RSSI of -75 or better. This
results in strage behaviour, as a scan still shows networks, that can't
be connected to, even though with older versions, connecting to those
networks was possible and the connection (albeit slow) was stable.

Remove the RSSI filter for now by setting the threshold to -127, i.e.
the lowest possible value. Maybe in the future the filter threshold
could be exposed to users, to allow filtering out nearly unreachable
networks.

[1] github.com/espressif/arduino-esp32/pull/4996/commits/d15e1b0
2021-07-16 23:43:25 +03:00
Me No Dev
5eda278177
Update camera example (#5397)
Fixes: https://github.com/espressif/arduino-esp32/issues/5128
Fixes: https://github.com/espressif/arduino-esp32/issues/5324
2021-07-16 16:55:59 +03:00
Me No Dev
c8a4010fa6
Rename LITTLEFS to LittleFS to match ESP8266 (#5396)
Fixes: https://github.com/espressif/arduino-esp32/issues/5103
2021-07-16 15:46:38 +03:00
Me No Dev
dd25e2b9d6
Fix some WiFi issues (#5395)
* Add back ARDUINO_EVENT_WIFI_READY

Fixes: https://github.com/espressif/arduino-esp32/issues/5315

* use strncpy and strncmp for WiFi SSID and Password in AP and STA

Fixes: https://github.com/espressif/arduino-esp32/issues/5367

* Implement timeout for waitForConnectResult

Fixes: https://github.com/espressif/arduino-esp32/issues/5330

* Remove old definition of "reverse" from stdlib_noniso

Fixes: https://github.com/espressif/arduino-esp32/issues/5045

* Make "reverse" noniso conditional on ESP_DSP
2021-07-16 14:48:57 +03:00
Me No Dev
cf43d174b7
Add FTM support and examples (#5272)
Rework of #5266 by @pedrominatel
2021-06-16 21:24:48 +03:00
Me No Dev
1f4f2b6e97
Enable clock output for Ethernet RMII on ESP32 (#5274)
fixes #5239

* Add back clock mode argument
2021-06-16 20:45:20 +03:00
Maurin
5ae3e836f9
Fix wrong password same SSID (#5124)
When iterating through APlist from first to the last element, a corrected password for already known SSID is not used. Therefore, I propose to iterate from the back of the list. With iterating from the back through the vector, an already known SSID with a corrected password is used instead.
2021-06-10 13:19:58 +03:00
Rotzbua
5b5cbb4926
Fix softap_config_equal compare auth_mode/cipher #5115 (#5121)
fixes #5115
2021-06-10 13:16:38 +03:00
Rotzbua
aec2635b07
WifiAP disable insecure TKIP (#5122)
fixes #4805
2021-06-10 13:16:12 +03:00
Pablo Clemente Maseda
e7e94ea247
Enable I2C_BUFFER_LENGTH definition for Wire lib (#5172) 2021-06-10 13:15:35 +03:00
Pedro Minatel
23820874ec
Added the README template for examples and libraries (#5228)
Typos fixed and added more details and instructions
Added README file to WiFiScan example
Review on the README template
Added link to DevKits
2021-06-09 21:12:29 +03:00
Me No Dev
7f87d0fc3a
Fix compilation for use as IDF component (#5265) 2021-06-09 12:56:12 +03:00
lucashutchinson
483a424d0a
restore apache-2.0 licence to to BLE library (#5261)
The code in the BLE library originates from https://github.com/nkolban/esp32-snippets/tree/master/cpp_utils as well as https://github.com/nkolban/ESP32_BLE_Arduino

The original code in the esp32-snippets library is apache-2.0 licence'ed.
In addition when Neil Kolban stopped maintaining this library he made it available with the express requirement that the licence stays as apache-2.0
(Please see: https://github.com/nkolban/esp32-snippets/issues/813)
"... I do require that it continue to be Apache Licensed and free of charge for any and all uses (private or commercial)."

This change is to clarify the licence of this library.
2021-06-09 12:41:19 +03:00
Ben79543
e7d0ad2efd
Update BLEScan.cpp (#5241)
Proposed fix to #4627 as a remediation to PR #3995
#3995 introduced that a device detected on BLE would not be entered in vector if a callback has been defined. 
By doing so, it was not possible anymore to have a counter in a call back (AND device in vector) to limit the number of detected device in a single scan, which could crash ESP32 as a result.
2021-06-09 12:40:59 +03:00
David Lehrian
67de199bac
add onMtuChanged to BLEServerCallbacks (#5222)
* add onMtuChanged to BLEServerCallbacks

Add method onMtuChanged to the BLEServerCallbacks so the application can be notified if the MTU size changes.

* Correct missing semicolon and misspelled method.

Correct missing semicolon and misspelled method.
2021-06-09 12:37:46 +03:00
rolsen
39155e70a6
ssl_client.cpp: Fix parameter name in _handle_error. (#5217) 2021-06-09 12:33:52 +03:00
Paolo Messina
cb7aef1e88
Fix crash in WiFiClient when read() called after stop() (#5197)
Thi may happen if read() gets called repeatedly (such as in HttpClient to parse response headers) and the connection is closed unexpectedly or the remote peer may have unexpected behavior that causes the underlying socket to report an error. In that case read() itself calls stop(), which invalidates the receive buffer object. Then when read() is called again without checking, such as inside readStringUntil(), the _rxBuffer is null and ESP32 crashes.
2021-06-09 12:30:14 +03:00
Me No Dev
a618fc1361
IDF master c13afea63 (#5214)
esp-dsp: master 7cc5073
esp-face: master 420fc7e
esp-rainmaker: f1b82c7
esp32-camera: master 6f8489e
esp_littlefs: master b58f00c
2021-05-31 16:32:51 +03:00
Ato Araki
a1d8b959b0
Fix length typo (#5189) 2021-05-18 14:01:20 +03:00
lbernstone
de66c39f04
Bump library versions to 2.0.0 (#5182)
* Bump library versions to 2.0.0

* Fixed name on SD library (see #5181)
2021-05-18 14:00:49 +03:00
poozy101
0d6b142228
Update BLE_client.ino (#5156)
Pull request #4999 added setMTU function to BLEClient.cpp/.h, this line provides implementation of this added functionality to the BLE client example to resolve cases in which data from notifyCallback exceeds 20 characters (3 bytes for command type and attribute ID, 20 bytes for attribute data (char*)pData).
2021-05-18 13:57:56 +03:00
Helio Machado
7c3a82a525
Fix (en|dis)able typo on BLEAdvertising start() (#5142) 2021-05-18 13:54:48 +03:00
Alexey D. Filimonov
1b2f34b0d6
MDNSResponder: Add method to get TXT key values. (#5135) 2021-05-18 13:51:43 +03:00
lbernstone
76f0a80fe7
Removed second NTP server from configTime. SNTP only uses one (#5127) 2021-05-18 13:50:40 +03:00
Rotzbua
7a53c2d371
softAP should only start modern WPA2 (#5114)
* AP with old WPA should not be used due security flaws.
* restore behavior from 1.0.6, see 46d5afb17f/libraries/WiFi/src/WiFiAP.cpp (L127)
2021-05-18 13:34:52 +03:00
Piyush Shah
15f8853819
RMaker_readme: Minor corrections (#5175) 2021-05-18 13:31:29 +03:00
chegewara
7856de7a57
BLE5 features to use with C3/S3 (#5085)
Added new BLE5 features to use on C3/S3 family:

extended scan,
extended/multi advertising
New code is not fancy (no feedback from events), but i think it is functional. To get feedback from events i am suggesting to use custom GAP callback, which is already implemented in BLEDevice.
2021-04-22 13:01:20 +03:00
Piyush Shah
e62ff6dc37
RainMaker library: Minor changes (#5092)
- Use Serial.print instead of log_i for QR code helper information,
  so that it is always printed by default.
- Expose the RainMaker factory reset and wifi reset APIs.
- Simplify example to have only a Switch device. Create another example for custom device.
- Enable push button based Factory reset and Wi-Fi reset.
- Added support for the TimeZone service.
- Moved API doc to RainMaker library's top level README.
- Other minor doc changes.
2021-04-22 12:59:27 +03:00
Deffendor
11f89cddf6
WiFiClientSecure fix flipped cert/key in comment (#5065) 2021-04-17 02:07:41 +03:00
me-no-dev
57cf2fb9f5 Fix possible string overflow in BTAdvertisedDeviceSet::toString() 2021-04-16 18:51:01 +03:00
Thomas M
41c372c143
[2.0.0] BtClassic Discovery with info without connect (#4811)
Hey guys,
so I wanted to do a BtClassic Discovery without the need to call connect
and to list all found devices on a display and continue work with that list.

I wasn't capable to test the example code with my file structure, but I did use the discovery already in some different situations.

However when I noted that the Bluedroid stack won't let me enforce an RfComm SPP connection to a GPS Device (Skytraxx 2 plus, I guess its interface is built so simple that it doesn't advertise its SPP over SDP), I will probably have to switch to BtStack (BlueKitchen) and stop on this side meanwhile
2021-04-16 01:37:33 +03:00