Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 13 additions & 1 deletion data/config/mosquitto/public/default-dynamic-security.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"anonymousGroup": "anonymous",
"roles": [
{
"rolename": "openwb-version:5",
"rolename": "openwb-version:6",
"textname": "openWB Versionsnummer",
"textdescription": "Diese Rolle ist ein Platzhalter für die openWB Versionsnummer und wird automatisch aktualisiert. Sie hat keine direkten Berechtigungen.",
"acls": []
Expand Down Expand Up @@ -2480,6 +2480,12 @@
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/system/pnp_ip",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientSend",
"topic": "openWB/set/system/secondary_auto_update",
Expand Down Expand Up @@ -2552,6 +2558,12 @@
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/system/pnp_ip",
"priority": 0,
"allow": true
},
{
"acltype": "publishClientReceive",
"topic": "openWB/chargepoint/+/get/version",
Expand Down
3 changes: 2 additions & 1 deletion packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,8 @@ def process_system_topic(self, msg: mqtt.MQTTMessage):
"openWB/set/system/hostname" in msg.topic or
"openWB/set/system/release_train" in msg.topic):
self._validate_value(msg, str)
elif "openWB/set/system/mqtt/bridge/" in msg.topic:
elif ("openWB/set/system/mqtt/bridge/" in msg.topic or
msg.topic == "openWB/set/system/pnp_ip"):
self._validate_value(msg, "json")
elif "openWB/set/system/mqtt/valid_partner_ids" == msg.topic:
self._validate_value(msg, str, collection=list)
Expand Down
16 changes: 16 additions & 0 deletions packages/helpermodules/subdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,22 @@ def process_system_topic(self, client: mqtt.Client, var: dict, msg: mqtt.MQTTMes
# MessageType.SUCCESS
# )
self.set_json_payload(var["system"].data, msg)
elif "openWB/system/pnp_ip" == msg.topic:
new_pnp_ip = decode_payload(msg.payload)
if (
self.event_subdata_initialized.is_set() and
var["system"].data["pnp_ip"] != new_pnp_ip
):
log.warning("Änderung der Einstellung 'pnp_ip' erkannt. "
"Konfiguration wird beim nächsten Neustart angepasst.")
pub_system_message(
msg.payload,
f"Die PnP-IP wird zu <strong>{new_pnp_ip['address']}/{new_pnp_ip['prefix']}</strong> geändert."
"<br />Bitte die openWB <a href=\"/openWB/web/settings/#/System/SystemConfiguration\">"
"neu starten</a>, damit die Änderungen wirksam werden.",
MessageType.WARNING
)
self.set_json_payload(var["system"].data, msg)
elif "openWB/system/security/user_management_active" == msg.topic:
user_management_active = decode_payload(msg.payload)
if (
Expand Down
4 changes: 4 additions & 0 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,10 @@ class UpdateConfig:
"^openWB/system/io/[0-9]+/config$",
"^openWB/system/ip_address$",
"^openWB/system/lastlivevaluesJson$",
"^openWB/system/mac_address$",
"^openWB/system/mqtt/bridge/[0-9]+$",
"^openWB/system/mqtt/valid_partner_ids$",
"^openWB/system/pnp_ip$",
"^openWB/system/release_train$",
"^openWB/system/secondary_auto_update$",
"^openWB/system/security/user_management_active$",
Expand Down Expand Up @@ -658,6 +660,8 @@ class UpdateConfig:
("openWB/system/hostname", "unknown"),
("openWB/system/ip_address", "unknown"),
("openWB/system/mqtt/valid_partner_ids", []),
("openWB/system/mac_address", "unknown"),
("openWB/system/pnp_ip", {"address": "192.168.193.250", "prefix": 24}),
("openWB/system/release_train", "master"),
("openWB/system/secondary_auto_update", True),
("openWB/system/serial_number", get_serial_number()),
Expand Down
37 changes: 33 additions & 4 deletions runs/setup_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,37 @@ function get_mac() {
}

function setup_pnp_network() {
# ToDo: make ip configurable
myVirtualIp="192.168.193.250"
defaultPnpIpAddress="192.168.193.250"
defaultPnpIpPrefix=24
defaultPnpIp="{\"address\": \"$defaultPnpIpAddress\", \"prefix\": $defaultPnpIpPrefix}"
if myPnpIp=$(mosquitto_sub -t "openWB/system/pnp_ip" -p 1886 -C 1 -W 1 --quiet); then
echo "got plug'n'play ip setting: '$myPnpIp'"
else
echo "failed getting plug'n'play ip setting! assuming '$defaultPnpIp'"
myPnpIp="$defaultPnpIp"
fi
if myPnpIpAddress=$(echo "$myPnpIp" | jq -r -e '.address'); then
Comment thread
benderl marked this conversation as resolved.
Resolved
echo "got plug'n'play ip address: '$myPnpIpAddress'"
# check if the address is valid
if ! [[ $myPnpIpAddress =~ ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ ]]; then
echo "invalid plug'n'play ip address! assuming '$defaultPnpIpAddress'"
myPnpIpAddress="$defaultPnpIpAddress"
fi
else
echo "failed getting plug'n'play ip address! assuming '$defaultPnpIpAddress'"
myPnpIpAddress="$defaultPnpIpAddress"
fi
if myPnpIpPrefix=$(echo "$myPnpIp" | jq -r -e '.prefix'); then
echo "got plug'n'play ip prefix: '$myPnpIpPrefix'"
# check if the prefix is valid, prevent using too small prefixes which would cause large network ranges and potential conflicts
if ! [[ $myPnpIpPrefix =~ ^[0-9]+$ ]] || ((myPnpIpPrefix < 8 || myPnpIpPrefix > 32)); then
echo "invalid plug'n'play ip prefix! assuming '$defaultPnpIpPrefix'"
myPnpIpPrefix="$defaultPnpIpPrefix"
fi
else
echo "failed getting plug'n'play ip prefix! assuming '$defaultPnpIpPrefix'"
myPnpIpPrefix="$defaultPnpIpPrefix"
fi
if isSecondary=$(mosquitto_sub -t "openWB/general/extern" -p 1886 -C 1 -W 1 --quiet); then
echo "got 'is secondary' setting: '$isSecondary'"
else
Expand All @@ -60,10 +89,10 @@ function setup_pnp_network() {
fi
if [[ $isSecondary == "true" ]]; then
echo "running as secondary, disabling plug'n'play network on dev $myPrimaryNetDevice"
sudo ip addr del "$myVirtualIp/24" dev "$myPrimaryNetDevice"
sudo ip addr del "$myPnpIpAddress/$myPnpIpPrefix" dev "$myPrimaryNetDevice"
else
echo "running as primary, enabling plug'n'play network on dev $myPrimaryNetDevice"
sudo ip addr add "$myVirtualIp/24" dev "$myPrimaryNetDevice"
sudo ip addr add "$myPnpIpAddress/$myPnpIpPrefix" dev "$myPrimaryNetDevice"
fi
}

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading