Add basic modem device support

The modem device will have hardcoded capability which make it
compatible with GSM connection settings.
It will be seen with hardcoded ModemManager manager dbus object path
for the UDI property.
Add also a dbus test method to add the modem device.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
This commit is contained in:
Frederic Martinsons
2020-10-27 14:45:31 +01:00
committed by Thomas Haller
parent f225148754
commit a3f596e273

View File

@@ -391,6 +391,7 @@ IFACE_SETTINGS = "org.freedesktop.NetworkManager.Settings"
IFACE_AGENT_MANAGER = "org.freedesktop.NetworkManager.AgentManager"
IFACE_AGENT = "org.freedesktop.NetworkManager.SecretAgent"
IFACE_WIRED = "org.freedesktop.NetworkManager.Device.Wired"
IFACE_MODEM = "org.freedesktop.NetworkManager.Device.Modem"
IFACE_VLAN = "org.freedesktop.NetworkManager.Device.Vlan"
IFACE_WIFI_AP = "org.freedesktop.NetworkManager.AccessPoint"
IFACE_ACTIVE_CONNECTION = "org.freedesktop.NetworkManager.Connection.Active"
@@ -843,8 +844,13 @@ class Device(ExportedObj):
self.prp_state = NM.DeviceState.UNAVAILABLE
if devtype == NM.DeviceType.MODEM:
udi = "/org/freedesktop/ModemManager1/Modem/0"
else:
udi = "/sys/devices/virtual/%s" % iface
props = {
PRP_DEVICE_UDI: "/sys/devices/virtual/%s" % (iface),
PRP_DEVICE_UDI: udi,
PRP_DEVICE_IFACE: iface,
PRP_DEVICE_DRIVER: "virtual",
PRP_DEVICE_STATE: dbus.UInt32(self.prp_state),
@@ -1112,6 +1118,30 @@ class WiredDevice(Device):
pass
###############################################################################
PM_CURRENT_CAPABILITIES = "CurrentCapabilities"
PM_MODEM_CAPABILITIES = "ModemCapabilities"
# capability to make device seen compatible with GSM connection
NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS = 0x00000004
class ModemDevice(Device):
def __init__(self, iface):
Device.__init__(self, iface, NM.DeviceType.MODEM)
props = {
PM_CURRENT_CAPABILITIES: dbus.UInt32(NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS),
PM_MODEM_CAPABILITIES: dbus.UInt32(0),
}
self.dbus_interface_add(IFACE_MODEM, props, ModemDevice.PropertiesChanged)
@dbus.service.signal(IFACE_MODEM, signature="a{sv}")
def PropertiesChanged(self, changed):
pass
###############################################################################
PRP_VLAN_HW_ADDRESS = "HwAddress"
@@ -1807,6 +1837,11 @@ class NetworkManager(ExportedObj):
dev = WiredDevice(ifname, mac, subchannels)
return ExportedObj.to_path(self.add_device(dev))
@dbus.service.method(IFACE_TEST, in_signature="s", out_signature="o")
def AddModemDevice(self, ifname):
dev = ModemDevice(ifname)
return ExportedObj.to_path(self.add_device(dev))
@dbus.service.method(IFACE_TEST, in_signature="s", out_signature="o")
def AddWifiDevice(self, ifname):
dev = WifiDevice(ifname)