pseudomodem: Implement org.freedesktop.ModemManager1.Modem.SetPowerState
This CL implements the SetPowerState method and PowerState property for
interface org.freedesktop.ModemManager1.Modem.
BUG=chromium-os:38897
TEST=Run pseudomodem. Should be able to set power state via DBus
commands.
Change-Id: I45860db432b37a5d87236d9c084343db0e647caf
Reviewed-on: https://gerrit.chromium.org/gerrit/43242
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Arman Uguray <armansito@chromium.org>
Tested-by: Arman Uguray <armansito@chromium.org>
diff --git a/client/cros/cellular/pseudomodem/enable_machine.py b/client/cros/cellular/pseudomodem/enable_machine.py
index e10d9a1..1790636 100644
--- a/client/cros/cellular/pseudomodem/enable_machine.py
+++ b/client/cros/cellular/pseudomodem/enable_machine.py
@@ -21,6 +21,9 @@
assert self._modem.disable_step is None
assert self._modem.connect_step is None
assert self._modem.disconnect_step is None
+ logging.info('EnableMachine: Setting power state to ON')
+ self._modem.SetUInt32(mm1.I_MODEM, 'PowerState',
+ mm1.MM_MODEM_POWER_STATE_ON)
logging.info('EnableMachine: Setting state to ENABLING')
reason = mm1.MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED
self._modem.ChangeState(mm1.MM_MODEM_STATE_ENABLING, reason)
diff --git a/client/cros/cellular/pseudomodem/mm1.py b/client/cros/cellular/pseudomodem/mm1.py
index 0f2791c..fd61567 100644
--- a/client/cros/cellular/pseudomodem/mm1.py
+++ b/client/cros/cellular/pseudomodem/mm1.py
@@ -302,6 +302,12 @@
def ModemStateToString(state):
return MODEM_STATE_STRINGS[state + 1]
+# enum MMModemPowerState
+MM_MODEM_POWER_STATE_UNKNOWN = 0
+MM_MODEM_POWER_STATE_OFF = 1
+MM_MODEM_POWER_STATE_LOW = 2
+MM_MODEM_POWER_STATE_ON = 3
+
# enum MMModemStateChangeReason
MM_MODEM_STATE_CHANGE_REASON_UNKNOWN = 0
MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED = 1
diff --git a/client/cros/cellular/pseudomodem/modem.py b/client/cros/cellular/pseudomodem/modem.py
index bef575f..8491690 100644
--- a/client/cros/cellular/pseudomodem/modem.py
+++ b/client/cros/cellular/pseudomodem/modem.py
@@ -14,7 +14,6 @@
import dbus_std_ifaces
import disable_machine
import enable_machine
-import gobject
import logging
import mm1
import modem_simple
@@ -100,6 +99,7 @@
[dbus.types.UInt32(100), True],
signature='ub'),
'OwnNumbers' : ['5555555555'],
+ 'PowerState' : dbus.types.UInt32(mm1.MM_MODEM_POWER_STATE_ON),
# specified by subclass:
'ModemCapabilities' :
@@ -289,6 +289,10 @@
def Command(self, cmd, timeout):
return 'Bananas are tasty and fresh.'
+ @dbus.service.method(mm1.I_MODEM, in_signature='u')
+ def SetPowerState(self, power_state):
+ self.SetUInt32(mm1.I_MODEM, 'PowerState', power_state);
+
@dbus.service.signal(mm1.I_MODEM, signature='iiu')
def StateChanged(self, old, new, reason):
logging.info('Modem state changed from %u to %u for reason %u',