From 40b4c19495591b60a659f8946b6a4811556ade36 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 30 Apr 2021 13:45:07 -0700 Subject: [PATCH] ESP32CAM | Android(Flutter App) Wired Communication - Base64 Encoding/Decoding [2/2] --- .../Part.1_BaudRateTest.ino | 2 +- .../ESP32CAM_USBSerial/ESP32CAM_USBSerial.ino | 109 +++++++++++++ .../ESP32CAM_USBSerial/camera_pins2.h | 117 ++++++++++++++ .../esp32cam_wired_comm/.gitignore | 118 ++++++++++++++ .../esp32cam_wired_comm/.metadata | 10 ++ .../esp32cam_wired_comm/README.md | 16 ++ .../esp32cam_wired_comm/android/.gitignore | 11 ++ .../android/app/build.gradle | 55 +++++++ .../android/app/src/debug/AndroidManifest.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 48 ++++++ .../esp32cam_wired_comm/MainActivity.java | 6 + .../res/drawable-v21/launch_background.xml | 12 ++ .../main/res/drawable/launch_background.xml | 12 ++ .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 +++ .../app/src/main/res/values/styles.xml | 18 +++ .../app/src/main/res/xml/device_filter.xml | 27 ++++ .../app/src/profile/AndroidManifest.xml | 7 + .../esp32cam_wired_comm/android/build.gradle | 29 ++++ .../android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + .../android/settings.gradle | 11 ++ .../lib/controller/serial_controller.dart | 113 +++++++++++++ .../esp32cam_wired_comm/lib/main.dart | 151 ++++++++++++++++++ .../esp32cam_wired_comm/pubspec.yaml | 81 ++++++++++ 29 files changed, 986 insertions(+), 1 deletion(-) rename ESP32CAM_Projects/{WIRED_ESP32_CAM_w:FlutterApp => WIRED_ESP32_CAM_with_FlutterApp}/Part.1_BaudRateTest/Part.1_BaudRateTest.ino (99%) create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/ESP32CAM_USBSerial.ino create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/camera_pins2.h create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.gitignore create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.metadata create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/README.md create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/.gitignore create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/build.gradle create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/debug/AndroidManifest.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/AndroidManifest.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/java/com/thatproject/esp32cam_wired_comm/MainActivity.java create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable/launch_background.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values-night/styles.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values/styles.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/xml/device_filter.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/profile/AndroidManifest.xml create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/build.gradle create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle.properties create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/settings.gradle create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/controller/serial_controller.dart create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/main.dart create mode 100644 ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/pubspec.yaml diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_w:FlutterApp/Part.1_BaudRateTest/Part.1_BaudRateTest.ino b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.1_BaudRateTest/Part.1_BaudRateTest.ino similarity index 99% rename from ESP32CAM_Projects/WIRED_ESP32_CAM_w:FlutterApp/Part.1_BaudRateTest/Part.1_BaudRateTest.ino rename to ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.1_BaudRateTest/Part.1_BaudRateTest.ino index a6c1905..1a910b6 100644 --- a/ESP32CAM_Projects/WIRED_ESP32_CAM_w:FlutterApp/Part.1_BaudRateTest/Part.1_BaudRateTest.ino +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.1_BaudRateTest/Part.1_BaudRateTest.ino @@ -2,7 +2,7 @@ /* ESP32CAM | Android(Flutter App) Wired Communication - Baud Rate Test [1/2] https://youtu.be/Mod9gX7NWA8 - Created by Eric Nam (ThatProject) + Created by Eric N. (ThatProject) */ ///////////////////////////////////////////////////////////////// diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/ESP32CAM_USBSerial.ino b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/ESP32CAM_USBSerial.ino new file mode 100644 index 0000000..f2dc722 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/ESP32CAM_USBSerial.ino @@ -0,0 +1,109 @@ +///////////////////////////////////////////////////////////////// +/* + ESP32CAM | Android(Flutter App) Wired Communication - Base64 Encoding/Decoding [2/2] + Video Tutorial: https://youtu.be/-jygTxRmroA + Created by Eric N. (ThatProject) +*/ +///////////////////////////////////////////////////////////////// + +#include "esp_camera.h" +#include +#define CAMERA_MODEL_AI_THINKER +//#define TTGO_T_CAMERA_PLUS +#include "camera_pins2.h" + +#define USE_TFT_ESPI 0 + +#if USE_TFT_ESPI + #include + #include + TFT_eSPI tft = TFT_eSPI(); +#endif + +#define BAUD_RATE 2000000 + +void setup() +{ + Serial.begin(BAUD_RATE); + + displayInit(); + cameraInit(); +} + +void loop() { + grabImage(); +} + +void cameraInit(){ + camera_config_t config; + config.ledc_channel = LEDC_CHANNEL_0; + config.ledc_timer = LEDC_TIMER_0; + config.pin_d0 = Y2_GPIO_NUM; + config.pin_d1 = Y3_GPIO_NUM; + config.pin_d2 = Y4_GPIO_NUM; + config.pin_d3 = Y5_GPIO_NUM; + config.pin_d4 = Y6_GPIO_NUM; + config.pin_d5 = Y7_GPIO_NUM; + config.pin_d6 = Y8_GPIO_NUM; + config.pin_d7 = Y9_GPIO_NUM; + config.pin_xclk = XCLK_GPIO_NUM; + config.pin_pclk = PCLK_GPIO_NUM; + config.pin_vsync = VSYNC_GPIO_NUM; + config.pin_href = HREF_GPIO_NUM; + config.pin_sscb_sda = SIOD_GPIO_NUM; + config.pin_sscb_scl = SIOC_GPIO_NUM; + config.pin_pwdn = PWDN_GPIO_NUM; + config.pin_reset = RESET_GPIO_NUM; + config.xclk_freq_hz = 10000000; + config.pixel_format = PIXFORMAT_JPEG; + config.frame_size = FRAMESIZE_QVGA; //320x240 + config.jpeg_quality = 10; + config.fb_count = 2; + + esp_err_t err = esp_camera_init(&config); + if (err != ESP_OK) { + return; + } + + sensor_t * s = esp_camera_sensor_get(); + s->set_hmirror(s, 1); + s->set_vflip(s, 1); +} + +void grabImage(){ + + camera_fb_t* fb = esp_camera_fb_get(); + if(!fb || fb->format != PIXFORMAT_JPEG){ + }else{ + #if USE_TFT_ESPI + TJpgDec.drawJpg(-40, 0, (const uint8_t*)fb->buf, fb->len); + #else + delay(40); + #endif + + String encoded = base64::encode(fb->buf, fb->len); + Serial.write(encoded.c_str(), encoded.length()); + Serial.println(); + } + esp_camera_fb_return(fb); +} + +bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap){ + #if USE_TFT_ESPI + if( y>= tft.height()) return 0; + tft.pushImage(x, y, w, h, bitmap); + return 1; + #endif +} + +void displayInit(){ + #if USE_TFT_ESPI + tft.begin(); + tft.setRotation(0); + tft.fillScreen(TFT_WHITE); + + TJpgDec.setJpgScale(1); + TJpgDec.setSwapBytes(true); + TJpgDec.setCallback(tft_output); + #endif +} diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/camera_pins2.h b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/camera_pins2.h new file mode 100644 index 0000000..fee52c4 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/ESP32CAM_USBSerial/camera_pins2.h @@ -0,0 +1,117 @@ + +#if defined(CAMERA_MODEL_WROVER_KIT) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 21 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 19 +#define Y4_GPIO_NUM 18 +#define Y3_GPIO_NUM 5 +#define Y2_GPIO_NUM 4 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +#elif defined(CAMERA_MODEL_ESP_EYE) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 37 +#define Y7_GPIO_NUM 38 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 35 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 13 +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 + +#elif defined(CAMERA_MODEL_M5STACK_PSRAM) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 25 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 22 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_M5STACK_WIDE) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM 15 +#define XCLK_GPIO_NUM 27 +#define SIOD_GPIO_NUM 22 +#define SIOC_GPIO_NUM 23 + +#define Y9_GPIO_NUM 19 +#define Y8_GPIO_NUM 36 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 5 +#define Y4_GPIO_NUM 34 +#define Y3_GPIO_NUM 35 +#define Y2_GPIO_NUM 32 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 26 +#define PCLK_GPIO_NUM 21 + +#elif defined(CAMERA_MODEL_AI_THINKER) +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +#elif defined(TTGO_T_CAMERA_PLUS) +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 +#define XCLK_GPIO_NUM 4 +#define SIOD_GPIO_NUM 18 +#define SIOC_GPIO_NUM 23 +#define Y9_GPIO_NUM 36 +#define Y8_GPIO_NUM 37 +#define Y7_GPIO_NUM 38 +#define Y6_GPIO_NUM 39 +#define Y5_GPIO_NUM 35 +#define Y4_GPIO_NUM 26 +#define Y3_GPIO_NUM 13 +#define Y2_GPIO_NUM 34 +#define VSYNC_GPIO_NUM 5 +#define HREF_GPIO_NUM 27 +#define PCLK_GPIO_NUM 25 + +#else +#error "Camera model not selected" +#endif diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.gitignore b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.gitignore new file mode 100644 index 0000000..56909cc --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.gitignore @@ -0,0 +1,118 @@ +# Miscellaneous +*.class +*.lock +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.classpath +.project +.settings/ +.vscode/ + +# Flutter repo-specific +/bin/cache/ +/bin/internal/bootstrap.bat +/bin/internal/bootstrap.sh +/bin/mingit/ +/dev/benchmarks/mega_gallery/ +/dev/bots/.recipe_deps +/dev/bots/android_tools/ +/dev/devicelab/ABresults*.json +/dev/docs/doc/ +/dev/docs/flutter.docs.zip +/dev/docs/lib/ +/dev/docs/pubspec.yaml +/dev/integration_tests/**/xcuserdata +/dev/integration_tests/**/Pods +/packages/flutter/coverage/ +version +analysis_benchmark.json + +# packages file containing multi-root paths +.packages.generated + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +**/generated_plugin_registrant.dart +.packages +.pub-cache/ +.pub/ +build/ +flutter_*.png +linked_*.ds +unlinked.ds +unlinked_spec.ds + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java +**/android/key.properties +*.jks + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/.last_build_id +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/ephemeral +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# macOS +**/macos/Flutter/GeneratedPluginRegistrant.swift + +# Coverage +coverage/ + +# Symbols +app.*.symbols + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +!/dev/ci/**/Gemfile.lock diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.metadata b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.metadata new file mode 100644 index 0000000..be74985 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: adc687823a831bbebe28bdccfac1a628ca621513 + channel: stable + +project_type: app diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/README.md b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/README.md new file mode 100644 index 0000000..11e60d0 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/README.md @@ -0,0 +1,16 @@ +# esp32cam_wired_comm + +ESP32CAM Wired Comm + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/.gitignore b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/.gitignore new file mode 100644 index 0000000..0a741cb --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/.gitignore @@ -0,0 +1,11 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/build.gradle b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/build.gradle new file mode 100644 index 0000000..11a47db --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/build.gradle @@ -0,0 +1,55 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 30 + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.thatproject.esp32cam_wired_comm" + minSdkVersion 16 + targetSdkVersion 30 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } + + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } +} + +flutter { + source '../..' +} diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/debug/AndroidManifest.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..4c94360 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/AndroidManifest.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..aac7a4b --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/java/com/thatproject/esp32cam_wired_comm/MainActivity.java b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/java/com/thatproject/esp32cam_wired_comm/MainActivity.java new file mode 100644 index 0000000..d6374d5 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/java/com/thatproject/esp32cam_wired_comm/MainActivity.java @@ -0,0 +1,6 @@ +package com.thatproject.esp32cam_wired_comm; + +import io.flutter.embedding.android.FlutterActivity; + +public class MainActivity extends FlutterActivity { +} diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable-v21/launch_background.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable/launch_background.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values-night/styles.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values/styles.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..d74aa35 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/xml/device_filter.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/xml/device_filter.xml new file mode 100644 index 0000000..b705876 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/main/res/xml/device_filter.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/profile/AndroidManifest.xml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..4c94360 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/build.gradle b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/build.gradle new file mode 100644 index 0000000..fab3c2e --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.3' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle.properties b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle.properties new file mode 100644 index 0000000..94adc3a --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle/wrapper/gradle-wrapper.properties b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..bc6a58a --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/settings.gradle b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/settings.gradle new file mode 100644 index 0000000..44e62bc --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/controller/serial_controller.dart b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/controller/serial_controller.dart new file mode 100644 index 0000000..829bf83 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/controller/serial_controller.dart @@ -0,0 +1,113 @@ +///////////////////////////////////////////////////////////////// +/* + ESP32CAM | Android(Flutter App) Wired Communication - Base64 Encoding/Decoding [2/2] + Video Tutorial: https://youtu.be/-jygTxRmroA + Created by Eric N. (ThatProject) +*/ +///////////////////////////////////////////////////////////////// +import 'dart:async'; +import 'dart:typed_data'; + +import 'package:get/get.dart'; +import 'package:usb_serial/transaction.dart'; +import 'package:usb_serial/usb_serial.dart'; + +class SerialController extends GetxController { + UsbPort _port; + StreamSubscription _subscription; + Transaction _transaction; + int _deviceId; + String logMessage = ""; + final hardwareKeyConnected = false.obs; + final base64data = "".obs; + + Future _connectTo(device) async { + if (_subscription != null) { + _subscription.cancel(); + _subscription = null; + } + + if (_transaction != null) { + _transaction.dispose(); + _transaction = null; + } + + if (_port != null) { + _port.close(); + _port = null; + } + + if (device == null) { + _deviceId = null; + return true; + } + + _port = await device.create(); + if (!await _port.open()) { + return false; + } + + _deviceId = device.deviceId; + + await _port.setDTR(true); + await _port.setRTS(true); + await _port.setPortParameters( + 2000000, UsbPort.DATABITS_8, UsbPort.STOPBITS_1, UsbPort.PARITY_NONE); + + _transaction = Transaction.stringTerminated( + _port.inputStream, Uint8List.fromList([13, 10])); + + _subscription = _transaction.stream.listen((String line) { + base64data.value = line; + }); + + return true; + } + + void _getPorts() async { + List devices = await UsbSerial.listDevices(); + print(devices); + bool targetDeviceFound = false; + + devices.forEach((device) { + logMessage = "[Log] device pid: ${device.pid}, device vid: ${device.vid}"; + if (device.pid == 60000 && device.vid == 4292 || // CP210x UART + device.pid == 24577 && device.vid == 1027) // FT232R UART + { + targetDeviceFound = true; + + if (!hardwareKeyConnected.value) { + _connectTo(device).then((res) { + hardwareKeyConnected.value = res; + Get.snackbar("Device Status", "Connected!", + duration: Duration(seconds: 5)); + }); + } + } + }); + + if (!targetDeviceFound) { + hardwareKeyConnected.value = false; + } + } + + void sendString(String text) async { + if (_port == null) return; + await _port.write(Uint8List.fromList(text.codeUnits)); + } + + @override + void onInit() { + super.onInit(); + UsbSerial.usbEventStream.listen((UsbEvent event) { + _getPorts(); + }); + _getPorts(); + } + + @override + void onClose() { + _connectTo(null); + super.onClose(); + } +} diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/main.dart b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/main.dart new file mode 100644 index 0000000..301ecc8 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/lib/main.dart @@ -0,0 +1,151 @@ +///////////////////////////////////////////////////////////////// +/* + ESP32CAM | Android(Flutter App) Wired Communication - Base64 Encoding/Decoding [2/2] + Video Tutorial: https://youtu.be/-jygTxRmroA + Created by Eric N. (ThatProject) +*/ +///////////////////////////////////////////////////////////////// +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:image_gallery_saver/image_gallery_saver.dart'; +import 'package:pinch_zoom_image_last/pinch_zoom_image_last.dart'; +import 'package:string_validator/string_validator.dart'; + +import 'controller/serial_controller.dart'; + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + runApp(GetMaterialApp( + home: First(), + theme: ThemeData.light(), + darkTheme: ThemeData.dark(), + themeMode: ThemeMode.system, + debugShowCheckedModeBanner: false, + )); +} + +class First extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("ESP32CAM WIRED COMM APP For QVGA"), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GetX( + init: SerialController(), + builder: (_) => Column( + children: [ + Text(_.logMessage), + SizedBox( + height: 16, + ), + Text( + 'Your ESP32CAM Connected?: ${_.hardwareKeyConnected.value.toString().toUpperCase()}', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + SizedBox( + height: 16, + ), + _.hardwareKeyConnected.value + ? Column( + children: [ + SizedBox( + height: 32, + ), + TextButton( + child: Text( + 'Confirm', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 24), + ), + onPressed: () async { + Get.to(Second()); + }, + ) + ], + ) + : Padding( + padding: const EdgeInsets.only(top: 16), + child: Text( + 'Please connect\nyour ESP32CAM via USB', + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 20), + ), + ), + SizedBox( + height: 32, + ), + ], + ), + ), + ], + ), + ), + ); + } +} + +class Second extends StatelessWidget { + var _bytesImage; + + @override + Widget build(BuildContext context) { + return Scaffold( + floatingActionButton: FloatingActionButton( + backgroundColor: const Color(0xffffffff), + foregroundColor: Colors.black, + onPressed: () async { + if (_bytesImage == null) return; + + final result = await ImageGallerySaver.saveImage(_bytesImage); + Get.snackbar("Image Save", result != null ? "Success!" : "Fail!", + duration: Duration(seconds: 3)); + }, + child: Icon(Icons.save), + ), + appBar: AppBar( + title: Text('Viewer Page'), + ), + body: Center( + child: Obx(() { + final connected = + Get.find().hardwareKeyConnected.value; + + if (connected) { + final base64data = + Get.find().base64data.value.toString(); + + if (isBase64(base64data)) { + _bytesImage = Base64Decoder().convert(base64data); + return showImageWithPinchZoom(); + } else { + return showImageWithPinchZoom(); + } + } else { + Get.back(); + return Text('Disconnected =.='); + } + }), + )); + } + + Widget showImageWithPinchZoom() { + return PinchZoomImage( + image: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(10)), + child: Image.memory( + _bytesImage, + gaplessPlayback: true, + ), + ), + zoomedBackgroundColor: Colors.black.withOpacity(0.5), + ); + } +} diff --git a/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/pubspec.yaml b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/pubspec.yaml new file mode 100644 index 0000000..74aa319 --- /dev/null +++ b/ESP32CAM_Projects/WIRED_ESP32_CAM_with_FlutterApp/Part.2_FlutterAppForSerialCam/esp32cam_wired_comm/pubspec.yaml @@ -0,0 +1,81 @@ +name: esp32cam_wired_comm +description: ESP32CAM Wired Comm + +# The following line prevents the package from being accidentally published to +# pub.dev using `pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.0.0+1 + +environment: + sdk: ">=2.7.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + usb_serial: ^0.2.4 + get: ^4.1.4 + pinch_zoom_image_last: ^0.3.2 + image_gallery_saver: ^1.6.9 + string_validator: ^0.3.0 + +dev_dependencies: + flutter_test: + sdk: flutter + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages