proto_qmi.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- Copyright 2016 David Thornley <david.thornley@touchstargroup.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local netmod = luci.model.network
  4. local interface = luci.model.network.interface
  5. local proto = netmod:register_protocol("qmi")
  6. function proto.get_i18n(self)
  7. return luci.i18n.translate("QMI Cellular")
  8. end
  9. function proto.ifname(self)
  10. local base = netmod._M.protocol
  11. local ifname = base.ifname(self) -- call base class "protocol.ifname(self)"
  12. -- Note: ifname might be nil if the adapter could not be determined through ubus (default name to qmi-wan in this case)
  13. if ifname == nil then
  14. ifname = "qmi-" .. self.sid
  15. end
  16. return ifname
  17. end
  18. function proto.get_interface(self)
  19. return interface(self:ifname(), self)
  20. end
  21. function proto.opkg_package(self)
  22. return "uqmi"
  23. end
  24. function proto.is_installed(self)
  25. return nixio.fs.access("/lib/netifd/proto/qmi.sh")
  26. end
  27. function proto.is_floating(self)
  28. return true
  29. end
  30. function proto.is_virtual(self)
  31. return true
  32. end
  33. function proto.get_interfaces(self)
  34. return nil
  35. end
  36. function proto.contains_interface(self, ifc)
  37. return (netmod:ifnameof(ifc) == self:ifname())
  38. end
  39. netmod:register_pattern_virtual("^qmi%-%w")