From 19dc4ebeed6920dd956cf004c223bf3c7f5a71d5 Mon Sep 17 00:00:00 2001 From: Zoe Pfister <zoe.pfister@uibk.ac.at> Date: Wed, 12 Oct 2022 13:47:03 +0200 Subject: [PATCH] add small project for receiving espnow material from a host, transferring it via serial to another esp and finally storing it on a SD card --- host/esp32-espnow-recv/.gitignore | 3 + host/esp32-espnow-recv/CMakeLists.txt | 33 ++ host/esp32-espnow-recv/include/README | 39 ++ host/esp32-espnow-recv/platformio.ini | 23 ++ .../{esp32 => esp32-espnow-recv}/src/main.cpp | 12 + host/esp32-espnow-recv/src/main2.cpp | 229 +++++++++++ host/esp32-espnow-recv/test/README | 11 + host/esp32-serial-recv/.gitignore | 3 + host/esp32-serial-recv/CMakeLists.txt | 33 ++ host/esp32-serial-recv/include/README | 39 ++ host/esp32-serial-recv/platformio.ini | 23 ++ host/esp32-serial-recv/src/main.cpp | 236 ++++++++++++ host/esp32-serial-recv/test/README | 11 + .../esp32-c3-devkitm-1/ESP32Time/.piopm | 1 - .../ESP32Time/ESP32Time.cpp | 361 ------------------ .../esp32-c3-devkitm-1/ESP32Time/ESP32Time.h | 69 ---- .../esp32-c3-devkitm-1/ESP32Time/LICENSE | 21 - .../esp32-c3-devkitm-1/ESP32Time/README.md | 41 -- .../examples/esp32_time/esp32_time.ino | 77 ---- .../esp32_time_multiple.ino | 77 ---- .../esp32_time_sleep/esp32_time_sleep.ino | 70 ---- .../esp32-c3-devkitm-1/ESP32Time/keywords.txt | 22 -- .../esp32-c3-devkitm-1/ESP32Time/library.json | 21 - .../ESP32Time/library.properties | 11 - .../libdeps/esp32-c3-devkitm-1/integrity.dat | 1 - 25 files changed, 695 insertions(+), 772 deletions(-) create mode 100644 host/esp32-espnow-recv/.gitignore create mode 100644 host/esp32-espnow-recv/CMakeLists.txt create mode 100644 host/esp32-espnow-recv/include/README create mode 100644 host/esp32-espnow-recv/platformio.ini rename host/{esp32 => esp32-espnow-recv}/src/main.cpp (79%) create mode 100644 host/esp32-espnow-recv/src/main2.cpp create mode 100644 host/esp32-espnow-recv/test/README create mode 100644 host/esp32-serial-recv/.gitignore create mode 100644 host/esp32-serial-recv/CMakeLists.txt create mode 100644 host/esp32-serial-recv/include/README create mode 100644 host/esp32-serial-recv/platformio.ini create mode 100644 host/esp32-serial-recv/src/main.cpp create mode 100644 host/esp32-serial-recv/test/README delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/.piopm delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.cpp delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.h delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/LICENSE delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/README.md delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time/esp32_time.ino delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_multiple/esp32_time_multiple.ino delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_sleep/esp32_time_sleep.ino delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/keywords.txt delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.json delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.properties delete mode 100644 host/esp32/.pio/libdeps/esp32-c3-devkitm-1/integrity.dat diff --git a/host/esp32-espnow-recv/.gitignore b/host/esp32-espnow-recv/.gitignore new file mode 100644 index 0000000..3fe18ad --- /dev/null +++ b/host/esp32-espnow-recv/.gitignore @@ -0,0 +1,3 @@ +.pio +CMakeListsPrivate.txt +cmake-build-*/ diff --git a/host/esp32-espnow-recv/CMakeLists.txt b/host/esp32-espnow-recv/CMakeLists.txt new file mode 100644 index 0000000..ec76a43 --- /dev/null +++ b/host/esp32-espnow-recv/CMakeLists.txt @@ -0,0 +1,33 @@ +# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE +# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags +# +# If you need to override existing CMake configuration or add extra, +# please create `CMakeListsUser.txt` in the root of project. +# The `CMakeListsUser.txt` will not be overwritten by PlatformIO. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_C_COMPILER_WORKS 1) +set(CMAKE_CXX_COMPILER_WORKS 1) + +project("esp32" C CXX) + +include(CMakeListsPrivate.txt) + +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt) +include(CMakeListsUser.txt) +endif() + +add_custom_target( + Production ALL + COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target( + Debug ALL + COMMAND platformio -c clion debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(Z_DUMMY_TARGET ${SRC_LIST}) diff --git a/host/esp32-espnow-recv/include/README b/host/esp32-espnow-recv/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/host/esp32-espnow-recv/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/host/esp32-espnow-recv/platformio.ini b/host/esp32-espnow-recv/platformio.ini new file mode 100644 index 0000000..73a15dd --- /dev/null +++ b/host/esp32-espnow-recv/platformio.ini @@ -0,0 +1,23 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32-c3-devkitm-1] +platform = espressif32 +board = esp32-c3-devkitm-1 +monitor_speed = 115200 +framework = arduino +monitor_port = /dev/ttyUSB1 +upload_port = /dev/ttyUSB1 +build_flags = + -I include + -DCORE_DEBUG_LEVEL=5 + -std=gnu++17 +build_unflags = -std=gnu++11 +lib_deps = plerup/EspSoftwareSerial@^6.16.1 \ No newline at end of file diff --git a/host/esp32/src/main.cpp b/host/esp32-espnow-recv/src/main.cpp similarity index 79% rename from host/esp32/src/main.cpp rename to host/esp32-espnow-recv/src/main.cpp index 132224b..62893ed 100644 --- a/host/esp32/src/main.cpp +++ b/host/esp32-espnow-recv/src/main.cpp @@ -1,6 +1,15 @@ +#include "FS.h" +#include "SD.h" +#include "SPI.h" #include <Arduino.h> #include <WiFi.h> #include <esp_now.h> +#include <sys/unistd.h> + +#define RXD2 18 +#define TXD2 19 + +//SoftwareSerial mySerial(RXD2, TXD2); void on_data_sent(const uint8_t *mac_addr, esp_now_send_status_t status) { @@ -20,11 +29,14 @@ void on_data_recv(const uint8_t *mac, const uint8_t *incomingData, int len) char data[len]; memcpy(data, incomingData, len); Serial.println(data); + Serial1.write(data); } void setup() { Serial.begin(115200); + Serial1.begin(115200, SERIAL_8N1, RXD2, TXD2); + WiFi.mode(WIFI_STA); Serial.println("ESPNow init"); if (esp_now_init() != ESP_OK) { diff --git a/host/esp32-espnow-recv/src/main2.cpp b/host/esp32-espnow-recv/src/main2.cpp new file mode 100644 index 0000000..17684dc --- /dev/null +++ b/host/esp32-espnow-recv/src/main2.cpp @@ -0,0 +1,229 @@ +#include "FS.h" +#include "SD.h" +#include "SPI.h" +#include <Arduino.h> +#include <sys/unistd.h> + +#define RXD2 18 +#define TXD2 19 + +#define SCK 6 +#define MISO 10 +#define MOSI 7 +#define CS 5 + +/* + Rui Santos + Complete project details at https://RandomNerdTutorials.com/esp32-microsd-card-arduino/ + + This sketch can be found at: Examples > SD(esp32) > SD_Test +*/ + +void listDir(fs::FS &fs, const char *dirname, uint8_t levels) +{ + Serial.printf("Listing directory: %s\n", dirname); + + File root = fs.open(dirname); + if (!root) { + Serial.println("Failed to open directory"); + return; + } + if (!root.isDirectory()) { + Serial.println("Not a directory"); + return; + } + + File file = root.openNextFile(); + while (file) { + if (file.isDirectory()) { + Serial.print(" DIR : "); + Serial.println(file.name()); + if (levels) { + listDir(fs, file.name(), levels - 1); + } + } else { + Serial.print(" FILE: "); + Serial.print(file.name()); + Serial.print(" SIZE: "); + Serial.println(file.size()); + } + file = root.openNextFile(); + } +} + +void createDir(fs::FS &fs, const char *path) +{ + Serial.printf("Creating Dir: %s\n", path); + if (fs.mkdir(path)) { + Serial.println("Dir created"); + } else { + Serial.println("mkdir failed"); + } +} + +void removeDir(fs::FS &fs, const char *path) +{ + Serial.printf("Removing Dir: %s\n", path); + if (fs.rmdir(path)) { + Serial.println("Dir removed"); + } else { + Serial.println("rmdir failed"); + } +} + +void readFile(fs::FS &fs, const char *path) +{ + Serial.printf("Reading file: %s\n", path); + + File file = fs.open(path); + if (!file) { + Serial.println("Failed to open file for reading"); + return; + } + + Serial.print("Read from file: "); + while (file.available()) { + Serial.write(file.read()); + } + file.close(); +} + +void writeFile(fs::FS &fs, const char *path, const char *message) +{ + Serial.printf("Writing file: %s\n", path); + + File file = fs.open(path, FILE_WRITE); + if (!file) { + Serial.println("Failed to open file for writing"); + return; + } + if (file.print(message)) { + Serial.println("File written"); + } else { + Serial.println("Write failed"); + } + file.close(); +} + +void appendFile(fs::FS &fs, const char *path, const char *message) +{ + Serial.printf("Appending to file: %s\n", path); + + File file = fs.open(path, FILE_APPEND); + if (!file) { + Serial.println("Failed to open file for appending"); + return; + } + if (file.print(message)) { + Serial.println("Message appended"); + } else { + Serial.println("Append failed"); + } + file.close(); +} + +void renameFile(fs::FS &fs, const char *path1, const char *path2) +{ + Serial.printf("Renaming file %s to %s\n", path1, path2); + if (fs.rename(path1, path2)) { + Serial.println("File renamed"); + } else { + Serial.println("Rename failed"); + } +} + +void deleteFile(fs::FS &fs, const char *path) +{ + Serial.printf("Deleting file: %s\n", path); + if (fs.remove(path)) { + Serial.println("File deleted"); + } else { + Serial.println("Delete failed"); + } +} + +void testFileIO(fs::FS &fs, const char *path) +{ + File file = fs.open(path); + static uint8_t buf[512]; + size_t len = 0; + uint32_t start = millis(); + uint32_t end = start; + if (file) { + len = file.size(); + size_t flen = len; + start = millis(); + while (len) { + size_t toRead = len; + if (toRead > 512) { + toRead = 512; + } + file.read(buf, toRead); + len -= toRead; + } + end = millis() - start; + Serial.printf("%u bytes read for %u ms\n", flen, end); + file.close(); + } else { + Serial.println("Failed to open file for reading"); + } + + file = fs.open(path, FILE_WRITE); + if (!file) { + Serial.println("Failed to open file for writing"); + return; + } + + size_t i; + start = millis(); + for (i = 0; i < 2048; i++) { + file.write(buf, 512); + } + end = millis() - start; + Serial.printf("%u bytes written for %u ms\n", 2048 * 512, end); + file.close(); +} + +void setup_2() +{ + Serial.begin(115200); + Serial1.begin(115200, SERIAL_8N1, RX, TX); + Serial.println("Initializing SD card..."); + SPI.begin(SCK, MISO, MOSI, -1); + + if (!SD.begin(CS, SPI, 2000000)) { + Serial.println("Card Mount Failed"); + return; + } + uint8_t cardType = SD.cardType(); + + if (cardType == CARD_NONE) { + Serial.println("No SD card attached"); + return; + } + + Serial.print("SD Card Type: "); + if (cardType == CARD_MMC) { + Serial.println("MMC"); + } else if (cardType == CARD_SD) { + Serial.println("SDSC"); + } else if (cardType == CARD_SDHC) { + Serial.println("SDHC"); + } else { + Serial.println("UNKNOWN"); + } + + uint64_t cardSize = SD.cardSize() / (1024 * 1024); + Serial.printf("SD Card Size: %lluMB\n", cardSize); + + listDir(SD, "/", 0); + Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024)); + Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024)); +} + +void loop_2() +{ + if (Serial1.available()) { + Serial.println(Serial1.readString()); + } +} diff --git a/host/esp32-espnow-recv/test/README b/host/esp32-espnow-recv/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/host/esp32-espnow-recv/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/host/esp32-serial-recv/.gitignore b/host/esp32-serial-recv/.gitignore new file mode 100644 index 0000000..3fe18ad --- /dev/null +++ b/host/esp32-serial-recv/.gitignore @@ -0,0 +1,3 @@ +.pio +CMakeListsPrivate.txt +cmake-build-*/ diff --git a/host/esp32-serial-recv/CMakeLists.txt b/host/esp32-serial-recv/CMakeLists.txt new file mode 100644 index 0000000..ec76a43 --- /dev/null +++ b/host/esp32-serial-recv/CMakeLists.txt @@ -0,0 +1,33 @@ +# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE +# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags +# +# If you need to override existing CMake configuration or add extra, +# please create `CMakeListsUser.txt` in the root of project. +# The `CMakeListsUser.txt` will not be overwritten by PlatformIO. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_C_COMPILER_WORKS 1) +set(CMAKE_CXX_COMPILER_WORKS 1) + +project("esp32" C CXX) + +include(CMakeListsPrivate.txt) + +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsUser.txt) +include(CMakeListsUser.txt) +endif() + +add_custom_target( + Production ALL + COMMAND platformio -c clion run "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_custom_target( + Debug ALL + COMMAND platformio -c clion debug "$<$<NOT:$<CONFIG:All>>:-e${CMAKE_BUILD_TYPE}>" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_executable(Z_DUMMY_TARGET ${SRC_LIST}) diff --git a/host/esp32-serial-recv/include/README b/host/esp32-serial-recv/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/host/esp32-serial-recv/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/host/esp32-serial-recv/platformio.ini b/host/esp32-serial-recv/platformio.ini new file mode 100644 index 0000000..6fce3d0 --- /dev/null +++ b/host/esp32-serial-recv/platformio.ini @@ -0,0 +1,23 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32-c3-devkitm-1] +platform = espressif32 +board = esp32-c3-devkitm-1 +monitor_speed = 115200 +framework = arduino +monitor_port = /dev/ttyUSB0 +upload_port = /dev/ttyUSB0 +build_flags = + -I include + -DCORE_DEBUG_LEVEL=5 + -std=gnu++17 +build_unflags = -std=gnu++11 +lib_deps = plerup/EspSoftwareSerial@^6.16.1 diff --git a/host/esp32-serial-recv/src/main.cpp b/host/esp32-serial-recv/src/main.cpp new file mode 100644 index 0000000..511a10e --- /dev/null +++ b/host/esp32-serial-recv/src/main.cpp @@ -0,0 +1,236 @@ +#include "FS.h" +#include "SD.h" +#include "SPI.h" +#include <Arduino.h> +#include <sys/unistd.h> + +#define RXD2 18 +#define TXD2 19 + +#define SCK 6 +#define MISO 10 +#define MOSI 7 +#define CS 5 + +/* + Rui Santos + Complete project details at https://RandomNerdTutorials.com/esp32-microsd-card-arduino/ + + This sketch can be found at: Examples > SD(esp32) > SD_Test +*/ + +void listDir(fs::FS &fs, const char *dirname, uint8_t levels) +{ + Serial.printf("Listing directory: %s\n", dirname); + + File root = fs.open(dirname); + if (!root) { + Serial.println("Failed to open directory"); + return; + } + if (!root.isDirectory()) { + Serial.println("Not a directory"); + return; + } + + File file = root.openNextFile(); + while (file) { + if (file.isDirectory()) { + Serial.print(" DIR : "); + Serial.println(file.name()); + if (levels) { + listDir(fs, file.name(), levels - 1); + } + } else { + Serial.print(" FILE: "); + Serial.print(file.name()); + Serial.print(" SIZE: "); + Serial.println(file.size()); + } + file = root.openNextFile(); + } +} + +void createDir(fs::FS &fs, const char *path) +{ + Serial.printf("Creating Dir: %s\n", path); + if (fs.mkdir(path)) { + Serial.println("Dir created"); + } else { + Serial.println("mkdir failed"); + } +} + +void removeDir(fs::FS &fs, const char *path) +{ + Serial.printf("Removing Dir: %s\n", path); + if (fs.rmdir(path)) { + Serial.println("Dir removed"); + } else { + Serial.println("rmdir failed"); + } +} + +void readFile(fs::FS &fs, const char *path) +{ + Serial.printf("Reading file: %s\n", path); + + File file = fs.open(path); + if (!file) { + Serial.println("Failed to open file for reading"); + return; + } + + Serial.print("Read from file: "); + while (file.available()) { + Serial.write(file.read()); + } + file.close(); +} + +void writeFile(fs::FS &fs, const char *path, const char *message) +{ + Serial.printf("Writing file: %s\n", path); + + File file = fs.open(path, FILE_WRITE); + if (!file) { + Serial.println("Failed to open file for writing"); + return; + } + if (file.print(message)) { + Serial.println("File written"); + } else { + Serial.println("Write failed"); + } + file.close(); +} + +void appendFile(fs::FS &fs, const char *path, const char *message) +{ + Serial.printf("Appending to file: %s\n", path); + + File file = fs.open(path, FILE_APPEND); + if (!file) { + Serial.println("Failed to open file for appending"); + return; + } + if (file.print(message)) { + Serial.println("Message appended"); + } else { + Serial.println("Append failed"); + } + file.close(); +} + +void renameFile(fs::FS &fs, const char *path1, const char *path2) +{ + Serial.printf("Renaming file %s to %s\n", path1, path2); + if (fs.rename(path1, path2)) { + Serial.println("File renamed"); + } else { + Serial.println("Rename failed"); + } +} + +void deleteFile(fs::FS &fs, const char *path) +{ + Serial.printf("Deleting file: %s\n", path); + if (fs.remove(path)) { + Serial.println("File deleted"); + } else { + Serial.println("Delete failed"); + } +} + +void testFileIO(fs::FS &fs, const char *path) +{ + File file = fs.open(path); + static uint8_t buf[512]; + size_t len = 0; + uint32_t start = millis(); + uint32_t end = start; + if (file) { + len = file.size(); + size_t flen = len; + start = millis(); + while (len) { + size_t toRead = len; + if (toRead > 512) { + toRead = 512; + } + file.read(buf, toRead); + len -= toRead; + } + end = millis() - start; + Serial.printf("%u bytes read for %u ms\n", flen, end); + file.close(); + } else { + Serial.println("Failed to open file for reading"); + } + + file = fs.open(path, FILE_WRITE); + if (!file) { + Serial.println("Failed to open file for writing"); + return; + } + + size_t i; + start = millis(); + for (i = 0; i < 2048; i++) { + file.write(buf, 512); + } + end = millis() - start; + Serial.printf("%u bytes written for %u ms\n", 2048 * 512, end); + file.close(); +} + +void setup() +{ + Serial.begin(115200); + // If this (Serial1) is not available, use https://github.com/plerup/espsoftwareserial + Serial1.begin(115200, SERIAL_8N1, RXD2, TXD2); + Serial.println("Initializing SD card..."); + SPI.begin(SCK, MISO, MOSI, -1); + + if (!SD.begin(CS, SPI, 2000000)) { + Serial.println("Card Mount Failed"); + return; + } + uint8_t cardType = SD.cardType(); + + if (cardType == CARD_NONE) { + Serial.println("No SD card attached"); + return; + } + + Serial.print("SD Card Type: "); + if (cardType == CARD_MMC) { + Serial.println("MMC"); + } else if (cardType == CARD_SD) { + Serial.println("SDSC"); + } else if (cardType == CARD_SDHC) { + Serial.println("SDHC"); + } else { + Serial.println("UNKNOWN"); + } + + uint64_t cardSize = SD.cardSize() / (1024 * 1024); + Serial.printf("SD Card Size: %lluMB\n", cardSize); + + listDir(SD, "/", 0); + Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024)); + Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024)); + + createDir(SD, "/test"); + writeFile(SD, "/test/log.txt", ""); +} + +void loop() +{ + if (Serial1.available()) { + Serial.println("Received"); + auto data = Serial1.readString(); + Serial.println(data); + appendFile(SD, "/test/log.txt", data.c_str()); + } +} diff --git a/host/esp32-serial-recv/test/README b/host/esp32-serial-recv/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/host/esp32-serial-recv/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/.piopm b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/.piopm deleted file mode 100644 index fa0c3de..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/.piopm +++ /dev/null @@ -1 +0,0 @@ -{"type": "library", "name": "ESP32Time", "version": "2.0.0", "spec": {"owner": "fbiego", "id": 11703, "name": "ESP32Time", "requirements": null, "uri": null}} \ No newline at end of file diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.cpp b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.cpp deleted file mode 100644 index a4f05cb..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - MIT License - - Copyright (c) 2021 Felix Biego - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#include "ESP32Time.h" -#include "time.h" -#include <sys/time.h> - -/*! - @brief Constructor for ESP32Time -*/ -ESP32Time::ESP32Time(){} - -/*! - @brief Constructor for ESP32Time - @param offest - gmt offset in seconds -*/ -ESP32Time::ESP32Time(unsigned long offset){ - this->offset = offset; -} - -/*! - @brief set the internal RTC time - @param sc - second (0-59) - @param mn - minute (0-59) - @param hr - hour of day (0-23) - @param dy - day of month (1-31) - @param mt - month (1-12) - @param yr - year ie 2021 - @param ms - microseconds (optional) -*/ -void ESP32Time::setTime(int sc, int mn, int hr, int dy, int mt, int yr, int ms) { - // seconds, minute, hour, day, month, year $ microseconds(optional) - // ie setTime(20, 34, 8, 1, 4, 2021) = 8:34:20 1/4/2021 - struct tm t = {0}; // Initalize to all 0's - t.tm_year = yr - 1900; // This is year-1900, so 121 = 2021 - t.tm_mon = mt - 1; - t.tm_mday = dy; - t.tm_hour = hr; - t.tm_min = mn; - t.tm_sec = sc; - time_t timeSinceEpoch = mktime(&t); - setTime(timeSinceEpoch, ms); -} - -/*! - @brief set time from struct - @param tm - time struct -*/ -void ESP32Time::setTimeStruct(tm t) { - time_t timeSinceEpoch = mktime(&t); - setTime(timeSinceEpoch, 0); -} - -/*! - @brief set the internal RTC time - @param epoch - epoch time in seconds - @param ms - microseconds (optional) -*/ -void ESP32Time::setTime(unsigned long epoch, int ms) { - struct timeval tv; - if (epoch > 2082758399){ - this->overflow = true; - tv.tv_sec = epoch - 2082758399; // epoch time (seconds) - } else { - tv.tv_sec = epoch; // epoch time (seconds) - } - tv.tv_usec = ms; // microseconds - settimeofday(&tv, NULL); -} - -/*! - @brief get the internal RTC time as a tm struct -*/ -tm ESP32Time::getTimeStruct(){ - struct tm timeinfo; - time_t now; - time(&now); - localtime_r(&now, &timeinfo); - time_t tt = mktime (&timeinfo); - - if (this->overflow){ - tt += 63071999; - } - tt += offset; - struct tm * tn = localtime(&tt); - if (this->overflow){ - tn->tm_year += 64; - } - return *tn; -} - -/*! - @brief get the time and date as an Arduino String object - @param mode - true = Long date format - false = Short date format -*/ -String ESP32Time::getDateTime(bool mode){ - struct tm timeinfo = getTimeStruct(); - char s[51]; - if (mode) - { - strftime(s, 50, "%A, %B %d %Y %H:%M:%S", &timeinfo); - } - else - { - strftime(s, 50, "%a, %b %d %Y %H:%M:%S", &timeinfo); - } - return String(s); -} - -/*! - @brief get the time and date as an Arduino String object - @param mode - true = Long date format - false = Short date format -*/ -String ESP32Time::getTimeDate(bool mode){ - struct tm timeinfo = getTimeStruct(); - char s[51]; - if (mode) - { - strftime(s, 50, "%H:%M:%S %A, %B %d %Y", &timeinfo); - } - else - { - strftime(s, 50, "%H:%M:%S %a, %b %d %Y", &timeinfo); - } - return String(s); -} - -/*! - @brief get the time as an Arduino String object -*/ -String ESP32Time::getTime(){ - struct tm timeinfo = getTimeStruct(); - char s[51]; - strftime(s, 50, "%H:%M:%S", &timeinfo); - return String(s); -} - -/*! - @brief get the time as an Arduino String object with the specified format - @param format - time format - http://www.cplusplus.com/reference/ctime/strftime/ -*/ -String ESP32Time::getTime(String format){ - struct tm timeinfo = getTimeStruct(); - char s[128]; - char c[128]; - format.toCharArray(c, 127); - strftime(s, 127, c, &timeinfo); - return String(s); -} - -/*! - @brief get the date as an Arduino String object - @param mode - true = Long date format - false = Short date format -*/ -String ESP32Time::getDate(bool mode){ - struct tm timeinfo = getTimeStruct(); - char s[51]; - if (mode) - { - strftime(s, 50, "%A, %B %d %Y", &timeinfo); - } - else - { - strftime(s, 50, "%a, %b %d %Y", &timeinfo); - } - return String(s); -} - -/*! - @brief get the current milliseconds as unsigned long -*/ -unsigned long ESP32Time::getMillis(){ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_usec/1000; -} - -/*! - @brief get the current microseconds as unsigned long -*/ -unsigned long ESP32Time::getMicros(){ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_usec; -} - -/*! - @brief get the current epoch seconds as unsigned long -*/ -unsigned long ESP32Time::getEpoch(){ - struct tm timeinfo = getTimeStruct(); - return mktime(&timeinfo); -} - -/*! - @brief get the current epoch seconds as unsigned long from the rtc without offset -*/ -unsigned long ESP32Time::getLocalEpoch(){ - struct timeval tv; - gettimeofday(&tv, NULL); - unsigned long epoch = tv.tv_sec; - if (this->overflow){ - epoch += 63071999 + 2019686400; - } - return epoch; -} - -/*! - @brief get the current seconds as int -*/ -int ESP32Time::getSecond(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_sec; -} - -/*! - @brief get the current minutes as int -*/ -int ESP32Time::getMinute(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_min; -} - -/*! - @brief get the current hour as int - @param mode - true = 24 hour mode (0-23) - false = 12 hour mode (0-12) -*/ -int ESP32Time::getHour(bool mode){ - struct tm timeinfo = getTimeStruct(); - if (mode) - { - return timeinfo.tm_hour; - } - else - { - int hour = timeinfo.tm_hour; - if (hour > 12) - { - return timeinfo.tm_hour-12; - } - else - { - return timeinfo.tm_hour; - } - - } -} - -/*! - @brief return current hour am or pm - @param lowercase - true = lowercase - false = uppercase -*/ -String ESP32Time::getAmPm(bool lowercase){ - struct tm timeinfo = getTimeStruct(); - if (timeinfo.tm_hour >= 12) - { - if (lowercase) - { - return "pm"; - } - else - { - return "PM"; - } - } - else - { - if (lowercase) - { - return "am"; - } - else - { - return "AM"; - } - } -} - -/*! - @brief get the current day as int (1-31) -*/ -int ESP32Time::getDay(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_mday; -} - -/*! - @brief get the current day of week as int (0-6) -*/ -int ESP32Time::getDayofWeek(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_wday; -} - -/*! - @brief get the current day of year as int (0-365) -*/ -int ESP32Time::getDayofYear(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_yday; -} - -/*! - @brief get the current month as int (0-11) -*/ -int ESP32Time::getMonth(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_mon; -} - -/*! - @brief get the current year as int -*/ -int ESP32Time::getYear(){ - struct tm timeinfo = getTimeStruct(); - return timeinfo.tm_year+1900; -} diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.h b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.h deleted file mode 100644 index 43b46b1..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/ESP32Time.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - MIT License - - Copyright (c) 2021 Felix Biego - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#ifndef ESP32TIME_H -#define ESP32TIME_H - -#include <Arduino.h> - -class ESP32Time { - - public: - ESP32Time(); - ESP32Time(unsigned long offset); - void setTime(unsigned long epoch = 1609459200, int ms = 0); // default (1609459200) = 1st Jan 2021 - void setTime(int sc, int mn, int hr, int dy, int mt, int yr, int ms = 0); - void setTimeStruct(tm t); - tm getTimeStruct(); - String getTime(String format); - - String getTime(); - String getDateTime(bool mode = false); - String getTimeDate(bool mode = false); - String getDate(bool mode = false); - String getAmPm(bool lowercase = false); - - unsigned long getEpoch(); - unsigned long getMillis(); - unsigned long getMicros(); - int getSecond(); - int getMinute(); - int getHour(bool mode = false); - int getDay(); - int getDayofWeek(); - int getDayofYear(); - int getMonth(); - int getYear(); - - unsigned long offset; - unsigned long getLocalEpoch(); - - private: - bool overflow; - - -}; - - -#endif diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/LICENSE b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/LICENSE deleted file mode 100644 index d674f82..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Felix Biego - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/README.md b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/README.md deleted file mode 100644 index 2e6f19c..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# ESP32Time -An Arduino library for setting and retrieving internal RTC time on ESP32 boards - -[](https://www.arduinolibraries.info/libraries/esp32-time) - -## Functions - -``` -ESP32Time rtc(offset); // create an instance with a specifed offset in seconds -rtc.offset; // get or modify the current offset -setTime(30, 24, 15, 17, 1, 2021); // 17th Jan 2021 15:24:30 -setTime(1609459200); // 1st Jan 2021 00:00:00 -setTimeStruct(time); // set with time struct - -getTime() // (String) 15:24:38 -getDate() // (String) Sun, Jan 17 2021 -getDate(true) // (String) Sunday, January 17 2021 -getDateTime() // (String) Sun, Jan 17 2021 15:24:38 -getDateTime(true) // (String) Sunday, January 17 2021 15:24:38 -getTimeDate() // (String) 15:24:38 Sun, Jan 17 2021 -getTimeDate(true) // (String) 15:24:38 Sunday, January 17 2021 - -getMicros() // (unsigned long) 723546 -getMillis() // (unsigned long) 723 -getEpoch() // (unsigned long) 1609459200 -getLocalEpoch() // (unsigned long) 1609459200 // local epoch without offset -getSecond() // (int) 38 (0-59) -getMinute() // (int) 24 (0-59) -getHour() // (int) 3 (0-12) -getHour(true) // (int) 15 (0-23) -getAmPm() // (String) pm -getAmPm(false) // (String) PM -getDay() // (int) 17 (1-31) -getDayofWeek() // (int) 0 (0-6) -getDayofYear() // (int) 16 (0-365) -getMonth() // (int) 0 (0-11) -getYear() // (int) 2021 - -getTime("%A, %B %d %Y %H:%M:%S") // (String) returns time with specified format -``` -[`Formatting options`](http://www.cplusplus.com/reference/ctime/strftime/) diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time/esp32_time.ino b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time/esp32_time.ino deleted file mode 100644 index 029b72e..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time/esp32_time.ino +++ /dev/null @@ -1,77 +0,0 @@ -/* - MIT License - - Copyright (c) 2021 Felix Biego - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#include <ESP32Time.h> - -//ESP32Time rtc; -ESP32Time rtc(3600); // offset in seconds GMT+1 - -void setup() { - Serial.begin(115200); - rtc.setTime(30, 24, 15, 17, 1, 2042); // 17th Jan 2021 15:24:30 - //rtc.setTime(1609459200); // 1st Jan 2021 00:00:00 - //rtc.offset = 7200; // change offset value - -/*---------set with NTP---------------*/ -// configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); -// struct tm timeinfo; -// if (getLocalTime(&timeinfo)){ -// rtc.setTimeStruct(timeinfo); -// } -} - -void loop() { -// Serial.println(rtc.getTime()); // (String) 15:24:38 -// Serial.println(rtc.getDate()); // (String) Sun, Jan 17 2021 -// Serial.println(rtc.getDate(true)); // (String) Sunday, January 17 2021 -// Serial.println(rtc.getDateTime()); // (String) Sun, Jan 17 2021 15:24:38 -// Serial.println(rtc.getDateTime(true)); // (String) Sunday, January 17 2021 15:24:38 -// Serial.println(rtc.getTimeDate()); // (String) 15:24:38 Sun, Jan 17 2021 -// Serial.println(rtc.getTimeDate(true)); // (String) 15:24:38 Sunday, January 17 2021 -// -// Serial.println(rtc.getMicros()); // (long) 723546 -// Serial.println(rtc.getMillis()); // (long) 723 -// Serial.println(rtc.getEpoch()); // (long) 1609459200 -// Serial.println(rtc.getSecond()); // (int) 38 (0-59) -// Serial.println(rtc.getMinute()); // (int) 24 (0-59) -// Serial.println(rtc.getHour()); // (int) 3 (0-12) -// Serial.println(rtc.getHour(true)); // (int) 15 (0-23) -// Serial.println(rtc.getAmPm()); // (String) pm -// Serial.println(rtc.getAmPm(true)); // (String) PM -// Serial.println(rtc.getDay()); // (int) 17 (1-31) -// Serial.println(rtc.getDayofWeek()); // (int) 0 (0-6) -// Serial.println(rtc.getDayofYear()); // (int) 16 (0-365) -// Serial.println(rtc.getMonth()); // (int) 0 (0-11) -// Serial.println(rtc.getYear()); // (int) 2021 - -// Serial.println(rtc.getLocalEpoch()); // (long) 1609459200 epoch without offset - Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S")); // (String) returns time with specified format - // formating options http://www.cplusplus.com/reference/ctime/strftime/ - - - struct tm timeinfo = rtc.getTimeStruct(); - //Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S"); // (tm struct) Sunday, January 17 2021 07:24:38 - - delay(1000); -} diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_multiple/esp32_time_multiple.ino b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_multiple/esp32_time_multiple.ino deleted file mode 100644 index 97cdc25..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_multiple/esp32_time_multiple.ino +++ /dev/null @@ -1,77 +0,0 @@ -/* - MIT License - - Copyright (c) 2021 Felix Biego - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#include <ESP32Time.h> - -ESP32Time rtc; -ESP32Time rtc1(-3600); // offset GMT-1 -ESP32Time rtc2(7200); // offset GMT+2 - -void setup() { - Serial.begin(115200); - rtc.setTime(30, 24, 15, 17, 1, 2021); // 17th Jan 2021 15:24:30 - //rtc1.setTime(1609459200); // 1st Jan 2021 00:00:00 - // time can be set on one instance - // no need for rtc1.setTime() or rtc2.setTime() - - -} - -void loop() { -// Serial.println(rtc.getTime()); // (String) 15:24:38 -// Serial.println(rtc.getDate()); // (String) Sun, Jan 17 2021 -// Serial.println(rtc.getDate(true)); // (String) Sunday, January 17 2021 -// Serial.println(rtc.getDateTime()); // (String) Sun, Jan 17 2021 15:24:38 -// Serial.println(rtc.getDateTime(true)); // (String) Sunday, January 17 2021 15:24:38 -// Serial.println(rtc.getTimeDate()); // (String) 15:24:38 Sun, Jan 17 2021 -// Serial.println(rtc.getTimeDate(true)); // (String) 15:24:38 Sunday, January 17 2021 -// -// Serial.println(rtc.getMicros()); // (unsigned long) 723546 -// Serial.println(rtc.getMillis()); // (unsigned long) 723 -// Serial.println(rtc.getEpoch()); // (unsigned long) 1609459200 -// Serial.println(rtc.getSecond()); // (int) 38 (0-59) -// Serial.println(rtc.getMinute()); // (int) 24 (0-59) -// Serial.println(rtc.getHour()); // (int) 3 (0-12) -// Serial.println(rtc.getHour(true)); // (int) 15 (0-23) -// Serial.println(rtc.getAmPm()); // (String) pm -// Serial.println(rtc.getAmPm(true)); // (String) PM -// Serial.println(rtc.getDay()); // (int) 17 (1-31) -// Serial.println(rtc.getDayofWeek()); // (int) 0 (0-6) -// Serial.println(rtc.getDayofYear()); // (int) 16 (0-365) -// Serial.println(rtc.getMonth()); // (int) 0 (0-11) -// Serial.println(rtc.getYear()); // (int) 2021 - - Serial.println(rtc.getTime("RTC0: %A, %B %d %Y %H:%M:%S")); // (String) returns time with specified format - Serial.println(rtc1.getTime("RTC1: %A, %B %d %Y %H:%M:%S")); // (String) returns time with specified format - Serial.println(rtc2.getTime("RTC2: %A, %B %d %Y %H:%M:%S")); // (String) returns time with specified format - - // formating options http://www.cplusplus.com/reference/ctime/strftime/ - - Serial.println(rtc.getEpoch()); // (unsigned long) - Serial.println(rtc1.getEpoch()); // (unsigned long) - Serial.println(rtc2.getEpoch()); // (unsigned long) - - Serial.println(rtc.getLocalEpoch()); // (unsigned long) epoch without offset, same for all instances - delay(1000); -} diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_sleep/esp32_time_sleep.ino b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_sleep/esp32_time_sleep.ino deleted file mode 100644 index 805d7d6..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/examples/esp32_time_sleep/esp32_time_sleep.ino +++ /dev/null @@ -1,70 +0,0 @@ -/* - MIT License - - Copyright (c) 2021 Felix Biego - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#include <ESP32Time.h> - -#define uS_TO_S_FACTOR 1000000ULL /* Conversion factor for micro seconds to seconds */ -#define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */ - -ESP32Time rtc; - - -void wakeup_reason() { - esp_sleep_wakeup_cause_t wakeup_reason; - - wakeup_reason = esp_sleep_get_wakeup_cause(); - switch (wakeup_reason) - { - case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; - case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; - case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break; - case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break; - case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break; - default : - Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason); - rtc.setTime(30, 24, 15, 17, 1, 2021); // 17th Jan 2021 15:24:30 - //rtc.setTime(1609459200); // 1st Jan 2021 00:00:00 - //rtc.offset = 7200; // change offset value - - break; - } -} - -void setup() { - Serial.begin(115200); - - wakeup_reason(); - - Serial.println(rtc.getTime("%A, %B %d %Y %H:%M:%S")); // (String) returns time with specified format - - esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); - - Serial.println("Going to sleep now"); - Serial.flush(); - esp_deep_sleep_start(); -} - -void loop() { - -} diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/keywords.txt b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/keywords.txt deleted file mode 100644 index 9914509..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/keywords.txt +++ /dev/null @@ -1,22 +0,0 @@ -ESP32Time KEYWORD1 - -setTime KEYWORD2 -getTime KEYWORD2 -setTimeStruct KEYWORD2 -getTimeStruct KEYWORD2 -getDateTime KEYWORD2 -getTimeDate KEYWORD2 -getDate KEYWORD2 -getAmPm KEYWORD2 -getMillis KEYWORD2 -getMicros KEYWORD2 -getEpoch KEYWORD2 -getLocalEpoch KEYWORD2 -getSecond KEYWORD2 -getMinute KEYWORD2 -getHour KEYWORD2 -getDay KEYWORD2 -getDayofWeek KEYWORD2 -getDayofYear KEYWORD2 -getMonth KEYWORD2 -getYear KEYWORD2 diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.json b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.json deleted file mode 100644 index 185fee7..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "ESP32Time", - "version": "2.0.0", - "keywords": "Arduino, ESP32, Time, Internal RTC", - "description": "An Arduino library for setting and retrieving internal RTC time on ESP32 boards", - "repository": - { - "type": "git", - "url": "https://github.com/fbiego/ESP32Time" - }, - "authors": - [ - { - "name": "fbiego", - "email": "fbiego.fb@gmail.com", - "maintainer": true - } - ], - "frameworks": "arduino", - "platforms": "espressif8266, espressif32" -} diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.properties b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.properties deleted file mode 100644 index 5926944..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/ESP32Time/library.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=ESP32Time -version=2.0.0 -author=fbiego -maintainer=fbiego -sentence=Set and retrieve internal RTC time on ESP32 boards. -paragraph=No need for external RTC module or NTP time synchronization. -category=Timing -url=https://github.com/fbiego/ESP32Time -architectures=* -includes=ESP32Time.h - diff --git a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/integrity.dat b/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/integrity.dat deleted file mode 100644 index fd39b3c..0000000 --- a/host/esp32/.pio/libdeps/esp32-c3-devkitm-1/integrity.dat +++ /dev/null @@ -1 +0,0 @@ -fbiego/ESP32Time@^2.0.0 \ No newline at end of file -- GitLab