Hi @erik,
I flashed the POE device with the new config.json bootloader to set a static IP, and power cycled the POE Camera but do not see the device via ping or dai.getAllAvailableDevices().
When I try to ping the new IP 172.16.15.201 ping halts and does not even say the host is unreachable. The old IP before flashing was assigned via DHCP as 172.16.15.70 so if I could reach the old IP, I don't see why I couldn't have reached the new one. Do you have any suggestions?
For reference I created a script below (thanks GitHub CoPilot) to create a new JSON file that was used to flash the device via "python3 bootloader_config.py flash new_config.json". bootloader_config.py said the flash was successful.
#!/usr/bin/env python3
# import module to read command line arguments
import argparse
import json
import re
import os
# read json file and return a dictionary
def read_json(json_file):
with open(json_file) as json_data:
d = json.load(json_data)
return d
# convert ipv4 to 32 bit integer
def ipv4_to_int(ipv4):
field1, field2, field3, field4 = ipv4.split(".")
# same as int(field1)*(2**24) + int(field2)*(2**16) + int(field3)*(2**8) + int(field4)
return int(field1) << 24 | int(field2) << 16 | int(field3) << 8 | int(field4)
# read file from command line and check if it exists and if it is a .json file
def read_file(file):
if os.path.isfile(file):
if file.endswith(".json"):
return read_json(file)
else:
print(f"File {file} is not a .json file")
exit(1)
else:
print(f"File {file} does not exist")
exit(1)
# ask for arguments from command line
def get_args():
parser = argparse.ArgumentParser(description="Generate a config file")
parser.add_argument("-f", "--file", default="config.json", help="Path to the .json file")
parser.add_argument("-o", "--output", help="Path to the output file")
args = parser.parse_args()
return args
# ask user for input
def get_input(question, check_ipv4=False, check_bool=False):
user_input = input(question).strip()
if check_ipv4:
while not is_ipv4(user_input):
print("Please enter a valid IPv4 address")
user_input = input(question).strip()
elif check_bool:
while user_input not in ["y", "n"]:
print("Please enter y or n")
user_input = input(question).strip()
return user_input == "y"
return user_input
# check if string is ipv4
def is_ipv4(ipv4):
return re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", ipv4)
def start_configuration():
print("Started Bootloader IPv4 JSON Configuration")
args = get_args()
config = read_file(args.file)
ipv4 = get_input("Enter the IPv4 Address: ", check_ipv4=True)
static = get_input("Is this a static IPv4 Address? (y/n): ", check_bool=True)
netmask = get_input("Enter the IPv4 Netmask: ", check_ipv4=True)
gateway = get_input("Enter the IPv4 Gateway: ", check_ipv4=True)
config["network"]["ipv4"] = ipv4_to_int(ipv4)
config["network"]["staticIpv4"] = static
config["network"]["ipv4Gateway"] = ipv4_to_int(gateway)
config["network"]["ipv4Mask"] = ipv4_to_int(netmask)
if args.output:
with open(args.output, "w") as outfile:
json.dump(config, outfile, indent=4)
print(f"JSON Config Saved to {args.output}")
else:
print("JSON Config Result:")
print(json.dumps(config, indent=4))
if __name__ == "__main__":
start_configuration()
The resulting JSON created was below where ipv4 is 172.16.15.201, ipv4Mask is 255.255.255.0, ipv4Gateway is 172.16.15.254, and staticIpv4 was set to true:
{
"appMem": -1,
"network": {
"ipv4": 2886733769,
"ipv4Dns": 0,
"ipv4DnsAlt": 0,
"ipv4Gateway": 2886733822,
"ipv4Mask": 4294967040,
"ipv6": [
0,
0,
0,
0
],
"ipv6Dns": [
0,
0,
0,
0
],
"ipv6DnsAlt": [
0,
0,
0,
0
],
"ipv6Gateway": [
0,
0,
0,
0
],
"ipv6Prefix": 0,
"mac": [
0,
0,
0,
0,
0,
0
],
"staticIpv4": true,
"staticIpv6": false,
"timeoutMs": 30000
},
"usb": {
"maxUsbSpeed": 3,
"pid": 63036,
"timeoutMs": 3000,
"vid": 999
}
}