×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    How to do network connection the proper way?

    I'm been struggling with network connection on the Symbian device (I'm currently testing it an a N8). I can get the network connection on the Qt Simulator just fine (also Maemo works), but not on the N8 nor different remote devices (like the N97).

    I've been trying to find a wiki page or something that would give a sample how to do network connection properly on a Symbian device with Qt, but I haven't found any good ones. Can anyone please point me to a page?

    What I need is this:
    1. Find out if there is an existing connection
    2. If not, check that the device is not in Offline mode
    3. If not, establish connection
    4. Check for connection errors


    Cheers

  2. #2
    Registered User
    Join Date
    Aug 2009
    Posts
    173

    Re: How to do network connection the proper way?

    Which way you want to do your network connection.

    By http or with tcp protocol.

    Do you want to connect with your application on internet
    (as http:///www... way) or on the local network as (connect to
    local ip as : 192.168.1.1:4444) or how.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    Quote Originally Posted by teknikko View Post
    Which way you want to do your network connection.

    By http or with tcp protocol.

    Do you want to connect with your application on internet
    (as http:///www... way) or on the local network as (connect to
    local ip as : 192.168.1.1:4444) or how.
    I'm using normal http protocol to get data from the internet. But it's the connection manager thing I'm interested in. To see if the device is already connected to the internet or should a connection be opened.

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    173

    Re: How to do network connection the proper way?

    With my E71 device, i have found, that when i am connected with browser to internet
    allready with my E71 device, the device is not asking any more about connection
    procedures when i am connected to "internet" or to "local network" with my own made application.

    But as you are using http protocol to connect to "internet", i am not able to help
    you on your case.

    "With socket you are able to connect any where from your phone as :192.168.1.55",
    as far you just know the "numerical" ip address where to connect from you phone.

    Sure, local differencies are between local carriers (=telephone or internet operators).
    Last edited by teknikko; 2010-11-10 at 23:36.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    OK, let me be a little bit more specific and show what I've been trying. Here is the code to check whether there is an existing network connection (this works in Qt Simulator and Maemo/N900, but not in N8 which always return false even when there is a connection present):

    Code:
        QNetworkConfigurationManager mgr;
        QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);
        if (activeConfigs.count() > 0) {
            return true;
        } else {
            return false;
        }
    And here is how I try to open the connection:

    Code:
                QNetworkConfigurationManager mgr;
                QNetworkConfiguration ap = mgr.defaultConfiguration();
                QNetworkSession* session = new QNetworkSession(ap);
                session->open();
                if (session->waitForOpened(1000)) {
    //                do something
                } else {
                    qDebug() << session->errorString();
                }
    When I run this, I can see that the device (N8) is making an connection (in this case a WLAN connection), but I get the following error:

    Unknown session error.
    Again, this works in Maemo/N900.

    So is this all wrong for Symbian? Should I do this differently and how?


    Cheers

  6. #6
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: How to do network connection the proper way?

    If it is running in N900 Maemo device and not in the Symbian N8.

    Then one thing click in my mind is :

    have you added NetworkServices in Symbian Capabilities ?

    Like below :

    symbian:TARGET.CAPABILITY = NetworkServices

    Best regards,

  7. #7
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    OK, I found CS001619 - Opening a network connection in Qt and I did the following modifications:

    Code:
        if (m_session->waitForOpened()) {
            qDebug() << "Session Open";
        } else {
            qDebug() << m_session->errorString();
        }
    This is what I get:

    The specified configuration cannot be used.
    Any thoughts?

    Cheers

  8. #8
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    Quote Originally Posted by rahulvala View Post
    If it is running in N900 Maemo device and not in the Symbian N8.

    Then one thing click in my mind is :

    have you added NetworkServices in Symbian Capabilities ?

    Like below :

    symbian:TARGET.CAPABILITY = NetworkServices

    Best regards,
    I have this:

    Code:
    symbian {
        TARGET.UID3 = 0xef50b89f
        TARGET.CAPABILITY = NetworkServices ReadUserData
        TARGET.EPOCSTACKSIZE = 0x14000
        TARGET.EPOCHEAPSIZE = 0x020000 0x800000
        ICON = icon.svg
    }

  9. #9
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    Now I tried this:

    Code:
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        connect(manager, SIGNAL(finished(QNetworkReply*)),
                this, SLOT(getData(QNetworkReply*)));
    
        manager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));

    And in getData I have:

    Code:
        if (reply->error() == QNetworkReply::NoError) {
    //      do something
        } else {  
            qDebug() << reply->errorString();
        }
    The error I get is this:

    Host qt.nokia.com not found
    If the device is not connected, I see "Connecting MyWLAN" appearing twice and then the afore mentioned error. If it's already connected to the WLAN, it just gives the error immediately.

    Any help would be greatly appreciated.

    Cheers

  10. #10
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    I just created a new project with exactly the same network things and it works!

    In the very beginning of my original project I was missing the TARGET.CAPABILITY = NetworkServices in the symbian section of my pro file. I did add that early on, but it didn't help. However, after reading this I wanted to test it in a new project and that works.

    But now my question is how can I fix this on my old project (which has quite a lot of code)? That is, if CAPABILITY = NetworkServices was missing in the initial testing, how can I get it work?

    Cheers

  11. #11
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to do network connection the proper way?

    make distclean
    qmake
    make
    ?

  12. #12
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to do network connection the proper way?

    Quote Originally Posted by divanov View Post
    make distclean
    qmake
    make
    ?
    Thanks, that was it!

Similar Threads

  1. Proper way to check for network connection
    By bercobeute in forum Python
    Replies: 0
    Last Post: 2006-12-13, 11:34
  2. Network connection over bluetooth
    By larsolsson in forum Bluetooth Technology
    Replies: 2
    Last Post: 2004-06-17, 17:33
  3. Need help with network connection
    By guibiao in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-06-15, 18:47
  4. Proper access point selection and connection build up
    By gjk in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2002-12-05, 05:38
  5. Network connection
    By donlexx in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2002-05-16, 11:41

Posting Permissions

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