Skip to content

Commit

Permalink
Merge upstream tag 'v24.6.29' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Jul 10, 2024
2 parents e358513 + e541a88 commit d9d0141
Show file tree
Hide file tree
Showing 19 changed files with 369 additions and 315 deletions.
2 changes: 2 additions & 0 deletions include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define NTP_MAX_TIMEZONEDESCR_STRLEN 50

#define MQTT_MAX_HOSTNAME_STRLEN 128
#define MQTT_MAX_CLIENTID_STRLEN 64
#define MQTT_MAX_USERNAME_STRLEN 64
#define MQTT_MAX_PASSWORD_STRLEN 64
#define MQTT_MAX_TOPIC_STRLEN 256
Expand Down Expand Up @@ -161,6 +162,7 @@ struct CONFIG_T {
char Hostname[MQTT_MAX_HOSTNAME_STRLEN + 1];
bool VerboseLogging;
uint32_t Port;
char ClientId[MQTT_MAX_CLIENTID_STRLEN + 1];
char Username[MQTT_MAX_USERNAME_STRLEN + 1];
char Password[MQTT_MAX_PASSWORD_STRLEN + 1];
char Topic[MQTT_MAX_TOPIC_STRLEN + 1];
Expand Down
3 changes: 2 additions & 1 deletion include/MqttSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MqttSettingsClass {
void unsubscribe(const String& topic);

String getPrefix() const;
String getClientId();

private:
void NetworkEvent(network_event event);
Expand All @@ -41,4 +42,4 @@ class MqttSettingsClass {
bool _verboseLogging = true;
};

extern MqttSettingsClass MqttSettings;
extern MqttSettingsClass MqttSettings;
1 change: 1 addition & 0 deletions include/WebApi_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum WebApiError {
MqttHassTopicLength,
MqttHassTopicCharacter,
MqttLwtQos,
MqttClientIdLength,

NetworkBase = 8000,
NetworkIpInvalid,
Expand Down
2 changes: 1 addition & 1 deletion include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define ACCESS_POINT_NAME "OpenDTU-"
#define ACCESS_POINT_PASSWORD "openDTU42"
#define ACCESS_POINT_TIMEOUT 3;
#define ACCESS_POINT_TIMEOUT 3
#define AUTH_USERNAME "admin"
#define SECURITY_ALLOW_READONLY true

Expand Down
24 changes: 9 additions & 15 deletions pio-scripts/auto_firmware_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,27 @@
# Copyright (C) 2022 Thomas Basler and others
#
import os
import pkg_resources

Import("env")

required_pkgs = {'dulwich'}
installed_pkgs = {pkg.key for pkg in pkg_resources.working_set}
missing_pkgs = required_pkgs - installed_pkgs

if missing_pkgs:
try:
from dulwich import porcelain
except ModuleNotFoundError:
env.Execute('"$PYTHONEXE" -m pip install dulwich')

from dulwich import porcelain
from dulwich import porcelain


def updateFileIfChanged(filename, content):
mustUpdate = True
try:
fp = open(filename, "rb")
if fp.read() == content:
mustUpdate = False
fp.close()
with open(filename, "rb") as fp:
if fp.read() == content:
mustUpdate = False
except:
pass
if mustUpdate:
fp = open(filename, "wb")
fp.write(content)
fp.close()
with open(filename, "wb") as fp:
fp.write(content)
return mustUpdate


Expand Down
3 changes: 3 additions & 0 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
#include "Configuration.h"
#include "MessageOutput.h"
#include "NetworkSettings.h"
#include "Utils.h"
#include "defaults.h"
#include <LittleFS.h>
Expand Down Expand Up @@ -115,6 +116,7 @@ bool ConfigurationClass::write()
mqtt["verbose_logging"] = config.Mqtt.VerboseLogging;
mqtt["hostname"] = config.Mqtt.Hostname;
mqtt["port"] = config.Mqtt.Port;
mqtt["clientid"] = config.Mqtt.ClientId;
mqtt["username"] = config.Mqtt.Username;
mqtt["password"] = config.Mqtt.Password;
mqtt["topic"] = config.Mqtt.Topic;
Expand Down Expand Up @@ -427,6 +429,7 @@ bool ConfigurationClass::read()
config.Mqtt.VerboseLogging = mqtt["verbose_logging"] | VERBOSE_LOGGING;
strlcpy(config.Mqtt.Hostname, mqtt["hostname"] | MQTT_HOST, sizeof(config.Mqtt.Hostname));
config.Mqtt.Port = mqtt["port"] | MQTT_PORT;
strlcpy(config.Mqtt.ClientId, mqtt["clientid"] | NetworkSettings.getApName().c_str(), sizeof(config.Mqtt.ClientId));
strlcpy(config.Mqtt.Username, mqtt["username"] | MQTT_USER, sizeof(config.Mqtt.Username));
strlcpy(config.Mqtt.Password, mqtt["password"] | MQTT_PASSWORD, sizeof(config.Mqtt.Password));
strlcpy(config.Mqtt.Topic, mqtt["topic"] | MQTT_TOPIC, sizeof(config.Mqtt.Topic));
Expand Down
11 changes: 10 additions & 1 deletion src/MqttSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void MqttSettingsClass::performConnect()
const CONFIG_T& config = Configuration.get();
_verboseLogging = config.Mqtt.VerboseLogging;
const String willTopic = getPrefix() + config.Mqtt.Lwt.Topic;
const String clientId = NetworkSettings.getApName();
String clientId = getClientId();
if (config.Mqtt.Tls.Enabled) {
static_cast<espMqttClientSecure*>(_mqttClient)->setCACert(config.Mqtt.Tls.RootCaCert);
static_cast<espMqttClientSecure*>(_mqttClient)->setServer(config.Mqtt.Hostname, config.Mqtt.Port);
Expand Down Expand Up @@ -183,6 +183,15 @@ String MqttSettingsClass::getPrefix() const
return Configuration.get().Mqtt.Topic;
}

String MqttSettingsClass::getClientId()
{
String clientId = Configuration.get().Mqtt.ClientId;
if (clientId == "") {
clientId = NetworkSettings.getApName();
}
return clientId;
}

void MqttSettingsClass::publish(const String& subtopic, const String& payload)
{
String topic = getPrefix();
Expand Down
11 changes: 11 additions & 0 deletions src/WebApi_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void WebApiMqttClass::onMqttStatus(AsyncWebServerRequest* request)
root["mqtt_verbose_logging"] = config.Mqtt.VerboseLogging;
root["mqtt_hostname"] = config.Mqtt.Hostname;
root["mqtt_port"] = config.Mqtt.Port;
root["mqtt_clientid"] = MqttSettings.getClientId();
root["mqtt_username"] = config.Mqtt.Username;
root["mqtt_topic"] = config.Mqtt.Topic;
root["mqtt_connected"] = MqttSettings.getConnected();
Expand Down Expand Up @@ -73,6 +74,7 @@ void WebApiMqttClass::onMqttAdminGet(AsyncWebServerRequest* request)
root["mqtt_verbose_logging"] = config.Mqtt.VerboseLogging;
root["mqtt_hostname"] = config.Mqtt.Hostname;
root["mqtt_port"] = config.Mqtt.Port;
root["mqtt_clientid"] = config.Mqtt.ClientId;
root["mqtt_username"] = config.Mqtt.Username;
root["mqtt_password"] = config.Mqtt.Password;
root["mqtt_topic"] = config.Mqtt.Topic;
Expand Down Expand Up @@ -115,6 +117,7 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
&& root.containsKey("mqtt_verbose_logging")
&& root.containsKey("mqtt_hostname")
&& root.containsKey("mqtt_port")
&& root.containsKey("mqtt_clientid")
&& root.containsKey("mqtt_username")
&& root.containsKey("mqtt_password")
&& root.containsKey("mqtt_topic")
Expand Down Expand Up @@ -149,6 +152,13 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
return;
}

if (root["mqtt_clientid"].as<String>().length() > MQTT_MAX_CLIENTID_STRLEN) {
retMsg["message"] = "Client ID must not be longer than " STR(MQTT_MAX_CLIENTID_STRLEN) " characters!";
retMsg["code"] = WebApiError::MqttClientIdLength;
retMsg["param"]["max"] = MQTT_MAX_CLIENTID_STRLEN;
WebApi.sendJsonResponse(request, response, __FUNCTION__, __LINE__);
return;
}
if (root["mqtt_username"].as<String>().length() > MQTT_MAX_USERNAME_STRLEN) {
retMsg["message"] = "Username must not be longer than " STR(MQTT_MAX_USERNAME_STRLEN) " characters!";
retMsg["code"] = WebApiError::MqttUsernameLength;
Expand Down Expand Up @@ -279,6 +289,7 @@ void WebApiMqttClass::onMqttAdminPost(AsyncWebServerRequest* request)
strlcpy(config.Mqtt.Tls.ClientKey, root["mqtt_client_key"].as<String>().c_str(), sizeof(config.Mqtt.Tls.ClientKey));
config.Mqtt.Port = root["mqtt_port"].as<uint>();
strlcpy(config.Mqtt.Hostname, root["mqtt_hostname"].as<String>().c_str(), sizeof(config.Mqtt.Hostname));
strlcpy(config.Mqtt.ClientId, root["mqtt_clientid"].as<String>().c_str(), sizeof(config.Mqtt.ClientId));
strlcpy(config.Mqtt.Username, root["mqtt_username"].as<String>().c_str(), sizeof(config.Mqtt.Username));
strlcpy(config.Mqtt.Password, root["mqtt_password"].as<String>().c_str(), sizeof(config.Mqtt.Password));
strlcpy(config.Mqtt.Lwt.Topic, root["mqtt_lwt_topic"].as<String>().c_str(), sizeof(config.Mqtt.Lwt.Topic));
Expand Down
2 changes: 1 addition & 1 deletion webapp/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default [
"**/*.mts",
],
languageOptions: {
ecmaVersion: 'latest'
ecmaVersion: 2022
},
}
]
16 changes: 8 additions & 8 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
"mitt": "^3.0.1",
"sortablejs": "^1.15.2",
"spark-md5": "^3.0.2",
"vue": "^3.4.27",
"vue": "^3.4.31",
"vue-i18n": "^9.13.1",
"vue-router": "^4.3.3"
"vue-router": "^4.4.0"
},
"devDependencies": {
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@tsconfig/node18": "^18.2.4",
"@types/bootstrap": "^5.2.10",
"@types/node": "^20.14.2",
"@types/node": "^20.14.9",
"@types/pulltorefreshjs": "^0.1.7",
"@types/sortablejs": "^1.15.8",
"@types/spark-md5": "^3.0.4",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^9.4.0",
"eslint": "^9.6.0",
"eslint-plugin-vue": "^9.26.0",
"npm-run-all": "^4.1.5",
"pulltorefreshjs": "^0.1.22",
"sass": "^1.77.4",
"sass": "^1.77.6",
"terser": "^5.31.1",
"typescript": "^5.4.5",
"vite": "^5.2.13",
"typescript": "^5.5.2",
"vite": "^5.3.2",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^3.5.1",
"vue-tsc": "^2.0.21"
"vue-tsc": "^2.0.22"
}
}
2 changes: 1 addition & 1 deletion webapp/src/components/HardwareInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<th>{{ $t('hardwareinfo.CpuFrequency') }}</th>
<td>{{ systemStatus.cpufreq }} {{ $t('hardwareinfo.Mhz') }}</td>
</tr>
<tr>
<tr v-if="systemStatus.cputemp">
<th>{{ $t('hardwareinfo.CpuTemperature') }}</th>
<td>{{ $n(systemStatus.cputemp, 'celsius') }}</td>
</tr>
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"7014": "Hass-Topic darf nicht länger als {max} Zeichen sein!",
"7015": "Hass-Topic darf keine Leerzeichen enthalten!",
"7016": "LWT QOS darf icht größer als {max} sein!",
"7017": "Client ID darf nicht länger als {max} Zeichen sein!",
"8001": "IP-Adresse ist ungültig!",
"8002": "Netzmaske ist ungültig!",
"8003": "Standardgateway ist ungültig!",
Expand Down Expand Up @@ -345,6 +346,7 @@
"Disabled": "nicht aktiv",
"Server": "@:ntpinfo.Server",
"Port": "Port",
"ClientId": "Client ID",
"Username": "Benutzername",
"BaseTopic": "Basis-Topic",
"PublishInterval": "Veröffentlichungsintervall",
Expand Down Expand Up @@ -508,6 +510,7 @@
"Hostname": "Hostname:",
"HostnameHint": "Hostname oder IP-Adresse",
"Port": "Port:",
"ClientId": "Client ID:",
"Username": "Benutzername:",
"UsernameHint": "Benutzername, leer lassen für anonyme Verbindung",
"Password": "Passwort:",
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"7014": "Hass topic must not longer then {max} characters!",
"7015": "Hass topic must not contain space characters!",
"7016": "LWT QOS must not greater then {max}!",
"7017": "Client ID must not longer then {max} characters!",
"8001": "IP address is invalid!",
"8002": "Netmask is invalid!",
"8003": "Gateway is invalid!",
Expand Down Expand Up @@ -347,6 +348,7 @@
"Disabled": "Disabled",
"Server": "@:ntpinfo.Server",
"Port": "Port",
"ClientId": "Client ID",
"Username": "Username",
"BaseTopic": "Base Topic",
"PublishInterval": "Publish Interval",
Expand Down Expand Up @@ -510,6 +512,7 @@
"Hostname": "Hostname:",
"HostnameHint": "Hostname or IP address",
"Port": "Port:",
"ClientId": "Client ID:",
"Username": "Username:",
"UsernameHint": "Username, leave empty for anonymous connection",
"Password": "Password:",
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"7014": "Le sujet Hass ne doit pas dépasser {max} caractères !",
"7015": "Le sujet Hass ne doit pas contenir d'espace !",
"7016": "LWT QOS ne doit pas être supérieur à {max}!",
"7017": "Client ID must not longer then {max} characters!",
"8001": "L'adresse IP n'est pas valide !",
"8002": "Le masque de réseau n'est pas valide !",
"8003": "La passerelle n'est pas valide !",
Expand Down Expand Up @@ -380,6 +381,7 @@
"Disabled": "Désactivé",
"Server": "@:ntpinfo.Server",
"Port": "Port",
"ClientId": "Client ID",
"Username": "Nom d'utilisateur",
"BaseTopic": "Sujet de base",
"PublishInterval": "Intervalle de publication",
Expand Down Expand Up @@ -543,6 +545,7 @@
"Hostname": "Nom d'hôte",
"HostnameHint": "Nom d'hôte ou adresse IP",
"Port": "Port",
"ClientId": "Client ID:",
"Username": "Nom d'utilisateur",
"UsernameHint": "Nom d'utilisateur, laisser vide pour une connexion anonyme",
"Password": "Mot de passe:",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/types/MqttConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface MqttConfig {
mqtt_verbose_logging: boolean;
mqtt_hostname: string;
mqtt_port: number;
mqtt_clientid: string;
mqtt_username: string;
mqtt_password: string;
mqtt_topic: string;
Expand All @@ -23,4 +24,4 @@ export interface MqttConfig {
mqtt_hass_retain: boolean;
mqtt_hass_topic: string;
mqtt_hass_individualpanels: boolean;
}
}
3 changes: 2 additions & 1 deletion webapp/src/types/MqttStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface MqttStatus {
mqtt_verbose_logging: boolean;
mqtt_hostname: string;
mqtt_port: number;
mqtt_clientid: string;
mqtt_username: string;
mqtt_topic: string;
mqtt_publish_interval: number;
Expand All @@ -18,4 +19,4 @@ export interface MqttStatus {
mqtt_hass_retain: boolean;
mqtt_hass_topic: string;
mqtt_hass_individualpanels: boolean;
}
}
4 changes: 4 additions & 0 deletions webapp/src/views/MqttAdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
v-model="mqttConfigList.mqtt_port"
type="number" min="1" max="65535"/>

<InputElement :label="$t('mqttadmin.ClientId')"
v-model="mqttConfigList.mqtt_clientid"
type="text" maxlength="64"/>

<InputElement :label="$t('mqttadmin.Username')"
v-model="mqttConfigList.mqtt_username"
type="text" maxlength="64"
Expand Down
4 changes: 4 additions & 0 deletions webapp/src/views/MqttInfoView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<th>{{ $t('mqttinfo.Port') }}</th>
<td>{{ mqttDataList.mqtt_port }}</td>
</tr>
<tr>
<th>{{ $t('mqttinfo.ClientId') }}</th>
<td>{{ mqttDataList.mqtt_clientid }}</td>
</tr>
<tr>
<th>{{ $t('mqttinfo.Username') }}</th>
<td>{{ mqttDataList.mqtt_username }}</td>
Expand Down
Loading

0 comments on commit d9d0141

Please sign in to comment.