Merge "gfch100: add ACM control to UI"
diff --git a/craftui/craftui.py b/craftui/craftui.py
index 1bcd704..d7385d5 100755
--- a/craftui/craftui.py
+++ b/craftui/craftui.py
@@ -257,11 +257,10 @@
     self.api = api
     self.fmt = fmt
 
-  def Configure(self):
+  def CallJson(self, url, payload):
     """Handle a JSON request to glaukusd."""
-    url = 'http://localhost:8080' + self.api
-    payload = self.fmt % self.validator.config
     print 'Glaukus: ', url, payload
+
     try:
       fd = urllib2.urlopen(url, payload)
     except urllib2.URLError as ex:
@@ -275,6 +274,33 @@
         raise ConfigError(j.message)
       raise ConfigError('failed to configure glaukus')
 
+  def Configure(self):
+    url = 'http://localhost:8080' + self.api
+    payload = self.fmt % self.validator.config
+    self.CallJson(url, payload)
+
+
+class GlaukusACM(Glaukus):
+  """Configure glaukus ACM."""
+
+  def __init__(self, validator):
+    super(GlaukusACM, self).__init__(validator, '/unused', 'unused')
+
+  def Configure(self):
+    enable = self.validator.config
+    if enable:
+      url = '/api/modem/acm'
+      payload = '{"rxSensorsEnabled":true,"txSwitchEnabled":true}'
+      self.CallJson(url, payload)
+    else:
+      url = '/api/modem/acm'
+      payload = '{"rxSensorsEnabled":false,"txSwitchEnabled":false}'
+      self.CallJson(url, payload)
+
+      url = '/api/modem/acm/profile'
+      payload = '{"profileIndex":0,"isLocal":true}'
+      self.CallJson(url, payload)
+
 
 class Reboot(Config):
   """Reboot."""
@@ -316,6 +342,8 @@
                               '%s'),
       'palna_on': Glaukus(VTrueFalse, '/api/radio/paLnaPowerEnabled', '%s'),
 
+      'acm_on': GlaukusACM(VTrueFalse),
+
       'reboot': Reboot(VTrueFalse)
   }
   ifmap = {
diff --git a/craftui/sim.tgz b/craftui/sim.tgz
index d3b157d..dba301f 100644
--- a/craftui/sim.tgz
+++ b/craftui/sim.tgz
Binary files differ
diff --git a/craftui/www/config.thtml b/craftui/www/config.thtml
index 7f87c26..5a3d96a 100644
--- a/craftui/www/config.thtml
+++ b/craftui/www/config.thtml
@@ -200,6 +200,15 @@
               <span id=mode_hi_result>...</span>
 
           <tr>
+            <td><b>ACM enabled
+            <td align=right><span id="modem/status/acmEngineRxSensorsEnabled">...</span>
+            <td>
+              <input id=acm_on type=text value="">
+              <input type=submit value=Configure onclick="CraftUI.config('acm_on')">
+            <td>
+              <span id=acm_on_result>...</span>
+
+          <tr>
             <td><b>Transmit Power (dB x 100)
             <td align=right><span id="radio/tx/paPowerSet">...</span>
             <td>