From 3fb6cb1d53eaf6fc48ba815a9d7243a96323b6e1 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Wed, 13 Mar 2019 21:38:11 -0700 Subject: [PATCH] Add a chargen example --- examples/Chargen/Chargen.ino | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/Chargen/Chargen.ino diff --git a/examples/Chargen/Chargen.ino b/examples/Chargen/Chargen.ino new file mode 100644 index 0000000..2befd99 --- /dev/null +++ b/examples/Chargen/Chargen.ino @@ -0,0 +1,36 @@ +const char* host = "ESP32-OTA"; // Used for MDNS resolution +const char* ssid = "ssid"; +const char* password = "password"; + +#include +WebServer OTAServer(8080); + +void setup() { + Serial.begin(115200); + + init_wifi(ssid, password, host); + init_web_ota(&OTAServer); +} + +int offset = 0; +void loop() { + // Whatever string we want to spit out + const char* str = "abcdefghijklmnopqrtuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()"; + int len = strlen(str); + + for (int i = 0; i < len; i++) { + int char_num = i + offset; + char_num = char_num % len; // Roll around the end if we go to far + + char c = str[char_num]; + + Serial.print(c); + } + + Serial.print("\r\n"); + offset++; + + if (offset >= len) { offset = 0; } + + OTAServer.handleClient(); +}