начальные изменения

This commit is contained in:
Dmitry Borisenko
2022-08-11 14:50:37 +02:00
parent 0dc05a14d4
commit 6d4b899fc0
5 changed files with 201 additions and 33 deletions

View File

@@ -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

170
myProfile.json Normal file
View File

@@ -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
}
]
}
}

View File

@@ -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]

View File

@@ -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);
// }
}
//здесь мы получаем прямые команды которые сразу выполнятся на этом устройстве

View File

@@ -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;