diff --git a/PrepareProject.py b/PrepareProject.py index 3e4cb507..f0b58f8d 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -15,7 +15,10 @@ # # поддерживаемые контроллеры (профили): # esp8266_4mb +# esp8266_16mb # esp32_4mb +# esp32cam_4mb +# esp32_16mb # esp32s2_4mb # esp8266_1mb # esp8266_1mb_ota diff --git a/data_svelte/myProfile.json b/data_svelte/myProfile.json index 0170a5e1..a6e193dc 100644 --- a/data_svelte/myProfile.json +++ b/data_svelte/myProfile.json @@ -25,7 +25,7 @@ "projectProp": { "platformio": { "default_envs": "esp8266_4mb", - "comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32s2_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota", + "comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32cam_4mb or esp32s2_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota", "envs": [ { "name": "esp8266_4mb", @@ -45,6 +45,14 @@ "partitions": "0x8000", "littlefs": "0x290000" }, + { + "name": "esp32cam_4mb", + "boot_app0": "0xe000", + "bootloader_qio_80m": "0x1000", + "firmware": "0x10000", + "partitions": "0x8000", + "littlefs": "0x290000" + }, { "name": "esp32_16mb", "boot_app0": "0xe000", @@ -372,6 +380,10 @@ "path": "src/modules/exec/TelegramLT", "active": true }, + { + "path": "src/modules/exec/Telegram_v2", + "active": false + }, { "path": "src/modules/exec/Thermostat", "active": false diff --git a/include/Const.h b/include/Const.h index 754121aa..c88153b6 100644 --- a/include/Const.h +++ b/include/Const.h @@ -32,6 +32,10 @@ #define FIRMWARE_NAME "esp32_4mb" #endif +#ifdef esp32cam_4mb +#define FIRMWARE_NAME "esp32cam_4mb" +#endif + #ifdef esp32_16mb #define FIRMWARE_NAME "esp32_16mb" #endif diff --git a/include/Global.h b/include/Global.h index 285e08ba..4922d660 100644 --- a/include/Global.h +++ b/include/Global.h @@ -56,6 +56,8 @@ **********************************************************************************************************************/ extern IoTGpio IoTgpio; extern IoTItem* rtcItem; +//extern IoTItem* camItem; +extern IoTItem* tlgrmItem; extern TickerScheduler ts; extern WiFiClient espClient; diff --git a/include/classes/IoTItem.h b/include/classes/IoTItem.h index bb64a69f..afb6be02 100644 --- a/include/classes/IoTItem.h +++ b/include/classes/IoTItem.h @@ -51,8 +51,16 @@ class IoTItem { virtual IoTGpio* getGpioDriver(); virtual IoTItem* getRtcDriver(); + //virtual IoTItem* getCAMDriver(); + virtual IoTItem* getTlgrmDriver(); virtual unsigned long getRtcUnixTime(); + // делаем доступным модулям отправку сообщений в телеграм + virtual void sendTelegramMsg(bool often, String msg); + virtual void sendFoto(uint8_t *buf, uint32_t length, const String &name); + virtual void editFoto(uint8_t *buf, uint32_t length, const String &name); + + virtual void setValue(const IoTValue& Value, bool genEvent = true); virtual void setValue(const String& valStr, bool genEvent = true); String getRoundValue(); @@ -65,9 +73,6 @@ class IoTItem { virtual void onModuleOrder(String& key, String& value); virtual void onTrackingValue(IoTItem* item); // момент, когда ядро заметило изменение отслеживаемого значения - // делаем доступным модулям отправку сообщений в телеграм - virtual void sendTelegramMsg(bool often, String msg); - // методы для графиков (будет упрощено) virtual void publishValue(); virtual void clearValue(); diff --git a/myProfile.json b/myProfile.json index 0170a5e1..a6e193dc 100644 --- a/myProfile.json +++ b/myProfile.json @@ -25,7 +25,7 @@ "projectProp": { "platformio": { "default_envs": "esp8266_4mb", - "comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32s2_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota", + "comments_default_envs": "choose from: esp8266_4mb or esp32_4mb or esp32cam_4mb or esp32s2_4mb or esp8266_1mb or esp8266_1mb_ota or esp8285_1mb or esp8285_1mb_ota", "envs": [ { "name": "esp8266_4mb", @@ -45,6 +45,14 @@ "partitions": "0x8000", "littlefs": "0x290000" }, + { + "name": "esp32cam_4mb", + "boot_app0": "0xe000", + "bootloader_qio_80m": "0x1000", + "firmware": "0x10000", + "partitions": "0x8000", + "littlefs": "0x290000" + }, { "name": "esp32_16mb", "boot_app0": "0xe000", @@ -372,6 +380,10 @@ "path": "src/modules/exec/TelegramLT", "active": true }, + { + "path": "src/modules/exec/Telegram_v2", + "active": false + }, { "path": "src/modules/exec/Thermostat", "active": false diff --git a/platformio.ini b/platformio.ini index 72fb7ea9..2b2e296c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -199,6 +199,29 @@ build_src_filter = + ${env:esp32_4mb_fromitems.build_src_filter} +[env:esp32cam_4mb] +lib_deps = + ${common_env_data.lib_deps_external} + ${env:esp32cam_4mb_fromitems.lib_deps} +build_flags = + -Desp32cam_4mb="esp32cam_4mb" + -DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue +framework = arduino +board = esp32cam +platform = espressif32 @5.1.1 +monitor_filters = esp32_exception_decoder +upload_speed = 921600 +monitor_speed = 115200 +debug_tool = esp-prog +board_build.filesystem = littlefs +build_src_filter = + +<*.cpp> + + + + + + + ${env:esp32cam_4mb_fromitems.build_src_filter} + [env:esp32s2_4mb] lib_deps = ${common_env_data.lib_deps_external} @@ -557,11 +580,25 @@ build_src_filter = + + +[env:esp32cam_4mb_fromitems] +lib_deps = + espressif/esp32-camera @ ^2.0.0 + gyverlibs/FastBot +build_src_filter = + + + + + + + + + + + + + + + + + + + [env:esp32s2_4mb_fromitems] lib_deps = build_src_filter = + - + + + + diff --git a/src/ESPConfiguration.cpp b/src/ESPConfiguration.cpp index 796e7bb5..d0ee0bc8 100644 --- a/src/ESPConfiguration.cpp +++ b/src/ESPConfiguration.cpp @@ -31,7 +31,10 @@ void configure(String path) { if (driver = myIoTItem->getGpioDriver()) IoTgpio.regDriver((IoTGpio*)driver); // пробуем спросить драйвер RTC if (driver = myIoTItem->getRtcDriver()) rtcItem = (IoTItem*)driver; - + // пробуем спросить драйвер CAM + //if (driver = myIoTItem->getCAMDriver()) camItem = (IoTItem*)driver; + // пробуем спросить драйвер Telegram_v2 + if (driver = myIoTItem->getTlgrmDriver()) tlgrmItem = (IoTItem*)driver; IoTItems.push_back(myIoTItem); } } @@ -44,6 +47,8 @@ void configure(String path) { void clearConfigure() { Serial.printf("Start clearing config\n"); rtcItem = nullptr; + //camItem = nullptr; + tlgrmItem = nullptr; IoTgpio.clearDrivers(); for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { diff --git a/src/Global.cpp b/src/Global.cpp index efab097a..1130691c 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -31,7 +31,8 @@ WebSocketsServer standWebSocket = WebSocketsServer(81); **********************************************************************************************************************/ IoTGpio IoTgpio(0); IoTItem* rtcItem = nullptr; - +//IoTItem* camItem = nullptr; +IoTItem* tlgrmItem = nullptr; String settingsFlashJson = "{}"; // переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью String valuesFlashJson = "{}"; // переменная в которой хранятся все значения элементов, которые необходимо сохранить на flash. Находится в оперативной памяти и синхронизированна с flash памятью String errorsHeapJson = "{}"; // переменная в которой хранятся все ошибки, находится в оперативной памяти только diff --git a/src/Main.cpp b/src/Main.cpp index 140332aa..0d1e7951 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -44,7 +44,7 @@ void elementsLoop() { #define COUNTER_ERRORMARKER 4 // количество шагов счетчика #define STEPPER_ERRORMARKER 100000 // размер шага счетчика интервала доверия выполнения блока кода мкс -#ifdef esp32_4mb +#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb) static int IRAM_ATTR initErrorMarkerId = 0; // ИД маркера static int IRAM_ATTR errorMarkerId = 0; @@ -63,14 +63,14 @@ void IRAM_ATTR onTimer() { #endif void initErrorMarker(int id) { -#ifdef esp32_4mb +#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb) initErrorMarkerId = id; errorMarkerCounter = 0; #endif } void stopErrorMarker(int id) { -#ifdef esp32_4mb +#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb) errorMarkerCounter = -1; if (errorMarkerId) SerialPrint("I", "WARNING!", "A lazy (freezing loop more than " + (String)(COUNTER_ERRORMARKER * STEPPER_ERRORMARKER / 1000) + " ms) section has been found! With ID=" + (String)errorMarkerId); @@ -83,7 +83,7 @@ void setup() { #ifdef esp32s2_4mb USB.begin(); #endif -#ifdef esp32_4mb +#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb) My_timer = timerBegin(0, 80, true); timerAttachInterrupt(My_timer, &onTimer, true); timerAlarmWrite(My_timer, STEPPER_ERRORMARKER, true); diff --git a/src/PeriodicTasks.cpp b/src/PeriodicTasks.cpp index 05ff1a20..aca4f182 100644 --- a/src/PeriodicTasks.cpp +++ b/src/PeriodicTasks.cpp @@ -101,7 +101,7 @@ String ESP32GetResetReason(uint32_t cpu_no) { } } #endif -#if defined(esp32_4mb) || defined(esp32_16mb) +#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb) String ESP_getResetReason(void) { return ESP32GetResetReason(0); // CPU 0 } diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index 3df79e82..ab749e96 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -200,7 +200,8 @@ bool IoTItem::isTracking(IoTItem* item) { // делаем доступным модулям отправку сообщений в телеграм void IoTItem::sendTelegramMsg(bool often, String msg) {} - +void IoTItem::sendFoto(uint8_t *buf, uint32_t length, const String &name) {} +void IoTItem::editFoto(uint8_t *buf, uint32_t length, const String &name) {} // методы для графиков (будет упрощено) void IoTItem::publishValue() {} void IoTItem::clearValue() {} @@ -233,6 +234,14 @@ IoTGpio* IoTItem::getGpioDriver() { IoTItem* IoTItem::getRtcDriver() { return nullptr; } +/* +IoTItem* IoTItem::getCAMDriver() { + return nullptr; +} +*/ +IoTItem* IoTItem::getTlgrmDriver() { + return nullptr; +} unsigned long IoTItem::getRtcUnixTime() { return 0; diff --git a/src/modules/display/DwinI/modinfo.json b/src/modules/display/DwinI/modinfo.json index 079ba5ec..c696860a 100644 --- a/src/modules/display/DwinI/modinfo.json +++ b/src/modules/display/DwinI/modinfo.json @@ -44,6 +44,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/display/Lcd2004/modinfo.json b/src/modules/display/Lcd2004/modinfo.json index ccd53c60..f96cf0f5 100644 --- a/src/modules/display/Lcd2004/modinfo.json +++ b/src/modules/display/Lcd2004/modinfo.json @@ -123,6 +123,10 @@ "https://github.com/robotclass/RobotClass_LiquidCrystal_I2C", "marcoschwartz/LiquidCrystal_I2C@^1.1.4" ], + "esp32cam_4mb": [ + "https://github.com/robotclass/RobotClass_LiquidCrystal_I2C", + "marcoschwartz/LiquidCrystal_I2C@^1.1.4" + ], "esp8266_4mb": [ "https://github.com/robotclass/RobotClass_LiquidCrystal_I2C", "marcoschwartz/LiquidCrystal_I2C@^1.1.4" diff --git a/src/modules/display/NextionUpload/modinfo.json b/src/modules/display/NextionUpload/modinfo.json index a3a7efa5..da09e32a 100644 --- a/src/modules/display/NextionUpload/modinfo.json +++ b/src/modules/display/NextionUpload/modinfo.json @@ -39,6 +39,9 @@ "esp32_4mb": [ "https://github.com/avaksru/ESPNexUpload.git" ], + "esp32cam_4mb": [ + "https://github.com/avaksru/ESPNexUpload.git" + ], "esp8266_4mb": [ "https://github.com/avaksru/ESPNexUpload.git" ], diff --git a/src/modules/display/Smi2_m/modinfo.json b/src/modules/display/Smi2_m/modinfo.json index 34a1ff2d..f79a7051 100644 --- a/src/modules/display/Smi2_m/modinfo.json +++ b/src/modules/display/Smi2_m/modinfo.json @@ -52,6 +52,7 @@ }, "defActive": true, "usedLibs": { - "esp32_4mb": [] + "esp32_4mb": [], + "esp32cam_4mb": [] } } \ No newline at end of file diff --git a/src/modules/display/TM16XX/modinfo.json b/src/modules/display/TM16XX/modinfo.json index 1476107f..25d74438 100644 --- a/src/modules/display/TM16XX/modinfo.json +++ b/src/modules/display/TM16XX/modinfo.json @@ -107,6 +107,11 @@ "adafruit/Adafruit GFX Library @ ^1.11.5", "adafruit/Adafruit BusIO @ ^1.13.2" ], + "esp32cam_4mb": [ + "https://github.com/maxint-rd/TM16xx", + "adafruit/Adafruit GFX Library @ ^1.11.5", + "adafruit/Adafruit BusIO @ ^1.13.2" + ], "esp8266_4mb": [ "https://github.com/maxint-rd/TM16xx", "adafruit/Adafruit GFX Library @ ^1.11.5", diff --git a/src/modules/display/Ws2812b/modinfo.json b/src/modules/display/Ws2812b/modinfo.json index 4b601f4b..4aa08ae6 100644 --- a/src/modules/display/Ws2812b/modinfo.json +++ b/src/modules/display/Ws2812b/modinfo.json @@ -100,6 +100,9 @@ "esp32_4mb": [ "adafruit/Adafruit NeoPixel@^1.10.6" ], + "esp32cam_4mb": [ + "adafruit/Adafruit NeoPixel@^1.10.6" + ], "esp8266_4mb": [ "adafruit/Adafruit NeoPixel@^1.10.6" ] diff --git a/src/modules/exec/ButtonIn/modinfo.json b/src/modules/exec/ButtonIn/modinfo.json index 7c185014..e241adec 100644 --- a/src/modules/exec/ButtonIn/modinfo.json +++ b/src/modules/exec/ButtonIn/modinfo.json @@ -46,6 +46,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/exec/ButtonOut/modinfo.json b/src/modules/exec/ButtonOut/modinfo.json index 6de870f7..6a16dd18 100644 --- a/src/modules/exec/ButtonOut/modinfo.json +++ b/src/modules/exec/ButtonOut/modinfo.json @@ -50,6 +50,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/exec/Buzzer/modinfo.json b/src/modules/exec/Buzzer/modinfo.json index 44dcdf97..4d22dbcd 100644 --- a/src/modules/exec/Buzzer/modinfo.json +++ b/src/modules/exec/Buzzer/modinfo.json @@ -104,6 +104,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/exec/Enconder/modinfo.json b/src/modules/exec/Enconder/modinfo.json index 1a86b03c..f344bf17 100644 --- a/src/modules/exec/Enconder/modinfo.json +++ b/src/modules/exec/Enconder/modinfo.json @@ -46,6 +46,9 @@ "esp32_4mb": [ "gyverlibs/EncButton @ ^2.0" ], + "esp32cam_4mb": [ + "gyverlibs/EncButton @ ^2.0" + ], "esp8266_4mb": [ "gyverlibs/EncButton @ ^2.0" ], diff --git a/src/modules/exec/EspCam/EspCam.cpp b/src/modules/exec/EspCam/EspCam.cpp index 59cd07fd..12a63ea6 100644 --- a/src/modules/exec/EspCam/EspCam.cpp +++ b/src/modules/exec/EspCam/EspCam.cpp @@ -3,64 +3,108 @@ #include "NTP.h" #include "esp_camera.h" -#include "soc/soc.h" // Disable brownour problems -#include "soc/rtc_cntl_reg.h" // Disable brownour problems +#include "soc/soc.h" // Disable brownour problems +#include "soc/rtc_cntl_reg.h" // Disable brownour problems -#include "FS.h" // SD Card ESP32 -#include "SD_MMC.h" // SD Card ESP32 +#include "FS.h" // SD Card ESP32 +#include "SD_MMC.h" // SD Card ESP32 void handleGetPic(); // =================== // Select camera model // =================== -//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM -//#define CAMERA_MODEL_ESP_EYE // Has PSRAM -//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM -//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM -//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM -//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM -//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM -//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM +// #define CAMERA_MODEL_WROVER_KIT // Has PSRAM +// #define CAMERA_MODEL_ESP_EYE // Has PSRAM +// #define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM +// #define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM +// #define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM +// #define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM +// #define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM +// #define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM #define CAMERA_MODEL_AI_THINKER // Has PSRAM -//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM -//#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM -// ** Espressif Internal Boards ** -//#define CAMERA_MODEL_ESP32_CAM_BOARD -//#define CAMERA_MODEL_ESP32S2_CAM_BOARD -//#define CAMERA_MODEL_ESP32S3_CAM_LCD +// #define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM +// #define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM +// ** Espressif Internal Boards ** +// #define CAMERA_MODEL_ESP32_CAM_BOARD +// #define CAMERA_MODEL_ESP32S2_CAM_BOARD +// #define CAMERA_MODEL_ESP32S3_CAM_LCD - -#define LED_LEDC_CHANNEL 2 //Using different ledc channel/timer than camera +#define LED_LEDC_CHANNEL 2 // Using different ledc channel/timer than camera #define CONFIG_LED_MAX_INTENSITY 255 #include "camera_pins.h" - -IoTItem* globalItem = nullptr; - - -class EspCam : public IoTItem { - private: + IoTItem *_camItem = nullptr; +camera_fb_t *frame = NULL; +class EspCam : public IoTItem +{ +private: bool _useLed, _ticker, _webTicker, _initSD; - public: +public: bool isUsedLed() { return _useLed; } bool isWebTicker() { return _webTicker; } - EspCam(String parameters): IoTItem(parameters) { - WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector + EspCam(String parameters) : IoTItem(parameters) + { - jsonRead(parameters, "useLed", _useLed); // используем = 1 или нет = 0 подсветку (вспышку) - if (_useLed) { + jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов + jsonRead(parameters, "webTicker", _webTicker); // сообщать всем, что через веб попросили отдать картинку с камеры + jsonRead(parameters, "flashOn", _useLed); // используем = 1 или нет = 0 подсветку (вспышку) + // globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб + _camItem = this; + initCam(); + + HTTP.on("/getpic", HTTP_GET, handleGetPic); + + initSD(); + } + + void doByInterval() + { + // save_picture(); + } + + IoTValue execute(String command, std::vector ¶m) + { + if (command == "save") + { + if (param.size() == 1) + save_picture(param[0].valS); + else + save_picture(); + } + else if (command == "flashOn") + { ledcSetup(LED_LEDC_CHANNEL, 5000, 8); ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL); + _useLed = true; + } + else if (command == "flashOff") + { + _useLed = false; + } + else if (command == "sendFoto") + { + sendFoto(); + } + else if (command == "editFoto") + { + editFoto(); } - jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов - jsonRead(parameters, "webTicker", _webTicker); // сообщать всем, что через веб попросили отдать картинку с камеры - globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб - + return {}; + } + /* + IoTItem *getCAMDriver() + { + return this; + } +*/ + void initCam() + { + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // disable brownout detector camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; @@ -83,110 +127,141 @@ class EspCam : public IoTItem { config.xclk_freq_hz = 20000000; config.frame_size = FRAMESIZE_UXGA; config.pixel_format = PIXFORMAT_JPEG; // for streaming - //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition + // config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; config.fb_location = CAMERA_FB_IN_PSRAM; config.jpeg_quality = 12; config.fb_count = 1; - + // if PSRAM IC present, init with UXGA resolution and higher JPEG quality // for larger pre-allocated frame buffer. - if(psramFound()){ + if (psramFound()) + { config.jpeg_quality = 10; config.fb_count = 2; config.grab_mode = CAMERA_GRAB_LATEST; - } else { + } + else + { // Limit the frame size when PSRAM is not available config.frame_size = FRAMESIZE_SVGA; config.fb_location = CAMERA_FB_IN_DRAM; } - - #if defined(CAMERA_MODEL_ESP_EYE) + +#if defined(CAMERA_MODEL_ESP_EYE) pinMode(13, INPUT_PULLUP); pinMode(14, INPUT_PULLUP); - #endif +#endif // camera init esp_err_t err = esp_camera_init(&config); - if (err != ESP_OK) { + if (err != ESP_OK) + { Serial.printf("Camera init failed with error 0x%x", err); return; } - sensor_t * s = esp_camera_sensor_get(); + sensor_t *s = esp_camera_sensor_get(); // initial sensors are flipped vertically and colors are a bit saturated - if (s->id.PID == OV3660_PID) { - s->set_vflip(s, 1); // flip it back - s->set_brightness(s, 1); // up the brightness just a bit + if (s->id.PID == OV3660_PID) + { + s->set_vflip(s, 1); // flip it back + s->set_brightness(s, 1); // up the brightness just a bit s->set_saturation(s, -2); // lower the saturation } - #if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM) + if (_useLed) + { + ledcSetup(LED_LEDC_CHANNEL, 5000, 8); + ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL); + } + +#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM) s->set_vflip(s, 1); s->set_hmirror(s, 1); - #endif +#endif - #if defined(CAMERA_MODEL_ESP32S3_EYE) +#if defined(CAMERA_MODEL_ESP32S3_EYE) s->set_vflip(s, 1); - #endif - - HTTP.on("/getpic", HTTP_GET, handleGetPic); +#endif + } + void initSD() + { // Start Micro SD card _initSD = true; Serial.println("Starting SD Card"); - if(!SD_MMC.begin("/sdcard", true)){ + if (!SD_MMC.begin("/sdcard", true)) + { Serial.println("SD Card Mount Failed"); _initSD = false; return; } - + uint8_t cardType = SD_MMC.cardType(); - if(cardType == CARD_NONE){ + if (cardType == CARD_NONE) + { Serial.println("No SD Card attached"); _initSD = false; return; } - + fs::FS &fs = SD_MMC; - fs.mkdir("/photos/"); + fs.mkdir("/photos"); } - void save_picture(String path = "") { - // if (_useLed) digitalWrite(4, HIGH); //Turn on the flash + void sendFoto() + { + if (tlgrmItem) + { + if (_useLed) + ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); // Turn on the flash + frame = esp_camera_fb_get(); + if (!frame) + { + SerialPrint("E", F("Esp-Cam to Telegram"), "Fail esp-cam initialization"); + return; + } + if (_useLed) + ledcWrite(LED_LEDC_CHANNEL, 0); + (tlgrmItem)->sendFoto((byte *)frame->buf, frame->len, "photo.jpg"); + esp_camera_fb_return(frame); + SerialPrint("i", F("Esp-Cam to Telegram"), "esp_CAM send foto"); + } + } - // // Take Picture with Camera - // fb = esp_camera_fb_get(); - // if(!fb || fb->len >= PICBUF_SIZE) { - // if (fb) { - // Serial.printf("Camera capture failed size=%d\n", fb->len); - // esp_camera_fb_return(fb); - // } else Serial.printf("Camera capture failed\n"); - // return; - // } - - // // if (value.extBinInfoSize < fb->len) { - // // if (value.extBinInfo) free(value.extBinInfo); - // // value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * fb->len); - // // } - // memcpy(value.extBinInfo, fb->buf, fb->len); - // value.extBinInfoSize = fb->len; - - // Serial.printf("try send pic by size=%d", fb->len); - - // if (_useLed) digitalWrite(4, LOW); - // if (_ticker) regEvent("shot", "EspCam"); - // esp_camera_fb_return(fb); + void editFoto() + { + if (tlgrmItem) + { + if (_useLed) + ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); // Turn on the flash + frame = esp_camera_fb_get(); + if (!frame) + { + SerialPrint("E", F("Esp-Cam to Telegram"), "Fail esp-cam initialization"); + return; + } + if (_useLed) + ledcWrite(LED_LEDC_CHANNEL, 0); + (tlgrmItem)->editFoto((byte *)frame->buf, frame->len, "photo.jpg"); + esp_camera_fb_return(frame); + SerialPrint("i", F("Esp-Cam to Telegram"), "esp_CAM edit foto"); + } + } + void save_picture(String path = "") + { // Save picture to microSD card fs::FS &fs = SD_MMC; - if (path == "") { + if (path == "") + { path = "/photos/"; - path += getTodayDateDotFormated(); - path += "/"; + path += getTodayDateDotFormated(); + // path += "/"; fs.mkdir(path.c_str()); char buf[32]; @@ -196,79 +271,78 @@ class EspCam : public IoTItem { } Serial.println(path); - // Take Picture with Camera - camera_fb_t * fb = esp_camera_fb_get(); + if (_useLed) + ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); // Turn on the flash - if(!fb) { + // Take Picture with Camera + frame = esp_camera_fb_get(); + if (_useLed) + ledcWrite(LED_LEDC_CHANNEL, 0); // Turn on the flash + + if (!frame) + { Serial.println("Camera capture failed"); return; } - + File file = fs.open(path.c_str(), FILE_WRITE); - if(!file){ + if (!file) + { Serial.println("Failed to open file in writing mode"); - } - else { - file.write(fb->buf, fb->len); // payload (image), payload length + } + else + { + file.write(frame->buf, frame->len); // payload (image), payload length Serial.printf("Saved file to path: %s\n", path.c_str()); } file.close(); - - //return the frame buffer back to the driver for reuse - esp_camera_fb_return(fb); + + // return the frame buffer back to the driver for reuse + esp_camera_fb_return(frame); } - void doByInterval() { - //save_picture(); - } - - IoTValue execute(String command, std::vector ¶m) { - if (command == "save") { - if (param.size() == 1) - save_picture(param[0].valS); - else - save_picture(); - } else if (command == "ledOn" && param.size() == 1) { - ledcSetup(LED_LEDC_CHANNEL, 5000, 8); - ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL); - ledcWrite(LED_LEDC_CHANNEL, param[0].valD); - } else if (command == "ledOff") { - ledcWrite(LED_LEDC_CHANNEL, 0); - } - - return {}; - } - - ~EspCam() { - //free(value.extBinInfo); - globalItem = nullptr; + ~EspCam() + { + // free(value.extBinInfo); + _camItem = nullptr; }; }; -void handleGetPic() { - if (!globalItem) return; +void handleGetPic() +{ + if (!_camItem) + return; - if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); //Turn on the flash + if (((EspCam *)_camItem)->isUsedLed()) + ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); // Turn on the flash - camera_fb_t* fb = NULL; - fb = esp_camera_fb_get(); - if (!fb) { + // camera_fb_t *fb = NULL; + frame = esp_camera_fb_get(); + + if (((EspCam *)_camItem)->isUsedLed()) + ledcWrite(LED_LEDC_CHANNEL, 0); + + if (!frame) + { HTTP.send(200, "text/json", F("Item EspCam not prepared yet or camera hasn't taken a picture yet")); return; } - - HTTP.send_P(200, "image/jpeg", (char *)fb->buf, fb->len); - if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, 0); - if (((EspCam*)globalItem)->isWebTicker()) globalItem->regEvent("webTakesPhoto", "EspCam"); - esp_camera_fb_return(fb); + HTTP.send_P(200, "image/jpeg", (char *)frame->buf, frame->len); + + if (((EspCam *)_camItem)->isWebTicker()) + _camItem->regEvent("webTakesPhoto", "EspCam"); + esp_camera_fb_return(frame); } - -void* getAPI_EspCam(String subtype, String param) { - if (subtype == F("EspCam")) { +void *getAPI_EspCam(String subtype, String param) +{ + if (subtype == F("EspCam")) + { return new EspCam(param); - } else { + } + else + { return nullptr; } } diff --git a/src/modules/exec/EspCam/modinfo.json b/src/modules/exec/EspCam/modinfo.json index a0e01934..27984669 100644 --- a/src/modules/exec/EspCam/modinfo.json +++ b/src/modules/exec/EspCam/modinfo.json @@ -11,27 +11,27 @@ "page": "", "descr": "", "int": 60, - "useLed": 0, + "flashOn": 0, "ticker": 0, "webTicker": 0 } ], "about": { - "authorName": "Ilya Belyakov", + "authorName": "Ilya Belyakov, Mikhail Bubnov", "authorContact": "https://t.me/Biveraxe", "authorGit": "https://github.com/biveraxe", "specialThanks": "", "moduleName": "EspCam", - "moduleVersion": "2.1", + "moduleVersion": "3.0", "usedRam": { "esp32_4mb": 15, "esp8266_4mb": 15 }, "title": "Camera OV2640 (ESPcam)", - "moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения на SD при наличии. По адресу /getpic можно получить текущее фото (работает в том числе без SD карты).", + "moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения на SD при наличии. По адресу /getpic можно получить текущее фото (работает в том числе без SD карты). Отправка фото в телеграмм через модуль Telegram_v2", "propInfo": { "int": "Пауза в секундах во время постоянной фотосъемки.", - "useLed": "использовать диод подсветки при съемке.", + "flashOn": "использовать диод подсветки при съемке. используем = 1 или нет = 0 подсветку (вспышку)", "ticker": "Генерировать(1) или нет(0) событие с интервалом int", "webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу по адресу /getpic." }, @@ -41,23 +41,31 @@ "descr": "Сохранить снимок на SD", "params": [] }, + { + "name": "sendFoto", + "descr": "Отправить фото с esp-CAM в телеграмм", + "params": [""] + }, + { + "name": "editFoto", + "descr": "Отредактировать последнее отправленное фото в телеграмм", + "params": [""] + }, { - "name": "ledOn", - "descr": "Включить подсветку", - "params": [ - "Яркость 0-255" - ] + "name": "flashOn", + "descr": "Включить вспышку", + "params": [] }, { - "name": "ledOff", - "descr": "Отключить подсветку", + "name": "flashOff", + "descr": "Отключить вспышку", "params": [] } ] }, "defActive": false, "usedLibs": { - "esp32_4mb": [ + "esp32cam_4mb": [ "espressif/esp32-camera @ ^2.0.0" ] } diff --git a/src/modules/exec/Ftp/modinfo.json b/src/modules/exec/Ftp/modinfo.json index 475a3f1c..3f9dd379 100644 --- a/src/modules/exec/Ftp/modinfo.json +++ b/src/modules/exec/Ftp/modinfo.json @@ -35,6 +35,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/exec/HttpGet/modinfo.json b/src/modules/exec/HttpGet/modinfo.json index 2c483c06..4cbe39da 100644 --- a/src/modules/exec/HttpGet/modinfo.json +++ b/src/modules/exec/HttpGet/modinfo.json @@ -50,6 +50,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], diff --git a/src/modules/exec/IoTServo/modinfo.json b/src/modules/exec/IoTServo/modinfo.json index 1bb4f300..df3be571 100644 --- a/src/modules/exec/IoTServo/modinfo.json +++ b/src/modules/exec/IoTServo/modinfo.json @@ -51,6 +51,9 @@ "esp32_4mb": [ "https://github.com/RoboticsBrno/ServoESP32#v1.0.3" ], + "esp32cam_4mb": [ + "https://github.com/RoboticsBrno/ServoESP32#v1.0.3" + ], "esp8266_4mb": [] } } \ No newline at end of file diff --git a/src/modules/exec/Mcp23008/modinfo.json b/src/modules/exec/Mcp23008/modinfo.json index 2f322ce3..dbd92130 100644 --- a/src/modules/exec/Mcp23008/modinfo.json +++ b/src/modules/exec/Mcp23008/modinfo.json @@ -40,6 +40,10 @@ "adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0", "adafruit/Adafruit BusIO @ ^1.13.2" ], + "esp32cam_4mb": [ + "adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0", + "adafruit/Adafruit BusIO @ ^1.13.2" + ], "esp8266_4mb": [ "adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0", "adafruit/Adafruit BusIO @ ^1.13.2" diff --git a/src/modules/exec/Mcp23017/modinfo.json b/src/modules/exec/Mcp23017/modinfo.json index 88659ccb..e08d8c77 100644 --- a/src/modules/exec/Mcp23017/modinfo.json +++ b/src/modules/exec/Mcp23017/modinfo.json @@ -40,6 +40,10 @@ "adafruit/Adafruit MCP23017 Arduino Library@^2.1.0", "adafruit/Adafruit BusIO @ ^1.13.2" ], + "esp32cam_4mb": [ + "adafruit/Adafruit MCP23017 Arduino Library@^2.1.0", + "adafruit/Adafruit BusIO @ ^1.13.2" + ], "esp8266_4mb": [ "adafruit/Adafruit MCP23017 Arduino Library@^2.1.0", "adafruit/Adafruit BusIO @ ^1.13.2" diff --git a/src/modules/exec/Mp3/modinfo.json b/src/modules/exec/Mp3/modinfo.json index 381bd309..a8f8c296 100644 --- a/src/modules/exec/Mp3/modinfo.json +++ b/src/modules/exec/Mp3/modinfo.json @@ -92,6 +92,9 @@ "esp32_4mb": [ "dfrobot/DFRobotDFPlayerMini @ ^1.0.5" ], + "esp32cam_4mb": [ + "dfrobot/DFRobotDFPlayerMini @ ^1.0.5" + ], "esp8266_4mb": [ "dfrobot/DFRobotDFPlayerMini @ ^1.0.5" ] diff --git a/src/modules/exec/Multitouch/modinfo.json b/src/modules/exec/Multitouch/modinfo.json index d9d2f31a..416cb8c2 100644 --- a/src/modules/exec/Multitouch/modinfo.json +++ b/src/modules/exec/Multitouch/modinfo.json @@ -44,6 +44,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/exec/MySensors/modinfo.json b/src/modules/exec/MySensors/modinfo.json index 252c70d1..e36a743c 100644 --- a/src/modules/exec/MySensors/modinfo.json +++ b/src/modules/exec/MySensors/modinfo.json @@ -49,6 +49,7 @@ }, "defActive": false, "usedLibs": { - "esp32_4mb": [] + "esp32_4mb": [], + "esp32cam_4mb": [] } } \ No newline at end of file diff --git a/src/modules/exec/Pcf8574/modinfo.json b/src/modules/exec/Pcf8574/modinfo.json index 782a86d6..c83ab02b 100644 --- a/src/modules/exec/Pcf8574/modinfo.json +++ b/src/modules/exec/Pcf8574/modinfo.json @@ -35,6 +35,9 @@ "esp32_4mb": [ "adafruit/Adafruit BusIO @ ^1.13.2" ], + "esp32cam_4mb": [ + "adafruit/Adafruit BusIO @ ^1.13.2" + ], "esp8266_4mb": [ "adafruit/Adafruit BusIO @ ^1.13.2" ], diff --git a/src/modules/exec/Pwm32/modinfo.json b/src/modules/exec/Pwm32/modinfo.json index e8a685b8..b864baef 100644 --- a/src/modules/exec/Pwm32/modinfo.json +++ b/src/modules/exec/Pwm32/modinfo.json @@ -44,6 +44,7 @@ }, "defActive": true, "usedLibs": { - "esp32_4mb": [] + "esp32_4mb": [], + "esp32cam_4mb": [] } } \ No newline at end of file diff --git a/src/modules/exec/SDcard/modinfo.json b/src/modules/exec/SDcard/modinfo.json index eea8b9c2..aacf0091 100644 --- a/src/modules/exec/SDcard/modinfo.json +++ b/src/modules/exec/SDcard/modinfo.json @@ -34,6 +34,9 @@ "usedLibs": { "esp32_4mb": [ "espressif/esp32-camera @ ^2.0.0" + ], + "esp32cam_4mb": [ + "espressif/esp32-camera @ ^2.0.0" ] } } \ No newline at end of file diff --git a/src/modules/exec/SysExt/modinfo.json b/src/modules/exec/SysExt/modinfo.json index bb978bff..b77d3d80 100644 --- a/src/modules/exec/SysExt/modinfo.json +++ b/src/modules/exec/SysExt/modinfo.json @@ -33,6 +33,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [] } } \ No newline at end of file diff --git a/src/modules/exec/Telegram/modinfo.json b/src/modules/exec/Telegram/modinfo.json index 9e073cea..bce50689 100644 --- a/src/modules/exec/Telegram/modinfo.json +++ b/src/modules/exec/Telegram/modinfo.json @@ -58,6 +58,9 @@ "esp32_4mb": [ "CTBot @2.1.9" ], + "esp32cam_4mb": [ + "CTBot @2.1.9" + ], "esp32_16mb": [ "CTBot @2.1.9" ], diff --git a/src/modules/exec/TelegramLT/modinfo.json b/src/modules/exec/TelegramLT/modinfo.json index 3edf2da6..98cccde7 100644 --- a/src/modules/exec/TelegramLT/modinfo.json +++ b/src/modules/exec/TelegramLT/modinfo.json @@ -52,6 +52,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/exec/Telegram_v2/Telegram_v2.cpp b/src/modules/exec/Telegram_v2/Telegram_v2.cpp new file mode 100644 index 00000000..5c59b48d --- /dev/null +++ b/src/modules/exec/Telegram_v2/Telegram_v2.cpp @@ -0,0 +1,365 @@ +#include "Global.h" +#include "classes/IoTItem.h" +// #define FB_NO_UNICODE +// #define FB_NO_URLENCODE +// #define FB_NO_OTA +// #define FB_DYNAMIC +// #include +// #include +// #include "esp_camera.h" + +#include +#include + +// FastBot _myBot; +FastBot *_myBot = nullptr; +FastBot *instanceBot() +{ + if (!_myBot) + { + _myBot = new FastBot(); + // ot->begin(); + } + return _myBot; +} + +String _token; +String _chatID; +bool _autos; +bool _initSD; + +class Telegram_v2 : public IoTItem +{ +private: + bool _receiveMsg; + String _prevMsg = ""; + bool _useLed = false; + +public: + Telegram_v2(String parameters) : IoTItem(parameters) + { + jsonRead(parameters, "token", _token); + jsonRead(parameters, "autos", _autos); + jsonRead(parameters, "receiveMsg", _receiveMsg); + jsonRead(parameters, "chatID", _chatID); + instanceBot(); + _myBot->attach(telegramMsgParse); + +#ifdef ESP32 + // _myBot->useDNS(true); +#endif + + _myBot->setToken(_token); + // _myBot->enableUTF8Encoding(true); + _myBot->setChatID(_chatID); + // _myBot->showMenuText("help","help",false); + } + + void loop() + { + if (_receiveMsg) + { + _myBot->tick(); + } + // Далее вызов doByInterval для обработки комманд + if (enableDoByInt) + { + currentMillis = millis(); + difference = currentMillis - prevMillis; + if (difference >= _interval) + { + prevMillis = millis(); + this->doByInterval(); + } + } + } + + void doByInterval() + { + } + + IoTValue execute(String command, std::vector ¶m) + { + if (command == "sendMsg") + { + if (param.size()) + { + String strTmp; + if (param[0].isDecimal) + strTmp = param[0].valD; + else + strTmp = param[0].valS; + sendTelegramMsg(false, strTmp); + } + } + else if (command == "sendOftenMsg") + { + if (param.size()) + { + String strTmp; + if (param[0].isDecimal) + strTmp = param[0].valD; + else + strTmp = param[0].valS; + sendTelegramMsg(true, strTmp); + } + } + else if (command == "sendPinMsg") + { + if (param.size()) + { + String strTmp; + if (param[0].isDecimal) + strTmp = param[0].valD; + else + strTmp = param[0].valS; + _myBot->sendMessage(strTmp, _chatID); + _myBot->pinMessage(_myBot->lastBotMsg()); + + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ",pin msg: " + strTmp); + } + } + else if (command == "editMsg") + { + if (param.size()) + { + String strTmp; + if (param[0].isDecimal) + strTmp = param[0].valD; + else + strTmp = param[0].valS; + _myBot->editMessage(_myBot->lastBotMsg(), strTmp); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ",edit msg: " + strTmp); + } + } + else if (command == "sendFile") + { + if (param.size() && !param[0].isDecimal) + { + // String path = filepath(filename); + auto file = FileFS.open(param[0].valS, FILE_READ); + if (!file) + { + SerialPrint("E", F("Telegram"), "Fail send file: " + param[0].valS); + return {}; + } + // File file = LittleFS.open(param[0].valS, "r"); // /test.png + // selectToMarkerLast(msg.text, "_") + uint8_t res = _myBot->sendFile(file, (FB_FileType)param[1].valD, selectToMarkerLast(param[0].valS, "/"), _chatID); + file.close(); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", sendFile: " + param[0].valS + " res: " + String(res)); + } + } + + else if (command == "editFile") + { + if (param.size() && !param[0].isDecimal) + { + // String path = filepath(filename); + auto file = FileFS.open(param[0].valS, FILE_READ); + if (!file) + { + SerialPrint("E", F("Telegram"), "Fail edit file: " + param[0].valS); + return {}; + } + // File file = LittleFS.open(param[0].valS, "r"); // /test.png + // selectToMarkerLast(msg.text, "_") + uint8_t res = _myBot->editFile(file, (FB_FileType)param[1].valD, selectToMarkerLast(param[0].valS, "/"), _myBot->lastBotMsg(), _chatID); + file.close(); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", editFile: " + param[0].valS + " res: " + String(res)); + } + } + return {}; + } + + void static telegramMsgParse(FB_msg &msg) + { + // FB_msg msg; + SerialPrint("->", F("Telegram"), "chat ID: " + msg.chatID + ", msg: " + msg.text); + // _myBot->setChatID(_chatID); + if (_autos) + { + _chatID = msg.chatID; + } + if (msg.text.indexOf("set") != -1) + { + msg.text = deleteBeforeDelimiter(msg.text, "_"); + generateOrder(selectToMarker(msg.text, "_"), selectToMarkerLast(msg.text, "_")); + _myBot->replyMessage("order done", msg.messageID, _chatID); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); + } + else if (msg.text.indexOf("get") != -1) + { + msg.text = deleteBeforeDelimiter(msg.text, "_"); + IoTItem *item = findIoTItem(msg.text); + if (item) + { + _myBot->replyMessage(item->getValue(), msg.messageID, _chatID); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + String(msg.text)); + } + } + + else if (msg.text.indexOf("all") != -1) + { + // String list = returnListOfParams(); + String out; + std::vector vctr; + for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) + { + if ((*it)->iAmLocal) + { + if (it == IoTItems.begin()) + { + out = "get_" + (*it)->getID(); + } + else + { + out = out + " \n " + "get_" + (*it)->getID(); + } + vctr.push_back(atoff((*it)->getValue().c_str())); + // _myBot->sendMessage((*it)->getID() + ": " + (*it)->getValue(), _chatID); + } + } + _myBot->showMenuText("select Id", out, true); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + "\n" + out); + // _myBot->sendMessage(CharPlot(&vctr[0], vctr.size(), 5), _chatID); + // SerialPrint("<-", F("Telegram"), CharPlot(&vctr[0], vctr.size(), 10)); + } + + else if (msg.text.indexOf("file") != -1 && msg.chatID == _chatID) + { + msg.text = deleteBeforeDelimiter(msg.text, "_"); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", get file: " + String(msg.text)); + auto file = FileFS.open(selectToMarker(msg.text, "_"), FILE_READ); // /test.png + if (!file) + { + SerialPrint("E", F("Telegram"), "Fail send file: " + selectToMarker(msg.text, "_")); + return; + } + int type = atoi(selectToMarkerLast(msg.text, "_").c_str()); + _myBot->sendFile(file, (FB_FileType)type, selectToMarker(msg.text, "_"), _chatID); + file.close(); + } + else if (msg.isFile) + { + if (msg.text.indexOf("download") != -1 && msg.chatID == _chatID) + { + downloadFile(msg); + } + else if (msg.text.indexOf("nextion") != -1 && msg.chatID == _chatID) + { + if (downloadFile(msg)) + { + // flashNextion(); + } + } + } + else if (msg.text.indexOf("help") != -1) + { + _myBot->sendMessage("ID: " + chipId, _chatID); + _myBot->sendMessage("chatID: " + _chatID, _chatID); + _myBot->sendMessage(F("Wrong order, use /all to get all values, /get_id to get value, /set_id_value to set value, or /file_name_type or send file msg=download"), _chatID); + } + else + { + // setValue(msg.text); + } + } + + void sendTelegramMsg(bool often, String msg) + { + if (often) + { + _myBot->sendMessage(msg, _chatID); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); + } + else + { + if (_prevMsg != msg) + { + _prevMsg = msg; + _myBot->sendMessage(msg, _chatID); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", msg: " + msg); + } + } + } + + void sendFoto(uint8_t *buf, uint32_t length, const String &name) + { + _myBot->sendFile(buf, length, FB_PHOTO, name, _chatID); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", send foto from esp-cam"); + } + + void editFoto(uint8_t *buf, uint32_t length, const String &name) + { + _myBot->editFile(buf, length, FB_PHOTO, name, _myBot->lastBotMsg(), _chatID); + SerialPrint("<-", F("Telegram"), "chat ID: " + _chatID + ", edit foto from esp-cam"); + } + + int static downloadFile(FB_msg &msg) + { + int _size = 0; + String path = '/' + msg.fileName; // вида /filename.xxx + auto file = FileFS.open(path, FILE_WRITE); // открываем для записи + // _myBot->sendMessage("Downloading from: " + _chatID + ", file: " + String(msg.fileName), _chatID); + if (file) + { // файл открылся/создался + HTTPClient http; + +#ifdef ESP8266 // esp8266 требует SSl + BearSSL::WiFiClientSecure client; + client.setInsecure(); + http.begin(client, msg.fileUrl); // пингуем файл +#else // esp32 сама умеет SSL + http.begin(msg.fileUrl); // пингуем файл +#endif + + if (http.GET() == HTTP_CODE_OK) + { // файл доступен + // загружаем в память. Результат > 0 - успешно + _size = http.writeToStream(&file); + } + http.end(); // закрываем соединение + file.close(); // закрываем файл + + if (_size == 0) + { + SerialPrint("E", F("Telegram"), "download error file url: " + msg.fileUrl); + _myBot->sendMessage(F("Download Fail"), _chatID); + } + else + { + SerialPrint("<-", F("Telegram"), "download from: " + _chatID + ", file: " + msg.fileName + " size = " + String(_size) + " byte"); + _myBot->sendMessage("Download Ok, size = " + String(_size) + " byte", _chatID); + } + return _size; + } + else + { + SerialPrint("E", F("Telegram"), F("file write error")); + _myBot->sendMessage(F("file write error"), _chatID); + } + } + + IoTItem *getTlgrmDriver() + { + return this; + } + + ~Telegram_v2() + { + tlgrmItem = nullptr; + }; +}; + +void *getAPI_Telegram_v2(String subtype, String param) +{ + if (subtype == F("Telegram_v2")) + { + return new Telegram_v2(param); + } + else + { + return nullptr; + } +} diff --git a/src/modules/exec/Telegram_v2/modinfo.json b/src/modules/exec/Telegram_v2/modinfo.json new file mode 100644 index 00000000..9f6dd6a6 --- /dev/null +++ b/src/modules/exec/Telegram_v2/modinfo.json @@ -0,0 +1,93 @@ +{ + "menuSection": "executive_devices", + + "configItem": [{ + "global": 0, + "name": "Телеграм-Бот v2", + "type": "Writing", + "subtype": "Telegram_v2", + "id": "tg", + "widget": "", + "page": "", + "descr": "", + "int": 10, + + "token": "", + "autos": 1, + "receiveMsg": 0, + "chatID": "" + }], + + "about": { + "authorName": "Mikhail Bubnov", + "authorContact": "https://t.me/Mit4bmw", + "authorGit": "https://github.com/Mit4el", + "specialThanks": "", + "moduleName": "Telegram_v2", + "moduleVersion": "1.0", + "usedRam": { + "esp32_4mb": 37, + "esp8266_4mb": 37 + }, + "title": "Телеграм-Бот v2", + "moduleDesc": "Добавляет возможность отправлять сообщения от имени бота контакту в Телеграм-чате и получать команды.", + "propInfo": { + "token": "Токен для авторизации бота в системе Telegram", + "autos": "Автоматически(1) или нет(0) запоминать ChatID по входящим сообщениям. Т.е. бот будет информировать тех, кто последний прислал сообщение.", + "receiveMsg": "Обрабатывать(1) или нет(0) входящие сообщения.", + "chatID": "ИД диалога с контактом. Необходим для отправки сообщений именно вам." + }, + "funcInfo": [ + { + "name": "sendMsg", + "descr": "Отправить сообщение без повторений.", + "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] + }, + { + "name": "sendOftenMsg", + "descr": "Отправить сообщение в любом случае, даж если отправляли такое ранее.", + "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] + }, + { + "name": "sendPinMsg", + "descr": "Отправить закрепленное сообщение в любом случае, даж если отправляли такое ранее.", + "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] + }, + { + "name": "editMsg", + "descr": "Отредактировать последнее отправленное ботом сообщение.", + "params": ["Сообщение, может быть строкой, числом или ИД другого элемента для получения значения"] + }, + { + "name": "sendFile", + "descr": "Отправить файл в телеграмм, с указанием типа файла: 0-фото, 1-аудио, 2-документ, 3-видео, 4-анимация, 5-голос", + "params": ["Путь к файлу (/test.png)", "Тип файла/информации (число)"] + }, + { + "name": "editFile", + "descr": "Отредактировать последний отправленный файл, с указанием типа файла: 0-фото, 1-аудио, 2-документ, 3-видео, 4-анимация, 5-голос", + "params": ["Путь к файлу (/test.png)", "Тип файла/информации (число)"] + } + ] + }, + + "defActive": false, + + "usedLibs": { + "esp32_4mb": [ + "gyverlibs/FastBot" + ], + "esp32cam_4mb": [ + "gyverlibs/FastBot" + ], + "esp32s2_4mb": [ + "gyverlibs/FastBot" + ], + "esp32_16mb": [ + "gyverlibs/FastBot" + ], + "esp8266_4mb": [ + "gyverlibs/FastBot" + ] + } +} \ No newline at end of file diff --git a/src/modules/exec/Thermostat/modinfo.json b/src/modules/exec/Thermostat/modinfo.json index 925e0df3..2aeb4ae3 100644 --- a/src/modules/exec/Thermostat/modinfo.json +++ b/src/modules/exec/Thermostat/modinfo.json @@ -134,6 +134,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/Acs712/modinfo.json b/src/modules/sensors/Acs712/modinfo.json index 4ee63507..ed26573e 100644 --- a/src/modules/sensors/Acs712/modinfo.json +++ b/src/modules/sensors/Acs712/modinfo.json @@ -42,6 +42,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], diff --git a/src/modules/sensors/Ads1115/modinfo.json b/src/modules/sensors/Ads1115/modinfo.json index d859db77..9a69a717 100644 --- a/src/modules/sensors/Ads1115/modinfo.json +++ b/src/modules/sensors/Ads1115/modinfo.json @@ -44,6 +44,9 @@ "esp32_4mb": [ "adafruit/Adafruit ADS1X15 @ ^2.3.0" ], + "esp32cam_4mb": [ + "adafruit/Adafruit ADS1X15 @ ^2.3.0" + ], "esp8266_4mb": [ "adafruit/Adafruit ADS1X15 @ ^2.3.0" ] diff --git a/src/modules/sensors/AhtXX/modinfo.json b/src/modules/sensors/AhtXX/modinfo.json index ef05d3a7..9f28ea3e 100644 --- a/src/modules/sensors/AhtXX/modinfo.json +++ b/src/modules/sensors/AhtXX/modinfo.json @@ -59,6 +59,9 @@ "esp32_4mb": [ "https://github.com/enjoyneering/AHTxx.git" ], + "esp32cam_4mb": [ + "https://github.com/enjoyneering/AHTxx.git" + ], "esp8266_4mb": [ "https://github.com/enjoyneering/AHTxx.git" ], diff --git a/src/modules/sensors/AnalogAdc/modinfo.json b/src/modules/sensors/AnalogAdc/modinfo.json index a28e901a..21ecc6ac 100644 --- a/src/modules/sensors/AnalogAdc/modinfo.json +++ b/src/modules/sensors/AnalogAdc/modinfo.json @@ -42,6 +42,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/BH_1750/modinfo.json b/src/modules/sensors/BH_1750/modinfo.json index 0843f2e7..41e3f369 100644 --- a/src/modules/sensors/BH_1750/modinfo.json +++ b/src/modules/sensors/BH_1750/modinfo.json @@ -37,6 +37,9 @@ "esp32_4mb": [ "BH1750" ], + "esp32cam_4mb": [ + "BH1750" + ], "esp8266_4mb": [ "BH1750" ] diff --git a/src/modules/sensors/Ble/modinfo.json b/src/modules/sensors/Ble/modinfo.json index 0a231625..8b0e8457 100644 --- a/src/modules/sensors/Ble/modinfo.json +++ b/src/modules/sensors/Ble/modinfo.json @@ -62,6 +62,10 @@ "esp32_4mb": [ "https://github.com/h2zero/NimBLE-Arduino.git", "https://github.com/avaksru/decoder.git" + ], + "esp32cam_4mb": [ + "https://github.com/h2zero/NimBLE-Arduino.git", + "https://github.com/avaksru/decoder.git" ] } } \ No newline at end of file diff --git a/src/modules/sensors/Bme280/modinfo.json b/src/modules/sensors/Bme280/modinfo.json index 4f11d152..86af866e 100644 --- a/src/modules/sensors/Bme280/modinfo.json +++ b/src/modules/sensors/Bme280/modinfo.json @@ -83,6 +83,9 @@ "esp32_4mb": [ "adafruit/Adafruit BME280 Library" ], + "esp32cam_4mb": [ + "adafruit/Adafruit BME280 Library" + ], "esp8266_4mb": [ "adafruit/Adafruit BME280 Library" ], diff --git a/src/modules/sensors/Bmp280/modinfo.json b/src/modules/sensors/Bmp280/modinfo.json index 608d5c18..03b6f3e0 100644 --- a/src/modules/sensors/Bmp280/modinfo.json +++ b/src/modules/sensors/Bmp280/modinfo.json @@ -55,6 +55,9 @@ "esp32_4mb": [ "adafruit/Adafruit BMP280 Library" ], + "esp32cam_4mb": [ + "adafruit/Adafruit BMP280 Library" + ], "esp8266_4mb": [ "adafruit/Adafruit BMP280 Library" ], diff --git a/src/modules/sensors/DS2401/modinfo.json b/src/modules/sensors/DS2401/modinfo.json index a7db4500..0954be0a 100644 --- a/src/modules/sensors/DS2401/modinfo.json +++ b/src/modules/sensors/DS2401/modinfo.json @@ -36,6 +36,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/Dht1122/modinfo.json b/src/modules/sensors/Dht1122/modinfo.json index 604c0a2c..d4df0ce6 100644 --- a/src/modules/sensors/Dht1122/modinfo.json +++ b/src/modules/sensors/Dht1122/modinfo.json @@ -55,6 +55,9 @@ "esp32_4mb": [ "beegee-tokyo/DHT sensor library for ESPx" ], + "esp32cam_4mb": [ + "beegee-tokyo/DHT sensor library for ESPx" + ], "esp8266_4mb": [ "beegee-tokyo/DHT sensor library for ESPx" ] diff --git a/src/modules/sensors/Ds18b20/modinfo.json b/src/modules/sensors/Ds18b20/modinfo.json index a5423121..b4806609 100644 --- a/src/modules/sensors/Ds18b20/modinfo.json +++ b/src/modules/sensors/Ds18b20/modinfo.json @@ -42,6 +42,9 @@ "esp32_4mb": [ "https://github.com/milesburton/Arduino-Temperature-Control-Library" ], + "esp32cam_4mb": [ + "https://github.com/milesburton/Arduino-Temperature-Control-Library" + ], "esp8266_4mb": [ "https://github.com/milesburton/Arduino-Temperature-Control-Library" ], diff --git a/src/modules/sensors/Ds2423/modinfo.json b/src/modules/sensors/Ds2423/modinfo.json index 866af40a..50fd76ba 100644 --- a/src/modules/sensors/Ds2423/modinfo.json +++ b/src/modules/sensors/Ds2423/modinfo.json @@ -64,6 +64,10 @@ "https://github.com/jbechter/arduino-onewire-DS2423", "paulstoffregen/OneWire @ ^2.3.7" ], + "esp32cam_4mb": [ + "https://github.com/jbechter/arduino-onewire-DS2423", + "paulstoffregen/OneWire @ ^2.3.7" + ], "esp8266_4mb": [ "https://github.com/jbechter/arduino-onewire-DS2423", "paulstoffregen/OneWire @ ^2.3.7" diff --git a/src/modules/sensors/Emon/modinfo.json b/src/modules/sensors/Emon/modinfo.json index 03b1f832..f518a1f3 100644 --- a/src/modules/sensors/Emon/modinfo.json +++ b/src/modules/sensors/Emon/modinfo.json @@ -62,6 +62,9 @@ "esp32_4mb": [ "openenergymonitor/EmonLib@1.1.0" ], + "esp32cam_4mb": [ + "openenergymonitor/EmonLib@1.1.0" + ], "esp8266_4mb": [ "openenergymonitor/EmonLib@1.1.0" ] diff --git a/src/modules/sensors/ExampleModule/modinfo.json b/src/modules/sensors/ExampleModule/modinfo.json index e605d2fa..00632cc6 100644 --- a/src/modules/sensors/ExampleModule/modinfo.json +++ b/src/modules/sensors/ExampleModule/modinfo.json @@ -76,6 +76,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], diff --git a/src/modules/sensors/FreqMeter/modinfo.json b/src/modules/sensors/FreqMeter/modinfo.json index b1680a47..ef730773 100644 --- a/src/modules/sensors/FreqMeter/modinfo.json +++ b/src/modules/sensors/FreqMeter/modinfo.json @@ -87,6 +87,9 @@ "esp32_4mb": [ "kosme/arduinoFFT@^1.5.6" ], + "esp32cam_4mb": [ + "kosme/arduinoFFT@^1.5.6" + ], "esp8266_4mb": [ "kosme/arduinoFFT@^1.5.6" ] diff --git a/src/modules/sensors/GY21/modinfo.json b/src/modules/sensors/GY21/modinfo.json index 12928240..5018a9fd 100644 --- a/src/modules/sensors/GY21/modinfo.json +++ b/src/modules/sensors/GY21/modinfo.json @@ -52,6 +52,9 @@ "esp32_4mb": [ "https://github.com/JonasGMorsch/GY-21.git" ], + "esp32cam_4mb": [ + "https://github.com/JonasGMorsch/GY-21.git" + ], "esp8266_4mb": [ "https://github.com/JonasGMorsch/GY-21.git" ] diff --git a/src/modules/sensors/Hdc1080/modinfo.json b/src/modules/sensors/Hdc1080/modinfo.json index b9154665..c5514c3d 100644 --- a/src/modules/sensors/Hdc1080/modinfo.json +++ b/src/modules/sensors/Hdc1080/modinfo.json @@ -55,6 +55,9 @@ "esp32_4mb": [ "ClosedCube HDC1080" ], + "esp32cam_4mb": [ + "ClosedCube HDC1080" + ], "esp8266_4mb": [ "ClosedCube HDC1080" ] diff --git a/src/modules/sensors/Hx710/modinfo.json b/src/modules/sensors/Hx710/modinfo.json index c6a9ca16..e98e3c34 100644 --- a/src/modules/sensors/Hx710/modinfo.json +++ b/src/modules/sensors/Hx710/modinfo.json @@ -49,6 +49,9 @@ "esp32_4mb": [ "https://github.com/kurimawxx00/hx710B_pressure_sensor" ], + "esp32cam_4mb": [ + "https://github.com/kurimawxx00/hx710B_pressure_sensor" + ], "esp8266_4mb": [ "https://github.com/kurimawxx00/hx710B_pressure_sensor" ] diff --git a/src/modules/sensors/Hx711/modinfo.json b/src/modules/sensors/Hx711/modinfo.json index 43e4b7fd..04573254 100644 --- a/src/modules/sensors/Hx711/modinfo.json +++ b/src/modules/sensors/Hx711/modinfo.json @@ -64,6 +64,9 @@ "esp32_4mb": [ "GyverHX711@1.2" ], + "esp32cam_4mb": [ + "GyverHX711@1.2" + ], "esp8266_4mb": [ "GyverHX711@1.2" ] diff --git a/src/modules/sensors/Impulse/modinfo.json b/src/modules/sensors/Impulse/modinfo.json index ee92191f..a9cf2fd4 100644 --- a/src/modules/sensors/Impulse/modinfo.json +++ b/src/modules/sensors/Impulse/modinfo.json @@ -41,6 +41,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/Ina219/modinfo.json b/src/modules/sensors/Ina219/modinfo.json index 7e35d23e..7bc545f3 100644 --- a/src/modules/sensors/Ina219/modinfo.json +++ b/src/modules/sensors/Ina219/modinfo.json @@ -122,6 +122,9 @@ "esp32_4mb": [ "https://github.com/GyverLibs/GyverINA" ], + "esp32cam_4mb": [ + "https://github.com/GyverLibs/GyverINA" + ], "esp32s2_4mb": [ "https://github.com/GyverLibs/GyverINA" ], diff --git a/src/modules/sensors/Ina226/modinfo.json b/src/modules/sensors/Ina226/modinfo.json index 98b68d5e..c6b6576d 100644 --- a/src/modules/sensors/Ina226/modinfo.json +++ b/src/modules/sensors/Ina226/modinfo.json @@ -122,6 +122,9 @@ "esp32_4mb": [ "https://github.com/GyverLibs/GyverINA" ], + "esp32cam_4mb": [ + "https://github.com/GyverLibs/GyverINA" + ], "esp32s2_4mb": [ "https://github.com/GyverLibs/GyverINA" ], diff --git a/src/modules/sensors/IoTWiegand/modinfo.json b/src/modules/sensors/IoTWiegand/modinfo.json index 9b592590..34f165a3 100644 --- a/src/modules/sensors/IoTWiegand/modinfo.json +++ b/src/modules/sensors/IoTWiegand/modinfo.json @@ -39,6 +39,9 @@ "esp32_4mb": [ "https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino" ], + "esp32cam_4mb": [ + "https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino" + ], "esp8266_4mb": [ "https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino" ] diff --git a/src/modules/sensors/Mhz19/modinfo.json b/src/modules/sensors/Mhz19/modinfo.json index d65d7466..953e43b3 100644 --- a/src/modules/sensors/Mhz19/modinfo.json +++ b/src/modules/sensors/Mhz19/modinfo.json @@ -82,6 +82,7 @@ "esp32s2_4mb": [ "plerup/EspSoftwareSerial" ], + "esp32cam_4mb": [], "esp8266_4mb": [] } } \ No newline at end of file diff --git a/src/modules/sensors/Ntc/modinfo.json b/src/modules/sensors/Ntc/modinfo.json index c2730bf6..d5c2aa4c 100644 --- a/src/modules/sensors/Ntc/modinfo.json +++ b/src/modules/sensors/Ntc/modinfo.json @@ -51,6 +51,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/Pzem004t/modinfo.json b/src/modules/sensors/Pzem004t/modinfo.json index e8a71705..5028d83a 100644 --- a/src/modules/sensors/Pzem004t/modinfo.json +++ b/src/modules/sensors/Pzem004t/modinfo.json @@ -128,6 +128,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/RCswitch/modinfo.json b/src/modules/sensors/RCswitch/modinfo.json index ed549042..ffd93884 100644 --- a/src/modules/sensors/RCswitch/modinfo.json +++ b/src/modules/sensors/RCswitch/modinfo.json @@ -64,6 +64,9 @@ "esp32_4mb": [ "rc-switch @ ^2.6.4" ], + "esp32cam_4mb": [ + "rc-switch @ ^2.6.4" + ], "esp8266_4mb": [ "rc-switch @ ^2.6.4" ], diff --git a/src/modules/sensors/RTC/modinfo.json b/src/modules/sensors/RTC/modinfo.json index 67c40768..d9992762 100644 --- a/src/modules/sensors/RTC/modinfo.json +++ b/src/modules/sensors/RTC/modinfo.json @@ -62,6 +62,9 @@ "esp32_4mb": [ "https://github.com/tremaru/iarduino_RTC" ], + "esp32cam_4mb": [ + "https://github.com/tremaru/iarduino_RTC" + ], "esp8266_4mb": [ "https://github.com/tremaru/iarduino_RTC" ], diff --git a/src/modules/sensors/Scd40/modinfo.json b/src/modules/sensors/Scd40/modinfo.json index 601723b0..cef07681 100644 --- a/src/modules/sensors/Scd40/modinfo.json +++ b/src/modules/sensors/Scd40/modinfo.json @@ -74,6 +74,10 @@ "Sensirion I2C SCD4x @0.4.0", "Sensirion Core @0.6.0" ], + "esp32cam_4mb": [ + "Sensirion I2C SCD4x @0.4.0", + "Sensirion Core @0.6.0" + ], "esp8266_4mb": [ "Sensirion I2C SCD4x @0.4.0", "Sensirion Core @0.6.0" diff --git a/src/modules/sensors/Sds011/modinfo.json b/src/modules/sensors/Sds011/modinfo.json index 78f053e8..f8a41fdb 100644 --- a/src/modules/sensors/Sds011/modinfo.json +++ b/src/modules/sensors/Sds011/modinfo.json @@ -69,6 +69,9 @@ "esp32_4mb": [ "Nova Fitness Sds dust sensors library@1.5.1" ], + "esp32cam_4mb": [ + "Nova Fitness Sds dust sensors library@1.5.1" + ], "esp8266_4mb": [ "Nova Fitness Sds dust sensors library@1.5.1" ] diff --git a/src/modules/sensors/Sgp30/modinfo.json b/src/modules/sensors/Sgp30/modinfo.json index 0857dc39..ec2ad09d 100644 --- a/src/modules/sensors/Sgp30/modinfo.json +++ b/src/modules/sensors/Sgp30/modinfo.json @@ -51,6 +51,9 @@ "esp32_4mb": [ "sparkfun/SparkFun SGP30 Arduino Library@^1.0.5" ], + "esp32cam_4mb": [ + "sparkfun/SparkFun SGP30 Arduino Library@^1.0.5" + ], "esp8266_4mb": [ "sparkfun/SparkFun SGP30 Arduino Library@^1.0.5" ], diff --git a/src/modules/sensors/Sht30/modinfo.json b/src/modules/sensors/Sht30/modinfo.json index 9c065c41..fccb48d6 100644 --- a/src/modules/sensors/Sht30/modinfo.json +++ b/src/modules/sensors/Sht30/modinfo.json @@ -52,6 +52,9 @@ "esp32_4mb": [ "WEMOS SHT3x@1.0.0" ], + "esp32cam_4mb": [ + "WEMOS SHT3x@1.0.0" + ], "esp8266_4mb": [ "WEMOS SHT3x@1.0.0" ], diff --git a/src/modules/sensors/Sonar/modinfo.json b/src/modules/sensors/Sonar/modinfo.json index 0e02af75..94487829 100644 --- a/src/modules/sensors/Sonar/modinfo.json +++ b/src/modules/sensors/Sonar/modinfo.json @@ -38,6 +38,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp8266_4mb": [], "esp8266_1mb": [], "esp8266_1mb_ota": [], diff --git a/src/modules/sensors/UART/modinfo.json b/src/modules/sensors/UART/modinfo.json index b7c5e5b3..9ab0f506 100644 --- a/src/modules/sensors/UART/modinfo.json +++ b/src/modules/sensors/UART/modinfo.json @@ -77,6 +77,9 @@ "esp32_4mb": [ "plerup/EspSoftwareSerial" ], + "esp32cam_4mb": [ + "plerup/EspSoftwareSerial" + ], "esp8266_4mb": [ "plerup/EspSoftwareSerial" ], diff --git a/src/modules/virtual/Cron/modinfo.json b/src/modules/virtual/Cron/modinfo.json index 7bb1fc78..07ceb83f 100644 --- a/src/modules/virtual/Cron/modinfo.json +++ b/src/modules/virtual/Cron/modinfo.json @@ -50,6 +50,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/GoogleSheet/modinfo.json b/src/modules/virtual/GoogleSheet/modinfo.json index 4c046fdb..5e7865f7 100644 --- a/src/modules/virtual/GoogleSheet/modinfo.json +++ b/src/modules/virtual/GoogleSheet/modinfo.json @@ -59,6 +59,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32s2_4mb": [], "esp8266_4mb": [] } diff --git a/src/modules/virtual/Loging/modinfo.json b/src/modules/virtual/Loging/modinfo.json index c9c9ceb4..a3e50cbb 100644 --- a/src/modules/virtual/Loging/modinfo.json +++ b/src/modules/virtual/Loging/modinfo.json @@ -51,6 +51,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/LogingDaily/LogingDaily.cpp b/src/modules/virtual/LogingDaily/LogingDaily.cpp index bc5556b6..32a0e68d 100644 --- a/src/modules/virtual/LogingDaily/LogingDaily.cpp +++ b/src/modules/virtual/LogingDaily/LogingDaily.cpp @@ -85,7 +85,7 @@ class LogingDaily : public IoTItem { if (telegram == 1) { String msg = descr + ": total " + String(currentValue) + ", consumed " + String(difference); for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { - if ((*it)->getSubtype() == "TelegramLT" || "Telegram") { + if ((*it)->getSubtype() == "TelegramLT" || "Telegram" || "Telegram_v2") { (*it)->sendTelegramMsg(false, msg); } } diff --git a/src/modules/virtual/LogingDaily/modinfo.json b/src/modules/virtual/LogingDaily/modinfo.json index c34ee78f..13176ebb 100644 --- a/src/modules/virtual/LogingDaily/modinfo.json +++ b/src/modules/virtual/LogingDaily/modinfo.json @@ -44,6 +44,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/Timer/modinfo.json b/src/modules/virtual/Timer/modinfo.json index f65b2c54..993b68f7 100644 --- a/src/modules/virtual/Timer/modinfo.json +++ b/src/modules/virtual/Timer/modinfo.json @@ -74,6 +74,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/VButton/modinfo.json b/src/modules/virtual/VButton/modinfo.json index 9c6b6488..82b69dae 100644 --- a/src/modules/virtual/VButton/modinfo.json +++ b/src/modules/virtual/VButton/modinfo.json @@ -36,6 +36,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/Variable/modinfo.json b/src/modules/virtual/Variable/modinfo.json index 55b11e20..f5f14605 100644 --- a/src/modules/virtual/Variable/modinfo.json +++ b/src/modules/virtual/Variable/modinfo.json @@ -96,6 +96,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/VariableColor/modinfo.json b/src/modules/virtual/VariableColor/modinfo.json index 4ff78661..3bd3db9e 100644 --- a/src/modules/virtual/VariableColor/modinfo.json +++ b/src/modules/virtual/VariableColor/modinfo.json @@ -35,6 +35,7 @@ "defActive": true, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [], diff --git a/src/modules/virtual/Weather/modinfo.json b/src/modules/virtual/Weather/modinfo.json index bd0acc77..a95ccd2f 100644 --- a/src/modules/virtual/Weather/modinfo.json +++ b/src/modules/virtual/Weather/modinfo.json @@ -40,6 +40,7 @@ "defActive": false, "usedLibs": { "esp32_4mb": [], + "esp32cam_4mb": [], "esp32_16mb": [], "esp32s2_4mb": [], "esp8266_4mb": [],