changeset 370:0da72ce64c86

aci3: AT+CBC reimplemented in terms of FCHG API
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 01 Jan 2018 18:23:11 +0000
parents 65d53dede3b2
children 9a237d51c226
files src/g23m-aci/aci/ati_bas.c
diffstat 1 files changed, 21 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/g23m-aci/aci/ati_bas.c	Mon Jan 01 18:11:24 2018 +0000
+++ b/src/g23m-aci/aci/ati_bas.c	Mon Jan 01 18:23:11 2018 +0000
@@ -78,6 +78,8 @@
 #include "cmh_ss.h"
 
 #include "fc-target.cfg"
+#include "rv/rv_defined_swe.h"     // for RVM_FCHG_SWE
+#include "fchg/fchg_api.h"
 
 LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef);
 LOCAL T_ATI_RSLT setaciPrcsVolLevel ( CHAR* cl, UBYTE device );
@@ -1775,36 +1777,38 @@
 
 GLOBAL T_ATI_RSLT atPlusCBC ( char *cl, UBYTE srcId )
 {
-  pwr_Status_Type powerStat;
+  struct fchg_user_state fchg;
   UBYTE           bcs;
 
   TRACE_FUNCTION("atPlusCBC()");
 
-  if ( pwr_GetStatus ( &powerStat ) NEQ DRV_OK )
-  {
-    cmdCmeError ( CME_ERR_Unknown );
-    return ATI_FAIL;
-  }
-  else
+#ifdef RVM_FCHG_SWE
+  if (fchg_get_current_state(&fchg) == RV_OK)
   {
-    switch ( powerStat.Status )
+    switch (fchg.chg_state)
     {
-      case ( PWR_EXTPOWER_ON ):
-        bcs = ACI_BCS_NoBatt;
-        break;
-
-      case ( PWR_CHARGER_ON ):
+      case FCHG_STATE_CI_CHARGING:
+      case FCHG_STATE_CV_CHARGING:
         bcs = ACI_BCS_BattCnctd;
         break;
 
       default:
         bcs = ACI_BCS_BattPower;
-        break;
     }
-    sprintf(g_sa, "+CBC: %d,%d", bcs, powerStat.ChargeLevel );
-    io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
-	return ATI_CMPL;
+  }
+  else
+  {
+    bcs = ACI_BCS_PowerFault;
+    fchg.batt_percent = 0;
   }
+#else
+  bcs = ACI_BCS_NoBatt;
+  fchg.batt_percent = 0;
+#endif
+
+  sprintf(g_sa, "+CBC: %d,%d", bcs, fchg.batt_percent );
+  io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
+  return ATI_CMPL;
 }
 
 /*