diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index f253ef9b2..352d181e9 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -311,7 +311,13 @@ function Device:retrieveNetworkInfo() std_out:close() end if os.execute("ip r | grep -q default") == 0 then - local pingok = os.execute("ping -q -w 3 -c 2 `ip r | grep default | cut -d ' ' -f 3` > /dev/null") + -- NOTE: No -w flag available in the old busybox build used on Legacy Kindles... + local pingok + if self:isKindle() and self:hasKeyboard() then + pingok = os.execute("ping -q -c 2 `ip r | grep default | cut -d ' ' -f 3` > /dev/null") + else + pingok = os.execute("ping -q -w 3 -c 2 `ip r | grep default | cut -d ' ' -f 3` > /dev/null") + end if pingok == 0 then result = result .. "Gateway ping successful" else diff --git a/frontend/device/kindle/device.lua b/frontend/device/kindle/device.lua index 4183bc7e7..501d07356 100644 --- a/frontend/device/kindle/device.lua +++ b/frontend/device/kindle/device.lua @@ -13,6 +13,11 @@ local function kindleEnableWifi(toggle) if lipc_handle then lipc_handle:set_int_property("com.lab126.cmd", "wirelessEnable", toggle) lipc_handle:close() + else + -- No liblipclua on FW < 5.x ;) + -- Always kill 3G first... + os.execute("lipc-set-prop -i com.lab126.wan enable 0") + os.execute("lipc-set-prop -i com.lab126.wifid enable " .. toggle) end end @@ -27,14 +32,18 @@ local function isWifiUp() status = lipc_handle:get_int_property("com.lab126.wifid", "enable") or 0 lipc_handle:close() else - -- NOTE: Pilfered from Cervantes, c.f., #4380 - -- Possibly race-y, if we're extremely unlucky and lipc drops WiFi between our open and our read... - -- But then, if we're here, it's because we failed to acquire an lipc handle, - -- so it's likely we've failed to do that earlier when trying to toggle WiFi, too... - local file = io.open("/sys/class/net/wlan0/carrier", "rb") - if not file then return 0 end - status = tonumber(file:read("*all")) or 0 - file:close() + local std_out = io.popen("lipc-get-prop -i com.lab126.wifid enable", "r") + if std_out then + local result = std_out:read("*all") + std_out:close() + if result then + return tonumber(result) + else + return 0 + end + else + return 0 + end end return status end diff --git a/frontend/device/kindle/powerd.lua b/frontend/device/kindle/powerd.lua index e723d5ec1..e6225c1b6 100644 --- a/frontend/device/kindle/powerd.lua +++ b/frontend/device/kindle/powerd.lua @@ -92,6 +92,8 @@ end function KindlePowerD:toggleSuspend() if self.lipc_handle then self.lipc_handle:set_int_property("com.lab126.powerd", "powerButton", 1) + else + os.execute("powerd_test -p") end end diff --git a/frontend/ui/network/manager.lua b/frontend/ui/network/manager.lua index bd22626fc..5c3c7301a 100644 --- a/frontend/ui/network/manager.lua +++ b/frontend/ui/network/manager.lua @@ -102,7 +102,12 @@ function NetworkMgr:isConnected() return self:isWifiOn() else -- `-c1` try only once; `-w2` wait 2 seconds - return 0 == os.execute([[ping -c1 -w2 $(/sbin/route -n | awk '$4 == "UG" {print $2}')]]) + -- NOTE: No -w flag available in the old busybox build used on Legacy Kindles... + if Device:isKindle() and Device:hasKeyboard() then + return 0 == os.execute([[ping -c1 $(/sbin/route -n | awk '$4 == "UG" {print $2}')]]) + else + return 0 == os.execute([[ping -c1 -w2 $(/sbin/route -n | awk '$4 == "UG" {print $2}')]]) + end end end