reworked topic structure added GROUP subtopic

This commit is contained in:
Bogdan Pilyugin 2022-09-29 14:16:25 +02:00
parent cce7f193f6
commit eaf9b47a8e
4 changed files with 86 additions and 93 deletions

View File

@ -1,77 +1,79 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="iconsfont.css">
<script src="main.js"></script>
<script src="res.js"></script>
<title>~name~</title>
</head>
<body>
<script>PageSurround();</script>
<!--========== CONTENTS ==========-->
<main>
<section>
<div class="ml">
<div class="mlp">
<div class="mlpc">
<form name="conf1" method="post">
<div class="mlhdr">SNTP</div>
<table class='cntr'>
<tr><td class='rl'>Включить SNTP клиент</td><td><input type="checkbox" name="sntpen" value="1" ~sntpen~></td></tr>
<tr><td class='rl'>Адрес SNTP сервера:</td><td><input type="text" required size="20" name='tsr' value="~tmsrv~" title="3-32 символов A-Z,a-z,0-9,." pattern="^[0-9a-zA-Z\.]{3,32}$"/></td></tr><tr><td></td></tr><tr><td></td></tr>
</table>
<table class='cntr'>
<tr><td width=90% align='center'>
Установить текущее время вручную:<br/>
<input type='datetime-local' id="curdt">
<button id='sendt' type='button' class ='btn sbtn'>Передать</button><br/><br/><br/>
</td></tr>
</table>
<script>PrintSaveFail('~status_fail~');
PrintSaveBtn('sntp'); PrintApplyBtn('sntp')</script>
</form>
</div>
</div>
<div class="mlp">
<div class="mlpc">
<form name="conf2" method="post">
<div class="mlhdr">MQTT</div>
<table class='cntr'>
<script>PrintCheckBox('Включить MQTT 1','mqttenb1','~mqtten1~',null);
PrintTextInput('URL шлюза сообщений','cld1','~ipcld1~',3,31);
PrintInt('Порт шлюза сообщений','mprt1','~mport1~',1000,65534);
PrintTextInput('ID станции','idd1','~idcld1~',3,31);
PrintTextInput('Корневая тема','top1','~topic1~',3,31);
PrintTextInput('Логин','clnm1','~clname1~',3,31);
PrintTextInput('Пароль','clps1','~clpass1~',3,31);
PrintSep();
if(~ifc_mq2~){
PrintCheckBox('Включить MQTT 2','mqttenb2','~mqtten2~',null);
PrintTextInput('URL шлюза сообщений','cld2','~ipcld2~',3,31);
PrintInt('Порт шлюза сообщений','mprt2','~mport2~',1000,65534);
PrintTextInput('ID станции','idd2','~idcld2~',3,31);
PrintTextInput('Корневая тема','top2','~topic2~',3,31);
PrintTextInput('Логин','clnm2','~clname2~',3,31);
PrintTextInput('Пароль','clps2','~clpass2~',3,31);}</script>
</table>
<script>PrintSaveFail('~status_fail~');
PrintSaveBtn('mqtt'); PrintApplyBtn('mqtt')</script>
</form>
</div>
</div>
</div>
</section>
</main>
<script>
showMenu('header-toggle','navbar');
linkColor.forEach(l => l.addEventListener('click', colorLink))
</script>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="iconsfont.css">
<script src="main.js"></script>
<script src="res.js"></script>
<title>~name~</title>
</head>
<body>
<script>PageSurround();</script>
<!--========== CONTENTS ==========-->
<main>
<section>
<div class="ml">
<div class="mlp">
<div class="mlpc">
<form name="conf1" method="post">
<div class="mlhdr">SNTP</div>
<table class='cntr'>
<tr><td class='rl'>Включить SNTP клиент</td><td><input type="checkbox" name="sntpen" value="1" ~sntpen~></td></tr>
<tr><td class='rl'>Адрес SNTP сервера:</td><td><input type="text" required size="20" name='tsr' value="~tmsrv~" title="3-32 символов A-Z,a-z,0-9,." pattern="^[0-9a-zA-Z\.]{3,32}$"/></td></tr><tr><td></td></tr><tr><td></td></tr>
</table>
<table class='cntr'>
<tr><td width=90% align='center'>
Установить текущее время вручную:<br/>
<input type='datetime-local' id="curdt">
<button id='sendt' type='button' class ='btn sbtn'>Передать</button><br/><br/><br/>
</td></tr>
</table>
<script>PrintSaveFail('~status_fail~');
PrintSaveBtn('sntp'); PrintApplyBtn('sntp')</script>
</form>
</div>
</div>
<div class="mlp">
<div class="mlpc">
<form name="conf2" method="post">
<div class="mlhdr">MQTT</div>
<table class='cntr'>
<script>PrintCheckBox('Enable MQTT 1','mqen1','~mqen1~',null);
PrintTextInput('MQTT broker URL','mqurl1','~mqurl1~',3,31);
PrintInt('MQTT broker port','mqport1','~mqport1~',1000,65534);
PrintTextInput('Global system name','mqsys1','~mqsys1~',3,31);
PrintTextInput('Group name','mqgrp1','~mqgrp1~',3,31);
PrintTextInput('Device ID prefix','mqid1','~mqid1~',3,31);
PrintTextInput('Login','mqname1','~mqname1~',3,31);
PrintTextInput('Password','mqpass1','~mqpass1~',3,31);
PrintSep();
if(~ifc_mq2~){
PrintCheckBox('Enable MQTT 2','mqen2','~mqen2~',null);
PrintTextInput('MQTT broker URL','mqurl2','~mqurl2~',3,31);
PrintInt('MQTT broker port','mqport2','~mqport2~',1000,65534);
PrintTextInput('Global system name','mqsys2','~mqsys2~',3,31);
PrintTextInput('Group name','mqgrp2','~mqgrp2~',3,31);
PrintTextInput('Device ID prefix','mqid2','~mqid2~',3,31);
PrintTextInput('Login','mqname2','~mqname2~',3,31);
PrintTextInput('Password','mqpass2','~mqpass2~',3,31);}</script>
</table>
<script>PrintSaveFail('~status_fail~');
PrintSaveBtn('mqtt'); PrintApplyBtn('mqtt')</script>
</form>
</div>
</div>
</div>
</section>
</main>
<script>
showMenu('header-toggle','navbar');
linkColor.forEach(l => l.addEventListener('click', colorLink))
</script>
</body>
</html>

@ -1 +1 @@
Subproject commit f9576486d104b0e84bedb6f0a7f7c2913548cb73
Subproject commit a813d33168458e4d0492f72b1c1e679dcbe1e084

View File

@ -32,11 +32,7 @@ esp_err_t UserMQTTSendExample(int idx)
{
memcpy(buf, resp, strlen(resp));
DATA_SEND_STRUCT DSS;
ComposeTopic(DSS.topic,
GetSysConf()->mqttStation[idx].RootTopic,
"UPLINK",
GetSysConf()->mqttStation[idx].ClientID,
"USER");
ComposeTopic(DSS.topic, idx, "USER", "UPLINK");
DSS.raw_data_ptr = buf;
DSS.data_length = strlen(resp);
if (xQueueSend(GetMQTTHandlesPool(idx)->mqtt_queue, &DSS, pdMS_TO_TICKS(1000)) == pdPASS)
@ -61,22 +57,14 @@ void UserMQTTEventHndlr(void *handler_args, esp_event_base_t base, int32_t event
switch ((esp_mqtt_event_id_t) event_id)
{
case MQTT_EVENT_CONNECTED:
ComposeTopic(topic,
GetSysConf()->mqttStation[ctx->mqtt_index].RootTopic,
"DWLINK",
GetSysConf()->mqttStation[ctx->mqtt_index].ClientID,
"USER");
ComposeTopic(topic, ctx->mqtt_index, "USER", "DWLINK");
//Subscribe to the service called "USER"
msg_id = esp_mqtt_client_subscribe(client, (const char*) topic, 0);
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
break;
case MQTT_EVENT_DATA:
ComposeTopic(topic,
GetSysConf()->mqttStation[ctx->mqtt_index].RootTopic,
"DWLINK",
GetSysConf()->mqttStation[ctx->mqtt_index].ClientID,
"USER");
ComposeTopic(topic, ctx->mqtt_index, "USER", "DWLINK");
if (!memcmp(topic, event->topic, event->topic_len))
{
//Here data for service called "USER"

View File

@ -1232,6 +1232,8 @@ CONFIG_WEBGUIAPP_PROJECT_VER="0.0.0.0003"
CONFIG_WEBGUIAPP_HOSTNAME="DEVICE_HOSTNAME"
CONFIG_WEBGUIAPP_USERNAME="user"
CONFIG_WEBGUIAPP_USERPASS="password"
CONFIG_MAIN_FUNCTIONAL_BUTTON_GPIO=15
# CONFIG_DEBUG_MODE_ENABLE is not set
#
# SPI settings
@ -1310,7 +1312,8 @@ CONFIG_WEBGUIAPP_MQTT_SERVER_URL="myfirstmqttserver.com"
CONFIG_WEBGUIAPP_MQTT_SERVER_PORT=1883
CONFIG_WEBGUIAPP_MQTT_CLIENT_ID_1="DEVID1"
CONFIG_WEBGUIAPP_MQTT_CLIENT_ID_2="DEVID2"
CONFIG_WEBGUIAPP_MQTT_ROOT_TOPIC="ROOTTOPIC"
CONFIG_WEBGUIAPP_MQTT_SYSTEM_NAME="SYSTEMNAME"
CONFIG_WEBGUIAPP_MQTT_GROUP_NAME="GROUPNAME"
CONFIG_WEBGUIAPP_MQTT_USERNAME="username"
CONFIG_WEBGUIAPP_MQTT_PASSWORD="password"
# end of MQTT settings