--- a/src/eric7/MicroPython/Devices/EspDevices.py Thu Feb 23 13:31:55 2023 +0100 +++ b/src/eric7/MicroPython/Devices/EspDevices.py Fri Feb 24 14:11:20 2023 +0100 @@ -685,9 +685,10 @@ 'mac': ubinascii.hexlify(wifi.config('mac'), ':').decode(), } if wifi.active(): - station['txpower'] = wifi.config('txpower') - else: - station['txpower'] = 0 + try: + station['txpower'] = wifi.config('txpower') + except ValueError: + pass print(ujson.dumps(station)) wifi = network.WLAN(network.AP_IF) @@ -701,9 +702,10 @@ 'essid': wifi.config('essid'), } if wifi.active(): - ap['txpower'] = wifi.config('txpower') - else: - ap['txpower'] = 0 + try: + ap['txpower'] = wifi.config('txpower') + except ValueError: + pass print(ujson.dumps(ap)) wifi_status() @@ -1017,7 +1019,7 @@ else: return out.decode("utf-8").strip() == "True", "" - def startAccessPoint(self, ssid, security=None, password=None): + def startAccessPoint(self, ssid, security=None, password=None, ifconfig=None): """ Public method to start the access point interface. @@ -1027,6 +1029,9 @@ @type int (optional) @param password password (defaults to None) @type str (optional) + @param ifconfig IPv4 configuration for the access point if not default + (IPv4 address, netmask, gateway address, DNS server address) + @type tuple of (str, str, str, str) @return tuple containing a flag indicating success and an error message @rtype tuple of (bool, str) """ @@ -1037,21 +1042,23 @@ security = 4 # security >4 cause an error thrown by the ESP32 command = """ -def start_ap(): +def start_ap(ssid, authmode, password, ifconfig): import network ap = network.WLAN(network.AP_IF) ap.active(False) + if ifconfig: + ap.ifconfig(ifconfig) ap.active(True) try: - ap.config(ssid={0}, authmode={1}, password={2}) + ap.config(ssid=ssid, authmode=authmode, password=password) except: - ap.config(essid={0}, authmode={1}, password={2}) + ap.config(essid=ssid, authmode=authmode, password=password) -start_ap() +start_ap({0}, {1}, {2}, {3}) del start_ap """.format( - repr(ssid), security, repr(password) + repr(ssid), security, repr(password), ifconfig ) out, err = self._interface.execute(command, timeout=15000)