Search code examples
adafruit-circuitpython

circuitpython set_ipv4_address issue pico w


Getting the following error on set_ipv4_address line:

TypeError: extra positional arguments given

Code is below. Creating ipaddress objects as specified in the documentation for the wifi module. ipaddress objects are created correctly.

dic = {}
with open('PCATS_WID_CONFIG.ini') as f:
lines = f.readlines()
for line in lines:
if line[0] is not '#':
line = line.strip()
key = line.split(':')[0].lower()
value = line.split(': ')[1]
dic[key] = value

ip = ipaddress.ip_address(dic["ip"])
netmask = ipaddress.ip_address(dic["netmask"])
gateway = ipaddress.ip_address(dic["gateway"])
#print(ip,netmask,gateway)

wifi.radio.set_ipv4_address(ip,netmask,gateway) # LINE ERROR OCCURS ON
wifi.radio.connect(dic["ssid"],dic["password"])

Solution

  • ipv4 =  ipaddress.IPv4Address("192.168.1.101")
    netmask =  ipaddress.IPv4Address("255.255.255.0")
    gateway =  ipaddress.IPv4Address("192.168.1.1")
    wifi.radio.set_ipv4_address(ipv4=ipv4,netmask=netmask,gateway=gateway)