Skip to content

Commit

Permalink
20240507
Browse files Browse the repository at this point in the history
Web UI:
- Fix Git install latest version cmd
- Fix reboot timeout modal window
- Adjust min length of MQTT user and password (4-50 symbols now)
- Change "Connected" to "Connection status" (MQTT and VPN cards on root page)
- Fix russian translate Thanks to @artbrayko 🚀 PR #5
- Add file delete option in file browser
- Small translate fixes

Code:
- Add model display over MQTT - use board name
- Add device name display over MQTT - use hostname
- Fix network access when in USB mode with keep web server option
- Add DNS name over WiFi
- Add file delete API cmd
  • Loading branch information
xyzroe committed May 7, 2024
1 parent a0f1444 commit b86f00d
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 88 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build_fw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ jobs:
bin/XZG_${{ steps.get_version.outputs.version }}.ota.bin
bin/XZG_${{ steps.get_version.outputs.version }}.full.bin
- name: Send Telegram Notification about release
run: |
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
-d parse_mode="MarkdownV2" \
-d message_thread_id=14 \
-d text="[${{ steps.get_version.outputs.version }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.version }})" \
-d link_preview_options='{
"show_above_text": true,
"prefer_large_media": false
}'
- name: Checkout releases branch
uses: actions/checkout@v3
with:
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions lib/CCTools/src/CCTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class CommandInterface
{
return "CC2652P";
}
else if (chip_id == 0x3102 && wafer_id == 0xBB41 && pg_rev == 0x3)
{
return "CC2652RB";
}
else
{
static char unknownDescription[50];
Expand Down
29 changes: 14 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <CronAlarms.h>

// NO SSL SUPPORT in current SDK
//#define ASYNC_TCP_SSL_ENABLED 1
// #define ASYNC_TCP_SSL_ENABLED 1

#include "config.h"
#include "web.h"
Expand Down Expand Up @@ -138,7 +138,6 @@ void startServers(bool usb = false)
}
}


