Commit Graph

895 Commits

Author SHA1 Message Date
Yiğit
02a70bbd21
fixed http.end taking too long (#6277)
http end takes 20-30 seconds if there is a large amount of data
replacing this read loop with flush fixes that problem
2022-02-21 10:03:25 +02:00
Rodrigo Garcia
e83a9b5f60
Adds BLE examples to ESP32-C3 CI cycle (#6285) 2022-02-16 14:25:39 +02:00
Rodrigo Garcia
7be846cb23
Fixes softAPConfig() return (#6294) 2022-02-16 13:51:21 +02:00
BBsan
c99f594b63
Fix Check for _cookieJar in HTTPClient (#6266) (#6280)
* Check for cookieJar before setting cookies

* Return as soon as possible w/o _cookieJar
2022-02-16 12:08:24 +02:00
Me No Dev
05d8cddee7
Fix CDC+JTAG is disabled when WiFi is used on ESP32-C3 (#6287)
Fixes: https://github.com/espressif/arduino-esp32/issues/6264
Thanks @Spritetm
2022-02-16 09:30:59 +02:00
Jason2866
c4954dd582
Fix compile with Arduino lib builder (#6244) 2022-02-07 16:31:38 +02:00
Me No Dev
4cbb7389db
Support the updated MbedTLS in ESP-IDF v4.4 (#6243) 2022-02-07 13:42:22 +02:00
mattsches1
ab6e010c20
HttpClient: Add cookie support (cookie jar) (#6216)
* Support concatenation of headers (as in 1de0c341b5 (diff-977435a9cc4619fa0b8b995085f6ae683485cf563722756bab57108b362da316) for ESP8266, fixes https://github.com/espressif/arduino-esp32/issues/4069)

* Add support for receiving, storing and sending cookies (cookie jar)

* Cookie support: Respect `secure` attribute when sending a request

* Fix missing `_secure` flag

* Comment out support concatenation of headers (not needed anymore when using cookie jar)
2022-02-05 13:04:57 +02:00
Pedro Minatel
9b066ea61c
Added dual antenna for WiFi (based on the ESP32-WROOM-DA module) (#6226)
* Added dual antenna for WiFi (based on the ESP32-WROOM-DA module)

* Fixed build error

* Fixed indentation and renamed function to setDualAntennaConfig

* Added the RX and TX selection modes as configuration

* Mode code optimization
2022-02-03 20:56:25 +02:00
Rodrigo Garcia
0ea485e518
Touch Sensor IDF Refactoring (#6194)
Summary

Touch Sensor refactoring to be based on IDF 4.4.
Adds support to ESP32S2 and future ESP32S3.

Adds some new APIs:

For all chips:

void touchAttachInterruptArg(uint8_t pin, void (*userFunc)(void*), void *arg, uint32_t threshold);
This function allows the user to add and pass a void* parameter to the ISR user callback.

void touchDetachInterrupt(uint8_t pin);
This function detaches ISR call back for the touch pad pin.

Only ESP32 chip

void touchInterruptSetThresholdDirection(bool mustbeLower);
This function allows the user to set if the ISR callback will be activated when the touch sensor readings are lower or higher than the threshold defined. See example TouchButton.ino.

Only ESP32-S2 and ESP32-S3 chips

bool touchInterruptGetLastStatus(uint8_t pin);
This function reports if the touch pad pin is touched or untouched. It can be used with ISR to identify when it is touched and untouched (released). See example TouchButtonV2.ino.

Impact

None. ll original APIs and examples now run on ESP32 and ESP32-S2.

Related links

Fix #6095
Fix #6034
Fix #5799
Fix #5745
Fix #5527
Fix #5493
Fix #4321
Fix #4044
Fix #2722
Fix #2625
2022-02-03 19:06:12 +02:00
René Bohne
3a96fc0e4a
framebuffer location for no-psram boards (#6219)
If board has no PSRAM, we need to set the framebuffer location to DRAM:
config.fb_location = CAMERA_FB_IN_DRAM;
2022-02-01 13:59:32 +02:00
Patrick Behal
ef35baffb0
Fix random CaptivePortal.ino crashes (#6206)
CaptivePortal.ino example did randomly crash for me ... so I start investigate ;-)

Decoding stack results
0x4016faea: WiFiUDP::write(unsigned char const*, unsigned int) at C:\Users\knoeb\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\libraries\WiFi\src\WiFiUdp.cpp line 201
0x400d4a4a: DNSServer::replyWithIP() at C:\Users\knoeb\AppData\Local\Temp\arduino_build_486825\sketch\src\DNSServer\DNSServer.cpp line 187
0x400d4d01: DNSServer::processNextRequest() at C:\Users\knoeb\AppData\Local\Temp\arduino_build_486825\sketch\src\DNSServer\DNSServer.cpp line 117
0x400d3e81: loop() at D:\Drive\Dokumente\HTL_Lehrer\2021_22\Projekte\Stromzaehler_Patrick\arduino/arduino.ino line 1078
0x400dd545: loopTask(void*) at C:\Users\knoeb\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32\main.cpp line 37
0x4008a0de: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

I found with wireshark a possibility to trigger the crash on demand is:
nslookup 3.1o1osr0092ons87rp375p1pq8q066o8p56or1sqsps6rs17r4384q9748qr1r52.699p1r741q737393648s29917o45p16q50rn517rnsp73pp68p1q259s92693qp.s607408539s0p06p7559os0899866344r7qq7rpns960o9576q65.r5n94r5so9784pq1.i.03.s.sophosxl.net

The problem was that QNameLength is a signed byte and therefore its not possible to count up to 255. Additionally we need 256 bytes for the QName string to accommodate for the zero termination.
2022-01-31 13:25:43 +02:00
Matthias Hertel
9f08cf4767
Update RequestHandlersImpl.h (#6179)
With LittleFS the `fs.exists(path)` returns true also on folders. A `isDirectory()` call is required to set _isFile to false on directories.
This enables serving all files from a folder like : `server->serveStatic("/", LittleFS, "/", cacheHeader.c_str());
        File f = fs.open(path);
        _isFile = (f && (! f.isDirectory()));
2022-01-31 13:09:04 +02:00
Clemens Kirchgatterer
96a5ddcd0e
Allow HTTPCLIENT_1_1_COMPATIBLE to be disabled (#6200)
Allow a user to disable the HTTPCLIENT_1_1_COMPATIBLE flag from the command line, or whichever means available.
2022-01-31 13:08:09 +02:00
mrengineer7777
cbeb7c4df8
Add conditional include to WiFiProv.h (#6192)
Resolves issue #6171
2022-01-31 13:06:39 +02:00
Enes Şimşek
754ceddf48
added explanatory comments to WebServer.h (#6204) 2022-01-31 13:04:29 +02:00
Vlasta Hajek
0d665d7e55
fix: restoring handshake timeout (#6165) (#6166) 2022-01-31 13:01:32 +02:00
P-R-O-C-H-Y
bb7df04446
Fix - SD mount issue (#6162)
* sdSelectCard longer timeout for sdWait

* GO_IDLE_STATE command ignores sdWait fail
2022-01-31 13:01:01 +02:00
esp32wrangler
cbfcfbf970
Add certificate bundle capability to WiFiClientSecure (#6106)
* Add certificate bundle capability to WiFiClientSecure

Enable usage of the ESP32 IDF's certificate bundle for WiFiClientSecure connections.

Adds the ability to load a bundle or root certificates and use them for authenticating SSL servers.

Based on work from Onno-Dirkzwager, Duckle29, kubo6472, meltdown03, kinafu and others.

See also:
- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/esp_crt_bundle.html
- https://github.com/espressif/arduino-esp32/issues/3646
- libraries/WiFiClientSecure/README.md

* Fix build issues

* Clean up old bundle index when NULL bundle is attached
2022-01-19 15:42:36 +02:00
Clemens Kirchgatterer
a134088a0b
Implement Ticker::active() (#6148) 2022-01-18 17:40:03 +02:00
Shawn A
41d972564c
Proposed fix for #2501 (#6113)
Reliability fix for autoReconnect when assoc_fail, autoReconnect did not work before for these failures.

Changes behavior of WIFI_REASON_ASSOC_FAIL event when autoReconnect is set, removes WIFI_REASON_ASSOC_FAIL/WL_CONNECT_FAILED so retry waitforconnectresult loop stays active for the retry, was not working before.
2022-01-17 16:39:16 +02:00
Eckhard Völlm
a0beb81a4c
Consistently change device index to singed integer in BluetoothSerial lib (#6109)
* change parameter to signed int

As of wrong paramater, the following problem existed, that will be fixed now with this change.

BTScanResultsSet.cpp:67:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (i < 0)

* Change parameter and variable to int

As of wrong paramater, the following problem existed, that will be fixed now with this change.

BTScanResultsSet.cpp:67:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (i < 0)
2022-01-17 16:31:58 +02:00
P-R-O-C-H-Y
702db50627
BUGFIX - Sd check status (#6103)
* Edit sd_diskio to check card status

* Bugfix of ff_sd_status
2022-01-17 16:15:16 +02:00
Darek7D
1ac3aefa61
Add KSZ8041 support (#6087) 2022-01-17 16:14:09 +02:00
vortigont
b3b3403296
NTP Examples: revert obsolete comment and updated Time example (#6073)
* Revert "Examples update, add a note for configTime() that only one ntp server is supported by lwip",
fixed in espressif/esp32-arduino-lib-builder#51

This reverts commit 6b1020967a.

* SimpleTime: add NTPoDHCP option and TimeZone env variable
2022-01-17 16:09:58 +02:00
P-R-O-C-H-Y
caef4006af
Implement SigmaDelta based on ESP-IDF API (#6053)
Summary

This PR is refactoring of SigmaDelta HAL in order to use IDF instead of current Register manipulation approach.

Impact

Change in API:

uint32_t sigmaDeltaSetup(uint8_t channel, uint32_t freq);
changed to -->
uint32_t sigmaDeltaSetup(uint8_t pin, uint8_t channel, uint32_t freq);

void sigmaDeltaAttachPin(uint8_t pin); removed, no longer needed. Pin is attached in sigmaDeltaSetup()
2021-12-22 16:41:52 +02:00
Rodrigo Garcia
7cf162346a
RMT refactoring based on IDF (#6024)
Summary

RMT HAL refactoring based on IDF.

Impact

Improves RMT by adding IDF v4.4 support.
Receiving RMT can handle any size of data.
rmtInit() has a new parameter - RxBufferSize - to hold any number of data when receiving RMT.
rmtWrite() has a new parameter - wait_tx_done - to block writing until sending all data.

Related links

fix #5905
2021-12-21 15:02:40 +02:00
Pedro Minatel
c66c7fe27e
[Examples] README revision to include missing and remove old entries (#6049) 2021-12-21 15:00:37 +02:00
discapacidad5
6b90627b21
HID_BRAILLE_DISPLAY (#6043)
23 Braille Display Page (0x41)
Braille display allow visually impaired computer users to read out text using raised pins. The pins are electro-mechanically
activated. These devices also have support for controls that help navigate the computer screen. Typically, braille displays
interface with software known as a screen reader in order to perform this navigation.
2021-12-20 13:22:58 +02:00
Rodrigo Garcia
82ec74a072
Adds support to change LoopTask Stack size (#6025)
## Summary
Arduino ```setup()``` and ```loop()``` run under a Task with a fixed Stack size of 8KB.
Users may want to change this size.

This PR adds this possibility by just adding a line of code, as for example:
``` dart
ESP_LOOP_TASK_STACK_SIZE(16384);

void setup() { 
}

void loop() { 
}
```
## Impact
None. It adds a new functionality to ESP32 Arduino.
If ```ESP_LOOP_TASK_STACK_SIZE(newSize);``` is not declared/used, it will compile the sketch with the default stack size of 8KB.

## Related links
fix #6010 

https://github.com/espressif/arduino-esp32/issues/6010#issuecomment-992701658
Thanks @igrr for the suggestion!
2021-12-20 13:10:36 +02:00
me-no-dev
5940d89e67 Fix wrongly applied patch to WiFi STA Init 2021-12-20 10:17:25 +02:00
Me No Dev
40a5c1e461
Change default WiFi encryption to WIFI_AUTH_WPA2_PSK (#6022)
Fixes: https://github.com/espressif/arduino-esp32/issues/6020
2021-12-14 20:07:08 +02:00
Alexandre-Jacques St-Jacques
7bb30b3cf8
Refactoring TwoWire::requestFrom() headers in Wire.cpp (#5935)
* Refactoring function headers

Changing the header so the main TwoWire::requestFrom() definition uses a `size_t` instead of a `uint8_t`, removing the 255 bytes limit on I2C requests.

Co-authored-by: Flaviu Tamas <me@flaviutamas.com>
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2021-12-14 16:25:01 +02:00
Vítor Ângelo Russi
4b638de19d
using ksz8081 only from ESP-IDF 4.4 onwards (#5918)
* using ksz8081 only from ESP-IDF 4.4 onwards

The previous assertion only considerate the existance of ESP-IDF 4.3, but with the ESP-IDF 4.3.1 release this assertion would generate errors. Now only includes from ESP-IDF 4.4 onwards.

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2021-12-14 16:09:01 +02:00
Paolo Messina
f29f4485b5
Fix memory leaks when SSL/TLS connection fails (#5945) 2021-12-14 15:59:26 +02:00
Jakub Rybakowski
8a8f87d3a0
Fix for BluetoothSerial build when using nimBLE instead of Bluedroid (#5920) 2021-12-14 15:56:25 +02:00
Wojtek Kaniewski
cb25fe8c7e
Don't clear headers on redirect (#5973)
Current implementation clears _headers when request was sent. If the
user added custom request headers, they will be lost and the redirected
request will not contain them. This commit changes the scope of cleanup
so that the headers survive redirects but don't survive connection
reuse.
2021-12-14 15:37:31 +02:00
obaterspok
f5b04b9197
Use WIFI_FAST_SCAN if a specific channel was used (#5975)
1.0.6 changed scanning method to always scan all available channels during connect. This results in results in connect taking about ~3 seconds instead of ~1. This patch changes the behavior to use WIFI_FAST_SCAN if client used a specific channel.
2021-12-14 15:37:00 +02:00
Pedro Minatel
fa03966fcf
[Feature] Added Sonoff DUALR3 support with RainMaker example (#5980)
* [Feature] Added Sonoff DUALR3 support with RainMaker example

* [Feature] Added skip files for C3 and S2
2021-12-14 14:35:10 +02:00
P-R-O-C-H-Y
c90dffef44
Edit sd_diskio to check card status (#5988) 2021-12-14 14:22:30 +02:00
Rodrigo Garcia
da72bc90b7
eliminates error messages when using Ethernet Static IP (#5836)
Summary

Only affects ETH (not WiFi)

This PR solves #5733 by allowing the DHCP IDF server to complete its tasks and only then it sets a static IP.
This also solves another related failure reported in this issue (#5733 (comment)).

fix #5733

Impact

Adds a delay in order to wait for DHCP to actually terminate before setting the static IP configuration in ETH.
2021-11-09 10:23:29 +02:00
Anthony Elder
16a9cf781f
Add another Wire requestFrom function signature (#5768)
* Re-add with clean master

* Address @me-no-dev's comments

* static_cast<size_t> to static_cast<uint8_t>
2021-11-08 14:29:04 +02:00
Benjamin Staar
4b9dc61447
Solving *"wifi:channel=0 is invalid"* when using FTM example code (#5809)
When using the FTM examples I got an error in the FTM_Initiator.ino:

*"wifi:channel=0 is invalid"*

I solved it for myself by simply passing the channel argument to be 1 in *WiFi.initiateFTM*. However, a better fix would be to directly change the default channel here.
2021-11-04 16:08:50 +02:00
Pedro Minatel
a2d7c0dcf6
[Examples] WiFi and Ethernet examples organization (#5830)
* examples: WiFi and Ethernet examples organization

* examples: Change on CI scripts to include new folder

* Library name reverted to WiFi

* examples: WiFi and Ethernet examples organization in a new folder

* examples: Eth files moved from WiFi to Ethernet lib and CMakeLists updated
2021-11-04 16:08:08 +02:00
Scott Smith
4aff6dde39
Support additional authorization schemes (#5845)
The client always appends "Basic" to the authorization header, however there are other auth schemes that can be used: https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
For example "Bearer" when using OAuth.
This PR adds a `setAuthorizationType` method to the HTTPClient which allows this scheme to be configured by the caller. Authorization type is set to "Basic" by default so this will have no impact on existing usecases.
2021-11-04 14:25:12 +02:00
Anthony Elder
15bbd0a187
Add ALPN support to WiFiClientSecure (#5633)
This adds a function to WiFiClientSecure to set the ALPN protocol.

This is required for an MQTT client to connect to AWS IoT when using an AWS Custom Authorizer, as described here.

Example code snippet:

...
WiFiClientSecure wiFiClient;

// ALPN protocol, needed with AWS custom authorizer
const char *aws_protos[] = {"mqtt", NULL};

void setup() {
  wiFiClient.setCACert(AWSCAPEM);
  wiFiClient.setAlpnProtocols(aws_protos);
}
...
2021-10-25 09:20:47 +03:00
Hideaki Tai
02c3ec01cc
remove _user_defined_size from EEPROM (#5775)
Summary

Related to the issue #5773 and #2280.

_user_defined_size is removed from EEPROMClass because it is redundant in the current code
EEPROMClass::length() returns _size that is the true available size of EEPROM
Impact

_user_defined_size is removed from EEPROMClass
EEPROMClass::length() returns _size that is the true available size of EEPROM
2021-10-25 09:15:47 +03:00
Rodrigo Garcia
a418058a66
log statement missing parameter #5778 (#5796) 2021-10-23 11:34:00 -03:00
Rodrigo Garcia
2673b88582 removes deprecated esp_eth_set_default_handlers() 2021-10-22 21:56:14 -03:00
Rodrigo Garcia
67c99142d2
Allows spiram malloc with wifi dynamic buffers - better free heap (#5791)
Summary

Modifies WiFi lib to allow dynamic buffer allocation along with SPIRAM MALLOC enabled
This gives more heap space to the users

Related PR in Arduino Lib Builder: espressif/esp32-arduino-lib-builder#47

Impact

WiFi will work the same as it was in version 1.0.6, restoring free heap.

close #5630
close #5474
close #5699
close #5697
2021-10-22 02:22:20 +03:00
michlv
951c8bece5
libraries/SPI/src/SPI.h: SPIClass: add method to get SS pin number (#5788)
* SPI.h add new call to return a SS pin number used.

As code example states, the SS pin needs to be explicitly set for output for SPI to work, but the pin number have to be coded in addition to the SPI logic in the library, which means this duplicates code. It is much better to just be able to get the pin number from library itself.

* Update SPI_Multiple_Buses.ino to use new pinSS method

Simplify the example case, to show usage of pinSS method. This also simplifies the example, removing duplicated code.
2021-10-21 16:48:55 +03:00
me-no-dev
b145e65975 API Optimizations
- Support Wire::end() for Slave
- Prevent Master operations when in Slave mode
2021-10-11 14:46:31 +03:00
Me No Dev
951c32056a
Merge branch 'master' into i2c-slave 2021-10-11 13:13:13 +03:00
Me No Dev
7a7bd37e51
feat: Add the ability to get the peer certificate of an SSL connection
Summary

New feature: Add the ability to get the peer certificate of an SSL connectio. This is useful for IoT when the root/cert trust chain has a shorter lifecylce than the device itself. Includes example code.

It adds two methods to the WiFiClientSecure client:

bool getFingerprintSHA256( uint8_t fingerprint_remote_sha256[32]) -- return true and the fingerprint (i.e. the SHA256 of the raw x509 as a DER - identical to what you see in for example your webbrowser). Or false on error.
const mbedtls_x509_crt* getPeerCertificate(); -- return the actual X509 struct or NULL on error.
Impact

No impact; backwards compatible (only adds to the API)
2021-10-11 13:04:13 +03:00
otakuto
a75602dc68
Add support M5Stack Unit CAM (#5748)
In this PR, we add support for M5Stack Unit CAM to CameraWebServer.
https://docs.m5stack.com/en/unit/unit_cam
2021-10-11 13:01:10 +03:00
Uri Shaked
88789cd817
Fix build error when compiling with verbose logging (#5747)
When compiling with verbose logging, the build would error with a message saying `len` is not defined in `tud_vendor_rx_cb()`. This change fixes the error.
2021-10-11 13:00:25 +03:00
me-no-dev
f9f70d2f73 I2C Slave Implementation 2021-10-09 14:30:20 +03:00
P-R-O-C-H-Y
5b207104aa
Fix: SD_MMC deinit (#5732)
* SD.open() new feature for creating all folders in path

This PR adds to the SD.open() function option to create all folders to the file.

SD.open(const char* path, const char* mode, const bool create)

Default value of create is false.
When true folders are created.

From issue #5019

* Update vfs_api.cpp

memccpy -> memcpy

* SD_MMC deinit fix

Wrong deinit function was called.
2021-10-09 14:12:25 +03:00
Dirk-Willem van Gulik
1706af4656
Add the ability to get the peer certificate of an SSL connection; useful for IoT when the root/cert trust chain has a shorter lifecylce than the device itself. Includes example 2021-10-08 14:20:43 +02:00
Me No Dev
00214d5c2a
IDF master 3e370c4296
* Fix build compilation due to changes in the HW_TIMER's structs

* Fix compilation warnings and errors with USB

* Update USBCDC.cpp

* Update CMakeLists.txt

* Update HWCDC.cpp
2021-10-01 17:52:29 +03:00
Me No Dev
f87107dedb
Implement Thread-Safe I2C based on ESP-IDF API (#5683)
* Implement Thread-Safe I2C based on ESP-IDF API

* Update esp32-hal.h

* use proper types for size and timeout

* Allow disabling of the HAL locks

* Limit frequency settings to prevent Interrupt WDT
2021-10-01 17:34:20 +03:00
Akash Mankar
ce85cf03cc
added comment for user clarity (#5724) 2021-10-01 17:17:42 +03:00
P-R-O-C-H-Y
f2a20e8a38
SD.open() new feature for creating all folders in path (#5721)
* SD.open() new feature for creating all folders in path

This PR adds to the SD.open() function option to create all folders to the file.

SD.open(const char* path, const char* mode, const bool create)

Default value of create is false.
When true folders are created.

From issue #5019

* Update vfs_api.cpp

memccpy -> memcpy

* File f = open() edit

added false for create
2021-10-01 17:16:59 +03:00
Serguei S. Dukachev
93f10609f4
SDMMC frequency selection based on board type (#5688)
* SDMMC frequency selection based on board type

On Olimex ESP32 EVB I/O operations with SD card can cause error when LAN is used in same time.
Problem is disappearing if SD MMC frequency lower down from SDMMC_FREQ_HIGHSPEED to SDMMC_FREQ_DEFAULT.

No problem if WiFi used instead LAN.

* Code rewritten according to https://github.com/espressif/arduino-esp32/pull/5688#pullrequestreview-759359645
2021-10-01 15:48:20 +03:00
Felix Collins
67583e84d6
Return size_t instead of uint8_t from BLECharacteristic::getLength(). Allows large MTU to be used. (#5687) 2021-10-01 15:47:42 +03:00
long_long_float
204f360dce
Append '/' to an URL with empty path in HTTPClient::begin (#5634)
* Add an error check for empty path of an URL

* Append '/' to an URL with empty path instead of returning an error
2021-10-01 15:04:09 +03:00
Danylo Ulianych
3f06a38f69
SD_MMC max_freq_khz is set to HIGHSPEED by default (#5631) 2021-10-01 15:03:38 +03:00
liebman
e4acfbc54a
only use ksz8081 for idf versions later than 4.3 (this fixes compile as component for idf 4.3) (#5599)
esp_eth_phy_new_ksz8081 was added in IDF after version 4.3 and generates a compilation error with IDF-4.3. This change will only use esp_eth_phy_new_ksz8081 for IDF versions after 4.3
2021-10-01 14:38:45 +03:00
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 bee1e7088c 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
Me No Dev
f6c9faf4da
[2.0.0] FS::name() returns the item name as in Arduino SD (#4892)
* FS::name() returns the item name as in Arduino SD

Added method FS::path() that returns the full path

* Adjust examples
2021-04-15 17:25:01 +03:00
mixa3607
89e7893b1a
[2.0.0] Add BLE characteristic callbacks overloads (#4832)
Add BLE characteristic callbacks overloads with esp_ble_gatts_cb_param_t* param.
Example:

class BleCharactCallback : public BLECharacteristicCallbacks
{
    void onRead(BLECharacteristic *pCharacteristic, esp_ble_gatts_cb_param_t *param)
    {
        auto addr = param->read.bda;
        ESP_LOGV(TAG, "Device " ESP_BD_ADDR_STR " request data", ESP_BD_ADDR_HEX(addr));
    }
    void onWrite(BLECharacteristic *pCharacteristic, esp_ble_gatts_cb_param_t *param)
    {
        auto addr = param->write.bda;
        ESP_LOGV(TAG, "Device " ESP_BD_ADDR_STR " transmit data", ESP_BD_ADDR_HEX(addr));
    }
};
2021-04-15 16:08:22 +03:00
Eric Albers
7a4e7066f9
Add setMTU function to BLEClient.cpp/.h (#4999)
The current implementation has a getMTU function which returns the mtu sent in a message.

This function allows you to set the MTU value on the connected device, it first sets the MTU locally by calling esp_ble_gatt_set_local_mtu. It then calls esp_ble_gattc_send_mtu_req to have the connected device also change its MTU size.
2021-04-15 16:07:45 +03:00
lorol
9a518cd3d7
LITTLEFS update - partition label and multiple partitions, idea copied from SPIFFS (#5023)
Note, maxOpenFiles parameter is unused but kept for compatibility.
2021-04-15 14:31:01 +03:00
rtrbt
e6ba8c7ac9
Add KSZ8081 support. (#5061)
This adds support for the KSZ8081 ethernet phy.
Only the IDF 4+ specific code is modified, as the phy support was only
added recently:
espressif/esp-idf@aecfbf96
2021-04-15 12:43:29 +03:00
Me No Dev
404a31f445
Initial Esp32c3 Support (#5060) 2021-04-14 18:10:05 +03:00
Me No Dev
5502879a5b
v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0

Some APIs have changed. New libraries have been added. LittleFS included.

Co-authored-by: Seon Rozenblum <seonr@3sprockets.com>
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
Co-authored-by: geeksville <kevinh@geeksville.com>
Co-authored-by: Mike Dunston <m_dunston@comcast.net>
Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com>
Co-authored-by: Seon Rozenblum <seonr@3sprockets.com>
Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com>
Co-authored-by: tobozo <tobozo@users.noreply.github.com>
Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com>
Co-authored-by: lorol <lorolouis@gmail.com>
Co-authored-by: geeksville <kevinh@geeksville.com>
Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
Co-authored-by: Sweety <switi.mhaiske@espressif.com>
Co-authored-by: Loick MAHIEUX <loick111@gmail.com>
Co-authored-by: Larry Bernstone <lbernstone@gmail.com>
Co-authored-by: Valerii Koval <valeros@users.noreply.github.com>
Co-authored-by: 快乐的我531 <2302004040@qq.com>
Co-authored-by: chegewara <imperiaonline4@gmail.com>
Co-authored-by: Clemens Kirchgatterer <clemens@1541.org>
Co-authored-by: Aron Rubin <aronrubin@gmail.com>
Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
2021-04-05 14:23:58 +03:00
Me No Dev
e7a2759b65
Allow STA SSID length of 32
Fixes: https://github.com/espressif/arduino-esp32/issues/3218
2021-03-23 14:30:19 +02:00
me-no-dev
2d3c57635d Fix: WebServer: Digest authentication failed for some clients
Ports: 4d3850e87e
2021-03-19 02:10:16 +02:00
me-no-dev
a299ddc99e Change send_ssl_data to use size_t instead of uint16_t
Fixes: https://github.com/espressif/arduino-esp32/issues/4960
2021-03-18 15:02:37 +02:00
Mohammed Noureldin
93bcf5f250
Allow passing custom HTTPClient to HTTPUpdate (#4959)
This enables customizing HTTP headers which adds some extra flexibility.
This does not break anything of course because this change introduces a new constructor with a new additional HTTPClient argument for HTTPUpdate class.
2021-03-18 13:12:57 +02:00
me-no-dev
bd41334265 Fix ETH not enabling DHCP when configured with INADDR_NONE
Fixes: https://github.com/espressif/arduino-esp32/issues/4778
2021-03-18 00:53:53 +02:00
Me No Dev
9a0762ad2a
[BLE Client] Fix Deadlock when calling writeValue after registerForNotify
Fixes: https://github.com/espressif/arduino-esp32/issues/4952
2021-03-17 18:46:55 +02:00
me-no-dev
a451c9ef0d Fix HTTPClient crash on GET() for url with redirects
Fixes: https://github.com/espressif/arduino-esp32/issues/4931
2021-03-16 21:28:19 +02:00
Raúl C.G
d362e1ee1a
[BLE] Allows you to specify which channels are used to advertise. (#4954)
In some use cases getting rssi signal from one channel is more stable (less variance) than rssi from the three advertising channels.

This change allows you to specify which channels are used to advertise.
2021-03-16 11:56:23 +02:00
Darrell
63c51d51fb
Update HTTPUpdate.cpp (#4942)
This is a mirror of a change in esp8266 needed to update with a url that redirects.
2021-03-16 02:14:53 +02:00
me-no-dev
5b845272ed Fix BluetoothSerial TX Stall
Fixes: https://github.com/espressif/arduino-esp32/issues/4949
2021-03-16 02:11:59 +02:00
Jiri Drozd
3253de8792
added scan_method = WIFI_ALL_CHANNEL_SCAN into wifi config in WiFi.begin() to let the scan choose the nearest / strongest AP in case that there are multiple APs with the same SSID (#4947)
In case you have multiple APs with the same SSID/password and WiFi.begin(ssid, pwd) is called, ESP32 defaults to connect to THE FIRST AP FOUND matching ssid - according to:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv418wifi_scan_method_t

This can cause situations that ESP32 is trying to connect to AP which is far away from it (weak signal) even there is AP close to it, just as in my house - I have AP on channel 6 which is in the 1st floor (quite far from room where I do the programming) and AP on channel 13 in the same room I do the programming (which is in the 2nd floor) - result: ESP32 is trying to connect to the AP on channel 6 because it finds it first and never try the AP on channel 13 in the same room, result of this is very unreliable WiFi connection.

When scan_method is set to WIFI_ALL_CHANNEL_SCAN, ESP32 scans all channels and choose the nearest / strongest AP (matching the ssid of course) as expected - result is no connection problems at all.

Therefore I propose adding this parameter into WiFi.begin, connection problems as described above are quite confusing (especially for beginners), I can imagine that for example Schools there are usually using mutliple APs and this can cause intermittent connection problems without obvious reason.
2021-03-15 13:21:43 +02:00
Holger Lembke
35643bdd9b
adds esp8266-style hostname setting (#4938)
a little step to make esp8266 code compile without changes under esp32
2021-03-15 10:10:30 +02:00
me-no-dev
8dc70e0add Revert "Update licenses"
This reverts commit 4b3f5c8ed4.
2021-03-11 12:11:53 +02:00
me-no-dev
b42739dfa4 Update howsmyssl.com root certificate 2021-03-10 17:55:40 +02:00
me-no-dev
f815a7c636 Add WiFi.softAPSSID()
Fixes: https://github.com/espressif/arduino-esp32/issues/4922
2021-03-10 16:36:51 +02:00
me-no-dev
23f6e81d52 Fix AsyncUDP reporting bad address and port
Fixes: https://github.com/espressif/arduino-esp32/issues/4923
2021-03-10 16:20:18 +02:00
me-no-dev
4d95e3a7ea Fix BT not starting correctly and SPP Coex not working
Fixes: https://github.com/espressif/arduino-esp32/issues/4912
2021-03-09 01:56:47 +02:00
Me No Dev
f7fc8ab377
Use HTTP method table from ESP-IDF's nghttp (#4900)
Fixes: #4884

* Use HTTP method table from ESP-IDF's nghttp
* Parse methods using IDF's HTTP method list
* Make example's loops to allow the CPU to switch tasks
2021-03-05 13:40:52 +02:00
Me No Dev
1cf1c8eb79
Fix several SD card issues (#4876)
- File might not eval to false if opened with write/append and SD is gone
- Allow card to be formatted if FAT partition was not found
- Mark card as gone in certain situations
- Fix several logic errors in low level SD API
2021-03-01 23:52:57 +02:00
me-no-dev
5d00b6eb16 Fix case where EEPROM will try to return longer string than it should
Fixes: https://github.com/espressif/arduino-esp32/issues/4768
2021-02-24 18:47:11 +02:00
Bascy
44aaf13225
Added BLEAddress operator overload methods (#4839)
Allows BLEAddress to be used as key in std::map etc
2021-02-22 19:37:07 +02:00
Clemens Kirchgatterer
560c0f45f5
Fix dropped SSL connection when buffer gets full. (#4820)
mbedTLS requires repeated calls to mbedtls_ssl_write() whenever it returns MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE. this happens when the client sends data faster then the server or the connection can handle.
2021-02-22 19:34:56 +02:00
me-no-dev
4b3f5c8ed4 Update licenses 2021-02-18 12:14:35 +02:00
Clemens Kirchgatterer
c282cd8f5f
Remove temp buffer in WiFiClientSecure::lastError (#4822)
The temp buffer serves no purpose here. Also mbedtls_strerror can be called with size == 0 safely.
2021-02-18 11:44:44 +02:00
Michael
1ab550f6f2
Changed BLE notify_callback from raw function pointer to std::function (#4737) 2021-02-16 22:10:04 +02:00
Emanuel Posescu
9be784f69b
Improve cleanup in BLEClient (#4742)
- Remove client from the list of devices in case registration fails
- Filter other events not related to registration during registration phase
- Cleanup if connect fails
- Reset if after disconnect
- Disconnect callback *after* cleanup is done so object can be deleted

This fixes some of the issues I had like:
- `BLEClient::connect` hangs up and never recovered because registration failed
- `BLEClient` could not be deleted after disconnect or deletion creating ghost events https://github.com/espressif/arduino-esp32/issues/4047
- `BLEClient` could not be properly reused after a connection was attempted (successful or not) 

* Cleanup in case of registration and connect failure.
Cleanup before calling disconnect callback for safe delete.
Reject other events during registration.
Adresses #4047, #4055

* Clear if after unregister #4047
2021-02-16 11:21:45 +02:00
Markus Frey
7cdfb8bc7c
Refactor BLEAdvertisedDevice (#4739)
fixes #4596

* Prevent possible undefined behaviour by get methods not taking an index as parameter
* Add methods to get the count of service data UUIDs and service UUIDs
* Various code improvements
2021-02-16 11:02:58 +02:00
me-no-dev
8134a42162 Fix leak of memory and possible crashes in AsyncUDP 2021-02-16 10:26:37 +02:00
Andre Lorbach
f13ff65691
AsyncUDP: Added lastErr helper variable (#4789)
The variable is useful when debugging AsyncUDP send problems.
The upper application can read and analyze the error reason.
2021-02-16 02:21:53 +02:00
ushiboy
e831680a41
Fixed a memory leak in BLE (issue #4753) (#4761)
* Fixed crash on delete after disconnect

* Fixed memory leak when getting characteristics

* Removed guard

Co-authored-by: ushiboy <ushiboy.dev@gmail.com>
2021-02-16 01:50:24 +02:00
Szymon Zmilczak
d964873840
Added more inclusive CORS policy (#4767) 2021-02-16 01:49:30 +02:00
Mitch Bradley
7e8993fc83
Speed up upload by a factor of 17 (#4787)
* Speed up upload by a factor of 17

Uploads are very slow because of an unnecessary "client.connected()" check in _uploadReadByte().

Here is what happens:
client.connected() is called for every byte read.  WiFiClient::connected() calls recv(fd(), &dummy, 0, MSG_DONTWAIT); which takes a relatively long time, so the optimized path of returning a buffered byte via client.read() is effectively nullified.

Removing the one line changed the upload speed for a 2 MB file (discarding the received data) from 22 KB/sec (before) to 367 KB/sec (after).

The change is safe in the face of disconnects because client.read(), when it no longer has buffered data, calls (WiFiClient)  fillBuffer(), which calls recv(), so the disconnection will be detected in due course.

* Move disconnect check into the timeout loop
2021-02-16 01:47:01 +02:00
Me No Dev
15bae92a72
Idf release/v3.3 d8082b7f3
* Update IDF to d8082b7f3
2021-02-16 01:37:37 +02:00
me-no-dev
6f23cd5988 Make sure that HTTPClient disconnects from the old server if redirecting to new one
Fixes: https://github.com/espressif/arduino-esp32/issues/4763
2021-02-04 02:42:44 +02:00
me-no-dev
ad4cf1461b Rework setHostname for WiFi STA
Fixes: https://github.com/espressif/arduino-esp32/issues/2537
2021-02-03 13:17:49 +02:00
me-no-dev
5de03a3918 Fix WiFi STA config IP to INADDR_NONE results in 255.255.255.255
Fixes: https://github.com/espressif/arduino-esp32/issues/4732
2021-02-03 11:47:35 +02:00
Emanuel Posescu
c9b3e512dd
Make BLERemoteCharacteristic::getRemoteService() public #3367 (#4735) 2021-01-21 14:30:33 +02:00
bot1131357
8d0e68db4f
Added parameter to Preferences::begin to select non-default NVS partition (#4718) 2021-01-15 19:06:51 +02:00
Keegan Morrow
5f98370707
Add IP101 support (#4620) 2021-01-11 12:00:35 +02:00
richardclli
81b9130d8d
BluetoothSerial SSP Authentication with callbacks (#4634)
Added authentication callbacks and example, resolves #4622.
2021-01-11 11:58:15 +02:00
Andrew
434d02c49f
BLERemoteCharacteristic::registerForNotify: Permit event registration without updating descriptor. (#4659) 2021-01-11 11:44:38 +02:00
Verkehrsrot
fe093a5e35
Sanitize compiler warning in BLERemoteService.cpp (issue #4660) (#4669)
Compiler complains on unused parameter pCharacteristicMap:

framework-arduinoespressif32\libraries\BLE\src\BLERemoteService.cpp: In member function 'void BLERemoteService::getCharacteristics(std::map<short unsigned int, BLERemoteCharacteristic*>*)':
\framework-arduinoespressif32\libraries\BLE\src\BLERemoteService.cpp:246:89: warning: parameter 'pCharacteristicMap' set but not used [-Wunused-but-set-parameter]
 void BLERemoteService::getCharacteristics(std::map<uint16_t, BLERemoteCharacteristic*>* pCharacteristicMap) {
2021-01-11 11:42:32 +02:00
Me No Dev
ef99cd7fe7
Add WiFiClientSecure::setInsecure() to equalize API with ESP8266 (#4648) 2020-12-21 01:09:37 +02:00
Clemens Kirchgatterer
3236358ded
Update WiFiClient.cpp (#4573)
Replace (depricated) bzero, bcopy with memset and memcpy.
2020-12-01 16:35:12 +02:00
Clemens Kirchgatterer
82e71f9b50
Update ssl_client.cpp (#4574)
Replace (depricated) bzero with memset.
2020-12-01 16:34:36 +02:00
Marc J
6b0114366b
Fix logic in SPIClass::setHwCs. (#4559)
Fixes #4558
2020-11-23 14:22:43 +02:00
Mike Dunston
97dcea2b99
Update library.properties (#4563)
Set the category to silence this warning in the Arduino IDE:
```
WARNING: Category '' in library WiFiProv is not valid. Setting to 'Uncategorized'
```
2020-11-23 14:21:34 +02:00
Sweety
dcff2e9774
Separate Provisioning library from WiFi library (#4547) 2020-11-19 00:12:16 +02:00
lbernstone
d8b1fc81c0
Added usedBytes to match other filesystems (#4534) 2020-11-15 08:48:21 +02:00
Me No Dev
378b6ac032
Fix issue in webserver with Chrome based browsers
https://github.com/espressif/arduino-esp32/issues/3652
2020-11-15 08:46:23 +02:00
Clemens Kirchgatterer
b6cc108d49
Update WiFiProv.cpp (#4519)
Do not pollute the global namespace with generic names like 'config' by declaring global variables 'static'.
2020-11-10 20:51:10 +02:00
Robby Decosemaeker
3274602eb0
Notify the batteryLevel change (#4517) 2020-11-10 13:02:00 +02:00
Me No Dev
486a4c66c4
SDCARD: First sector always written twice if multiple sectors are updated 2020-11-06 22:20:20 +02:00
ahorn42
c6a8da61f7
Allow faster reuse of socket, to be able to restart WifiServer. (#4306)
See #3960 for more details of the problem and the solution. I only implemented what was proposed in this ticket, as it solves my problem, which was the same as in this ticket. Credits for the code going to @etrinh ;-)

This also is a more consistence behaviour compared to esp8266, where it also is possible to restart the wifiserver immediately on the same port.
2020-11-06 14:16:50 +02:00
Frank
3968821834
HttpClient uses Serial.printf() (#4488)
changed to log_d()
2020-11-04 14:49:33 +02:00
Frank
90f869e772
Fix BUG: Parsing of first line fails (#4484)
..because a firstLine = false; is missing ;)
2020-11-04 02:24:01 +02:00
Me No Dev
22b427df0f
IDF release/v3.3 (#3672)
ESP-IDF release/v3.3: 66d3783c8
esp-face: 420fc7e
esp32-camera: 0107093
2020-11-03 21:20:00 +02:00
lbernstone
e2452c0dfc
Added isKey method to Preferences (#4441)
Checks to see if a string is a key in the namespace. 

Fixes #4440
2020-11-03 17:03:04 +02:00
Mark D
56a7ae8712
Trailing spaces (#3738)
* fix typo in WiFiMulti

* clean up trailing spaces

* clean up script file used in cleaning

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2020-11-02 22:11:26 +02:00
Denys Fedoryshchenko
e4b008e712
Handle stream timeouts properly, for slow HTTP/HTTPS links (#3752)
This patch fixes update timeouts (error #6) on slow HTTP/HTTPS links.
2020-11-02 22:01:27 +02:00
saknarak
dccb4e8608
improve & fix BLEScan when wantDuplicates (#3995)
* improve & fix BLEScan when too many BLE devices
- when wantDuplicates, no need to check duplicate and no more insert into vector
- delete advertisedDevice when not insert into vector, fix memory leak
- add showParse when you just want raw advertised data
2020-11-02 20:41:50 +02:00
Ivorius
0e341a6192
Add sdkconfig option CONFIG_ARDUINO_UDP_TASK_PRIORITY, which sets the task priority for the UDP vtask." (#4131) 2020-11-02 20:21:59 +02:00
buxtronix
76cd2e2375
Fix BLE connection handling (#4137)
Remove device from Peer list if connection fails.

Only call onConnect callback if connection was successful.

Only call onDisconnect callback if the connection was previously connected (ESP_GATTC_DISCONNECT_EVT is fired on a unsuccessful connection attempt also).

Resolves a number of issues with phantom events and callbacks being fired.
2020-11-02 20:20:40 +02:00
buxtronix
9f7ff009c6
Fix parameter to BLEDevice::updatePeerDevice (#4133)
::addPeerDevice and ::removePeerDevice are called with m_appId, so should ::updatePeerDevice as all use the same parameter for the underlying map's key.
2020-11-02 20:20:16 +02:00
Me No Dev
704b71dabe
Fix header parsing
fixes #4454

closes #4455
2020-11-02 20:10:22 +02:00
Ernst Sikora
7c0572172c
Fix for issue #4158: BLEAdvertising - Crash with stack trace originating in Bluedroid (#4182)
* Fix for issue #4158: Crash with stack trace originating in Bluedroid
Improved configuration of scan response data in 'BLEAdvertising' avoids the crash:
- Added member variable 'm_scanRespData' to configure scan response differently from advertising data
- Initialization of 'm_scanRespData' in BLEAdvertising constructor
- Use of 'm_scanRespData' within BLEAdvertising::start() to configure the scan response
- 'Flags' and 'Appearance' are cleared in the scan response data
- With this fix, device names of up to 29 characters can be used without causing a crash.
2020-11-02 19:39:20 +02:00
Niklas Mollenhauer
f57c36782f
Add sendContent overload that takes a const char* and a length (#4276)
The web server currently lacks the ability to send a buffer. Only strings are supported.

This PR adds an overload to sendContent.
2020-11-02 19:17:02 +02:00
Hristo Kapanakov
3054bdf5a5
HTTPUpdateServer library (#4244) 2020-11-02 19:16:23 +02:00
Ivan Golubic
d6b91872cb
Fix for espressif#3460 issue (#4424)
Fixes: #3460

This code has been run in production for 1 month and it looks stable, no data dropped and it definitely fixes the issue described. I think that this can be merged to avoid using custom package referencing in PlatformIO that has been used in quite a few projects for now.

Co-authored-by: Ivan Golubic <ivan@mvt-solutions.com>
2020-11-02 18:59:03 +02:00
Me No Dev
d6b383f84b
Merge pull request #4429 from Bmooij/feature/Add_flash_helper_constructor_to_Uri
Add flash helper constructor to Uri
2020-11-02 18:56:08 +02:00
thewavelength
cadbad8850
Add partition label argument to Update and ArduinoOTA classThe UpdateClass in the Updater component has the ability to update data toa SPIFFS partition. It selects the first available partition using theESP-IDF esp_partition_find_first() function.That behaviour is problematic if one has multiple SPIFFS partitions.This change allows a user to pass the label argument (defaults to NULL)to UpdateClass::begin() so a specific SPIFFS partition can be updated.Additionally, ArduinoOTA can set this partition label using thenew method ArduinoOTAClass::setPartitionLabel which is optional.This change does not break compatibility. (#4442)
The UpdateClass in the Updater component has the ability to update data to
a SPIFFS partition. It selects the first available partition using the
ESP-IDF esp_partition_find_first() function.
That behaviour is problematic if one has multiple SPIFFS partitions.

This change allows a user to pass the label argument (defaults to NULL)
to UpdateClass::begin() so a specific SPIFFS partition can be updated.

Additionally, ArduinoOTA can set this partition label using the
new method ArduinoOTAClass::setPartitionLabel which is optional.

This change does not break compatibility.
2020-11-02 18:49:24 +02:00
thewavelength
3cbfa2ffef
Add partition label argument to SPIFFS (#4443)
* Add partition label argument to SPIFFSSPIFFS currently assumes there is only ever one partition.This change allows a user to pass the label argument (defaults to NULL)to SPIFFS::begin() so a specific SPIFFS partition can be referenced.This change does not break compatibility.
2020-11-02 18:47:36 +02:00
Jimmy Durand Wesolowski
360e04fa36
Fixing BLE GATT Characteristic notification and Characteristic Descriptor read (#4464)
* BLERemoteChar: fix descriptor 2902 write for characteristic notifications

When registering a notification on a characteristic, the 2902 descriptor
(CCCD) value is set to 1 (or 2 for indication).
According to the BLUETOOTH CORE SPECIFICATION Version 5.2, Revision Date
2019-12-31, section 4.12.3 "Write Characteristic Descriptors" (page 1588),
the characteristic descriptor write must expect a response.
Currently, the descriptor write is performed without expecting a reponse,
which prevents the notification to be functional with some BLE stacks.
This commit modify the write to expect the response.

Signed-off-by: Jimmy Durand Wesolowski <jimmy.durand.wesolowski@commsolid.com>

* BLERemoteChar: forward GATT client event to characteristic descriptors

This commits prevents a permanent wait when calling BLERemoteDescriptor
readValue function, on the m_semaphoreReadDescrEvt semaphore.

ESP32 BLE stack calls to remote characteristic
- notification,
- value read
- value write
and remote characteristic descriptor
- value read
are asynchronous.

When such a call is performed by this library, a semaphore is taken prior
to the BLE stack read or write operation, and waited on after it.

Releasing the semaphore is done by the characteristic event handling
function (gattClientEventHandler), when the appropriate event is received.

However, the characteristic descriptor events are discarded, and the
value read semaphore is never released.

This commits forwards the GATT client events from the remote
characteristic down to their remote characteristic descriptor, and
implements their event handling.

Adding a semaphore for the remote characteristic descriptor value write
will be done in a separate commit.

Signed-off-by: Jimmy Durand Wesolowski <jimmy.durand.wesolowski@commsolid.com>

* BLERemoteDescriptor: add semaphore to characteristic descriptor write

This adds a semaphore to characteristic descriptor value write, to mimic
the value read function, and to ensure completion of the operation before
we carry on.

Signed-off-by: Jimmy Durand Wesolowski <jimmy.durand.wesolowski@commsolid.com>

Co-authored-by: Jimmy Durand Wesolowski <jimmy.durand.wesolowski@commsolid.com>
2020-11-02 18:36:25 +02:00
Muhammad Mobashir
57145ade6f
Small description comment correction (#4471)
esp8266 --> esp32
2020-11-02 18:35:23 +02:00
snosrap
f39024675c
Don't convert to null-terminated string prior to writeValue (#4473)
fixes: #4472
2020-11-02 18:34:57 +02:00
JelleWho
f7fb00632e
#4293 added missing '<tr>' (#4450)
Fixes issue #4293
2020-10-27 15:35:54 +02:00
M Hotchin
7e40de226f
Fixes #4435 - WiFiClient improperly treats zero data available for read as an error (#4448) 2020-10-27 12:01:41 +02:00
Bob Mooij
ae240a3902 Add flash helper constructor to Uri 2020-10-19 16:20:49 +02:00
Dirk-Willem van Gulik
d79a1f3d10
Add an aditional (void *) arg to the RMT callback (much like Ticker() et.al.). (#3345)
* Add an aditional (void *) arg to the RMT callback - to allow more flexible handling of the callback (e.g. by passing a private struct or a class pointer). Same pattern as used by the Ticker() and many others. Example updated & new example with a trapoline added.

* Fix example for new API

* Fix lint warnings

* Add a second missed example.

* Correct timeout & improve socket error handling.
2020-10-14 14:41:50 +03:00
Dan Oprescu
ee3bb16c77
Fix support for following redirects added by ee88c42c3b (#4240) (#4385) 2020-10-14 14:32:47 +03:00
programminghoch10
c3f3497048
fixed some typos (#4395) 2020-10-14 14:27:49 +03:00
programminghoch10
18c3345451
fix typos in WiFiSTA.cpp (#4396)
* fix typos

* made return value description a bit more helpful
2020-10-14 14:27:19 +03:00
Vo Linh Truc
2685a5dd7b
Certificate isn't be free in case parse failure. (#4412)
I met problem while I was working with the WiFiClientSecure.
I tried to found the source of the problem, and I found it in the sll_client.cpp.
Please check my contribution.

I've open this problem in #4335 but received no response.
2020-10-14 14:25:26 +03:00
TANAKA Masayuki
675a40b257
Fix Not by reference. But the value was updated. (#3279) 2020-10-03 03:41:03 +03:00
Shawn A
f76ec4f50b
adds debugging to dnsserver (#1046) 2020-10-03 02:59:55 +03:00
sasodoma
219ff3005b
Add missing slashes in HTTPUpdate examples (#4238)
I spent quite a while today figuring out how to get an OTA update over HTTPS on a custom port working. A part of my problem was not putting a slash before the .bin filename, since it wasn't there in the example. This produced invalid HTTP requests. Adding the slash would make it clear that it needs to be there.

Given that the URL in line 53 contains the same words "server" and "file.bin", one might assume that in line 55, the slash after the port number would get added automatically, however I have found out that without a slash you get an invalid request. Adding the slash removes any doubt.
2020-10-03 02:13:27 +03:00
thebigpotatoe
99aa866477
Update MDNSResponder::addService to return a boolean (#4365)
I was playing with the mDNS service and noticed the method MDNSResponder::addService could return a Boolean with the way it is implemented just like other functions in this library.

This would be handy to know at a higher level weather or not the service was added correctly to the mDNS server of the ESP32.
2020-10-01 15:44:24 +03:00
Jens Hauke
82670b96f8
Fix for missed scan response data (BLEScan). (#4358)
This is a fix for missing scan responses after a first successfull scan.

While running the BLE_scan.ino sketch with wantDuplicates=false, i got
only one result with correct advertising and scan response length (31,26):

pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), false);
pBLEScan->start(scanTime, false);
...
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 31 + 26, addr type: 1

All following calls to start() just returned the advertising data without
scan response data:

pBLEScan->start(scanTime, false);
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 31 + 0, addr type: 1

With "wantDuplicates=true" i got:

pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), true);
pBLEScan->start(scanTime, false);
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 31 + 26, addr type: 1
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 31 + 26, addr type: 1
[W][BLEScan.cpp:73] handleGAPEvent(): ESP_GAP_SEARCH_INQ_CMPL_EVT
Devices found: 1
Scan done!
pBLEScan->start(scanTime, false);
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 31 + 0, addr type: 1
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 0 + 26, addr type: 1
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 31 + 0, addr type: 1
[W][BLEScan.cpp:109] handleGAPEvent(): bytes length: 0 + 26, addr type: 1

Explicitly initializing m_scan_params.scan_duplicate of BLEScan solves
this issue (In my case the un-initialized value was
m_scan_params.scan_duplicate == 1073599044).

Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2020-10-01 15:43:30 +03:00
lbernstone
9e7b13e46d
WebServer.handleClient delay (#4350)
* If WebServer.handleClient is run in a tight loop, it will starve other processes.  So, if there is no connection, throw in a delay(1).  Fixes #4348

* Made a variable to control the delay behavior
2020-10-01 15:42:23 +03:00
Tom Davis
1f4491f4ee
Updated AzureIoT submodule. (#4322) 2020-10-01 15:38:56 +03:00
wadim
aa529eb5a0
Fix getString() freeze on empty responses (#4317) 2020-10-01 15:36:23 +03:00
lbernstone
99c94bb482
Set SD state to idle before unregister (reduces power) (#4272) 2020-10-01 15:31:16 +03:00
Cristian Popescu
0957776855
Reinit updater md5 related fields (#4260)
MD5 cleanup on begin
Typos
2020-10-01 15:29:58 +03:00
Clickau
ee88c42c3b
Add support for following redirects in HTTPClient (#4240) 2020-10-01 14:41:54 +03:00
nicolaser15
663effa00e
Update Parsing.cpp (#4217)
* Update Parsing.cpp

When uploading TLS cert files the end of file "-----END CERTIFICATE-----" (or any kind of file with the sequence "CRLF--") is taken as posible end boundary. Then it is compared to the start boundary string. As it is expected, comparison turns to be false, and the whole end boundary string is put to _currentUpload->buf through _uploadWriteByte(). Here you have the problem: if you read boundary.length() bytes from HTTP request and you have some of the actual end boundary bytes in it, when you put all those bytes into _currentUpload->buf you are making a mistake. You will miss the actual end boundary string because some of those bytes were put in _currentUpload->buf.

* Update Parsing.cpp
2020-10-01 14:37:59 +03:00
lbernstone
882b12c44e
rmdir causes issues in SPIFFS. Fixes #4138, albeit not very cleanly (#4154)
SPIFFS causes crashes if you attempt to rmdir. Since there are no true directories in spiffs, this ought to be a noop. It looks like @me-no-dev worked around this by using unlink instead of rmdir, which works in fatfs and doesn't panic spiffs. This behavior is not universal. In order to get littlefs working, it would be good to get this back to conformity. Rather than digging deep into the upstream spiffs, I just check the mountpoint and noop if it is "/spiffs". So, if the user has changed the mountpoint, this will not work, but I think it's a pretty good tradeoff.
2020-10-01 13:52:24 +03:00
Dan Head
93d850f783
Fixed comment with correct FQDN (#4152) 2020-10-01 13:51:36 +03:00
buxtronix
4f48caca2c
Set scan_duplicate in BLE scan params (#4126)
This value is uninitialised and as such can be a random (and invalid) value. It's needs to be set per the espressif documentation here:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_gap_ble.html#_CPPv4N21esp_ble_scan_params_t14scan_duplicateE

This PR sets it to DUPLICATE_DISABLE. Chosen as this is needed to ensure all scan data is populated in the scan callback, per this comment in the IDF:

https://github.com/espressif/esp-idf/blob/master/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c#L3591

"//if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer"

We **don't** want it to report to the higher layer (ie BLEScan.cpp) **unless** it has the active scan response.

Seems to resolve #3770 #3677 and possibly others.
2020-10-01 13:45:45 +03:00
Nikos Mouratidis
80e9e42c3b
Fix issue #3522 (WiFi does not restart after stopped) (#4114)
This commit fixes issue https://github.com/espressif/arduino-esp32/issues/3522 where WiFi service fails to start after a WiFi.disconnect(true) or a WiFi.mode(WIFI_OFF).
2020-09-30 15:34:10 +03:00
Emil Sandstø
494061af26
WebServer: Fix OOB write (#4088)
Successful exploitation could lead to arbitrary code execution.

The bug can be reproduced by running the following in a browser:
```
const formData = new FormData();
for (let i = 0;i < 33;++i) { formData.append("foo", i.toString()); }
await fetch("http://esp.local", { method: 'POST', body: formData });
```
2020-09-30 15:28:28 +03:00
Kevin Hester
2fd3d042b2
Fix #4046 Details below: (#4086)
Informed by the discussion in the bug and the code in 'that other branch'
the fix was clear.  Just set a flag if we start handling a write, and
use that flag to guard the long write complete call.
2020-09-30 15:27:35 +03:00
ToXIc
b551310c37
Minor change but could confuse some (#4084) 2020-09-30 15:26:38 +03:00
lbernstone
f30edd040e
Update CaptivePortal.ino (#4080)
* Update CaptivePortal.ino

Illegal SSID used for SoftAP

* Fixed ordering problem.  Now actually works
2020-09-30 15:26:15 +03:00
chegewara
b7c5e502e7
Add static pin support (#4078) 2020-09-30 15:25:42 +03:00
M. Betz
fa8a1c38d5
fix #4071 (#4072)
SPIFFS File object evaluates as true even if the file could not be opened.
2020-09-30 15:24:59 +03:00
cweinhofer
d56267bd8c
Update GetChipID.ino (#4070)
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2020-09-30 15:24:29 +03:00
buxtronix
1f6b0b35f8
Have BLECLient gattc event handlers verify conn_id (#4064)
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
2020-09-30 15:21:59 +03:00
buxtronix
342b9cf2d8
Fix handling of registerForNotify in BLERemoteCharacteristic.cpp (#4063) 2020-09-30 15:20:28 +03:00
pulquero
11d071b1c8
Fix to allow more than one certificate to be loaded (espressif#3248). (#4056)
Co-authored-by: Mark Hale <mark.hale@physics.org>
2020-09-30 15:19:41 +03:00
Bascy
c1a7198e7d
Don't change owner if take() doesnt succeed (#3987) 2020-09-30 15:15:47 +03:00
lbernstone
19ccc479c3
WIFI_PS_MAX_MODEM feature requested #3896 (#3900) 2020-09-30 15:06:58 +03:00
robertpoll
c18d50cb91
Use esp_partition_* functions in Updater.cpp (#3898)
Background

The current implementation of Update() uses the spi_flash_* api to write and read from flash. These functions ignore the partition->encrypted flag and always write raw data to flash even if the partition is marked as encrypted.

Changes in this PR

Update() now uses the esp_partition_* api.
Wrapper functions for esp_partition_* added to ESP.cpp. This was done to maintain a consistent approach to the way the spi_flash_* functions were used. I note though that not all of the esp-idf functions are used are wrapped, for example esp_ota_get_next_update_partition() so it may be that these should not be added?
The current implementation of Update() changes the first (magic) byte of firmware to 0xFF on write, and then when the firmware is completely written changes it back to ESP_IMAGE_HEADER_MAGIC. This works without erasing the sector because flash bits can be changed from 1->0 (but not 0->1). If the flash is encrypted then the actual data written to flash will not be all ones, so this approach will not work. In addition, encrypted flash must be written in 16 byte blocks. So, instead of changing the first byte the changed code stashes the first 16 bytes, and starts writing at the 17th byte, leaving the first 16 bytes as 0xFF. Then, in _enablePartition() the stashed bytes can be successfully written.
Benefits

Whilst it's not possible to use encrypted flash directly from either the Arduino IDE or PIO it's reasonably straightforward to compile and flash a bootloader with the necessary support from a simple esp-idf project and then use ArduinoOTA for subsequent updates. This PR enables the use of this workflow until such time as encrypted flash is supported, and is a first (small) step toward adding support.
Regardless of the above, the esp_partition_* api is recommended over the api_flash_* api.
Application code should mostly use these esp_partition_* API functions instead of lower level spi_flash_* API functions. Partition table API functions do bounds checking and calculate correct offsets in flash, based on data stored in a partition table.
2020-09-30 15:06:19 +03:00
sindney
5197916983
Fix BLEClient disconnect bug (#3876)
By default the disconnect is broadcasted to every clients. So if you call disconnect on one connected client, they'll all be disconnected if we don't filter the event by conn_id.
2020-09-30 15:01:02 +03:00
Martijn Scheepers
7e9d42da68
ESP.getChipModel() and ESP.getChipCores() (#3847)
* ESP.getChipModel() returns model of the chip

* ESP.getChipCores() returns the core count.

* Example gives chip model, revision and core count.

* Read efuse for chipmodel

Co-authored-by: Martijn Scheepers <ms@SDNengineering.nl>
2020-09-30 14:57:36 +03:00
Bernd Giesecke
ef2b54547e
Fix issue #3833, data parsing of Eddystone TLM data frame (#3836)
* Fix issue #3833, data parsing of Eddystone TLM data frame    
Add Beacon scanner example to show usage of BLEEddystoneTLM class and  BLEEddystoneURL class     
Add EddystoneTLM beacon example    
Add EddystoneURL beacon example

* Fix buffer size for .toString()
2020-09-30 14:55:58 +03:00
jgdent
9856f0cc28
Update RMTLoopback.ino (#3823)
BUGFIX: avoids assertion in xEventGroupWaitBits()
(/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/event_groups.c:350 (xEventGroupWaitBits)- assert failed!)
2020-09-30 14:52:22 +03:00
Mark D
af7ec4ead1
fix EEPROM class example (#3786) 2020-09-30 14:43:05 +03:00
kliment
7a92f89d12
Set TLS cert options before calling connect on client, so verify works (#3774)
When connecting using transportTraits, the CA and client certificates are ignored after the initial _client->connect() is called. This is because on connect, WiFiClientSecure will call start_ssl_client with _CA_Cert and other cert options set to null unless setCACert, setCertificate etc. are called before connect. Running _transportTraits->verify after connect therefore does exactly nothing. It's easy to verify that this is the case by passing a CACert to HTTPClient with verbose logging enabled - the logs will say "WARNING: Use certificates for a more secure communication!" which is only present when both PSK and CA are null. This change fixes the issue.
2020-09-30 14:41:03 +03:00
puuu
5871ca9ce9
UpdateClass::printError now accepts the Print object (#3763) 2020-09-30 14:39:25 +03:00
Mark D
0dfa5babc2
fix typo in WiFiMulti (#3737) 2020-09-30 14:37:21 +03:00
Andrzej Sierżęga
e4b2ce4e81
DNS resolving timeout change to prevent stack overlapping (#3731)
Real DNS resolving timeout used by lwip library is 14[s] (7[s] for DNS1 + 7[s] for DNS2). Function WiFiGenericClass::hostByName() has timeout set to lower value (only 4[s]), so callback function may be called after this low timeout and it may overlappe stack memory used now by other function.
Fixes #3722
2020-09-30 14:35:53 +03:00
Me No Dev
7af4490fcc
Update SPI.h 2020-09-30 14:34:37 +03:00
crnchbng
5999b7ba46
removed double delete of characteristics (#3521) 2020-09-30 14:25:31 +03:00
Sweety
9d547a8a44
Provisioning fixes for: 1.Space 2.Provisioned (#4291) 2020-08-25 11:03:06 +03:00
Sweety
1fd5cd79c5
Add OTA update feature
This sketch provide functionality for OTA firmware upgrade.
2020-08-25 11:01:58 +03:00