iPhone CellInfo

Discussion in 'iOS Development' started by chrizstone, Feb 19, 2010.

  1. chrizstone

    chrizstone New Member

    Joined:
    Feb 5, 2010
    Messages:
    10
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    Hi Guys, does anyone know how to get the CellInfo like CellID, Signal Strenght and so on in Xcode? I want to build an app like the FieldTest App from apple...
  2. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    Probably you'll need to access and reverse CoreTelephony and/or IOKit.
  3. chrizstone

    chrizstone New Member

    Joined:
    Feb 5, 2010
    Messages:
    10
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    Japp, thats right...But how?
  4. chrizstone

    chrizstone New Member

    Joined:
    Feb 5, 2010
    Messages:
    10
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    Here is my Code: In Xcode there aren´t any Error´s, but when i start it on my iPhone it breaks down suddenly...

    [OBJC]#include "CoreTelephony.h"
    #include <stdio.h>
    #include <CoreFoundation/CoreFoundation.h>
    #include <sys/time.h>
    #import "wfsfsfAppDelegate.h"

    @implementation wfsfsfAppDelegate

    @synthesize window;

    CFMachPortRef port;
    struct CTServerConnection *sc=NULL;
    struct CellInfo cellinfo;
    int b;
    int t1;


    - (void)applicationDidFinishLaunching

    Please Register or Log in to view images

    UIApplication *)application {

    // Override point for customization after application launch
    [window makeKeyAndVisible];

    //field.text = @"iPhone Cell Stumbler";
    //printf("iPhone Cell Stumbler\n");
    cellconnect();
    int cellcount;
    //while(1)
    //{
    getCellInfo();
    //sleep(1);
    //}


    //NSString * integerString = [[NSString alloc] initWithFormat

    Please Register or Log in to view images

    "%d", cellinfo.rxlevel];
    //field.text = integerString;
    }

    /*
    main.c : Hack to CoreTelephony. Most of the peculiarities of the code below is based on obervation.
    */

    /*
    For some reason, all these variables have to be global. Toolchain bug?
    */


    /*
    Never called.
    */
    void callback()
    {
    printf("Callback called\n");
    }

    /*
    Again, _CTServerConnectionCreate() has to be called outside the main(), or whatever is using CTServerConnection.
    Hence the existence of this function.
    */

    void cellconnect()
    {
    int t1;
    sc=_CTServerConnectionCreate(kCFAllocatorDefault, callback, NULL);

    /*
    port is not currently used, shuld be usable with a runloop.
    */
    port=CFMachPortCreateWithPort(kCFAllocatorDefault, _CTServerConnectionGetPort(sc), NULL, NULL, NULL);

    _CTServerConnectionCellMonitorStart(&t1,sc);

    printf("Connected\n");



    }

    void getCellInfo()
    {
    int cellcount;
    _CTServerConnectionCellMonitorGetCellCount(&t1,sc,&cellcount);



    unsigned char *a=malloc(sizeof(struct CellInfo));


    //OMG the toolchain is broken, &cellinfo doesn't work
    _CTServerConnectionCellMonitorGetCellInfo(&t1,sc,b,a); memcpy(&cellinfo,a,sizeof(struct CellInfo));
    //OMG the toolchain is more broken, these printfs don't work on one line
    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);


    }



    - (void)dealloc {
    [window release];
    [super dealloc];
    }


    @end
    [/OBJC]
    ------------------double post merged------------------
    hmm, my Device breaks down at this function:

    [OBJC]_CTServerConnectionCellMonitorStart[/OBJC]
  5. chrizstone

    chrizstone New Member

    Joined:
    Feb 5, 2010
    Messages:
    10
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
  6. lifangjie

    lifangjie New Member

    Joined:
    May 20, 2010
    Messages:
    3
    Likes Received:
    0
    :
    I have the same question with you? Do you have resloved it?

    Please Register or Log in to view images

  7. nwilliams

    nwilliams New Member

    Joined:
    Jun 7, 2010
    Messages:
    3
    Likes Received:
    0
    This is an interesting topic about the iPhone and an interesting cell. This Phone is allowed to the technicians. There is a special field test mode in the iPhone through which you can access the information of the iPhone. It is more comprehensive than any other phone.
  8. lifangjie

    lifangjie New Member

    Joined:
    May 20, 2010
    Messages:
    3
    Likes Received:
    0
    I want to get the information in my application,not only see through the iphone field test.
    ------------------double post merged------------------
    Can some one supply the coretelephony.h file completely?

Share This Page