| | 71 | |
| | 72 | function dev.cfgvalue(self, section) |
| | 73 | return m.uci:get("system", section, "dev") |
| | 74 | end |
| | 75 | |
| | 76 | function dev.write(self, section, value) |
| | 77 | m.uci:set("system", section, "dev", value) |
| | 78 | end |
| | 79 | |
| | 80 | function dev.remove(self, section) |
| | 81 | local t = trigger:formvalue(section) |
| | 82 | if t ~= "netdev" and t ~= "usbdev" then |
| | 83 | m.uci:delete("system", section, "dev") |
| | 84 | end |
| | 85 | end |
| | 86 | |
| | 101 | |
| | 102 | usbdev = s:option(ListValue, "_usb_dev", translate("USB Device")) |
| | 103 | usbdev:depends("trigger", "usbdev") |
| | 104 | usbdev.rmempty = true |
| | 105 | usbdev:value("") |
| | 106 | |
| | 107 | function usbdev.cfgvalue(self, section) |
| | 108 | return m.uci:get("system", section, "dev") |
| | 109 | end |
| | 110 | |
| | 111 | function usbdev.write(self, section, value) |
| | 112 | m.uci:set("system", section, "dev", value) |
| | 113 | end |
| | 114 | |
| | 115 | function usbdev.remove(self, section) |
| | 116 | local t = trigger:formvalue(section) |
| | 117 | if t ~= "netdev" and t ~= "usbdev" then |
| | 118 | m.uci:delete("system", section, "dev") |
| | 119 | end |
| | 120 | end |
| | 121 | |
| | 122 | for p in nixio.fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer") do |
| | 123 | local id = p:match("%d+-%d+") |
| | 124 | local mf = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/manufacturer") |
| | 125 | local pr = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/product") |
| | 126 | usbdev:value(id, "%s (%s - %s)" %{ id, mf, pr }) |
| | 127 | end |
| | 128 | |