Merge pull request #470 from ExpidusOS/fix/nil-net

widget.net: fix nil values; closes #469
This commit is contained in:
Luca CPZ 2020-11-05 15:34:42 +00:00 committed by GitHub
commit af9357a6e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -68,13 +68,19 @@ local function factory(args)
dev_now.last_t = now_t
dev_now.last_r = now_r
if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then
if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" then
dev_now.wifi = true
dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil
if string.match(dev_now.carrier, "1") then
dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil
end
else
dev_now.wifi = false
end
if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then
if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" then
dev_now.ethernet = true
else
dev_now.ethernet = false
end
net.devices[dev] = dev_now