/* //not available now
if (vpnCfg.hnEnable)
{
Expand All @@ -165,7 +164,6 @@ void handleTmrNetworkOverseer()
if (WiFi.isConnected())
{
LOGD("WIFI CONNECTED");
startServers();
tmrNetworkOverseer.stop();
}
else
Expand All @@ -185,7 +183,6 @@ void handleTmrNetworkOverseer()
if (vars.connectedEther)
{
LOGD("LAN CONNECTED");
startServers();
tmrNetworkOverseer.stop();
}
else
Expand Down Expand Up @@ -247,7 +244,7 @@ void NetworkEvent(WiFiEvent_t event)
LOGD("%s Connected", ethKey);
break;
case ARDUINO_EVENT_ETH_GOT_IP: // 22: // SYSTEM_EVENT_ETH_GOT_IP:

startServers();
LOGI("%s MAC: %s, IP: %s, Mask: %s, Gw: %s, %dMbps", ethKey,
ETH.macAddress().c_str(),
ETH.localIP().toString().c_str(),
Expand Down Expand Up @@ -278,7 +275,7 @@ void NetworkEvent(WiFiEvent_t event)
}
break;
case ARDUINO_EVENT_WIFI_STA_GOT_IP: // SYSTEM_EVENT_STA_GOT_IP:

startServers();
LOGI("%s MAC: %s, IP: %s, Mask: %s, Gw: %s", wifiKey,
WiFi.macAddress().c_str(),
WiFi.localIP().toString().c_str(),
Expand Down Expand Up @@ -378,14 +375,13 @@ void connectWifi()
}
else
{
WiFi.setHostname(systemCfg.hostname);
LOGD("WiFi.mode(WIFI_STA)");
WiFi.mode(WIFI_STA);
}
delay(100);

WiFi.begin(networkCfg.wifiSsid, networkCfg.wifiPass);
WiFi.setSleep(false);
LOGD("WiFi.begin");

if (!networkCfg.wifiDhcp)
{
Expand All @@ -394,8 +390,11 @@ void connectWifi()
}
else
{
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
LOGD("Try DHCP");
}
WiFi.begin(networkCfg.wifiSsid, networkCfg.wifiPass);
LOGD("WiFi.begin");
}
else
{
Expand Down Expand Up @@ -430,7 +429,7 @@ void mDNS_start()
{
LOGD("mDNS responder started");
//----- WEB ------
mDNS.addService(http, tcp, 80);
mDNS.addService(http, tcp, 80);
//--zeroconf zha--
mDNS.addService(host, tcp, systemCfg.socketPort);
mDNS.addServiceTxt(host, tcp, "version", "1.0");
Expand All @@ -452,13 +451,17 @@ void setupCoordinatorMode()
String workModeString = systemCfg.workMode ? "USB" : "Network";
LOGI("%s", workModeString);

if (systemCfg.workMode != WORK_MODE_USB || systemCfg.keepWeb)
if ((systemCfg.workMode != WORK_MODE_USB) || systemCfg.keepWeb)
{ // start network overseer
if (tmrNetworkOverseer.state() == STOPPED)
{
tmrNetworkOverseer.start();
}
WiFi.onEvent(NetworkEvent);
if (networkCfg.ethEnable)
initLan();
if (networkCfg.wifiEnable)
connectWifi();
}

switch (systemCfg.workMode)
Expand All @@ -470,16 +473,12 @@ void setupCoordinatorMode()
break;
case WORK_MODE_NETWORK:
ledControl.powerLED.mode = LED_BLINK_1Hz;
if (networkCfg.ethEnable)
initLan();
if (networkCfg.wifiEnable)
connectWifi();
break;
default:
break;
}

if (!systemCfg.disableWeb && (systemCfg.workMode != WORK_MODE_USB || systemCfg.keepWeb))
if (!systemCfg.disableWeb && ((systemCfg.workMode != WORK_MODE_USB) || systemCfg.keepWeb))
updWeb = true; // handle web server
if (systemCfg.workMode == WORK_MODE_USB && systemCfg.keepWeb)
connectWifi(); // try 2 connect wifi
Expand Down
3 changes: 2 additions & 1 deletion src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@ void mqttPublishDiscovery()
{
DynamicJsonDocument devInfo(256);
devInfo["ids"] = vars.deviceId;
devInfo["name"] = hwConfig.board;
devInfo["name"] = systemCfg.hostname;
devInfo["mf"] = "XZG";
devInfo["mdl"] = hwConfig.board;
char verArr[25];
const char *env = STRINGIFY(BUILD_ENV_NAME);
sprintf(verArr, "%s (%s)", VERSION, env);
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AUTO GENERATED FILE
#ifndef VERSION
#define VERSION "20240506"
#define VERSION "20240507"
#endif
18 changes: 16 additions & 2 deletions src/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ void handleApi()
API_SEND_HEX,
API_WIFICONNECTSTAT,
API_CMD,
API_GET_LOG //,
// API_FLASH_ZB
API_GET_LOG,
API_DEL_FILE,
API_FLASH_ZB
};
const char *action = "action";
const char *page = "page";
Expand Down Expand Up @@ -771,6 +772,19 @@ void handleApi()
serverWeb.send(HTTP_CODE_OK, contTypeText, result);
}
break;
case API_DEL_FILE:
{
String result = wrongArgs;
const char *argFilename = "filename";
if (serverWeb.hasArg(argFilename))
{
String filename = "/" + serverWeb.arg(argFilename);
LOGW("Remove file %s", filename.c_str());
LittleFS.remove(filename);
}
serverWeb.send(HTTP_CODE_OK, contTypeText, result);
}
break;
case API_GET_PARAM:
{
String resp = wrongArgs;
Expand Down
4 changes: 4 additions & 0 deletions src/websrc/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ body {
color: var(--link-color);
}

.del_icon {
color: red;
}

.status_icon {
width: 25px;
height: 25px;
Expand Down
36 changes: 15 additions & 21 deletions src/websrc/html/PAGE_MQTT.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
</div>
<div class="card-body">
<div class='mb-2 form-check form-switch'>
<label class='form-check-label' for='MqttEnable'
data-i18n="c.enable;p.mq.enb[title]">
<input data-r2v="enableMqtt" id="MqttEnable" class='form-check-input'
type='checkbox' role="switch" name='MqttEnable'
onclick="MqttInputDsbl(!this.checked)">
<label class='form-check-label' for='MqttEnable' data-i18n="c.enable;p.mq.enb[title]">
<input data-r2v="enableMqtt" id="MqttEnable" class='form-check-input' type='checkbox'
role="switch" name='MqttEnable' onclick="MqttInputDsbl(!this.checked)">
</label>
</div>
<div class='mb-2'>
Expand All @@ -26,23 +24,21 @@
</div>
<div class='mb-2'>
<label for='port' data-i18n="p.mq.port.n"></label>
<input data-r2v="portMqtt" class='form-control' id='MqttPort' type='number'
name='MqttPort' min="1025" max="65536"
data-i18n="p.mq.port.ph[placeholder];p.mq.port.tt[title]" required>
<input data-r2v="portMqtt" class='form-control' id='MqttPort' type='number' name='MqttPort'
min="1025" max="65536" data-i18n="p.mq.port.ph[placeholder];p.mq.port.tt[title]"
required>
</div>
<div class='mb-2'>
<label for='user' data-i18n="c.user"></label>
<input data-r2v="userMqtt" class='form-control' id='MqttUser' type='text'
name='MqttUser' minlength="5" maxlength="30"
data-i18n="p.mq.user.ph[placeholder];p.mq.user.tt[title]">
<input data-r2v="userMqtt" class='form-control' id='MqttUser' type='text' name='MqttUser'
minlength="4" maxlength="30" data-i18n="p.mq.user.ph[placeholder];p.mq.user.tt[title]">
</div>
<div class='mb-2'>
<label for='pass' data-i18n="c.pass"></label>
<div class="input-group">
<input type="password" id="MqttPass" data-r2v="passMqtt" class="form-control"
aria-describedby="tglPassViewVisibility" name="MqttPass" minlength="5"
maxlength="50"
data-i18n="p.mq.pass.ph[placeholder];p.mq.pass.tt[title]">
aria-describedby="tglPassViewVisibility" name="MqttPass" minlength="4"
maxlength="50" data-i18n="p.mq.pass.ph[placeholder];p.mq.pass.tt[title]">
<button class="btn inline_btn" type="button" id="tglPassViewVisibility"
onclick="tglPassView(this)">
<svg viewBox="0 0 16 16" class="inline_icon">
Expand All @@ -53,15 +49,14 @@
</div>
<div class='mb-2'>
<label for='topic' data-i18n="p.mq.topic.n"></label>
<input data-r2v="topicMqtt" class='form-control' id='MqttTopic' type='text'
name='MqttTopic' minlength="5" maxlength="50"
pattern="^[a-zA-Z0-9]+([a-zA-Z0-9_\-\/]*[a-zA-Z0-9]+)?$"
<input data-r2v="topicMqtt" class='form-control' id='MqttTopic' type='text' name='MqttTopic'
minlength="5" maxlength="50" pattern="^[a-zA-Z0-9]+([a-zA-Z0-9_\-\/]*[a-zA-Z0-9]+)?$"
data-i18n="p.mq.topic.ph[placeholder];p.mq.topic.tt[title]" required>
</div>
<div class='mb-2'>
<label for='interval' data-i18n="p.mq.interval.n"></label>
<input data-r2v="intervalMqtt" class='form-control' id='MqttInterval' type='number'
min="10" max="36000" name='MqttInterval'
<input data-r2v="intervalMqtt" class='form-control' id='MqttInterval' type='number' min="10"
max="36000" name='MqttInterval'
data-i18n="p.mq.interval.ph[placeholder];p.mq.interval.tt[title]" required>
</div>
<div class='mb-2'>
Expand All @@ -71,8 +66,7 @@
data-i18n="p.mq.reconnect.ph[placeholder];p.mq.reconnect.tt[title]" required>
</div>
<div class='mb-2 form-check form-switch'>
<label class='form-check-label' for='discovery'
data-i18n="p.mq.disc.n;p.mq.disc.tt[title]">
<label class='form-check-label' for='discovery' data-i18n="p.mq.disc.n;p.mq.disc.tt[title]">
<input data-r2v="discoveryMqtt" class='form-check-input' id='MqttDiscovery'
type='checkbox' role="switch" name='MqttDiscovery'>
</label>
Expand Down
4 changes: 2 additions & 2 deletions src/websrc/html/PAGE_ROOT.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<table class="table">
<tbody>
<tr>
<td data-i18n="c.conn"></td>
<td data-i18n="c.cst"></td>
<td data-r2v="mqConnect"></td>
</tr>
<tr>
Expand All @@ -294,7 +294,7 @@
<td data-r2v="wgInit"></td>
</tr>
<tr>
<td data-i18n="c.conn"></td>
<td data-i18n="c.cst"></td>
<td data-r2v="wgConnect"></td>
</tr>
<tr>
Expand Down
2 changes: 2 additions & 0 deletions src/websrc/html/PAGE_TOOLS.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@
<table id="filelist" class="table">
<thead>
<tr>
<th scope="col" class="col-min-width"></th>
<th scope="col" data-i18n="p.to.fn"></th>
<th scope="col" data-i18n="p.to.s"></th>
<th scope="col" class="col-min-width text-end"></th>
</tr>
</thead>
</table>
Expand Down
Loading

0 comments on commit b86f00d

Please sign in to comment.