mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 04:19:15 +03:00
UART working condition
This commit is contained in:
@@ -22,5 +22,9 @@
|
|||||||
"snaMqtt": "0",
|
"snaMqtt": "0",
|
||||||
"blink": "1",
|
"blink": "1",
|
||||||
"oneWirePin": "2",
|
"oneWirePin": "2",
|
||||||
"serverip": "http://206.189.49.244"
|
"serverip": "http://206.189.49.244",
|
||||||
|
"uart": "0",
|
||||||
|
"uartS":"9600",
|
||||||
|
"uartTX":"12",
|
||||||
|
"uartRX":"13"
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,16 @@
|
|||||||
{
|
{
|
||||||
"type": "input",
|
"type": "input",
|
||||||
"title": "",
|
"title": "",
|
||||||
"name": "uartTX-arg",
|
"name": "uartRX-arg",
|
||||||
"state": "{{uartRX}}",
|
"state": "{{uartRX}}",
|
||||||
"style": "width:40%;float:right"
|
"style": "width:40%;float:right"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"title": "{{ButSave}}",
|
||||||
|
"style": "width:100%;float:left;",
|
||||||
|
"action": "set?uartS=[[uartS-arg]]&uartTX=[[uartTX-arg]]&uartRX=[[uartRX-arg]]",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "SoftUART.h"
|
#include "SoftUART.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
SoftwareSerial* myUART = nullptr;
|
SoftwareSerial* myUART = nullptr;
|
||||||
@@ -7,10 +8,13 @@ HardwareSerial* myUART = nullptr;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void uartInit() {
|
void uartInit() {
|
||||||
|
if (!jsonReadBool(configSetupJson, "uart")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!myUART) {
|
if (!myUART) {
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
myUART = new SoftwareSerial(4, 5);
|
myUART = new SoftwareSerial(jsonReadInt(configSetupJson, "uartTX"), jsonReadInt(configSetupJson, "uartRX"));
|
||||||
myUART->begin(9600);
|
myUART->begin(jsonReadInt(configSetupJson, "uartS"));
|
||||||
#else
|
#else
|
||||||
myUART = new HardwareSerial(2);
|
myUART = new HardwareSerial(2);
|
||||||
myUART->begin(4, 5);
|
myUART->begin(4, 5);
|
||||||
@@ -19,6 +23,9 @@ void uartInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void uartHandle() {
|
void uartHandle() {
|
||||||
|
if (!jsonReadBool(configSetupJson, "uart")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
static String incStr;
|
static String incStr;
|
||||||
if (myUART->available()) {
|
if (myUART->available()) {
|
||||||
char inc;
|
char inc;
|
||||||
@@ -32,6 +39,12 @@ void uartHandle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void parse(String& incStr) {
|
void parse(String& incStr) {
|
||||||
|
if (incStr.indexOf("set") != -1) {
|
||||||
|
incStr.replace("\r\n", "");
|
||||||
|
incStr.replace("\r", "");
|
||||||
|
incStr.replace("\n", "");
|
||||||
|
incStr = deleteBeforeDelimiter(incStr, " ");
|
||||||
|
SerialPrint("I", "UART", incStr);
|
||||||
|
orderBuf += incStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
26
src/Web.cpp
26
src/Web.cpp
@@ -6,6 +6,7 @@
|
|||||||
#include "items/vLogging.h"
|
#include "items/vLogging.h"
|
||||||
#include "Telegram.h"
|
#include "Telegram.h"
|
||||||
#include "RemoteOrdersUdp.h"
|
#include "RemoteOrdersUdp.h"
|
||||||
|
#include "SoftUART.h"
|
||||||
|
|
||||||
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
|
bool parseRequestForPreset(AsyncWebServerRequest* request, uint8_t& preset) {
|
||||||
if (request->hasArg("preset")) {
|
if (request->hasArg("preset")) {
|
||||||
@@ -255,6 +256,31 @@ void web_init() {
|
|||||||
myNotAsyncActions->make(do_BUSSCAN);
|
myNotAsyncActions->make(do_BUSSCAN);
|
||||||
request->redirect("/?set.utilities");
|
request->redirect("/?set.utilities");
|
||||||
}
|
}
|
||||||
|
if (request->hasArg("uart")) {
|
||||||
|
bool value = request->getParam("uart")->value().toInt();
|
||||||
|
jsonWriteBool(configSetupJson, "uart", value);
|
||||||
|
saveConfig();
|
||||||
|
uartInit();
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
if (request->hasArg("uartS")) {
|
||||||
|
jsonWriteStr(configSetupJson, "uartS", request->getParam("uartS")->value());
|
||||||
|
saveConfig();
|
||||||
|
uartInit();
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
if (request->hasArg("uartTX")) {
|
||||||
|
jsonWriteStr(configSetupJson, "uartTX", request->getParam("uartTX")->value());
|
||||||
|
saveConfig();
|
||||||
|
uartInit();
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
if (request->hasArg("uartRX")) {
|
||||||
|
jsonWriteStr(configSetupJson, "uartRX", request->getParam("uartRX")->value());
|
||||||
|
saveConfig();
|
||||||
|
uartInit();
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
|
||||||
//==============================developer settings=============================================
|
//==============================developer settings=============================================
|
||||||
if (request->hasArg("serverip")) {
|
if (request->hasArg("serverip")) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "items/vCountDown.h"
|
#include "items/vCountDown.h"
|
||||||
#include "items/vSensorUltrasonic.h"
|
#include "items/vSensorUltrasonic.h"
|
||||||
#include "Telegram.h"
|
#include "Telegram.h"
|
||||||
|
#include "SoftUART.h"
|
||||||
|
|
||||||
void not_async_actions();
|
void not_async_actions();
|
||||||
|
|
||||||
@@ -91,6 +92,9 @@ void setup() {
|
|||||||
SerialPrint("I", F("Bus"), F("Bus Init"));
|
SerialPrint("I", F("Bus"), F("Bus Init"));
|
||||||
busInit();
|
busInit();
|
||||||
|
|
||||||
|
SerialPrint("I", F("UART"), F("UART Init"));
|
||||||
|
uartInit();
|
||||||
|
|
||||||
#ifdef SSDP_ENABLED
|
#ifdef SSDP_ENABLED
|
||||||
SerialPrint("I", F("SSDP"), F("Ssdp Init"));
|
SerialPrint("I", F("SSDP"), F("Ssdp Init"));
|
||||||
SsdpInit();
|
SsdpInit();
|
||||||
@@ -155,6 +159,8 @@ void loop() {
|
|||||||
|
|
||||||
handleTelegram();
|
handleTelegram();
|
||||||
|
|
||||||
|
uartHandle();
|
||||||
|
|
||||||
if (myLogging != nullptr) {
|
if (myLogging != nullptr) {
|
||||||
for (unsigned int i = 0; i < myLogging->size(); i++) {
|
for (unsigned int i = 0; i < myLogging->size(); i++) {
|
||||||
myLogging->at(i).loop();
|
myLogging->at(i).loop();
|
||||||
|
|||||||
Reference in New Issue
Block a user