SSDP added

This commit is contained in:
Dmitry Borisenko
2020-08-28 23:18:18 +03:00
parent 3ab75bcea6
commit 21e7297035
9 changed files with 161 additions and 214 deletions

View File

@@ -1,7 +1,5 @@
#pragma once
#include <Arduino.h>
#include "Class/LineParsing.h"
#include "Class/SensorConverting.h"
#include "Global.h"
@@ -23,16 +21,14 @@ class SensorAnalog : public SensorConverting {
pinInt = pinInt;
value = analogRead(A0);
#endif
//float valueFl = this->mapping(value);
// valueFl = this->correction(valueFl);
value = this->mapping(key, value);
float valueFl = this->correction(key, value);
eventGen(key, "");
jsonWriteFloat(configLiveJson, key, value);
MqttClient::publishStatus(key, String(value));
jsonWriteStr(configLiveJson, key, String(valueFl));
MqttClient::publishStatus(key, String(valueFl));
Serial.println("[I] sensor '" + key + "' data: " + String(value));
Serial.println("[I] sensor '" + key + "' data: " + String(valueFl));
return value;
}
};

View File

@@ -12,8 +12,6 @@ class SensorConverting : public LineParsing {
int mapping(String key, int input) {
String map_ = jsonReadStr(configOptionJson, key + "_map");
if (map_ != "") {
map_.replace("map[", "");
map_.replace("]", "");
input = map(input,
selectFromMarkerToMarker(map_, ",", 0).toInt(),
selectFromMarkerToMarker(map_, ",", 1).toInt(),
@@ -24,11 +22,11 @@ class SensorConverting : public LineParsing {
}
float correction(String key, float input) {
_c.replace("c[", "");
_c.replace("]", "");
float coef = _c.toFloat();
input = input * coef;
String corr = jsonReadStr(configOptionJson, key + "_с");
if (corr != "") {
float coef = corr.toFloat();
input = input * coef;
}
return input;
}
};
//extern SensorConverting* mySensorConverting;
};

View File

@@ -24,6 +24,9 @@ extern void textOutSet();
extern void analogAdc();
extern void analogReading();
extern void ultrasonicCm();
extern void ultrasonicReading();

View File

@@ -38,6 +38,7 @@
#include <time.h>
#include <ArduinoOTA.h>
#ifdef WEBSOCKET_ENABLED
extern AsyncWebSocket ws;
//extern AsyncEventSource events;

5
include/SSDP.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
extern void SsdpInit();
extern String xmlNode(String tags, String data);
extern String decToHex(uint32_t decValue, byte desiredStringLength);