[Bug]: Problems with network.ipv4Config.ip generally
Before submitting
- [x] I have searched existing issues to make sure this bug hasn't already been reported
- [x] I have updated to the latest version of the software to verify the issue still exists
- [x] I have cleared cache/cookies/storage or tried in a private/incognito window (if applicable)
Hardware
Heltec V3
Connection Type
HTTP
Local or Hosted
http://meshtastic.local
Firmware Version
v2.6.4.b89355f
Operating System
Ubuntu 24.04.2 LTS
Browser
Chrome Version 134.0.6998.165 (Official Build) (64-bit)
Expected Behavior
I want to start with a fresh device and configure it with a static IP of 192.168.1.201.
A freshly flashed Heltec V3 will be receptive to a serial connection from either my PC or Android phone.
From an Ubuntu PC, I run the following bash script.
meshtastic --port --set lora.region "US"
sleep 15s
meshtastic --port \
--set-owner-short "CE44"\
--set network.wifiSsid '█████████' \
--set network.wifiPsk ███████ \
--set network.addressMode DHCP \
--set network.wifiEnabled true \
--set network.ntpServer meshtastic.pool.ntp.org \
--reboot > ~/Documents/personal/ham/Pluto/B4F8.mt
sleep 15s
meshtastic --port \
--set network.ethEnabled true \
--set network.ipv4Config.ip 3540101334 \
--set network.ipv4Config.dns 16885952 \
--set network.ipv4Config.subnet 16777215 \
--set network.ipv4Config.gateway 16885952 \
--reboot > ~/Documents/personal/ham/Pluto/B4F8.mt
After that, I should be able to use the webui > Config > network window to alter addressMode and ipv4Config.ip. After I click the Save icon, I should get a "Delivery confirmed" notification.
In the alternative, I should able to run either of these two commands:
meshtastic --host 192.168.1.45 --set network.addressMode STATIC
meshtastic --port --set network.ipv4Config.ip 3540101334 --set network.addressMode STATIC
Actual Behavior
When I use the webui > Config > network window to alter addressMode and ipv4Config.ip and click the Save icon, I should get a "Delivery confirmed" notification. If I click to Message and return to Network, the old values DHCP and <IP> are still there.
When I run either of these two commands
meshtastic --host 192.168.1.45 --set network.addressMode STATIC
meshtastic --port --set network.ipv4Config.ip 3540101334 --set network.addressMode STATIC
I get notification of success. then Iwait for a half a minute for the device to reboot and join the network, nothing doing. A scan of the network does not show the device.
I can successfully use an Android device connected by USB-C to (first) change the mode to STATIC while leaving the IP address the same as assigned by the router, then (second) change the IP address to what I want.
Steps to Reproduce
(1) start with a freshly flashed Heltec V3. Firware v2.6.4.b89355f
(2) run this script:
meshtastic --port --set lora.region "US"
sleep 15s
meshtastic --port \
--set-owner-short "CE44"\
--set network.wifiSsid '█████████' \
--set network.wifiPsk ███████ \
--set network.addressMode DHCP \
--set network.wifiEnabled true \
--set network.ntpServer meshtastic.pool.ntp.org \
--reboot > ~/Documents/personal/ham/Pluto/B4F8.mt
sleep 15s
meshtastic --port \
--set network.ethEnabled true \
--set network.ipv4Config.ip 3540101334 \
--set network.ipv4Config.dns 16885952 \
--set network.ipv4Config.subnet 16777215 \
--set network.ipv4Config.gateway 16885952 \
--reboot > ~/Documents/personal/ham/Pluto/B4F8.mt
Try to use the webui to change mode from DHCP to STATIC.
Relevant console output
Screenshots
No response
Additional Context
"network": {
"wifiEnabled": true,
"wifiSsid": "████████████",
"wifiPsk": "████████████",
"ntpServer": "meshtastic.pool.ntp.org",
"ethEnabled": true,
"ipv4Config": {
"ip": 3540101334,
"gateway": 16885952,
"subnet": 16777215,
"dns": 16885952
},
"addressMode": "DHCP",
"rsyslogServer": "",
"enabledProtocols": 0
},
As to IP address conversion to integer, I don't remember when I learned this; it may be wrong.
The standard method of converting an IPv4 address strin in the form a.b.c.d to uint32 is:
a * 256^3 + b * 256^2 + c * 256^1 * d *256^0
The Meshtastic method to convert the string form of
network.ipv4Config.ip network.ipv4Config.gateway network.ipv4Config.subnet network.ipv4Config.dns
to uint32 is
a * 256^0 + b * 256^1 + c * 256^2 * d *256^3
If you are writing a CLI script, unless you know this in advance, you need to use another interface, then copy the result from CLI --info or config.yaml to your own work.
Here's how I do it in python:
import ipaddress
def setup_network(iface):
nw = iface.localNode.localConfig.network
addr_mode = 1 # 1 is static
ip = '192.168.1.163'
gw = '192.168.1.150'
subnet = '255.255.255.0'
dns = '8.8.8.8'
# reverse the octets for meshtastic
ip = '.'.join(ip.split('.')[::-1])
gw = '.'.join(gw.split('.')[::-1])
subnet = '.'.join(subnet.split('.')[::-1])
dns = '.'.join(dns.split('.')[::-1])
nw.address_mode = addr_mode
nw.ipv4_config.ip = int(ipaddress.IPv4Address(ip))
nw.ipv4_config.gateway = int(ipaddress.IPv4Address(gw))
nw.ipv4_config.subnet = int(ipaddress.IPv4Address(subnet))
nw.ipv4_config.dns = int(ipaddress.IPv4Address(dns))
nw.ipv6_enabled = False
nw.ntp_server = 'meshtastic.pool.ntp.org'
nw.wifi_enabled = True
nw.wifi_ssid = 'xxxxxx'
nw.wifi_psk = 'xxxxxx'
nw.rsyslog_server = ''
# iface.localNode.writeConfig(config_name='network') # reboots
return