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> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="iconsfont.css"> <link rel="stylesheet" href="iconsfont.css">
<script src="main.js"></script> <script src="main.js"></script>
<script src="res.js"></script> <script src="res.js"></script>
<title>~name~</title> <title>~name~</title>
</head> </head>
<body> <body>
<script>PageSurround();</script> <script>PageSurround();</script>
<!--========== CONTENTS ==========--> <!--========== CONTENTS ==========-->
<main> <main>
<section> <section>
<div class="ml"> <div class="ml">
<div class="mlp"> <div class="mlp">
<div class="mlpc"> <div class="mlpc">
<form name="conf1" method="post"> <form name="conf1" method="post">
<div class="mlhdr">SNTP</div> <div class="mlhdr">SNTP</div>
<table class='cntr'> <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="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> <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>
<table class='cntr'> <table class='cntr'>
<tr><td width=90% align='center'> <tr><td width=90% align='center'>
Установить текущее время вручную:<br/> Установить текущее время вручную:<br/>
<input type='datetime-local' id="curdt"> <input type='datetime-local' id="curdt">
<button id='sendt' type='button' class ='btn sbtn'>Передать</button><br/><br/><br/> <button id='sendt' type='button' class ='btn sbtn'>Передать</button><br/><br/><br/>
</td></tr> </td></tr>
</table> </table>
<script>PrintSaveFail('~status_fail~'); <script>PrintSaveFail('~status_fail~');
PrintSaveBtn('sntp'); PrintApplyBtn('sntp')</script> PrintSaveBtn('sntp'); PrintApplyBtn('sntp')</script>
</form> </form>
</div> </div>
</div> </div>
<div class="mlp"> <div class="mlp">
<div class="mlpc"> <div class="mlpc">
<form name="conf2" method="post"> <form name="conf2" method="post">
<div class="mlhdr">MQTT</div> <div class="mlhdr">MQTT</div>
<table class='cntr'> <table class='cntr'>
<script>PrintCheckBox('Включить MQTT 1','mqttenb1','~mqtten1~',null); <script>PrintCheckBox('Enable MQTT 1','mqen1','~mqen1~',null);
PrintTextInput('URL шлюза сообщений','cld1','~ipcld1~',3,31); PrintTextInput('MQTT broker URL','mqurl1','~mqurl1~',3,31);
PrintInt('Порт шлюза сообщений','mprt1','~mport1~',1000,65534); PrintInt('MQTT broker port','mqport1','~mqport1~',1000,65534);
PrintTextInput('ID станции','idd1','~idcld1~',3,31); PrintTextInput('Global system name','mqsys1','~mqsys1~',3,31);
PrintTextInput('Корневая тема','top1','~topic1~',3,31); PrintTextInput('Group name','mqgrp1','~mqgrp1~',3,31);
PrintTextInput('Логин','clnm1','~clname1~',3,31); PrintTextInput('Device ID prefix','mqid1','~mqid1~',3,31);
PrintTextInput('Пароль','clps1','~clpass1~',3,31); PrintTextInput('Login','mqname1','~mqname1~',3,31);
PrintSep(); PrintTextInput('Password','mqpass1','~mqpass1~',3,31);
if(~ifc_mq2~){ PrintSep();
PrintCheckBox('Включить MQTT 2','mqttenb2','~mqtten2~',null); if(~ifc_mq2~){
PrintTextInput('URL шлюза сообщений','cld2','~ipcld2~',3,31); PrintCheckBox('Enable MQTT 2','mqen2','~mqen2~',null);
PrintInt('Порт шлюза сообщений','mprt2','~mport2~',1000,65534); PrintTextInput('MQTT broker URL','mqurl2','~mqurl2~',3,31);
PrintTextInput('ID станции','idd2','~idcld2~',3,31); PrintInt('MQTT broker port','mqport2','~mqport2~',1000,65534);
PrintTextInput('Корневая тема','top2','~topic2~',3,31); PrintTextInput('Global system name','mqsys2','~mqsys2~',3,31);
PrintTextInput('Логин','clnm2','~clname2~',3,31); PrintTextInput('Group name','mqgrp2','~mqgrp2~',3,31);
PrintTextInput('Пароль','clps2','~clpass2~',3,31);}</script> PrintTextInput('Device ID prefix','mqid2','~mqid2~',3,31);
</table> PrintTextInput('Login','mqname2','~mqname2~',3,31);
<script>PrintSaveFail('~status_fail~'); PrintTextInput('Password','mqpass2','~mqpass2~',3,31);}</script>
PrintSaveBtn('mqtt'); PrintApplyBtn('mqtt')</script> </table>
</form> <script>PrintSaveFail('~status_fail~');
</div> PrintSaveBtn('mqtt'); PrintApplyBtn('mqtt')</script>
</div> </form>
</div>
</div> </div>
</section>
</main> </div>
<script> </section>
showMenu('header-toggle','navbar'); </main>
linkColor.forEach(l => l.addEventListener('click', colorLink)) <script>
</script> showMenu('header-toggle','navbar');
</body> linkColor.forEach(l => l.addEventListener('click', colorLink))
</script>
</body>
</html> </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)); memcpy(buf, resp, strlen(resp));
DATA_SEND_STRUCT DSS; DATA_SEND_STRUCT DSS;
ComposeTopic(DSS.topic, ComposeTopic(DSS.topic, idx, "USER", "UPLINK");
GetSysConf()->mqttStation[idx].RootTopic,
"UPLINK",
GetSysConf()->mqttStation[idx].ClientID,
"USER");
DSS.raw_data_ptr = buf; DSS.raw_data_ptr = buf;
DSS.data_length = strlen(resp); DSS.data_length = strlen(resp);
if (xQueueSend(GetMQTTHandlesPool(idx)->mqtt_queue, &DSS, pdMS_TO_TICKS(1000)) == pdPASS) 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) switch ((esp_mqtt_event_id_t) event_id)
{ {
case MQTT_EVENT_CONNECTED: case MQTT_EVENT_CONNECTED:
ComposeTopic(topic, ComposeTopic(topic, ctx->mqtt_index, "USER", "DWLINK");
GetSysConf()->mqttStation[ctx->mqtt_index].RootTopic,
"DWLINK",
GetSysConf()->mqttStation[ctx->mqtt_index].ClientID,
"USER");
//Subscribe to the service called "USER" //Subscribe to the service called "USER"
msg_id = esp_mqtt_client_subscribe(client, (const char*) topic, 0); msg_id = esp_mqtt_client_subscribe(client, (const char*) topic, 0);
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id); ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
break; break;
case MQTT_EVENT_DATA: case MQTT_EVENT_DATA:
ComposeTopic(topic, ComposeTopic(topic, ctx->mqtt_index, "USER", "DWLINK");
GetSysConf()->mqttStation[ctx->mqtt_index].RootTopic,
"DWLINK",
GetSysConf()->mqttStation[ctx->mqtt_index].ClientID,
"USER");
if (!memcmp(topic, event->topic, event->topic_len)) if (!memcmp(topic, event->topic, event->topic_len))
{ {
//Here data for service called "USER" //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_HOSTNAME="DEVICE_HOSTNAME"
CONFIG_WEBGUIAPP_USERNAME="user" CONFIG_WEBGUIAPP_USERNAME="user"
CONFIG_WEBGUIAPP_USERPASS="password" CONFIG_WEBGUIAPP_USERPASS="password"
CONFIG_MAIN_FUNCTIONAL_BUTTON_GPIO=15
# CONFIG_DEBUG_MODE_ENABLE is not set
# #
# SPI settings # SPI settings
@ -1310,7 +1312,8 @@ CONFIG_WEBGUIAPP_MQTT_SERVER_URL="myfirstmqttserver.com"
CONFIG_WEBGUIAPP_MQTT_SERVER_PORT=1883 CONFIG_WEBGUIAPP_MQTT_SERVER_PORT=1883
CONFIG_WEBGUIAPP_MQTT_CLIENT_ID_1="DEVID1" CONFIG_WEBGUIAPP_MQTT_CLIENT_ID_1="DEVID1"
CONFIG_WEBGUIAPP_MQTT_CLIENT_ID_2="DEVID2" 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_USERNAME="username"
CONFIG_WEBGUIAPP_MQTT_PASSWORD="password" CONFIG_WEBGUIAPP_MQTT_PASSWORD="password"
# end of MQTT settings # end of MQTT settings