diff --git a/libraries/BLE/examples/BLE5_extended_scan/BLE5_extended_scan.ino b/libraries/BLE/examples/BLE5_extended_scan/BLE5_extended_scan.ino index c2ff2ec8a524980a67abdaa9d74215183de83cad..d3606e691d5a4b5807137edd13dca4bf455a3296 100644 --- a/libraries/BLE/examples/BLE5_extended_scan/BLE5_extended_scan.ino +++ b/libraries/BLE/examples/BLE5_extended_scan/BLE5_extended_scan.ino @@ -18,26 +18,6 @@ uint32_t scanTime = 100; //In 10ms (1000ms) BLEScan* pBLEScan; -/** -* @brief extend adv report parameters -*/ -//typedef struct { -// esp_ble_gap_adv_type_t event_type; /*!< extend advertising type */ -// uint8_t addr_type; /*!< extend advertising address type */ -// esp_bd_addr_t addr; /*!< extend advertising address */ -// esp_ble_gap_pri_phy_t primary_phy; /*!< extend advertising primary phy */ -// esp_ble_gap_phy_t secondly_phy; /*!< extend advertising secondary phy */ -// uint8_t sid; /*!< extend advertising sid */ -// uint8_t tx_power; /*!< extend advertising tx power */ -// int8_t rssi; /*!< extend advertising rssi */ -// uint16_t per_adv_interval; /*!< periodic advertising interval */ -// uint8_t dir_addr_type; /*!< direct address type */ -// esp_bd_addr_t dir_addr; /*!< direct address */ -// esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */ -// uint8_t adv_data_len; /*!< extend advertising data length */ -// uint8_t adv_data[251]; /*!< extend advertising data */ -//} esp_ble_gap_ext_adv_reprot_t; - class MyBLEExtAdvertisingCallbacks: public BLEExtAdvertisingCallbacks { void onResult(esp_ble_gap_ext_adv_reprot_t report) { if(report.event_type & ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY){ diff --git a/libraries/BLE/examples/BLE5_periodic_sync/BLE5_periodic_sync.ino b/libraries/BLE/examples/BLE5_periodic_sync/BLE5_periodic_sync.ino index fdc25b394a2f2e05042892e518d103436ac00299..ac3a5e983a468d4f8fa87dad5cf665f497735a55 100644 --- a/libraries/BLE/examples/BLE5_periodic_sync/BLE5_periodic_sync.ino +++ b/libraries/BLE/examples/BLE5_periodic_sync/BLE5_periodic_sync.ino @@ -25,26 +25,6 @@ static esp_ble_gap_periodic_adv_sync_params_t periodic_adv_sync_params = { .sync_timeout = 1000, // timeout: 1000 * 10ms }; -/** -* @brief extend adv report parameters -*/ -//typedef struct { -// esp_ble_gap_adv_type_t event_type; /*!< extend advertising type */ -// uint8_t addr_type; /*!< extend advertising address type */ -// esp_bd_addr_t addr; /*!< extend advertising address */ -// esp_ble_gap_pri_phy_t primary_phy; /*!< extend advertising primary phy */ -// esp_ble_gap_phy_t secondly_phy; /*!< extend advertising secondary phy */ -// uint8_t sid; /*!< extend advertising sid */ -// uint8_t tx_power; /*!< extend advertising tx power */ -// int8_t rssi; /*!< extend advertising rssi */ -// uint16_t per_adv_interval; /*!< periodic advertising interval */ -// uint8_t dir_addr_type; /*!< direct address type */ -// esp_bd_addr_t dir_addr; /*!< direct address */ -// esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */ -// uint8_t adv_data_len; /*!< extend advertising data length */ -// uint8_t adv_data[251]; /*!< extend advertising data */ -//} esp_ble_gap_ext_adv_reprot_t; - class MyBLEExtAdvertisingCallbacks : public BLEExtAdvertisingCallbacks { void onResult(esp_ble_gap_ext_adv_reprot_t params) diff --git a/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino b/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino index 86cbe168a145c94fd83d003837c45d4dae6d528f..5027ae6a7e32570249f906856a9b8e6b4b26443e 100644 --- a/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino +++ b/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino @@ -6,6 +6,11 @@ #include "BluetoothSerial.h" +//#define USE_PIN // Uncomment this to use PIN during pairing. The pin is specified on the line below +const char *pin = "1234"; // Change this to more secure PIN. + +String device_name = "ESP32-BT-Slave"; + #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it #endif @@ -18,8 +23,13 @@ BluetoothSerial SerialBT; void setup() { Serial.begin(115200); - SerialBT.begin("ESP32test"); //Bluetooth device name - Serial.println("The device started, now you can pair it with bluetooth!"); + SerialBT.begin(device_name); //Bluetooth device name + Serial.printf("The device with name \"%s\" is started.\nNow you can pair it with Bluetooth!\n", device_name.c_str()); + //Serial.printf("The device with name \"%s\" and MAC address %s is started.\nNow you can pair it with Bluetooth!\n", device_name.c_str(), SerialBT.getMacString()); // Use this after the MAC method is implemented + #ifdef USE_PIN + SerialBT.setPin(pin); + Serial.println("Using PIN"); + #endif } void loop() { diff --git a/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino b/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino index fc650059fb711ded82ee4cef00d9480a300d927a..d71941b002d315df9e7f7efb029de7aa37a1f749 100644 --- a/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino +++ b/libraries/BluetoothSerial/examples/SerialToSerialBTM/SerialToSerialBTM.ino @@ -1,52 +1,81 @@ -//This example code is in the Public Domain (or CC0 licensed, at your option.) -//By Victor Tchistiak - 2019 +// This example code is in the Public Domain (or CC0 licensed, at your option.) +// By Victor Tchistiak - 2019 // -//This example demostrates master mode bluetooth connection and pin -//it creates a bridge between Serial and Classical Bluetooth (SPP) -//this is an extention of the SerialToSerialBT example by Evandro Copercini - 2018 +// This example demonstrates master mode Bluetooth connection to a slave BT device using PIN (password) +// defined either by String "slaveName" by default "OBDII" or by MAC address // +// This example creates a bridge between Serial and Classical Bluetooth (SPP) +// This is an extension of the SerialToSerialBT example by Evandro Copercini - 2018 +// +// DO NOT try to connect to phone or laptop - they are master +// devices, same as the ESP using this code - it will NOT work! +// +// You can try to flash a second ESP32 with the example SerialToSerialBT - it should +// automatically pair with ESP32 running this code #include "BluetoothSerial.h" +#define USE_NAME // Comment this to use MAC address instead of a slaveName +const char *pin = "1234"; // Change this to reflect the pin expected by the real slave BT device + #if !defined(CONFIG_BT_SPP_ENABLED) #error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip. #endif BluetoothSerial SerialBT; -String MACadd = "AA:BB:CC:11:22:33"; -uint8_t address[6] = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33}; -//uint8_t address[6] = {0x00, 0x1D, 0xA5, 0x02, 0xC3, 0x22}; -String name = "OBDII"; -const char *pin = "1234"; //<- standard pin would be provided by default -bool connected; +#ifdef USE_NAME + String slaveName = "ESP32-BT-Slave"; // Change this to reflect the real name of your slave BT device +#else + String MACadd = "AA:BB:CC:11:22:33"; // This only for printing + uint8_t address[6] = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33}; // Change this to reflect real MAC address of your slave BT device +#endif + +String myName = "ESP32-BT-Master"; void setup() { + bool connected; Serial.begin(115200); - //SerialBT.setPin(pin); - SerialBT.begin("ESP32test", true); - //SerialBT.setPin(pin); - Serial.println("The device started in master mode, make sure remote BT device is on!"); - - // connect(address) is fast (upto 10 secs max), connect(name) is slow (upto 30 secs max) as it needs - // to resolve name to address first, but it allows to connect to different devices with the same name. - // Set CoreDebugLevel to Info to view devices bluetooth address and device names - connected = SerialBT.connect(name); - //connected = SerialBT.connect(address); - + + SerialBT.begin(myName, true); + Serial.printf("The device \"%s\" started in master mode, make sure slave BT device is on!\n", myName.c_str()); + + #ifndef USE_NAME + SerialBT.setPin(pin); + Serial.println("Using PIN"); + #endif + + // connect(address) is fast (up to 10 secs max), connect(slaveName) is slow (up to 30 secs max) as it needs + // to resolve slaveName to address first, but it allows to connect to different devices with the same name. + // Set CoreDebugLevel to Info to view devices Bluetooth address and device names + #ifdef USE_NAME + connected = SerialBT.connect(slaveName); + Serial.printf("Connecting to slave BT device named \"%s\"\n", slaveName.c_str()); + #else + connected = SerialBT.connect(address); + Serial.print("Connecting to slave BT device with MAC "); Serial.println(MACadd); + #endif + if(connected) { - Serial.println("Connected Succesfully!"); + Serial.println("Connected Successfully!"); } else { while(!SerialBT.connected(10000)) { - Serial.println("Failed to connect. Make sure remote device is available and in range, then restart app."); + Serial.println("Failed to connect. Make sure remote device is available and in range, then restart app."); } } - // disconnect() may take upto 10 secs max + // Disconnect() may take up to 10 secs max if (SerialBT.disconnect()) { - Serial.println("Disconnected Succesfully!"); + Serial.println("Disconnected Successfully!"); } - // this would reconnect to the name(will use address, if resolved) or address used with connect(name/address). + // This would reconnect to the slaveName(will use address, if resolved) or address used with connect(slaveName/address). SerialBT.connect(); + if(connected) { + Serial.println("Reconnected Successfully!"); + } else { + while(!SerialBT.connected(10000)) { + Serial.println("Failed to reconnect. Make sure remote device is available and in range, then restart app."); + } + } } void loop() { diff --git a/libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino b/libraries/ESP32/examples/ESPNow/ESPNow_Basic_Master/ESPNow_Basic_Master.ino similarity index 100% rename from libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino rename to libraries/ESP32/examples/ESPNow/ESPNow_Basic_Master/ESPNow_Basic_Master.ino diff --git a/libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino b/libraries/ESP32/examples/ESPNow/ESPNow_Basic_Slave/ESPNow_Basic_Slave.ino similarity index 100% rename from libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino rename to libraries/ESP32/examples/ESPNow/ESPNow_Basic_Slave/ESPNow_Basic_Slave.ino diff --git a/libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino b/libraries/ESP32/examples/ESPNow/ESPNow_MultiSlave_Master/ESPNow_MultiSlave_Master.ino similarity index 100% rename from libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino rename to libraries/ESP32/examples/ESPNow/ESPNow_MultiSlave_Master/ESPNow_MultiSlave_Master.ino diff --git a/libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino b/libraries/ESP32/examples/ESPNow/ESPNow_MultiSlave_Slave/ESPNow_MultiSlave_Slave.ino similarity index 100% rename from libraries/ESP32/examples/ESPNow/Multi-Slave/Slave/Slave.ino rename to libraries/ESP32/examples/ESPNow/ESPNow_MultiSlave_Slave/ESPNow_MultiSlave_Slave.ino diff --git a/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino b/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino index f18db753342ad76cc3a14a228786a062ce39313f..844a14dabd1467c6ffd47ca5fb691c093809b0c6 100644 --- a/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino +++ b/libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino @@ -7,28 +7,28 @@ class Button { public: - Button(uint8_t reqPin) : PIN(reqPin){ - pinMode(PIN, INPUT_PULLUP); - attachInterrupt(PIN, std::bind(&Button::isr,this), FALLING); - }; - ~Button() { - detachInterrupt(PIN); - } - - void ARDUINO_ISR_ATTR isr() { - numberKeyPresses += 1; - pressed = true; - } - - void checkPressed() { - if (pressed) { - Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses); - pressed = false; - } - } + Button(uint8_t reqPin) : PIN(reqPin){ + pinMode(PIN, INPUT_PULLUP); + attachInterrupt(PIN, std::bind(&Button::isr,this), FALLING); + }; + ~Button() { + detachInterrupt(PIN); + } + + void ARDUINO_ISR_ATTR isr() { + numberKeyPresses += 1; + pressed = true; + } + + void checkPressed() { + if (pressed) { + Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses); + pressed = false; + } + } private: - const uint8_t PIN; + const uint8_t PIN; volatile uint32_t numberKeyPresses; volatile bool pressed; }; @@ -42,6 +42,6 @@ void setup() { } void loop() { - button1.checkPressed(); - button2.checkPressed(); + button1.checkPressed(); + button2.checkPressed(); } diff --git a/libraries/ESP32/examples/GPIO/FunctionalInterruptStruct/FunctionalInterruptStruct.ino b/libraries/ESP32/examples/GPIO/FunctionalInterruptStruct/FunctionalInterruptStruct.ino new file mode 100644 index 0000000000000000000000000000000000000000..87c88c851293fd9faaf0722f653e74605770ffe7 --- /dev/null +++ b/libraries/ESP32/examples/GPIO/FunctionalInterruptStruct/FunctionalInterruptStruct.ino @@ -0,0 +1,39 @@ +#include + +#define BUTTON1 16 +#define BUTTON2 17 + +struct Button { + uint8_t PIN; + volatile uint32_t numberKeyPresses; + volatile int pressed; +}; + +void isr(void* param) { + struct Button *button = (struct Button*) param; + button->numberKeyPresses += 1; + button->pressed = 1; +} + +void checkPressed(struct Button* button) { + if(button->pressed) { + Serial.printf("Button on pin %u has been pressed %u times\n", button->PIN, button->numberKeyPresses); + button->pressed = 0; + } +} + +struct Button button1 = {BUTTON1, 0, 0}; +struct Button button2 = {BUTTON2, 0, 0}; + +void setup() { + Serial.begin(115200); + pinMode(button1.PIN, INPUT_PULLUP); + pinMode(button2.PIN, INPUT_PULLUP); + attachInterruptArg(button1.PIN, isr, (void*)&button1, FALLING); + attachInterruptArg(button2.PIN, isr, (void*)&button2, FALLING); +} + +void loop() { + checkPressed(&button1); + checkPressed(&button2); +} diff --git a/libraries/WebServer/examples/MultiHomedServers/MultiHomedServers.ino b/libraries/WebServer/examples/MultiHomedServers/MultiHomedServers.ino index 0e77fc3dd641bcfe467704ad69b852bf0980b20c..47eb63b852ff39173f5d9277437fb2e575dc8462 100644 --- a/libraries/WebServer/examples/MultiHomedServers/MultiHomedServers.ino +++ b/libraries/WebServer/examples/MultiHomedServers/MultiHomedServers.ino @@ -3,62 +3,17 @@ #include #include -/* - * MultiHomedServers - * - * MultiHomedServers tests support for multi-homed servers, i.e. a distinct web servers on each IP interface. - * It only tests the case n=2 because on a basic ESP32 device, we only have two IP interfaces, namely - * the WiFi station interfaces and the WiFi soft AP interface. - * - * For this to work, the WebServer and the WiFiServer classes must correctly handle the case where an - * IP address is passed to their relevant constructor. It also requires WebServer to work with multiple, - * simultaneous instances. - * - * Testing the WebServer and the WiFiServer constructors was the primary purpose of this script. - * The part of WebServer used by this sketch does seem to work with multiple, simultaneous instances. - * However there is much functionality in WebServer that is not tested here. It may all be well, but - * that is not proven here. - * - * This sketch starts the mDNS server, as did HelloServer, and it resolves esp32.local on both interfaces, - * but was not otherwise tested. - * - * This script also tests that a server not bound to a specific IP address still works. - * - * We create three, simultaneous web servers, one specific to each interface and one that listens on both: - * - * name IP Address Port - * ---- ---------- ---- - * server0 INADDR_ANY 8080 - * server1 station address 8081 - * server2 soft AP address 8081 - * - * The expected responses to a brower's requests are as follows: - * - * 1. when client connected to the same WLAN as the station: - * Request URL Response - * ----------- -------- - * http://stationaddress:8080 "hello from server0" - * http://stationaddress:8081 "hello from server1" - * - * 2. when client is connected to the soft AP: - * - * Request URL Response - * ----------- -------- - * http://softAPaddress:8080 "hello from server0" - * http://softAPaddress:8081 "hello from server2" - * - * 3. Repeat 1 and 2 above with esp32.local in place of stationaddress and softAPaddress, respectively. - * - * MultiHomedServers was originally based on HelloServer. - */ - -const char* ssid = "........"; -const char* password = "........"; +const char* ssid = "WiFi_SSID"; +const char* password = "WiFi_Password"; const char *apssid = "ESP32"; WebServer *server0, *server1, *server2; +#ifdef LED_BUILTIN +const int led = LED_BUILTIN; +#else const int led = 13; +#endif void handleRoot(WebServer *server, const char *content) { digitalWrite(led, 1); @@ -67,15 +22,15 @@ void handleRoot(WebServer *server, const char *content) { } void handleRoot0() { - handleRoot(server0, "hello from server0"); + handleRoot(server0, "Hello from server0 who listens on both WLAN and own Soft AP"); } void handleRoot1() { - handleRoot(server1, "hello from server1"); + handleRoot(server1, "Hello from server1 who listens only on WLAN"); } void handleRoot2() { - handleRoot(server2, "hello from server2"); + handleRoot(server2, "Hello from server2 who listens only on own Soft AP"); } void handleNotFound(WebServer *server) { @@ -111,9 +66,12 @@ void setup(void) { pinMode(led, OUTPUT); digitalWrite(led, 0); Serial.begin(115200); + while(!Serial){ delay(100); } + Serial.println("Multi-homed Servers example starting"); + delay(1000); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); - Serial.println(""); + Serial.print("Connecting "); // Wait for connection while (WiFi.status() != WL_CONNECTED) { @@ -121,9 +79,9 @@ void setup(void) { Serial.print("."); } Serial.println(""); - Serial.print("Connected to "); - Serial.println(ssid); - Serial.print("IP address: "); + Serial.print("Connected to \""); + Serial.print(ssid); + Serial.print("\", IP address: \""); Serial.println(WiFi.localIP()); if (!WiFi.softAP(apssid)) { Serial.println("failed to start softAP"); @@ -134,9 +92,9 @@ void setup(void) { delay(100); } } - Serial.print("Soft AP: "); + Serial.print("Soft AP SSID: \""); Serial.print(apssid); - Serial.print(" IP address: "); + Serial.print("\", IP address: "); Serial.println(WiFi.softAPIP()); if (MDNS.begin("esp32")) { @@ -161,6 +119,10 @@ void setup(void) { Serial.println("HTTP server1 started"); server2->begin(); Serial.println("HTTP server2 started"); + + Serial.printf("SSID: %s\n\thttp://", ssid); Serial.print(WiFi.localIP()); Serial.print(":8080\n\thttp://"); Serial.print(WiFi.localIP()); Serial.println(":8081"); + Serial.printf("SSID: %s\n\thttp://", apssid); Serial.print(WiFi.softAPIP()); Serial.print(":8080\n\thttp://"); Serial.print(WiFi.softAPIP()); Serial.println(":8081"); + Serial.printf("Any of the above SSIDs\n\thttp://esp32.local:8080\n\thttp://esp32.local:8081\n"); } void loop(void) { diff --git a/libraries/WebServer/examples/MultiHomedServers/README.md b/libraries/WebServer/examples/MultiHomedServers/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ce869dcc6c3a10cd4ba332016254655e4f7e7648 --- /dev/null +++ b/libraries/WebServer/examples/MultiHomedServers/README.md @@ -0,0 +1,119 @@ +# Multi Homed Servers + +This example tests support for multi-homed servers, i.e. a distinct web servers on distinct IP interface. + +It only tests the case n=2 because on a basic ESP32 device, we only have two IP interfaces, namely the WiFi station interfaces and the WiFi soft AP interface. +For this to work, the WebServer and the WiFiServer classes must correctly handle the case where an IP address is passed to their relevant constructor. +It also requires WebServer to work with multiple, simultaneous instances. + +Testing the WebServer and the WiFiServer constructors was the primary purpose of this script. +The part of WebServer used by this sketch does seem to work with multiple, simultaneous instances. +However there is much functionality in WebServer that is not tested here. It may all be well, but that is not proven here. + +This sketch starts the mDNS server, as did HelloServer, and it resolves esp32.local on both interfaces, but was not otherwise tested. +This script also tests that a server not bound to a specific IP address still works. + +We create three, simultaneous web servers, one specific to each interface and one that listens on both: + +| name | IP Address | Port | +| ---- | ---------- | ---- | +| server0 | INADDR_ANY | 8080 | +| server1 | station address | 8081 | +| server2 | soft AP address | 8081 | + +The expected responses to a browser's requests are as follows: + +#### 1. The Client connected to the same WLAN as the station: + +| Request URL | Response | +| ----------- | -------- | +| [http://stationaddress:8080](http://stationaddress:8080) | Hello from server0 who listens on both WLAN and own Soft AP | +| [http://stationaddress:8081](http://stationaddress:8081) | Hello from server1 who listens only on WLAN | + +#### 2. The Client is connected to the soft AP: + +| Request URL | Response | +| ----------- | -------- | +| [http://softAPaddress:8080](http://softAPaddress:8080) | Hello from server0 who listens on both WLAN and own Soft AP | +| [http://softAPaddress:8081](http://softAPaddress:8081) | Hello from server2 who listens only on own Soft AP | + +#### 3. The Client is connect to either WLAN or SoftAP: + +| Request URL | Response | +| ----------- | -------- | +| [http://esp32.local:8080](http://esp32.local:8080) | Hello from server0 who listens on both WLAN and own Soft AP | +| [http://esp32.local:8081](http://esp32.local:8081) | Hello from server1 who listens only on WLAN | + +MultiHomedServers was originally based on HelloServer. + +# Supported Targets + +Currently, this example supports the following targets. + +| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | + +## How to Use Example + +Change the SSID and password in the example to your WiFi and flash the example. +Open a serial terminal and the example will write the exact addresses with used IP addresses you can use to test the servers. + +* How to install the Arduino IDE: [Install Arduino IDE](https://github.com/espressif/arduino-esp32/tree/master/docs/arduino-ide). + +#### Using Arduino IDE + +To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits). + +* Before Compile/Verify, select the correct board: `Tools -> Board`. +* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. + +#### Using Platform IO + +* Select the COM port: `Devices` or set the `upload_port` option on the `platformio.ini` file. + +## Example Log Output + +``` +Multi-homed Servers example starting +Connecting ... +Connected to "WiFi_SSID", IP address: "192.168.42.24 +Soft AP SSID: "ESP32", IP address: 192.168.4.1 +MDNS responder started +SSID: WiFi_SSID + http://192.168.42.24:8080 + http://192.168.42.24:8081 +SSID: ESP32 + http://192.168.4.1:8080 + http://192.168.4.1:8081 +Any of the above SSIDs + http://esp32.local:8080 + http://esp32.local:8081 +HTTP server0 started +HTTP server1 started +HTTP server2 started +``` + +## Known issues + +`http://esp32.local` Does not work on some Android phones + +## Troubleshooting + +***Important: Make sure you are using a good quality USB cable and that you have a reliable power source*** + +## Contribute + +To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst) + +If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome! + +Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else. + +## Resources + +* Official ESP32 Forum: [Link](https://esp32.com) +* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) +* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf) +* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf) +* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf) +* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com) diff --git a/libraries/WiFiClientSecure/README.md b/libraries/WiFiClientSecure/README.md index aa5199d2a4976c1cff95bdc565a2341c2030ee05..f08291de3f7849676bedd83cc9f6e68870125476 100644 --- a/libraries/WiFiClientSecure/README.md +++ b/libraries/WiFiClientSecure/README.md @@ -106,4 +106,28 @@ For example, this is used with AWS IoT Custom Authorizers where an MQTT client m const char *aws_protos[] = {"mqtt", NULL}; ... wiFiClient.setAlpnProtocols(aws_protos); -``` \ No newline at end of file +``` + +Examples +-------- +#### WiFiClientInsecure +Demonstrates usage of insecure connection using `WiFiClientSecure::setInsecure()` +#### WiFiClientPSK +Wifi secure connection example for ESP32 using a pre-shared key (PSK) +This is useful with MQTT servers instead of using a self-signed cert, tested with mosquitto. +Running on TLS 1.2 using mbedTLS +#### WiFiClientSecure +Wifi secure connection example for ESP32 +Running on TLS 1.2 using mbedTLS +#### WiFiClientSecureEnterprise +This example demonstrates a secure connection to a WiFi network using WPA/WPA2 Enterprise (for example eduroam), +and establishing a secure HTTPS connection with an external server (for example arduino.php5.sk) using the defined anonymous identity, user identity, and password. + +.. note:: + This example is outdated and might not work. For more examples see [https://github.com/martinius96/ESP32-eduroam](https://github.com/martinius96/ESP32-eduroam) + +#### WiFiClientShowPeerCredentials +Example of a establishing a secure connection and then showing the fingerprint of the certificate. +This can be useful in an IoT setting to know for sure that you are connecting to the right server. +Especially in situations where you cannot hardcode a trusted root certificate for long +periods of time (as they tend to get replaced more often than the lifecycle of IoT hardware). \ No newline at end of file diff --git a/libraries/WiFiClientSecure/examples/WiFiClientSecureEnterprise/WiFiClientSecureEnterprise.ino b/libraries/WiFiClientSecure/examples/WiFiClientSecureEnterprise/WiFiClientSecureEnterprise.ino index ee3f174d0cd217e05763c4268a965cbf00d9c82d..be051adaadc8082083868497fd2c66642dd8554c 100644 --- a/libraries/WiFiClientSecure/examples/WiFiClientSecureEnterprise/WiFiClientSecureEnterprise.ino +++ b/libraries/WiFiClientSecure/examples/WiFiClientSecureEnterprise/WiFiClientSecureEnterprise.ino @@ -7,6 +7,12 @@ /*|Supported methods: PEAP + MsCHAPv2, EAP-TTLS + MsCHAPv2 |*/ /*|-----------------------------------------------------------|*/ +// This example demonstrates a secure connection to a WiFi network using WPA/WPA2 Enterprise (for example eduroam), +// and establishing a secure HTTPS connection with an external server (for example arduino.php5.sk) using the defined anonymous identity, user identity, and password. + +// Note: this example is outdated and may not work! +// For more examples see https://github.com/martinius96/ESP32-eduroam + #include #include #include "esp_wpa2.h"