FreeCalypso > hg > fc-magnetite
changeset 246:a33da2d26a31
aci3: FreeCalypso +CGSN logic ported over
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 24 Jul 2017 06:18:10 +0000 |
parents | 3b8d291ed45a |
children | 294c26c07561 |
files | src/g23m-aci/aci/ati_bas.c |
diffstat | 1 files changed, 38 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/g23m-aci/aci/ati_bas.c Mon Jul 24 04:41:53 2017 +0000 +++ b/src/g23m-aci/aci/ati_bas.c Mon Jul 24 06:18:10 2017 +0000 @@ -73,6 +73,10 @@ #endif /*FF_ATI_BAT*/ +#include "cl_imei.h" +#include "ksd.h" +#include "cmh_ss.h" + #include "fc-target.cfg" LOCAL T_ATI_RSLT aciPrcsPlusCG (UBYTE srcId, CHAR* cl, CHAR* ef); @@ -2136,9 +2140,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; } /*