FreeCalypso > hg > fc-magnetite
changeset 228:d2cbdbffc528
aci2: FreeCalypso +CGSN logic implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 16 Nov 2016 05:28:00 +0000 |
parents | 763120534e54 |
children | 27b356aa0e5d |
files | src/aci2/aci/ati_bas.c |
diffstat | 1 files changed, 37 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aci2/aci/ati_bas.c Wed Oct 26 02:45:19 2016 +0000 +++ b/src/aci2/aci/ati_bas.c Wed Nov 16 05:28:00 2016 +0000 @@ -73,6 +73,9 @@ #endif /*FF_ATI_BAT*/ +#include "cl_imei.h" +#include "cmh_ss.h" + #include "fc-target.cfg" LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef); @@ -2107,9 +2110,42 @@ */ GLOBAL T_ATI_RSLT atPlusCGSN ( char *cl, UBYTE srcId ) { + int i; + UBYTE IMEIBuf[CL_IMEI_SIZE]; /* IMEI buffer */ + T_ACI_IMEI imei; + TRACE_FUNCTION("atPlusCGSN()"); - return aciPrcsPlusCG (srcId, cl, EF_CGSN_ID); + /* + * New FreeCalypso logic: + * + * look for /pcm/CGSN first, using direct FFS API rather than PCM; + * if /pcm/CGSN is present, return the string stored in there; + * if no /pcm/CGSN, return 15-digit IMEI with computed check digit. + */ + + i = ffs_file_read("/pcm/CGSN", (UBYTE *)g_sa, SIZE_EF_CGSN); + if (i > 0) + g_sa[i] = '\0'; + else { + cl_get_imeisv(CL_IMEI_SIZE, IMEIBuf, CL_IMEI_GET_STORED_IMEI); + imei.tac1 = IMEIBuf[0]; + imei.tac2 = IMEIBuf[1]; + imei.tac3 = IMEIBuf[2]; + imei.fac = IMEIBuf[3]; + imei.snr1 = IMEIBuf[4]; + imei.snr2 = IMEIBuf[5]; + imei.snr3 = IMEIBuf[6]; + imei.svn = IMEIBuf[7]; + imei.cd = cmhSS_getCdFromImei ( &imei ); + sprintf(g_sa, "%02x%02x%02x%02x%02x%02x%02x%d", + imei.tac1, imei.tac2, imei.tac3, imei.fac, + imei.snr1, imei.snr2, imei.snr3, imei.cd); + } + + io_sendMessage (srcId, g_sa, ATI_NORMAL_OUTPUT); + + return ATI_CMPL; } /*