Arduino Core 3 (#407)
* Add and remove libs and components for Arduino Core 3 * Arduino Core 3 * Add back Solo1 * Change ESP32-S3 to 4MB build * Update README.md * Fix retain and number of retries * Fix rolling log * Fix defaults * Fix BleScanner on Solo1 * Export settings * Import settings * Fix HA Battery voltage * Change submodule * Update espMqttClient and AsyncTCP * Webserial and MQTT/Network reconnecting * Update nuki_ble --------- Co-authored-by: iranl <iranl@github.com>
This commit is contained in:
87
lib/WebSerialLite/examples/Demo/Demo.ino
Normal file
87
lib/WebSerialLite/examples/Demo/Demo.ino
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
--------------
|
||||
WebSerial Demo
|
||||
--------------
|
||||
|
||||
Skill Level: Beginner
|
||||
|
||||
This example provides with a bare minimal app with WebSerial functionality.
|
||||
|
||||
Github: https://github.com/ayushsharma82/WebSerial
|
||||
Wiki: https://docs.webserial.pro
|
||||
|
||||
Works with following hardware:
|
||||
- ESP8266
|
||||
- ESP32
|
||||
|
||||
WebSerial terminal will be accessible at your microcontroller's <IPAddress>/webserial URL.
|
||||
|
||||
Checkout WebSerial Pro: https://webserial.pro
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#include <AsyncTCP.h>
|
||||
#endif
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WebSerial.h>
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
const char* ssid = ""; // Your WiFi SSID
|
||||
const char* password = ""; // Your WiFi Password
|
||||
|
||||
unsigned long last_print_time = millis();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||
Serial.printf("WiFi Failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Once connected, print IP
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
request->send(200, "text/plain", "Hi! This is WebSerial demo. You can access webserial interface at http://" + WiFi.localIP().toString() + "/webserial");
|
||||
});
|
||||
|
||||
// WebSerial is accessible at "<IP Address>/webserial" in browser
|
||||
WebSerial.begin(&server);
|
||||
|
||||
/* Attach Message Callback */
|
||||
WebSerial.onMessage([&](uint8_t *data, size_t len) {
|
||||
Serial.printf("Received %u bytes from WebSerial: ", len);
|
||||
Serial.write(data, len);
|
||||
Serial.println();
|
||||
WebSerial.println("Received Data...");
|
||||
String d = "";
|
||||
for(size_t i=0; i < len; i++){
|
||||
d += char(data[i]);
|
||||
}
|
||||
WebSerial.println(d);
|
||||
});
|
||||
|
||||
// Start server
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Print every 2 seconds (non-blocking)
|
||||
if ((unsigned long)(millis() - last_print_time) > 2000) {
|
||||
WebSerial.print(F("IP address: "));
|
||||
WebSerial.println(WiFi.localIP());
|
||||
WebSerial.printf("Uptime: %lums\n", millis());
|
||||
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
last_print_time = millis();
|
||||
}
|
||||
}
|
||||
80
lib/WebSerialLite/examples/Demo_AP/Demo_AP.ino
Normal file
80
lib/WebSerialLite/examples/Demo_AP/Demo_AP.ino
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
--------------
|
||||
WebSerial Demo
|
||||
--------------
|
||||
|
||||
Skill Level: Beginner
|
||||
|
||||
This example provides with a bare minimal app with WebSerial functionality using softAP mode.
|
||||
|
||||
Github: https://github.com/ayushsharma82/WebSerial
|
||||
Wiki: https://docs.webserial.pro
|
||||
|
||||
Works with following hardware:
|
||||
- ESP8266
|
||||
- ESP32
|
||||
|
||||
WebSerial terminal will be accessible at your microcontroller's <IPAddress>/webserial URL.
|
||||
|
||||
Checkout WebSerial Pro: https://webserial.pro
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#include <AsyncTCP.h>
|
||||
#endif
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WebSerial.h>
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
const char* ssid = "WSLDemo"; // WiFi AP SSID
|
||||
const char* password = ""; // WiFi AP Password
|
||||
|
||||
unsigned long last_print_time = millis();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
WiFi.softAP(ssid, password);
|
||||
// Once connected, print IP
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
request->send(200, "text/plain", "Hi! This is WebSerial demo. You can access webserial interface at http://" + WiFi.softAPIP().toString() + "/webserial");
|
||||
});
|
||||
|
||||
// WebSerial is accessible at "<IP Address>/webserial" in browser
|
||||
WebSerial.begin(&server);
|
||||
|
||||
/* Attach Message Callback */
|
||||
WebSerial.onMessage([&](uint8_t *data, size_t len) {
|
||||
Serial.printf("Received %u bytes from WebSerial: ", len);
|
||||
Serial.write(data, len);
|
||||
Serial.println();
|
||||
WebSerial.println("Received Data...");
|
||||
String d = "";
|
||||
for(size_t i=0; i < len; i++){
|
||||
d += char(data[i]);
|
||||
}
|
||||
WebSerial.println(d);
|
||||
});
|
||||
|
||||
// Start server
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Print every 2 seconds (non-blocking)
|
||||
if ((unsigned long)(millis() - last_print_time) > 2000) {
|
||||
WebSerial.print(F("IP address: "));
|
||||
WebSerial.println(WiFi.softAPIP());
|
||||
WebSerial.printf("Uptime: %lums\n", millis());
|
||||
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
last_print_time = millis();
|
||||
}
|
||||
}
|
||||
69
lib/WebSerialLite/examples/HighPerf/HighPerf.ino
Normal file
69
lib/WebSerialLite/examples/HighPerf/HighPerf.ino
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This example shows how to use WebSerial variant to send data to the browser when timing, speed and latency are important.
|
||||
* WebSerial focuses on reducing latency and increasing speed by enqueueing messages and sending them in a single packet.
|
||||
*
|
||||
* The responsibility is left to the caller to ensure that the messages sent are not too large or not too small and frequent.
|
||||
* For example, use of printf(), write(c), print(c), etc are not recommended.
|
||||
*
|
||||
* This variant can allow WebSerial to support a high speed of more than 20 messages per second like in this example.
|
||||
*
|
||||
* It can be used to log data, debug, or send data to the browser in real-time without any delay.
|
||||
*
|
||||
* You might want to look at the Logging variant to see how to better use WebSerial for streaming logging.
|
||||
*
|
||||
* You might want to control these flags to control the async library performance:
|
||||
* -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
|
||||
* -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
|
||||
* -D WS_MAX_QUEUED_MESSAGES=128
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <AsyncTCP.h>
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
#include <DNSServer.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WString.h>
|
||||
#include <WebSerial.h>
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
static const char* dict = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
|
||||
static uint32_t last = millis();
|
||||
static uint32_t count = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.softAP("WSLDemo");
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(WiFi.softAPIP().toString());
|
||||
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(&server);
|
||||
|
||||
server.onNotFound([](AsyncWebServerRequest* request) { request->redirect("/webserial"); });
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (millis() - last > 50) {
|
||||
count++;
|
||||
long r = random(10, 250) + 15;
|
||||
String buffer;
|
||||
buffer.reserve(r);
|
||||
buffer += count;
|
||||
while (buffer.length() < 10) {
|
||||
buffer += " ";
|
||||
}
|
||||
buffer += "";
|
||||
for (int i = 0; i < r; i++) {
|
||||
buffer += dict[random(0, 62)];
|
||||
}
|
||||
WebSerial.print(buffer);
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
55
lib/WebSerialLite/examples/Logging/Logging.ino
Normal file
55
lib/WebSerialLite/examples/Logging/Logging.ino
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This example shows how to use WebSerial variant to send logging data to the browser.
|
||||
*
|
||||
* Before using this example, make sure to look at the WebSerial example before and its description.\
|
||||
*
|
||||
* You might want to control these flags to control the async library performance:
|
||||
* -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
|
||||
* -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
|
||||
* -D WS_MAX_QUEUED_MESSAGES=128
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <AsyncTCP.h>
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
#include <DNSServer.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WString.h>
|
||||
#include <WebSerial.h>
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
static uint32_t last = millis();
|
||||
static uint32_t count = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.softAP("WSLDemo");
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(WiFi.softAPIP().toString());
|
||||
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(&server);
|
||||
WebSerial.setBuffer(100);
|
||||
|
||||
server.onNotFound([](AsyncWebServerRequest* request) { request->redirect("/webserial"); });
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (millis() - last > 1000) {
|
||||
count++;
|
||||
|
||||
WebSerial.print(F("IP address: "));
|
||||
WebSerial.println(WiFi.softAPIP());
|
||||
WebSerial.printf("Uptime: %lums\n", millis());
|
||||
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user