JamFfm / cbpi4-LCDisplay

This is the LCDisplay for CraftBeerPi4
GNU General Public License v3.0
2 stars 2 forks source link

Problem with get_ip if wlan is not connected #1

Closed avollkopf closed 3 years ago

avollkopf commented 3 years ago

I experienced this already with the cbpi3 version when I connected the pi to ethernet and disabled the wlan connection.

Although the get_ip function has a try, the issue appears because there is no except. By adding the except, the issue is solved. WLAN returns with 'Not connected' and the scrit moves on the eth0

    async def get_ip(self, interface):
        ip_addr = 'Not connected'
        so = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        try:
            ip_addr = socket.inet_ntoa(
                fcntl.ioctl(so.fileno(), 0x8915, struct.pack('256s', bytes(interface.encode())[:15]))[20:24])
        except:
            return ip_addr        
        finally:
            return ip_addr
JamFfm commented 3 years ago

Thanks its now build in.