mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-05-26 04:39:22 +03:00
@@ -15,7 +15,10 @@
|
|||||||
#
|
#
|
||||||
# поддерживаемые контроллеры (профили):
|
# поддерживаемые контроллеры (профили):
|
||||||
# esp8266_4mb
|
# esp8266_4mb
|
||||||
|
# esp8266_16mb
|
||||||
# esp32_4mb
|
# esp32_4mb
|
||||||
|
# esp32cam_4mb
|
||||||
|
# esp32_16mb
|
||||||
# esp32s2_4mb
|
# esp32s2_4mb
|
||||||
# esp8266_1mb
|
# esp8266_1mb
|
||||||
# esp8266_1mb_ota
|
# esp8266_1mb_ota
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"projectProp": {
|
"projectProp": {
|
||||||
"platformio": {
|
"platformio": {
|
||||||
"default_envs": "esp8266_4mb",
|
"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": [
|
"envs": [
|
||||||
{
|
{
|
||||||
"name": "esp8266_4mb",
|
"name": "esp8266_4mb",
|
||||||
@@ -45,6 +45,14 @@
|
|||||||
"partitions": "0x8000",
|
"partitions": "0x8000",
|
||||||
"littlefs": "0x290000"
|
"littlefs": "0x290000"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "esp32cam_4mb",
|
||||||
|
"boot_app0": "0xe000",
|
||||||
|
"bootloader_qio_80m": "0x1000",
|
||||||
|
"firmware": "0x10000",
|
||||||
|
"partitions": "0x8000",
|
||||||
|
"littlefs": "0x290000"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "esp32_16mb",
|
"name": "esp32_16mb",
|
||||||
"boot_app0": "0xe000",
|
"boot_app0": "0xe000",
|
||||||
@@ -372,6 +380,10 @@
|
|||||||
"path": "src/modules/exec/TelegramLT",
|
"path": "src/modules/exec/TelegramLT",
|
||||||
"active": true
|
"active": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "src/modules/exec/Telegram_v2",
|
||||||
|
"active": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "src/modules/exec/Thermostat",
|
"path": "src/modules/exec/Thermostat",
|
||||||
"active": false
|
"active": false
|
||||||
|
|||||||
@@ -301,6 +301,13 @@
|
|||||||
"after": "cm",
|
"after": "cm",
|
||||||
"icon": "speedometer"
|
"icon": "speedometer"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "anydataLiter",
|
||||||
|
"label": "Литры",
|
||||||
|
"widget": "anydata",
|
||||||
|
"after": "ltr",
|
||||||
|
"icon": "speedometer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "nil",
|
"name": "nil",
|
||||||
"label": "Без виджета"
|
"label": "Без виджета"
|
||||||
|
|||||||
@@ -301,6 +301,13 @@
|
|||||||
"after": "cm",
|
"after": "cm",
|
||||||
"icon": "speedometer"
|
"icon": "speedometer"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "anydataLiter",
|
||||||
|
"label": "Литры",
|
||||||
|
"widget": "anydata",
|
||||||
|
"after": "ltr",
|
||||||
|
"icon": "speedometer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "nil",
|
"name": "nil",
|
||||||
"label": "Без виджета"
|
"label": "Без виджета"
|
||||||
|
|||||||
@@ -32,6 +32,10 @@
|
|||||||
#define FIRMWARE_NAME "esp32_4mb"
|
#define FIRMWARE_NAME "esp32_4mb"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef esp32cam_4mb
|
||||||
|
#define FIRMWARE_NAME "esp32cam_4mb"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef esp32_16mb
|
#ifdef esp32_16mb
|
||||||
#define FIRMWARE_NAME "esp32_16mb"
|
#define FIRMWARE_NAME "esp32_16mb"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,6 +56,8 @@
|
|||||||
**********************************************************************************************************************/
|
**********************************************************************************************************************/
|
||||||
extern IoTGpio IoTgpio;
|
extern IoTGpio IoTgpio;
|
||||||
extern IoTItem* rtcItem;
|
extern IoTItem* rtcItem;
|
||||||
|
//extern IoTItem* camItem;
|
||||||
|
extern IoTItem* tlgrmItem;
|
||||||
|
|
||||||
extern TickerScheduler ts;
|
extern TickerScheduler ts;
|
||||||
extern WiFiClient espClient;
|
extern WiFiClient espClient;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ boolean publishChartMqtt(const String& topic, const String& data);
|
|||||||
boolean publishJsonMqtt(const String& topic, const String& json);
|
boolean publishJsonMqtt(const String& topic, const String& json);
|
||||||
boolean publishStatusMqtt(const String& topic, const String& data);
|
boolean publishStatusMqtt(const String& topic, const String& data);
|
||||||
boolean publishEvent(const String& topic, const String& data);
|
boolean publishEvent(const String& topic, const String& data);
|
||||||
void mqttSubscribeExternal(String topic, bool usePrefix);
|
void mqttSubscribeExternal(String topic, bool usePrefix = false);
|
||||||
|
|
||||||
bool publishChartFileToMqtt(String path, String id, int maxCount);
|
bool publishChartFileToMqtt(String path, String id, int maxCount);
|
||||||
|
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ extern const String getDateTimeDotFormated();
|
|||||||
extern const String getTodayDateDotFormated();
|
extern const String getTodayDateDotFormated();
|
||||||
extern unsigned long strDateToUnix(String date);
|
extern unsigned long strDateToUnix(String date);
|
||||||
extern const String getDateTimeDotFormatedFromUnix(unsigned long unixTime);
|
extern const String getDateTimeDotFormatedFromUnix(unsigned long unixTime);
|
||||||
|
extern const String getTimeDotFormatedFromUnix(unsigned long unixTime);
|
||||||
extern unsigned long gmtTimeToLocal(unsigned long gmtTimestamp);
|
extern unsigned long gmtTimeToLocal(unsigned long gmtTimestamp);
|
||||||
extern const String getDateDotFormatedFromUnix(unsigned long unixTime);
|
extern const String getDateDotFormatedFromUnix(unsigned long unixTime);
|
||||||
|
|||||||
@@ -51,8 +51,16 @@ class IoTItem {
|
|||||||
|
|
||||||
virtual IoTGpio* getGpioDriver();
|
virtual IoTGpio* getGpioDriver();
|
||||||
virtual IoTItem* getRtcDriver();
|
virtual IoTItem* getRtcDriver();
|
||||||
|
//virtual IoTItem* getCAMDriver();
|
||||||
|
virtual IoTItem* getTlgrmDriver();
|
||||||
virtual unsigned long getRtcUnixTime();
|
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 IoTValue& Value, bool genEvent = true);
|
||||||
virtual void setValue(const String& valStr, bool genEvent = true);
|
virtual void setValue(const String& valStr, bool genEvent = true);
|
||||||
String getRoundValue();
|
String getRoundValue();
|
||||||
@@ -65,9 +73,6 @@ class IoTItem {
|
|||||||
virtual void onModuleOrder(String& key, String& value);
|
virtual void onModuleOrder(String& key, String& value);
|
||||||
virtual void onTrackingValue(IoTItem* item); // момент, когда ядро заметило изменение отслеживаемого значения
|
virtual void onTrackingValue(IoTItem* item); // момент, когда ядро заметило изменение отслеживаемого значения
|
||||||
|
|
||||||
// делаем доступным модулям отправку сообщений в телеграм
|
|
||||||
virtual void sendTelegramMsg(bool often, String msg);
|
|
||||||
|
|
||||||
// методы для графиков (будет упрощено)
|
// методы для графиков (будет упрощено)
|
||||||
virtual void publishValue();
|
virtual void publishValue();
|
||||||
virtual void clearValue();
|
virtual void clearValue();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"projectProp": {
|
"projectProp": {
|
||||||
"platformio": {
|
"platformio": {
|
||||||
"default_envs": "esp8266_4mb",
|
"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": [
|
"envs": [
|
||||||
{
|
{
|
||||||
"name": "esp8266_4mb",
|
"name": "esp8266_4mb",
|
||||||
@@ -45,6 +45,14 @@
|
|||||||
"partitions": "0x8000",
|
"partitions": "0x8000",
|
||||||
"littlefs": "0x290000"
|
"littlefs": "0x290000"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "esp32cam_4mb",
|
||||||
|
"boot_app0": "0xe000",
|
||||||
|
"bootloader_qio_80m": "0x1000",
|
||||||
|
"firmware": "0x10000",
|
||||||
|
"partitions": "0x8000",
|
||||||
|
"littlefs": "0x290000"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "esp32_16mb",
|
"name": "esp32_16mb",
|
||||||
"boot_app0": "0xe000",
|
"boot_app0": "0xe000",
|
||||||
@@ -372,6 +380,10 @@
|
|||||||
"path": "src/modules/exec/TelegramLT",
|
"path": "src/modules/exec/TelegramLT",
|
||||||
"active": true
|
"active": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "src/modules/exec/Telegram_v2",
|
||||||
|
"active": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "src/modules/exec/Thermostat",
|
"path": "src/modules/exec/Thermostat",
|
||||||
"active": false
|
"active": false
|
||||||
|
|||||||
@@ -199,6 +199,29 @@ build_src_filter =
|
|||||||
+<modules/*.cpp>
|
+<modules/*.cpp>
|
||||||
${env:esp32_4mb_fromitems.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>
|
||||||
|
+<classes/*.cpp>
|
||||||
|
+<utils/*.cpp>
|
||||||
|
+<modules/*.cpp>
|
||||||
|
${env:esp32cam_4mb_fromitems.build_src_filter}
|
||||||
|
|
||||||
[env:esp32s2_4mb]
|
[env:esp32s2_4mb]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${common_env_data.lib_deps_external}
|
${common_env_data.lib_deps_external}
|
||||||
@@ -557,11 +580,25 @@ build_src_filter =
|
|||||||
+<modules/display/Smi2_m>
|
+<modules/display/Smi2_m>
|
||||||
+<modules/display/TM16XX>
|
+<modules/display/TM16XX>
|
||||||
|
|
||||||
|
[env:esp32cam_4mb_fromitems]
|
||||||
|
lib_deps =
|
||||||
|
espressif/esp32-camera @ ^2.0.0
|
||||||
|
gyverlibs/FastBot
|
||||||
|
build_src_filter =
|
||||||
|
+<modules/virtual/Cron>
|
||||||
|
+<modules/virtual/Loging>
|
||||||
|
+<modules/virtual/LogingDaily>
|
||||||
|
+<modules/virtual/Timer>
|
||||||
|
+<modules/virtual/Variable>
|
||||||
|
+<modules/virtual/VariableColor>
|
||||||
|
+<modules/virtual/VButton>
|
||||||
|
+<modules/exec/EspCam>
|
||||||
|
+<modules/exec/Telegram_v2>
|
||||||
|
|
||||||
[env:esp32s2_4mb_fromitems]
|
[env:esp32s2_4mb_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<modules/virtual/Cron>
|
+<modules/virtual/Cron>
|
||||||
+<modules/virtual/GoogleSheet>
|
|
||||||
+<modules/virtual/Loging>
|
+<modules/virtual/Loging>
|
||||||
+<modules/virtual/LogingDaily>
|
+<modules/virtual/LogingDaily>
|
||||||
+<modules/virtual/Timer>
|
+<modules/virtual/Timer>
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ void configure(String path) {
|
|||||||
if (driver = myIoTItem->getGpioDriver()) IoTgpio.regDriver((IoTGpio*)driver);
|
if (driver = myIoTItem->getGpioDriver()) IoTgpio.regDriver((IoTGpio*)driver);
|
||||||
// пробуем спросить драйвер RTC
|
// пробуем спросить драйвер RTC
|
||||||
if (driver = myIoTItem->getRtcDriver()) rtcItem = (IoTItem*)driver;
|
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);
|
IoTItems.push_back(myIoTItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,6 +47,8 @@ void configure(String path) {
|
|||||||
void clearConfigure() {
|
void clearConfigure() {
|
||||||
Serial.printf("Start clearing config\n");
|
Serial.printf("Start clearing config\n");
|
||||||
rtcItem = nullptr;
|
rtcItem = nullptr;
|
||||||
|
//camItem = nullptr;
|
||||||
|
tlgrmItem = nullptr;
|
||||||
IoTgpio.clearDrivers();
|
IoTgpio.clearDrivers();
|
||||||
|
|
||||||
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ WebSocketsServer standWebSocket = WebSocketsServer(81);
|
|||||||
**********************************************************************************************************************/
|
**********************************************************************************************************************/
|
||||||
IoTGpio IoTgpio(0);
|
IoTGpio IoTgpio(0);
|
||||||
IoTItem* rtcItem = nullptr;
|
IoTItem* rtcItem = nullptr;
|
||||||
|
//IoTItem* camItem = nullptr;
|
||||||
|
IoTItem* tlgrmItem = nullptr;
|
||||||
String settingsFlashJson = "{}"; // переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью
|
String settingsFlashJson = "{}"; // переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью
|
||||||
String valuesFlashJson = "{}"; // переменная в которой хранятся все значения элементов, которые необходимо сохранить на flash. Находится в оперативной памяти и синхронизированна с flash памятью
|
String valuesFlashJson = "{}"; // переменная в которой хранятся все значения элементов, которые необходимо сохранить на flash. Находится в оперативной памяти и синхронизированна с flash памятью
|
||||||
String errorsHeapJson = "{}"; // переменная в которой хранятся все ошибки, находится в оперативной памяти только
|
String errorsHeapJson = "{}"; // переменная в которой хранятся все ошибки, находится в оперативной памяти только
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ void elementsLoop() {
|
|||||||
#define COUNTER_ERRORMARKER 4 // количество шагов счетчика
|
#define COUNTER_ERRORMARKER 4 // количество шагов счетчика
|
||||||
#define STEPPER_ERRORMARKER 100000 // размер шага счетчика интервала доверия выполнения блока кода мкс
|
#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 initErrorMarkerId = 0; // ИД маркера
|
||||||
static int IRAM_ATTR errorMarkerId = 0;
|
static int IRAM_ATTR errorMarkerId = 0;
|
||||||
@@ -63,14 +63,14 @@ void IRAM_ATTR onTimer() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initErrorMarker(int id) {
|
void initErrorMarker(int id) {
|
||||||
#ifdef esp32_4mb
|
#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb)
|
||||||
initErrorMarkerId = id;
|
initErrorMarkerId = id;
|
||||||
errorMarkerCounter = 0;
|
errorMarkerCounter = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopErrorMarker(int id) {
|
void stopErrorMarker(int id) {
|
||||||
#ifdef esp32_4mb
|
#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb)
|
||||||
errorMarkerCounter = -1;
|
errorMarkerCounter = -1;
|
||||||
if (errorMarkerId)
|
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);
|
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
|
#ifdef esp32s2_4mb
|
||||||
USB.begin();
|
USB.begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef esp32_4mb
|
#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb)
|
||||||
My_timer = timerBegin(0, 80, true);
|
My_timer = timerBegin(0, 80, true);
|
||||||
timerAttachInterrupt(My_timer, &onTimer, true);
|
timerAttachInterrupt(My_timer, &onTimer, true);
|
||||||
timerAlarmWrite(My_timer, STEPPER_ERRORMARKER, true);
|
timerAlarmWrite(My_timer, STEPPER_ERRORMARKER, true);
|
||||||
|
|||||||
@@ -184,6 +184,14 @@ const String getDateTimeDotFormatedFromUnix(unsigned long unixTime) {
|
|||||||
return String(buf);
|
return String(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const String getTimeDotFormatedFromUnix(unsigned long unixTime) {
|
||||||
|
Time_t time;
|
||||||
|
breakEpochToTime(unixTime, time);
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "%02d:%02d:%02d", time.hour, time.minute, time.second);
|
||||||
|
return String(buf);
|
||||||
|
}
|
||||||
|
|
||||||
const String getDateDotFormatedFromUnix(unsigned long unixTime) {
|
const String getDateDotFormatedFromUnix(unsigned long unixTime) {
|
||||||
Time_t time;
|
Time_t time;
|
||||||
breakEpochToTime(unixTime, time);
|
breakEpochToTime(unixTime, time);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ String ESP32GetResetReason(uint32_t cpu_no) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(esp32_4mb) || defined(esp32_16mb)
|
#if defined(esp32_4mb) || defined(esp32_16mb) || defined(esp32cam_4mb)
|
||||||
String ESP_getResetReason(void) {
|
String ESP_getResetReason(void) {
|
||||||
return ESP32GetResetReason(0); // CPU 0
|
return ESP32GetResetReason(0); // CPU 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,8 @@ bool IoTItem::isTracking(IoTItem* item) {
|
|||||||
|
|
||||||
// делаем доступным модулям отправку сообщений в телеграм
|
// делаем доступным модулям отправку сообщений в телеграм
|
||||||
void IoTItem::sendTelegramMsg(bool often, String msg) {}
|
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::publishValue() {}
|
||||||
void IoTItem::clearValue() {}
|
void IoTItem::clearValue() {}
|
||||||
@@ -233,6 +234,14 @@ IoTGpio* IoTItem::getGpioDriver() {
|
|||||||
IoTItem* IoTItem::getRtcDriver() {
|
IoTItem* IoTItem::getRtcDriver() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
IoTItem* IoTItem::getCAMDriver() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
IoTItem* IoTItem::getTlgrmDriver() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned long IoTItem::getRtcUnixTime() {
|
unsigned long IoTItem::getRtcUnixTime() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -123,6 +123,10 @@
|
|||||||
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
|
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
|
||||||
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
|
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
|
||||||
|
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
|
"https://github.com/robotclass/RobotClass_LiquidCrystal_I2C",
|
||||||
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
|
"marcoschwartz/LiquidCrystal_I2C@^1.1.4"
|
||||||
|
|||||||
@@ -39,6 +39,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/avaksru/ESPNexUpload.git"
|
"https://github.com/avaksru/ESPNexUpload.git"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/avaksru/ESPNexUpload.git"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/avaksru/ESPNexUpload.git"
|
"https://github.com/avaksru/ESPNexUpload.git"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
},
|
},
|
||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": []
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,6 +107,11 @@
|
|||||||
"adafruit/Adafruit GFX Library @ ^1.11.5",
|
"adafruit/Adafruit GFX Library @ ^1.11.5",
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"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": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/maxint-rd/TM16xx",
|
"https://github.com/maxint-rd/TM16xx",
|
||||||
"adafruit/Adafruit GFX Library @ ^1.11.5",
|
"adafruit/Adafruit GFX Library @ ^1.11.5",
|
||||||
|
|||||||
@@ -100,6 +100,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"adafruit/Adafruit NeoPixel@^1.10.6"
|
"adafruit/Adafruit NeoPixel@^1.10.6"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit NeoPixel@^1.10.6"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit NeoPixel@^1.10.6"
|
"adafruit/Adafruit NeoPixel@^1.10.6"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -46,6 +46,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"gyverlibs/EncButton @ ^2.0"
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"gyverlibs/EncButton @ ^2.0"
|
"gyverlibs/EncButton @ ^2.0"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,64 +3,108 @@
|
|||||||
#include "NTP.h"
|
#include "NTP.h"
|
||||||
|
|
||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include "soc/soc.h" // Disable brownour problems
|
#include "soc/soc.h" // Disable brownour problems
|
||||||
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
#include "soc/rtc_cntl_reg.h" // Disable brownour problems
|
||||||
|
|
||||||
#include "FS.h" // SD Card ESP32
|
#include "FS.h" // SD Card ESP32
|
||||||
#include "SD_MMC.h" // SD Card ESP32
|
#include "SD_MMC.h" // SD Card ESP32
|
||||||
|
|
||||||
void handleGetPic();
|
void handleGetPic();
|
||||||
|
|
||||||
// ===================
|
// ===================
|
||||||
// Select camera model
|
// Select camera model
|
||||||
// ===================
|
// ===================
|
||||||
//#define CAMERA_MODEL_WROVER_KIT // Has PSRAM
|
// #define CAMERA_MODEL_WROVER_KIT // Has PSRAM
|
||||||
//#define CAMERA_MODEL_ESP_EYE // Has PSRAM
|
// #define CAMERA_MODEL_ESP_EYE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
|
// #define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
|
// #define CAMERA_MODEL_M5STACK_PSRAM // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
|
// #define CAMERA_MODEL_M5STACK_V2_PSRAM // M5Camera version B Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
|
// #define CAMERA_MODEL_M5STACK_WIDE // Has PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
|
// #define CAMERA_MODEL_M5STACK_ESP32CAM // No PSRAM
|
||||||
//#define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
|
// #define CAMERA_MODEL_M5STACK_UNITCAM // No PSRAM
|
||||||
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
|
#define CAMERA_MODEL_AI_THINKER // Has PSRAM
|
||||||
//#define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
|
// #define CAMERA_MODEL_TTGO_T_JOURNAL // No PSRAM
|
||||||
//#define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM
|
// #define CAMERA_MODEL_XIAO_ESP32S3 // Has PSRAM
|
||||||
// ** Espressif Internal Boards **
|
// ** Espressif Internal Boards **
|
||||||
//#define CAMERA_MODEL_ESP32_CAM_BOARD
|
// #define CAMERA_MODEL_ESP32_CAM_BOARD
|
||||||
//#define CAMERA_MODEL_ESP32S2_CAM_BOARD
|
// #define CAMERA_MODEL_ESP32S2_CAM_BOARD
|
||||||
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
|
// #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
|
#define CONFIG_LED_MAX_INTENSITY 255
|
||||||
|
|
||||||
#include "camera_pins.h"
|
#include "camera_pins.h"
|
||||||
|
|
||||||
|
IoTItem *_camItem = nullptr;
|
||||||
IoTItem* globalItem = nullptr;
|
camera_fb_t *frame = NULL;
|
||||||
|
class EspCam : public IoTItem
|
||||||
|
{
|
||||||
class EspCam : public IoTItem {
|
private:
|
||||||
private:
|
|
||||||
bool _useLed, _ticker, _webTicker, _initSD;
|
bool _useLed, _ticker, _webTicker, _initSD;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isUsedLed() { return _useLed; }
|
bool isUsedLed() { return _useLed; }
|
||||||
bool isWebTicker() { return _webTicker; }
|
bool isWebTicker() { return _webTicker; }
|
||||||
|
|
||||||
EspCam(String parameters): IoTItem(parameters) {
|
EspCam(String parameters) : IoTItem(parameters)
|
||||||
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
|
{
|
||||||
|
|
||||||
jsonRead(parameters, "useLed", _useLed); // используем = 1 или нет = 0 подсветку (вспышку)
|
jsonRead(parameters, "ticker", _ticker); // тикать = 1 - сообщаем всем, что сделали снимок и он готов
|
||||||
if (_useLed) {
|
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<IoTValue> ¶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);
|
ledcSetup(LED_LEDC_CHANNEL, 5000, 8);
|
||||||
ledcAttachPin(LED_GPIO_NUM, LED_LEDC_CHANNEL);
|
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 - сообщаем всем, что сделали снимок и он готов
|
return {};
|
||||||
jsonRead(parameters, "webTicker", _webTicker); // сообщать всем, что через веб попросили отдать картинку с камеры
|
}
|
||||||
globalItem = this; // выносим адрес переменной экземпляра для доступа к данным из обработчика событий веб
|
/*
|
||||||
|
IoTItem *getCAMDriver()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
void initCam()
|
||||||
|
{
|
||||||
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); // disable brownout detector
|
||||||
camera_config_t config;
|
camera_config_t config;
|
||||||
config.ledc_channel = LEDC_CHANNEL_0;
|
config.ledc_channel = LEDC_CHANNEL_0;
|
||||||
config.ledc_timer = LEDC_TIMER_0;
|
config.ledc_timer = LEDC_TIMER_0;
|
||||||
@@ -83,7 +127,7 @@ class EspCam : public IoTItem {
|
|||||||
config.xclk_freq_hz = 20000000;
|
config.xclk_freq_hz = 20000000;
|
||||||
config.frame_size = FRAMESIZE_UXGA;
|
config.frame_size = FRAMESIZE_UXGA;
|
||||||
config.pixel_format = PIXFORMAT_JPEG; // for streaming
|
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.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
|
||||||
config.fb_location = CAMERA_FB_IN_PSRAM;
|
config.fb_location = CAMERA_FB_IN_PSRAM;
|
||||||
config.jpeg_quality = 12;
|
config.jpeg_quality = 12;
|
||||||
@@ -92,101 +136,132 @@ class EspCam : public IoTItem {
|
|||||||
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
|
// if PSRAM IC present, init with UXGA resolution and higher JPEG quality
|
||||||
// for larger pre-allocated frame buffer.
|
// for larger pre-allocated frame buffer.
|
||||||
|
|
||||||
if(psramFound()){
|
if (psramFound())
|
||||||
|
{
|
||||||
config.jpeg_quality = 10;
|
config.jpeg_quality = 10;
|
||||||
config.fb_count = 2;
|
config.fb_count = 2;
|
||||||
config.grab_mode = CAMERA_GRAB_LATEST;
|
config.grab_mode = CAMERA_GRAB_LATEST;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Limit the frame size when PSRAM is not available
|
// Limit the frame size when PSRAM is not available
|
||||||
config.frame_size = FRAMESIZE_SVGA;
|
config.frame_size = FRAMESIZE_SVGA;
|
||||||
config.fb_location = CAMERA_FB_IN_DRAM;
|
config.fb_location = CAMERA_FB_IN_DRAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CAMERA_MODEL_ESP_EYE)
|
#if defined(CAMERA_MODEL_ESP_EYE)
|
||||||
pinMode(13, INPUT_PULLUP);
|
pinMode(13, INPUT_PULLUP);
|
||||||
pinMode(14, INPUT_PULLUP);
|
pinMode(14, INPUT_PULLUP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// camera init
|
// camera init
|
||||||
esp_err_t err = esp_camera_init(&config);
|
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);
|
Serial.printf("Camera init failed with error 0x%x", err);
|
||||||
return;
|
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
|
// initial sensors are flipped vertically and colors are a bit saturated
|
||||||
if (s->id.PID == OV3660_PID) {
|
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_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
|
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_vflip(s, 1);
|
||||||
s->set_hmirror(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);
|
s->set_vflip(s, 1);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
HTTP.on("/getpic", HTTP_GET, handleGetPic);
|
|
||||||
|
|
||||||
|
void initSD()
|
||||||
|
{
|
||||||
// Start Micro SD card
|
// Start Micro SD card
|
||||||
_initSD = true;
|
_initSD = true;
|
||||||
Serial.println("Starting SD Card");
|
Serial.println("Starting SD Card");
|
||||||
if(!SD_MMC.begin("/sdcard", true)){
|
if (!SD_MMC.begin("/sdcard", true))
|
||||||
|
{
|
||||||
Serial.println("SD Card Mount Failed");
|
Serial.println("SD Card Mount Failed");
|
||||||
_initSD = false;
|
_initSD = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t cardType = SD_MMC.cardType();
|
uint8_t cardType = SD_MMC.cardType();
|
||||||
if(cardType == CARD_NONE){
|
if (cardType == CARD_NONE)
|
||||||
|
{
|
||||||
Serial.println("No SD Card attached");
|
Serial.println("No SD Card attached");
|
||||||
_initSD = false;
|
_initSD = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::FS &fs = SD_MMC;
|
fs::FS &fs = SD_MMC;
|
||||||
fs.mkdir("/photos/");
|
fs.mkdir("/photos");
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_picture(String path = "") {
|
void sendFoto()
|
||||||
// if (_useLed) digitalWrite(4, HIGH); //Turn on the flash
|
{
|
||||||
|
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
|
void editFoto()
|
||||||
// fb = esp_camera_fb_get();
|
{
|
||||||
// if(!fb || fb->len >= PICBUF_SIZE) {
|
if (tlgrmItem)
|
||||||
// if (fb) {
|
{
|
||||||
// Serial.printf("Camera capture failed size=%d\n", fb->len);
|
if (_useLed)
|
||||||
// esp_camera_fb_return(fb);
|
ledcWrite(LED_LEDC_CHANNEL, CONFIG_LED_MAX_INTENSITY); // Turn on the flash
|
||||||
// } else Serial.printf("Camera capture failed\n");
|
frame = esp_camera_fb_get();
|
||||||
// return;
|
if (!frame)
|
||||||
// }
|
{
|
||||||
|
SerialPrint("E", F("Esp-Cam to Telegram"), "Fail esp-cam initialization");
|
||||||
// // if (value.extBinInfoSize < fb->len) {
|
return;
|
||||||
// // if (value.extBinInfo) free(value.extBinInfo);
|
}
|
||||||
// // value.extBinInfo = (uint8_t*)malloc(sizeof(uint8_t) * fb->len);
|
if (_useLed)
|
||||||
// // }
|
ledcWrite(LED_LEDC_CHANNEL, 0);
|
||||||
// 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);
|
|
||||||
|
|
||||||
|
(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
|
// Save picture to microSD card
|
||||||
fs::FS &fs = SD_MMC;
|
fs::FS &fs = SD_MMC;
|
||||||
|
|
||||||
if (path == "") {
|
if (path == "")
|
||||||
|
{
|
||||||
path = "/photos/";
|
path = "/photos/";
|
||||||
path += getTodayDateDotFormated();
|
path += getTodayDateDotFormated();
|
||||||
path += "/";
|
// path += "/";
|
||||||
fs.mkdir(path.c_str());
|
fs.mkdir(path.c_str());
|
||||||
|
|
||||||
char buf[32];
|
char buf[32];
|
||||||
@@ -196,79 +271,78 @@ class EspCam : public IoTItem {
|
|||||||
}
|
}
|
||||||
Serial.println(path);
|
Serial.println(path);
|
||||||
|
|
||||||
// Take Picture with Camera
|
if (_useLed)
|
||||||
camera_fb_t * fb = esp_camera_fb_get();
|
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");
|
Serial.println("Camera capture failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = fs.open(path.c_str(), FILE_WRITE);
|
File file = fs.open(path.c_str(), FILE_WRITE);
|
||||||
if(!file){
|
if (!file)
|
||||||
|
{
|
||||||
Serial.println("Failed to open file in writing mode");
|
Serial.println("Failed to open file in writing mode");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
file.write(fb->buf, fb->len); // payload (image), payload length
|
{
|
||||||
|
file.write(frame->buf, frame->len); // payload (image), payload length
|
||||||
Serial.printf("Saved file to path: %s\n", path.c_str());
|
Serial.printf("Saved file to path: %s\n", path.c_str());
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
//return the frame buffer back to the driver for reuse
|
// return the frame buffer back to the driver for reuse
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doByInterval() {
|
~EspCam()
|
||||||
//save_picture();
|
{
|
||||||
}
|
// free(value.extBinInfo);
|
||||||
|
_camItem = nullptr;
|
||||||
IoTValue execute(String command, std::vector<IoTValue> ¶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;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void handleGetPic() {
|
void handleGetPic()
|
||||||
if (!globalItem) return;
|
{
|
||||||
|
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;
|
// camera_fb_t *fb = NULL;
|
||||||
fb = esp_camera_fb_get();
|
frame = esp_camera_fb_get();
|
||||||
if (!fb) {
|
|
||||||
|
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"));
|
HTTP.send(200, "text/json", F("Item EspCam not prepared yet or camera hasn't taken a picture yet"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP.send_P(200, "image/jpeg", (char *)fb->buf, fb->len);
|
HTTP.send_P(200, "image/jpeg", (char *)frame->buf, frame->len);
|
||||||
|
|
||||||
if (((EspCam*)globalItem)->isUsedLed()) ledcWrite(LED_LEDC_CHANNEL, 0);
|
if (((EspCam *)_camItem)->isWebTicker())
|
||||||
if (((EspCam*)globalItem)->isWebTicker()) globalItem->regEvent("webTakesPhoto", "EspCam");
|
_camItem->regEvent("webTakesPhoto", "EspCam");
|
||||||
esp_camera_fb_return(fb);
|
esp_camera_fb_return(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *getAPI_EspCam(String subtype, String param)
|
||||||
void* getAPI_EspCam(String subtype, String param) {
|
{
|
||||||
if (subtype == F("EspCam")) {
|
if (subtype == F("EspCam"))
|
||||||
|
{
|
||||||
return new EspCam(param);
|
return new EspCam(param);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,27 +11,27 @@
|
|||||||
"page": "",
|
"page": "",
|
||||||
"descr": "",
|
"descr": "",
|
||||||
"int": 60,
|
"int": 60,
|
||||||
"useLed": 0,
|
"flashOn": 0,
|
||||||
"ticker": 0,
|
"ticker": 0,
|
||||||
"webTicker": 0
|
"webTicker": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"about": {
|
"about": {
|
||||||
"authorName": "Ilya Belyakov",
|
"authorName": "Ilya Belyakov, Mikhail Bubnov",
|
||||||
"authorContact": "https://t.me/Biveraxe",
|
"authorContact": "https://t.me/Biveraxe",
|
||||||
"authorGit": "https://github.com/biveraxe",
|
"authorGit": "https://github.com/biveraxe",
|
||||||
"specialThanks": "",
|
"specialThanks": "",
|
||||||
"moduleName": "EspCam",
|
"moduleName": "EspCam",
|
||||||
"moduleVersion": "2.1",
|
"moduleVersion": "3.0",
|
||||||
"usedRam": {
|
"usedRam": {
|
||||||
"esp32_4mb": 15,
|
"esp32_4mb": 15,
|
||||||
"esp8266_4mb": 15
|
"esp8266_4mb": 15
|
||||||
},
|
},
|
||||||
"title": "Camera OV2640 (ESPcam)",
|
"title": "Camera OV2640 (ESPcam)",
|
||||||
"moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения на SD при наличии. По адресу /getpic можно получить текущее фото (работает в том числе без SD карты).",
|
"moduleDesc": "Предназначен для специальной платы esp32 со встроенной камерой. Добавляет в прошивку функцию создания фото и сохранения на SD при наличии. По адресу /getpic можно получить текущее фото (работает в том числе без SD карты). Отправка фото в телеграмм через модуль Telegram_v2",
|
||||||
"propInfo": {
|
"propInfo": {
|
||||||
"int": "Пауза в секундах во время постоянной фотосъемки.",
|
"int": "Пауза в секундах во время постоянной фотосъемки.",
|
||||||
"useLed": "использовать диод подсветки при съемке.",
|
"flashOn": "использовать диод подсветки при съемке. используем = 1 или нет = 0 подсветку (вспышку)",
|
||||||
"ticker": "Генерировать(1) или нет(0) событие с интервалом int",
|
"ticker": "Генерировать(1) или нет(0) событие с интервалом int",
|
||||||
"webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу по адресу /getpic."
|
"webTicker": "Генерировать(1) или нет(0) событие при обращении через веб-страницу по адресу /getpic."
|
||||||
},
|
},
|
||||||
@@ -42,22 +42,30 @@
|
|||||||
"params": []
|
"params": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ledOn",
|
"name": "sendFoto",
|
||||||
"descr": "Включить подсветку",
|
"descr": "Отправить фото с esp-CAM в телеграмм",
|
||||||
"params": [
|
"params": [""]
|
||||||
"Яркость 0-255"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ledOff",
|
"name": "editFoto",
|
||||||
"descr": "Отключить подсветку",
|
"descr": "Отредактировать последнее отправленное фото в телеграмм",
|
||||||
|
"params": [""]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flashOn",
|
||||||
|
"descr": "Включить вспышку",
|
||||||
|
"params": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "flashOff",
|
||||||
|
"descr": "Отключить вспышку",
|
||||||
"params": []
|
"params": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [
|
"esp32cam_4mb": [
|
||||||
"espressif/esp32-camera @ ^2.0.0"
|
"espressif/esp32-camera @ ^2.0.0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
|
|||||||
@@ -51,6 +51,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/RoboticsBrno/ServoESP32#v1.0.3"
|
"https://github.com/RoboticsBrno/ServoESP32#v1.0.3"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/RoboticsBrno/ServoESP32#v1.0.3"
|
||||||
|
],
|
||||||
"esp8266_4mb": []
|
"esp8266_4mb": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,10 @@
|
|||||||
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
|
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
|
||||||
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
|
"adafruit/Adafruit Mcp23017 Arduino Library@^2.1.0",
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
|
|||||||
@@ -40,6 +40,10 @@
|
|||||||
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
|
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
|
||||||
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
|
"adafruit/Adafruit MCP23017 Arduino Library@^2.1.0",
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
|
|||||||
@@ -92,6 +92,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
|
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
|
"dfrobot/DFRobotDFPlayerMini @ ^1.0.5"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
},
|
},
|
||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": []
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit BusIO @ ^1.13.2"
|
"adafruit/Adafruit BusIO @ ^1.13.2"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
},
|
},
|
||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": []
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,9 @@
|
|||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"espressif/esp32-camera @ ^2.0.0"
|
"espressif/esp32-camera @ ^2.0.0"
|
||||||
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"espressif/esp32-camera @ ^2.0.0"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": []
|
"esp8266_4mb": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"CTBot @2.1.9"
|
"CTBot @2.1.9"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"CTBot @2.1.9"
|
||||||
|
],
|
||||||
"esp32_16mb": [
|
"esp32_16mb": [
|
||||||
"CTBot @2.1.9"
|
"CTBot @2.1.9"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
360
src/modules/exec/Telegram_v2/Telegram_v2.cpp
Normal file
360
src/modules/exec/Telegram_v2/Telegram_v2.cpp
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
// #define FB_NO_UNICODE
|
||||||
|
// #define FB_NO_URLENCODE
|
||||||
|
// #define FB_NO_OTA
|
||||||
|
// #define FB_DYNAMIC
|
||||||
|
// #include <GyverGFX.h>
|
||||||
|
// #include <CharPlot.h>
|
||||||
|
// #include "esp_camera.h"
|
||||||
|
|
||||||
|
#include <FastBot.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// 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 && isNetworkActive())
|
||||||
|
{
|
||||||
|
_myBot->tick();
|
||||||
|
}
|
||||||
|
// Далее вызов doByInterval для обработки комманд
|
||||||
|
IoTItem::loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||||
|
{
|
||||||
|
if (!isNetworkActive()) return {};
|
||||||
|
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<float> vctr;
|
||||||
|
for (std::list<IoTItem *>::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<LINE_X2>(&vctr[0], vctr.size(), 5), _chatID);
|
||||||
|
// SerialPrint("<-", F("Telegram"), CharPlot<LINE_X2>(&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 (!isNetworkActive()) return;
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (!isNetworkActive()) return;
|
||||||
|
_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)
|
||||||
|
{
|
||||||
|
if (!isNetworkActive()) return;
|
||||||
|
_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SerialPrint("E", F("Telegram"), F("file write error"));
|
||||||
|
_myBot->sendMessage(F("file write error"), _chatID);
|
||||||
|
}
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
93
src/modules/exec/Telegram_v2/modinfo.json
Normal file
93
src/modules/exec/Telegram_v2/modinfo.json
Normal file
@@ -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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -239,9 +239,9 @@ protected:
|
|||||||
}
|
}
|
||||||
if (sp && pv)
|
if (sp && pv)
|
||||||
{
|
{
|
||||||
value.valD = pid(sp, pv, pv_last, ierr, _int);
|
// value.valD = pid(sp, pv, pv_last, ierr, _int);
|
||||||
value.valS = (String)(int)pid(sp, pv, pv_last, ierr, _int);
|
// value.valS = (String)(int)value.valD;
|
||||||
regEvent(value.valS, "ThermostatPID", false, true);
|
regEvent(pid(sp, pv, pv_last, ierr, _int), "ThermostatPID", false, true);
|
||||||
}
|
}
|
||||||
pv_last = pv;
|
pv_last = pv;
|
||||||
}
|
}
|
||||||
@@ -332,8 +332,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
ThermostatETK(String parameters) : IoTItem(parameters)
|
ThermostatETK(String parameters) : IoTItem(parameters)
|
||||||
{
|
{
|
||||||
jsonRead(parameters, "set_id", _set_id);
|
// jsonRead(parameters, "set_id", _set_id);
|
||||||
jsonRead(parameters, "term_id", _term_id);
|
// jsonRead(parameters, "term_id", _term_id);
|
||||||
jsonRead(parameters, "iv_k", _iv_k);
|
jsonRead(parameters, "iv_k", _iv_k);
|
||||||
jsonRead(parameters, "outside_id", _outside_id);
|
jsonRead(parameters, "outside_id", _outside_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
|
|||||||
@@ -44,6 +44,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
|
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
|
"adafruit/Adafruit ADS1X15 @ ^2.3.0"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -59,6 +59,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/enjoyneering/AHTxx.git"
|
"https://github.com/enjoyneering/AHTxx.git"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/enjoyneering/AHTxx.git"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/enjoyneering/AHTxx.git"
|
"https://github.com/enjoyneering/AHTxx.git"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -37,6 +37,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"BH1750"
|
"BH1750"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"BH1750"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"BH1750"
|
"BH1750"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -62,6 +62,10 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/h2zero/NimBLE-Arduino.git",
|
"https://github.com/h2zero/NimBLE-Arduino.git",
|
||||||
"https://github.com/avaksru/decoder.git"
|
"https://github.com/avaksru/decoder.git"
|
||||||
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/h2zero/NimBLE-Arduino.git",
|
||||||
|
"https://github.com/avaksru/decoder.git"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,6 +83,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"adafruit/Adafruit BME280 Library"
|
"adafruit/Adafruit BME280 Library"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit BME280 Library"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit BME280 Library"
|
"adafruit/Adafruit BME280 Library"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -55,6 +55,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"adafruit/Adafruit BMP280 Library"
|
"adafruit/Adafruit BMP280 Library"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"adafruit/Adafruit BMP280 Library"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"adafruit/Adafruit BMP280 Library"
|
"adafruit/Adafruit BMP280 Library"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -55,6 +55,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"beegee-tokyo/DHT sensor library for ESPx"
|
"beegee-tokyo/DHT sensor library for ESPx"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"beegee-tokyo/DHT sensor library for ESPx"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"beegee-tokyo/DHT sensor library for ESPx"
|
"beegee-tokyo/DHT sensor library for ESPx"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -42,6 +42,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
|
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
|
"https://github.com/milesburton/Arduino-Temperature-Control-Library"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -64,6 +64,10 @@
|
|||||||
"https://github.com/jbechter/arduino-onewire-DS2423",
|
"https://github.com/jbechter/arduino-onewire-DS2423",
|
||||||
"paulstoffregen/OneWire @ ^2.3.7"
|
"paulstoffregen/OneWire @ ^2.3.7"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/jbechter/arduino-onewire-DS2423",
|
||||||
|
"paulstoffregen/OneWire @ ^2.3.7"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/jbechter/arduino-onewire-DS2423",
|
"https://github.com/jbechter/arduino-onewire-DS2423",
|
||||||
"paulstoffregen/OneWire @ ^2.3.7"
|
"paulstoffregen/OneWire @ ^2.3.7"
|
||||||
|
|||||||
@@ -62,6 +62,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"openenergymonitor/EmonLib@1.1.0"
|
"openenergymonitor/EmonLib@1.1.0"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"openenergymonitor/EmonLib@1.1.0"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"openenergymonitor/EmonLib@1.1.0"
|
"openenergymonitor/EmonLib@1.1.0"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ private:
|
|||||||
bool dataFromNode = false;
|
bool dataFromNode = false;
|
||||||
String _topic = "";
|
String _topic = "";
|
||||||
bool _isJson;
|
bool _isJson;
|
||||||
bool _addPrefix;
|
// bool _addPrefix;
|
||||||
bool _debug;
|
bool _debug;
|
||||||
bool sendOk = false;
|
bool sendOk = false;
|
||||||
|
|
||||||
@@ -28,12 +28,12 @@ public:
|
|||||||
jsonRead(parameters, F("offline"), offline);
|
jsonRead(parameters, F("offline"), offline);
|
||||||
_topic = jsonReadStr(parameters, "topic");
|
_topic = jsonReadStr(parameters, "topic");
|
||||||
jsonRead(parameters, "isJson", _isJson);
|
jsonRead(parameters, "isJson", _isJson);
|
||||||
jsonRead(parameters, "addPrefix", _addPrefix);
|
// jsonRead(parameters, "addPrefix", _addPrefix);
|
||||||
jsonRead(parameters, "debug", _debug);
|
jsonRead(parameters, "debug", _debug);
|
||||||
dataFromNode = false;
|
dataFromNode = false;
|
||||||
if (mqttIsConnect())
|
if (mqttIsConnect())
|
||||||
sendOk = true;
|
sendOk = true;
|
||||||
mqttSubscribeExternal(_topic, _addPrefix);
|
mqttSubscribeExternal(_topic);
|
||||||
}
|
}
|
||||||
char *TimeToString(unsigned long t)
|
char *TimeToString(unsigned long t)
|
||||||
{
|
{
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
if (mqttIsConnect() && !sendOk)
|
if (mqttIsConnect() && !sendOk)
|
||||||
{
|
{
|
||||||
sendOk = true;
|
sendOk = true;
|
||||||
mqttSubscribeExternal(_topic, _addPrefix);
|
mqttSubscribeExternal(_topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void onMqttWsAppConnectEvent()
|
void onMqttWsAppConnectEvent()
|
||||||
@@ -144,6 +144,8 @@ public:
|
|||||||
if (_minutesPassed >= offline)
|
if (_minutesPassed >= offline)
|
||||||
{
|
{
|
||||||
jsonWriteStr(json, F("info"), F("offline"));
|
jsonWriteStr(json, F("info"), F("offline"));
|
||||||
|
regEvent(NAN, "ExternalMQTT");
|
||||||
|
SerialPrint("E", "ExternalMQTT", "V error", _id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
"descr": "",
|
"descr": "",
|
||||||
"sensor": "",
|
"sensor": "",
|
||||||
"topic": "",
|
"topic": "",
|
||||||
"addPrefix": 0,
|
|
||||||
"isJson": 1,
|
"isJson": 1,
|
||||||
"round": "",
|
"round": "",
|
||||||
"orange": 60,
|
"orange": 60,
|
||||||
@@ -24,7 +23,7 @@
|
|||||||
],
|
],
|
||||||
"about": {
|
"about": {
|
||||||
"authorName": "AVAKS",
|
"authorName": "AVAKS",
|
||||||
"authorContact": "https://t.me/@avaks_dev",
|
"authorContact": "https://t.me/@avaks",
|
||||||
"authorGit": "https://github.com/avaksru",
|
"authorGit": "https://github.com/avaksru",
|
||||||
"specialThanks": "",
|
"specialThanks": "",
|
||||||
"moduleName": "ExternalMQTT",
|
"moduleName": "ExternalMQTT",
|
||||||
@@ -53,6 +52,7 @@
|
|||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -87,6 +87,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"kosme/arduinoFFT@^1.5.6"
|
"kosme/arduinoFFT@^1.5.6"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"kosme/arduinoFFT@^1.5.6"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"kosme/arduinoFFT@^1.5.6"
|
"kosme/arduinoFFT@^1.5.6"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -52,6 +52,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/JonasGMorsch/GY-21.git"
|
"https://github.com/JonasGMorsch/GY-21.git"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/JonasGMorsch/GY-21.git"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/JonasGMorsch/GY-21.git"
|
"https://github.com/JonasGMorsch/GY-21.git"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -55,6 +55,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"ClosedCube HDC1080"
|
"ClosedCube HDC1080"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"ClosedCube HDC1080"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"ClosedCube HDC1080"
|
"ClosedCube HDC1080"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -49,6 +49,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
"https://github.com/kurimawxx00/hx710B_pressure_sensor"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -64,6 +64,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"GyverHX711@1.2"
|
"GyverHX711@1.2"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"GyverHX711@1.2"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"GyverHX711@1.2"
|
"GyverHX711@1.2"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -122,6 +122,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/GyverLibs/GyverINA"
|
"https://github.com/GyverLibs/GyverINA"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/GyverLibs/GyverINA"
|
||||||
|
],
|
||||||
"esp32s2_4mb": [
|
"esp32s2_4mb": [
|
||||||
"https://github.com/GyverLibs/GyverINA"
|
"https://github.com/GyverLibs/GyverINA"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -122,6 +122,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/GyverLibs/GyverINA"
|
"https://github.com/GyverLibs/GyverINA"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/GyverLibs/GyverINA"
|
||||||
|
],
|
||||||
"esp32s2_4mb": [
|
"esp32s2_4mb": [
|
||||||
"https://github.com/GyverLibs/GyverINA"
|
"https://github.com/GyverLibs/GyverINA"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -39,6 +39,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino"
|
"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": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino"
|
"https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
"esp32s2_4mb": [
|
"esp32s2_4mb": [
|
||||||
"plerup/EspSoftwareSerial"
|
"plerup/EspSoftwareSerial"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": []
|
"esp8266_4mb": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -128,6 +128,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -64,6 +64,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"rc-switch @ ^2.6.4"
|
"rc-switch @ ^2.6.4"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"rc-switch @ ^2.6.4"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"rc-switch @ ^2.6.4"
|
"rc-switch @ ^2.6.4"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -62,6 +62,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"https://github.com/tremaru/iarduino_RTC"
|
"https://github.com/tremaru/iarduino_RTC"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"https://github.com/tremaru/iarduino_RTC"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"https://github.com/tremaru/iarduino_RTC"
|
"https://github.com/tremaru/iarduino_RTC"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -74,6 +74,10 @@
|
|||||||
"Sensirion I2C SCD4x @0.4.0",
|
"Sensirion I2C SCD4x @0.4.0",
|
||||||
"Sensirion Core @0.6.0"
|
"Sensirion Core @0.6.0"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"Sensirion I2C SCD4x @0.4.0",
|
||||||
|
"Sensirion Core @0.6.0"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"Sensirion I2C SCD4x @0.4.0",
|
"Sensirion I2C SCD4x @0.4.0",
|
||||||
"Sensirion Core @0.6.0"
|
"Sensirion Core @0.6.0"
|
||||||
|
|||||||
@@ -69,6 +69,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"Nova Fitness Sds dust sensors library@1.5.1"
|
"Nova Fitness Sds dust sensors library@1.5.1"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"Nova Fitness Sds dust sensors library@1.5.1"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"Nova Fitness Sds dust sensors library@1.5.1"
|
"Nova Fitness Sds dust sensors library@1.5.1"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -51,6 +51,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
|
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
|
"sparkfun/SparkFun SGP30 Arduino Library@^1.0.5"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -52,6 +52,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"WEMOS SHT3x@1.0.0"
|
"WEMOS SHT3x@1.0.0"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"WEMOS SHT3x@1.0.0"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"WEMOS SHT3x@1.0.0"
|
"WEMOS SHT3x@1.0.0"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
"esp8266_1mb": [],
|
"esp8266_1mb": [],
|
||||||
"esp8266_1mb_ota": [],
|
"esp8266_1mb_ota": [],
|
||||||
|
|||||||
@@ -77,6 +77,9 @@
|
|||||||
"esp32_4mb": [
|
"esp32_4mb": [
|
||||||
"plerup/EspSoftwareSerial"
|
"plerup/EspSoftwareSerial"
|
||||||
],
|
],
|
||||||
|
"esp32cam_4mb": [
|
||||||
|
"plerup/EspSoftwareSerial"
|
||||||
|
],
|
||||||
"esp8266_4mb": [
|
"esp8266_4mb": [
|
||||||
"plerup/EspSoftwareSerial"
|
"plerup/EspSoftwareSerial"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": []
|
"esp8266_4mb": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class LogingDaily : public IoTItem {
|
|||||||
if (telegram == 1) {
|
if (telegram == 1) {
|
||||||
String msg = descr + ": total " + String(currentValue) + ", consumed " + String(difference);
|
String msg = descr + ": total " + String(currentValue) + ", consumed " + String(difference);
|
||||||
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
for (std::list<IoTItem *>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||||
if ((*it)->getSubtype() == "TelegramLT" || "Telegram") {
|
if ((*it)->getSubtype() == "TelegramLT" || "Telegram" || "Telegram_v2") {
|
||||||
(*it)->sendTelegramMsg(false, msg);
|
(*it)->sendTelegramMsg(false, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
"defActive": true,
|
"defActive": true,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
"defActive": false,
|
"defActive": false,
|
||||||
"usedLibs": {
|
"usedLibs": {
|
||||||
"esp32_4mb": [],
|
"esp32_4mb": [],
|
||||||
|
"esp32cam_4mb": [],
|
||||||
"esp32_16mb": [],
|
"esp32_16mb": [],
|
||||||
"esp32s2_4mb": [],
|
"esp32s2_4mb": [],
|
||||||
"esp8266_4mb": [],
|
"esp8266_4mb": [],
|
||||||
|
|||||||
82
src/modules/virtual/owmWeather/modinfo.json
Normal file
82
src/modules/virtual/owmWeather/modinfo.json
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"menuSection": "virtual_elments",
|
||||||
|
|
||||||
|
"configItem": [
|
||||||
|
{
|
||||||
|
"global": 0,
|
||||||
|
"name": "Погода OWM",
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "owmWeather",
|
||||||
|
"id": "owm",
|
||||||
|
"needSave": 0,
|
||||||
|
"widget": "nil",
|
||||||
|
"page": "Погода",
|
||||||
|
"descr": "Температура на улице",
|
||||||
|
"int": 30,
|
||||||
|
"API_key": "",
|
||||||
|
"сity": "Moscow",
|
||||||
|
"lon": "37.54",
|
||||||
|
"lat": "57.74",
|
||||||
|
"lang": "ru",
|
||||||
|
"param": "",
|
||||||
|
"round": 1,
|
||||||
|
"val": "...",
|
||||||
|
"debug": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"about": {
|
||||||
|
"authorName": "Serghei Crasnicov, v2.0 Mikhail Bubnov",
|
||||||
|
"authorContact": "https://t.me/Serghei63",
|
||||||
|
"authorGit": "https://github.com/Serghei63",
|
||||||
|
"specialThanks": "AVAKS",
|
||||||
|
"moduleName": "owmWeather",
|
||||||
|
"moduleVersion": "2.0",
|
||||||
|
"usedRam": {
|
||||||
|
"esp32_4mb": 15,
|
||||||
|
"esp8266_4mb": 15
|
||||||
|
},
|
||||||
|
"subTypes": [
|
||||||
|
"temp",
|
||||||
|
"humidity",
|
||||||
|
"pressure",
|
||||||
|
"speed",
|
||||||
|
"deg",
|
||||||
|
"all",
|
||||||
|
"main",
|
||||||
|
"description",
|
||||||
|
"icon",
|
||||||
|
"sunrise",
|
||||||
|
"sunset",
|
||||||
|
"name"
|
||||||
|
],
|
||||||
|
"title": "Погода",
|
||||||
|
"moduleDesc": "Получение погоды из интернет OpenWeatherMap",
|
||||||
|
"propInfo": {
|
||||||
|
"param": "Тип текущего Item: temp - температура, humidity - влажность, pressure - давление, speed - скорость ветра, deg - направление ветра, all - процент облачности, sunrise - рассвет, sunset - закат, description - Погодные условия, icon - код иконки, name - город. Если оставить пустым пудет искать и публиковать при изменении в Items с именами wea_temp и т.д. wea_...",
|
||||||
|
"int": "Интервал запроса погоды в минутах",
|
||||||
|
"API_key": "API ключ",
|
||||||
|
"сity": "Название города, через запятую можно уочнить код страны. Наример Moscow или Moscow,ru или Москва. Если город не задан будут использоваться координаты. OWM рекомендует координаты",
|
||||||
|
"lon": "Долгота, при использовании координат, будет автоматически выбран ближайший город",
|
||||||
|
"lat": "Широта, при использовании координат, будет автоматически выбран ближайший город",
|
||||||
|
"lang": "Язык используемый в ответах OpenWetaherMap",
|
||||||
|
"debug":"1 - выводить дополнительный лог в сериал"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"defActive": true,
|
||||||
|
|
||||||
|
"usedLibs": {
|
||||||
|
"esp32_4mb": [],
|
||||||
|
"esp32s2_4mb": [],
|
||||||
|
"esp32_16mb": [],
|
||||||
|
"esp8266_4mb": [],
|
||||||
|
"esp8266_16mb": [],
|
||||||
|
"esp8266_1mb": [],
|
||||||
|
"esp8266_1mb_ota": [],
|
||||||
|
"esp8285_1mb": [],
|
||||||
|
"esp8285_1mb_ota": [],
|
||||||
|
"esp8266_2mb": [],
|
||||||
|
"esp8266_2mb_ota": []
|
||||||
|
}
|
||||||
|
}
|
||||||
255
src/modules/virtual/owmWeather/owmWeather.cpp
Normal file
255
src/modules/virtual/owmWeather/owmWeather.cpp
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include "classes/IoTItem.h"
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include "NTP.h"
|
||||||
|
// long prevWeatherMillis = millis() - 60001;
|
||||||
|
// TODO Зачем так много???
|
||||||
|
StaticJsonDocument<JSON_BUFFER_SIZE * 2> Weatherdoc1;
|
||||||
|
|
||||||
|
extern IoTGpio IoTgpio;
|
||||||
|
class owmWeather : public IoTItem
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// описание параметров передаваемых из настроек датчика из веба
|
||||||
|
|
||||||
|
String _location;
|
||||||
|
String _param;
|
||||||
|
// long interval;
|
||||||
|
String _API_key;
|
||||||
|
String _city = "";
|
||||||
|
String _lat = "";
|
||||||
|
String _lon = "";
|
||||||
|
String _lang = "";
|
||||||
|
bool _debug = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
owmWeather(String parameters) : IoTItem(parameters)
|
||||||
|
{
|
||||||
|
_API_key = jsonReadStr(parameters, "API_key");
|
||||||
|
// _ID_sity = jsonReadStr(parameters, "ID_sity");
|
||||||
|
_city = jsonReadStr(parameters, "city");
|
||||||
|
_lon = jsonReadStr(parameters, "lon");
|
||||||
|
_lat = jsonReadStr(parameters, "lat");
|
||||||
|
_lang = jsonReadStr(parameters, "lang");
|
||||||
|
_param = jsonReadStr(parameters, "param");
|
||||||
|
jsonRead(parameters, "debug", _debug);
|
||||||
|
long interval;
|
||||||
|
jsonRead(parameters, F("int"), interval); // в минутах
|
||||||
|
setInterval(interval * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
void getWeather()
|
||||||
|
{
|
||||||
|
String ret;
|
||||||
|
|
||||||
|
if (isNetworkActive())
|
||||||
|
{
|
||||||
|
String urlReq;
|
||||||
|
if (_city != "")
|
||||||
|
{
|
||||||
|
// Для нового API
|
||||||
|
// request = "http://api.openweathermap.org/geo/1.0/direct?q=" _сity + "&limit=1&appid=" + _API_key;
|
||||||
|
// Устарело, но пока работает
|
||||||
|
urlReq = "http://api.openweathermap.org/data/2.5/weather?q=" + _city + "&units=metric&lang=" + _lang + "&appid=" + _API_key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Получаем название города по координатам. Новый API
|
||||||
|
// request = "http://api.openweathermap.org/geo/1.0/reverse?lat=" + _lat + "&lon=" + _lon + "&limit=1&appid=" + _API_key;
|
||||||
|
//[0].local_names:{ru:Москва,...}
|
||||||
|
urlReq = "http://api.openweathermap.org/data/2.5/weather?lat=" + _lat + "&lon=" + _lon + "&units=metric&lang=" + _lang + "&appid=" + _API_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiClient client;
|
||||||
|
HTTPClient http;
|
||||||
|
String payload;
|
||||||
|
bool find = false;
|
||||||
|
http.setTimeout(500);
|
||||||
|
http.begin(client, urlReq); // urlCurrent
|
||||||
|
// http.begin(client, "http://api.openweathermap.org/data/2.5/weather?id=" + _ID_sity + "&appid=" + _API_key + "&units=metric");
|
||||||
|
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
int httpCode = http.GET();
|
||||||
|
|
||||||
|
if (httpCode > 0)
|
||||||
|
{
|
||||||
|
ret = httpCode;
|
||||||
|
|
||||||
|
if (httpCode == HTTP_CODE_OK)
|
||||||
|
{
|
||||||
|
payload = http.getString();
|
||||||
|
|
||||||
|
deserializeJson(Weatherdoc1, payload);
|
||||||
|
ret += payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = http.errorToString(httpCode).c_str();
|
||||||
|
}
|
||||||
|
if (_debug)
|
||||||
|
{
|
||||||
|
SerialPrint("<-", F("getOwmWeather"), urlReq);
|
||||||
|
SerialPrint("->", F("getOwmWeather"), "server: " + ret);
|
||||||
|
}
|
||||||
|
http.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval()
|
||||||
|
{
|
||||||
|
|
||||||
|
getWeather();
|
||||||
|
if (jsonReadStr(Weatherdoc1["main"], "temp", true) != "null")
|
||||||
|
{
|
||||||
|
|
||||||
|
publishNew("main", "temp");
|
||||||
|
publishNew("main", "pressure");
|
||||||
|
publishNew("main", "humidity");
|
||||||
|
publishNew("wind", "speed");
|
||||||
|
publishNew("wind", "deg");
|
||||||
|
publishNew("clouds", "all");
|
||||||
|
publishNew("weather", "main");
|
||||||
|
publishNew("weather", "description");
|
||||||
|
publishNew("weather", "icon");
|
||||||
|
publishNew("sys", "sunrise");
|
||||||
|
publishNew("sys", "sunset");
|
||||||
|
publishNew("", "name");
|
||||||
|
|
||||||
|
if (_param == "temp")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["main"], "temp", true);
|
||||||
|
}
|
||||||
|
else if (_param == "pressure")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["main"], "pressure", true);
|
||||||
|
}
|
||||||
|
else if (_param == "humidity")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["main"], "humidity", true);
|
||||||
|
}
|
||||||
|
else if (_param == "speed")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["wind"], "speed", true);
|
||||||
|
}
|
||||||
|
else if (_param == "deg")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["wind"], "deg", true);
|
||||||
|
}
|
||||||
|
else if (_param == "all")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["clouds"], "all", true);
|
||||||
|
}
|
||||||
|
else if (_param == "main")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["weather"][0], "main", true);
|
||||||
|
}
|
||||||
|
else if (_param == "description")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["weather"][0], "description", true);
|
||||||
|
}
|
||||||
|
else if (_param == "icon")
|
||||||
|
{
|
||||||
|
value.valS = jsonReadStr(Weatherdoc1["weather"][0], "icon", true);
|
||||||
|
}
|
||||||
|
else if (_param == "sunrise")
|
||||||
|
{
|
||||||
|
value.valS = getTimeDotFormatedFromUnix(std::atoll(jsonReadStr(Weatherdoc1["sys"], "sunrise", true).c_str()));
|
||||||
|
}
|
||||||
|
else if (_param == "sunset")
|
||||||
|
{
|
||||||
|
value.valS = getTimeDotFormatedFromUnix(std::atoll(jsonReadStr(Weatherdoc1["sys"], "sunset", true).c_str()));
|
||||||
|
}
|
||||||
|
else if (_param == "sunset")
|
||||||
|
{
|
||||||
|
value.valS = Weatherdoc1["name"].as<String>();
|
||||||
|
}
|
||||||
|
// value.isDecimal = false;
|
||||||
|
|
||||||
|
regEvent(value.valS, "owmWeather");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IoTValue execute(String command, std::vector<IoTValue> ¶m)
|
||||||
|
{
|
||||||
|
if (command == "get")
|
||||||
|
{
|
||||||
|
// getWeather();
|
||||||
|
doByInterval();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// проверяем если пришедшее значение отличается от предыдущего регистрируем событие
|
||||||
|
static void publishNew(String root, String param)
|
||||||
|
{
|
||||||
|
IoTItem *tmp = findIoTItem("wea_" + param);
|
||||||
|
if (!tmp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (root == "weather")
|
||||||
|
{ // ☔⛅❄🌤🌥🌦🌧🌨🌩🌫🌞
|
||||||
|
String icn = Weatherdoc1[root][0]["icon"].as<String>();
|
||||||
|
if (icn == "01d" || icn == "01n")
|
||||||
|
icn = "🌞";
|
||||||
|
else if (icn == "02d" || icn == "02n")
|
||||||
|
icn = "🌤";
|
||||||
|
else if (icn == "03d" || icn == "03n")
|
||||||
|
icn = "🌥";
|
||||||
|
else if (icn == "04d" || icn == "04n")
|
||||||
|
icn = "🌫";
|
||||||
|
else if (icn == "09d" || icn == "09n")
|
||||||
|
icn = "🌧";
|
||||||
|
else if (icn == "10d" || icn == "10n")
|
||||||
|
icn = "🌦";
|
||||||
|
else if (icn == "11d" || icn == "11n")
|
||||||
|
icn = "🌩";
|
||||||
|
else if (icn == "13d" || icn == "13n")
|
||||||
|
icn = "❄";
|
||||||
|
else
|
||||||
|
icn = "";
|
||||||
|
if (Weatherdoc1[root][0][param].as<String>() != tmp->value.valS)
|
||||||
|
{
|
||||||
|
if (param == "description")
|
||||||
|
tmp->setValue(Weatherdoc1[root][0][param].as<String>() + icn, true);
|
||||||
|
else
|
||||||
|
tmp->setValue(Weatherdoc1[root][0][param].as<String>(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (root == "")
|
||||||
|
{
|
||||||
|
if (Weatherdoc1[param].as<String>() != tmp->value.valS)
|
||||||
|
{
|
||||||
|
tmp->setValue(Weatherdoc1[param].as<String>(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (root == "sys")
|
||||||
|
{
|
||||||
|
if (Weatherdoc1[root][param].as<String>() != tmp->value.valS)
|
||||||
|
{
|
||||||
|
tmp->setValue(getTimeDotFormatedFromUnix(std::atoll(jsonReadStr(Weatherdoc1[root], param, true).c_str())), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Weatherdoc1[root][param].as<String>() != tmp->value.valS)
|
||||||
|
{
|
||||||
|
tmp->setValue(Weatherdoc1[root][param].as<String>(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~owmWeather(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
void *getAPI_owmWeather(String subtype, String param)
|
||||||
|
{
|
||||||
|
if (subtype == F("owmWeather"))
|
||||||
|
{
|
||||||
|
return new owmWeather(param);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
tools/partitions_custom.csv
Normal file
6
tools/partitions_custom.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
nvs, data, nvs, 0x9000, 0x5000,
|
||||||
|
otadata, data, ota, 0xe000, 0x2000,
|
||||||
|
app0, app, ota_0, 0x10000, 0x180000,
|
||||||
|
app1, app, ota_1, 0x190000,0x180000,
|
||||||
|
spiffs, data, spiffs, 0x310000,0xF0000,
|
||||||
|
Reference in New Issue
Block a user