From 6d4b899fc0ea13e18800e3a012a131f7b6dab6e9 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Thu, 11 Aug 2022 14:50:37 +0200 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_svelte/items.json | 8 +- myProfile.json | 170 +++++++++++++++++++++++++++++++++++++++++ platformio.ini | 2 +- src/MqttClient.cpp | 50 ++++++------ src/modules/API.cpp | 4 +- 5 files changed, 201 insertions(+), 33 deletions(-) create mode 100644 myProfile.json diff --git a/data_svelte/items.json b/data_svelte/items.json index f4028041..ebc91b24 100644 --- a/data_svelte/items.json +++ b/data_svelte/items.json @@ -96,18 +96,16 @@ "num": 6 }, { - "name": "7. PWM ESP32", + "name": "7. PWM ESP8266", "type": "Writing", - "subtype": "Pwm32", + "subtype": "Pwm8266", "id": "pwm", "widget": "range", "page": "Кнопки", "descr": "PWM", "int": 0, - "pin": 2, + "pin": 15, "freq": 5000, - "ledChannel": 2, - "PWM_resolution": 12, "val": 0, "apin": -1, "num": 7 diff --git a/myProfile.json b/myProfile.json new file mode 100644 index 00000000..aa55917f --- /dev/null +++ b/myProfile.json @@ -0,0 +1,170 @@ +{ + "iotmSettings": { + "settings": "", + "name": "IoTmanagerVer4", + "apssid": "IoTmanager", + "appass": "", + "routerssid": "MercureSpeedZone", + "routerpass": "", + "timezone": 1, + "ntp": "pool.ntp.org", + "weblogin": "admin", + "webpass": "admin", + "mqttServer": "m2.wqtt.ru", + "mqttPort": 8021, + "mqttPrefix": "/ver4test", + "mqttUser": "rise", + "mqttPass": "hostel3333", + "serverip": "http://206.189.49.244:8081", + "log": 0, + "mqttin": 0 + }, + "projectProp": { + "platformio": { + "default_envs": "esp8266_4mb", + "data_dir": "data_svelte" + } + }, + "modules": { + "Экраны": [ + { + "path": "src\\modules\\display\\Lcd2004", + "active": true + } + ], + "Модули управления": [ + { + "path": "src\\modules\\exec\\ButtonIn", + "active": true + }, + { + "path": "src\\modules\\exec\\ButtonOut", + "active": true + }, + { + "path": "src\\modules\\exec\\EspCam", + "active": false + }, + { + "path": "src\\modules\\exec\\IoTServo", + "active": true + }, + { + "path": "src\\modules\\exec\\Mp3", + "active": true + }, + { + "path": "src\\modules\\exec\\Pwm32", + "active": true + }, + { + "path": "src\\modules\\exec\\Pwm8266", + "active": true + }, + { + "path": "src\\modules\\exec\\SDcard", + "active": false + }, + { + "path": "src\\modules\\exec\\Telegram", + "active": false + }, + { + "path": "src\\modules\\exec\\Timer", + "active": true + } + ], + "Сенсоры": [ + { + "path": "src\\modules\\sensors\\Ads1115", + "active": false + }, + { + "path": "src\\modules\\sensors\\Aht20", + "active": true + }, + { + "path": "src\\modules\\sensors\\AnalogAdc", + "active": true + }, + { + "path": "src\\modules\\sensors\\Bme280", + "active": true + }, + { + "path": "src\\modules\\sensors\\Bmp280", + "active": true + }, + { + "path": "src\\modules\\sensors\\Dht1122", + "active": true + }, + { + "path": "src\\modules\\sensors\\Ds18b20", + "active": true + }, + { + "path": "src\\modules\\sensors\\Emon", + "active": false + }, + { + "path": "src\\modules\\sensors\\GY21", + "active": true + }, + { + "path": "src\\modules\\sensors\\Hdc1080", + "active": true + }, + { + "path": "src\\modules\\sensors\\IoTWiegand", + "active": false + }, + { + "path": "src\\modules\\sensors\\Max6675", + "active": true + }, + { + "path": "src\\modules\\sensors\\Mhz19", + "active": false + }, + { + "path": "src\\modules\\sensors\\RCswitch", + "active": true + }, + { + "path": "src\\modules\\sensors\\Sds011", + "active": false + }, + { + "path": "src\\modules\\sensors\\Sht20", + "active": true + }, + { + "path": "src\\modules\\sensors\\Sht30", + "active": true + }, + { + "path": "src\\modules\\sensors\\Sonar", + "active": true + } + ], + "Расширения": [ + { + "path": "src\\modules\\system\\IarduinoRTC", + "active": true + }, + { + "path": "src\\modules\\system\\Mcp23017", + "active": true + }, + { + "path": "src\\modules\\system\\SysExt", + "active": true + }, + { + "path": "src\\modules\\system\\Variable", + "active": true + } + ] + } +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 9e0deda1..726b79d5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -39,7 +39,7 @@ build_src_filter = ${env:esp32_4mb_fromitems.build_src_filter} [platformio] -default_envs = esp32_4mb +default_envs = esp8266_4mb data_dir = data_svelte [common_env_data] diff --git a/src/MqttClient.cpp b/src/MqttClient.cpp index 955033b7..84238237 100644 --- a/src/MqttClient.cpp +++ b/src/MqttClient.cpp @@ -125,9 +125,9 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) { payloadStr += (char)payload[i]; } - //SerialPrint("i", "=>MQTT", payloadStr); + // SerialPrint("i", "=>MQTT", payloadStr); - //SerialPrint("i", F("=>MQTT"), "Msg from iotmanager: " + topicStr); + // SerialPrint("i", F("=>MQTT"), "Msg from iotmanager: " + topicStr); if (payloadStr.startsWith("HELLO")) { SerialPrint("i", F("MQTT"), F("Full update")); @@ -149,29 +149,29 @@ void mqttCallback(char* topic, uint8_t* payload, size_t length) { //здесь мы получаем события с других устройств, которые потом проверяются в сценариях этого устройства else if (topicStr.indexOf("event") != -1) { - if (!jsonReadBool(settingsFlashJson, "mqttin")) { - return; - } - if (topicStr.indexOf(chipId) == -1) { - String devId = selectFromMarkerToMarker(topicStr, "/", 2); - String id = selectFromMarkerToMarker(topicStr, "/", 3); - IoTItem* itemExist = findIoTItem(id); - if (itemExist) { - String valAsStr; - if (jsonRead(payloadStr, F("val"), valAsStr, false)) { - itemExist->setValue(valAsStr); - unsigned long interval; - jsonRead(payloadStr, F("int"), interval); - itemExist->setInterval(interval); - } - } else { - //добавим событие в базу - IoTItems.push_back((IoTItem*)new externalVariable(payloadStr)); - } - //запустим проверку его в сценариях - generateEvent(id, payloadStr); - SerialPrint("i", F("=>MQTT"), "Received event from other device: '" + devId + "' " + id + " " + payloadStr); - } + // if (!jsonReadBool(settingsFlashJson, "mqttin")) { + // return; + // } + // if (topicStr.indexOf(chipId) == -1) { + // String devId = selectFromMarkerToMarker(topicStr, "/", 2); + // String id = selectFromMarkerToMarker(topicStr, "/", 3); + // IoTItem* itemExist = findIoTItem(id); + // if (itemExist) { + // String valAsStr; + // if (jsonRead(payloadStr, F("val"), valAsStr, false)) { + // itemExist->setValue(valAsStr); + // unsigned long interval; + // jsonRead(payloadStr, F("int"), interval); + // itemExist->setInterval(interval); + // } + // } else { + // //добавим событие в базу + // // IoTItems.push_back((IoTItem*)new externalVariable(payloadStr)); + // } + // //запустим проверку его в сценариях + // generateEvent(id, payloadStr); + // SerialPrint("i", F("=>MQTT"), "Received event from other device: '" + devId + "' " + id + " " + payloadStr); + // } } //здесь мы получаем прямые команды которые сразу выполнятся на этом устройстве diff --git a/src/modules/API.cpp b/src/modules/API.cpp index 23b69a3f..e32991d7 100644 --- a/src/modules/API.cpp +++ b/src/modules/API.cpp @@ -5,7 +5,7 @@ void* getAPI_ButtonIn(String subtype, String params); void* getAPI_ButtonOut(String subtype, String params); void* getAPI_IoTServo(String subtype, String params); void* getAPI_Mp3(String subtype, String params); -void* getAPI_Pwm32(String subtype, String params); +void* getAPI_Pwm8266(String subtype, String params); void* getAPI_Timer(String subtype, String params); void* getAPI_Aht20(String subtype, String params); void* getAPI_AnalogAdc(String subtype, String params); @@ -32,7 +32,7 @@ if ((tmpAPI = getAPI_ButtonIn(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_ButtonOut(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_IoTServo(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Mp3(subtype, params)) != nullptr) return tmpAPI; -if ((tmpAPI = getAPI_Pwm32(subtype, params)) != nullptr) return tmpAPI; +if ((tmpAPI = getAPI_Pwm8266(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Timer(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_Aht20(subtype, params)) != nullptr) return tmpAPI; if ((tmpAPI = getAPI_AnalogAdc(subtype, params)) != nullptr) return tmpAPI;