#!/opt/lnxall_app/bin/lua local hal = require "lnxhal" local function short_name(hwname) if type(hwname) == "string" and hwname:sub(1, 8) == "WLOSANY_" then return hwname:sub(9) end return hwname end local function detect_platform() local hwt = hal.hw_gettype() local hwname = hal.hw_getname(hwt) if type(hwname) ~= "string" or #hwname == 0 or hwname == "unknown" then return nil end local platobj = { name = short_name(hwname) } local mtab = { poweron = function(self, onoff) return hal.wwan_set_power(onoff) >= 0 end, ison = function(self) return hal.wwan_get_power() == 1 end, netdev = function(self) local ifname = hal.wwan_get_ifname() if type(ifname) == "string" and #ifname > 0 then return ifname end return nil end, } setmetatable(platobj, { __index = mtab }) return platobj end return { ["detect"] = detect_platform }