I'm using CellStumbler to obtain the iPhone's cell ID, location area code and other information.
After calling getInfo, I'm getting an EXC_BAD_ACCESS and I can't figure out why. This is all undocumented private functions, but certainly someone can help. The problem isn't associated with any of the lines in the function, it's only after running it that it happens.
I'm aware this isn't App Store approvable.
int cellcount;
_CTServerConnectionCellMonitorGetCellCount(&t1,sc,&cellcount);
printf("Cell count: %x\n",cellcount);
printf("Size = %lx\n", sizeof(struct CellInfo));
unsigned char *a=malloc(sizeof(struct CellInfo));
for(b=0;b<cellcount;b++)
{
_CTServerConnectionCellMonitorGetCellInfo(&t1,sc,b,a); memcpy(&cellinfo,a,sizeof(struct CellInfo));
printf("Cell Site: %d, MNC: %d, ",b,cellinfo.servingmnc);
printf("Location: %d, Cell ID: %d, Station: %d, ",cellinfo.location, cellinfo.cellid, cellinfo.station);
printf("Freq: %d, RxLevel: %d, ", cellinfo.freq, cellinfo.rxlevel);
printf("C1: %d, C2: %d\n", cellinfo.c1, cellinfo.c2);
}
if(a) free(a);
This is the getCellInfo function available in the CellStumbler project above. The error occurs after this is called, but not necessarily in this function, only after, as if an after effect of running this is some memory mangling.
I've temporarily solved this problem, by removing the for loop and only running _CTServerConnectionCellMonitorGetCellInfo once.