×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    26

    Country Code of current position/location

    Hi!

    I need to get the country code of the current location/position. Since obtaining the GPS position (and obtaining the countrycode from the QGeoAddress) tends to be too slow / not reliable (what happens if the user is indoors?) I was thinking of using QSystemNetworkInfo to get the info from there.

    Unfortunately I get only empty strings when using QSystemNetworkInfo on my Nokia C7 (+ Qt 4.7.3, Qt Mobility 1.1.3). See code below ...

    Code:
        QSystemNetworkInfo *m_networkInfo = new QSystemNetworkInfo(this);
        QString str = " cc:" + m_networkInfo->currentMobileCountryCode()
                + " nc:" + m_networkInfo->currentMobileNetworkCode()
                + " cid:" + QString::number(m_networkInfo->cellId())
                + " lac:" +QString::number(m_networkInfo->locationAreaCode());
    Are there any known issues regarding this API? Anything wrong with the code above?

    Thanks in advance!
    -Rob

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Country Code of current position/location

    from MCC and MNC of SIMCard QSystemDeviceInfo::imsi() then match it to a local DB but that at most can give you a country but not very accurate.. for that you need to use location APIs for sure.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    26

    Re: Country Code of current position/location

    Thanks for the quick response, but I don't see how the IMSI can solve my issue as the IMSI is a "An International Mobile Subscriber Identity or IMSI (play /ˈɪmziː/) is a unique identification associated with all GSM and UMTS network mobile phone users." Hence , the IMSI will always remain the same regardless in which country the user/device is located, right?

    "but that at most can give you a country"
    => That's actually all I need: the country the user is currently located in.

    Found this bug also http://bugreports.qt.nokia.com/browse/QTMOBILITY-615 But it was supposed to be fixed in Qt Mobility 1.1.1 (I am using 1.1.3)
    -Rob

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Country Code of current position/location

    AFAIK IMSI it is unique but will keep on changing when you roam

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,569

    Re: Country Code of current position/location

    Quote Originally Posted by skumar_rao View Post
    AFAIK IMSI it is unique but will keep on changing when you roam
    The IMSI is the SIM card's serial number (International Mobile Subscriber Identifier, GSM numbering plan E.212) and does not change. It is what is used to identify who the SIM user is (or, rather, who pays the phone bill for the SIM card).

    When roaming the IMSI doesn't change, but the MCC + MNC for routing the traffic correctly changes to the location country and network (E.214 numbering plan).

    http://www.mib.net.ua/2008/03/gsm-nu...-plans-en.html

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    376

    Re: Country Code of current position/location

    This is the complete list of MNC MCC code you may require http://en.wikipedia.org/wiki/Mobile_Network_Code

  7. #7
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Country Code of current position/location

    Quote Originally Posted by petrib View Post
    The IMSI is the SIM card's serial number (International Mobile Subscriber Identifier, GSM numbering plan E.212) and does not change. It is what is used to identify who the SIM user is (or, rather, who pays the phone bill for the SIM card).

    When roaming the IMSI doesn't change, but the MCC + MNC for routing the traffic correctly changes to the location country and network (E.214 numbering plan).

    http://www.mib.net.ua/2008/03/gsm-nu...-plans-en.html
    is not the IMSI's 1st 3 digits are MCC and afther that 3 digits are MNC

  8. #8
    Registered User
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    26

    Re: Country Code of current position/location

    Thanks for your efforts guys! I solved the issue ...

    Solution in short: QSystemNetworkInfo needs capability READDEVICEDATA in order to 'work' (work == return non-empty strings/values)

    Solution in detail:
    I had to dig into the QtMobility Symbian code that sets the country code string to find the answer:

    Code:
    void CCellNetworkInfo::RunL()
    {
    TRACES (qDebug() << "CCellNetworkInfo::RunL<---");
        if (m_initializing) {
            CTelephonyInfo::RunL();
            m_initializing = false;
        } else {
            if (iStatus != KErrNone) return; //To avoid looping if app doesn't have ReadDeviceData caps
            m_cellId = m_networkInfoV1.iCellId;
            m_locationAreaCode = m_networkInfoV1.iLocationAreaCode;
            TBuf<CTelephony::KNetworkIdentitySize> networkId = m_networkInfoV1.iNetworkId;
                m_networkId = QString::fromUtf16(networkId.Ptr(), networkId.Length());
            TBuf<CTelephony::KNetworkCountryCodeSize> countryCode = m_networkInfoV1.iCountryCode;
                m_countryCode = QString::fromUtf16(countryCode.Ptr(), countryCode.Length());
    m_countryCode is not set if the application doesnt have the ReadDeviceData capabilty.
    -Rob

  9. #9
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,569

    Re: Country Code of current position/location

    Quote Originally Posted by skumar_rao View Post
    is not the IMSI's 1st 3 digits are MCC and afther that 3 digits are MNC
    They arethe country and network code for the operator whose SIM card it is.

    Then in a roaming case, the IMSI per-se does not change (it is fixed), but the current MCC and MNC are changed so that calls/messages/data is routed correctly. Read the article I posted the link to.

    More also on wikipedia:

    http://en.wikipedia.org/wiki/IMSI
    http://en.wikipedia.org/wiki/E.164
    http://en.wikipedia.org/wiki/E.214

  10. #10
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Country Code of current position/location

    Thanks, i stand corrected.

Similar Threads

  1. Replies: 2
    Last Post: 2010-06-23, 11:33
  2. How to get current country code?
    By SymbianTH in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2009-07-23, 11:17
  3. Replies: 2
    Last Post: 2008-12-17, 09:39
  4. How to get the country code or country name
    By gpalvia in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-02-26, 18:18
  5. Current Location of Phone
    By amitaggarwal in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-10-02, 07:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×