×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188

    Need Help with RConnection

    Hi,

    I'm trying to handle the RConnection Class to monitor GPRS connections. My problem is, that I don't have a clue how to do it.
    I'm trying to write an AO which does the job, but I'm stuck at the moment. Would be nice if somebody can help me with it, it's really urgent.

    Could it be that there is no method called GetConnectionInfo? I've just found GetConnection in the header file.

    For now I've got

    // ------------------------------------------------------------------------
    // Implementation of CGprsObserver
    // ------------------------------------------------------------------------

    #include "CGprsObserver.h"

    // ------------------------------------------------------------------------
    // Construct object (private)
    // ------------------------------------------------------------------------
    CGprsObserver::CGprsObserver():CActive(EPriorityStandard)
    {
    //
    }

    // -----------------------------------------------------------------------
    // leaving construction methods
    // -----------------------------------------------------------------------
    CGprsObserver* CGprsObserver::NewL()
    {
    CGprsObserver* self = NewLC();
    CleanupStack::Pop(self);
    return self;
    }

    CGprsObserver* CGprsObserver::NewLC()
    {
    CGprsObserver* self = new (ELeave) CGprsObserver();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    // ------------------------------------------------------------------------
    // Destroy object
    // ------------------------------------------------------------------------
    CGprsObserver::~CGprsObserver()
    {
    //
    if(IsActive())
    {
    Cancel();
    }
    else
    {
    ReleaseConnection();
    }
    }

    // ------------------------------------------------------------------------
    // Construction leaving function (public)
    // ------------------------------------------------------------------------
    void CGprsObserver::ConstructL()
    {
    // set up a monitor connection to the GPRS connection
    iSubNotify = EFalse;
    CActiveScheduler::Add(this);
    }

    // ------------------------------------------------------------------------
    // DoCancel is necessary to cancel the AO
    // ------------------------------------------------------------------------
    void CGprsObserver::DoCancel()
    {
    //
    ReleaseConnection();
    }

    // ------------------------------------------------------------------------
    // RunL handles the completion of the AO
    // ------------------------------------------------------------------------
    void CGprsObserver::RunL()
    {
    //
    }

    // ------------------------------------------------------------------------
    // StartObserver starts the observer
    // ------------------------------------------------------------------------
    void CGprsObserver::StartObserver()
    {
    //
    if(InitializeConnection() == KErrNone)
    {
    // tells the active scheduler a request is active
    SetActive();
    }
    }

    // ------------------------------------------------------------------------
    // InitializeConnection sets up the connection
    // ------------------------------------------------------------------------
    TInt CGprsObserver::InitializeConnection()
    {
    //
    TInt Err = 0;
    Err = iConnection.Open(iSocketServer, KConnectionTypeDefault);
    //Find number of connection available
    TInt iNumberConnections;
    Err = iConnection.EnumerateConnections((TUint&)iNumberConnections);
    if(Err)
    {
    iConnection.Close();
    return Err;
    }
    // check there are available connections
    if(iNumberConnections < 1)
    {
    iConnection.Close();
    return KErrNotFound;
    }
    // get info about first available connection
    // todo: Get info right TDes8& aConnectionInfo
    TDes8& info;
    Err = iConnection.GetConnectionInfo(0, info);
    if(Err)
    {
    iConnection.Close();
    return Err;
    }
    // use this info to attach to a connection
    Err = iConnection.Attach(info, EAttachTypeMonitor);
    if(Err)
    {
    iConnection.Close();
    return Err;
    }
    /*
    // now check the subconnections
    TInt iNumberSubConnections;
    Err = iConnection.EnumerateSubConnections((TUint&) iNumberSubConnections);
    return Err;
    */
    //TSubConnectionNotificationBuf& aSubConnectionEvent
    // todo: iSubConnectionEvent
    iConnection.AllSubConnectionNotification(iSubConnectionEvent, iStatus);
    iSubNotify = ETrue;
    }

    // ------------------------------------------------------------------------
    // ReleaseConnection closes the connection
    // ------------------------------------------------------------------------
    void CGprsObserver::ReleaseConnection()
    {
    // do everything in InitializeConnection reverse
    // cancel Request for outstanding AllSubConnectionNotification
    if(iSubNotify)
    {
    iConnection.CancelAllSubConnectionNotification();
    iSubNotify = EFalse;
    }
    }
    Last edited by ArneH; 2004-11-10 at 08:34.

  2. #2
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Ok,

    I found an example in the SDKs help and changend my code after that. Now there are new problems, some things are missing. I hate that.
    The documentation tells other things than the example and the example doesn't work with the header file! They messed up again!

    Maybe somebody have the same problems and can help:

    1. RConnection::GetConnectionInfo(TUint aIndex, TDes8& aConnectionInfo); is not in the header file es_sock.h

    2. TPckgBuf<TConnectionInfoV2> connectionInfo; TConnectionInfoV2 is unknown

    3. EAttachTypeMonitor is undeclared identifier

    4. TPckgBuf<TSubConnectionInfoGPRS> subConnectionInfo[subConnectionCount]; TSubConnectionInfoGPRS is unknown

    What do I have to do to get this working???
    Are there header files missing or what is wrong? Please Help!

    Best regards

    Arne

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    3

    How to use RConnection

    An example from Nokia of how to Connect to interner by using RConnection can be found at:

    http://www.forum.nokia.com/main/1,65...l&fileID=4260.

    kg.

  4. #4
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Sorry, but I can't find any RConnection related code in the IAP example.
    However I found es_enum.h, seems to help a little. Should be quoted in the SDKs help, I think.

    So problem number 2 is solved:

    TPckgBuf<TConnectionInfoV2> connectionInfo is found in es_enum.h
    Last edited by ArneH; 2004-11-10 at 12:39.

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    3
    You will find it in the CIAPConnect_v20Engine class.

    kg

  6. #6
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Sorry about that,

    I got sample v10. Will have a look at the sample v20 now.

    Sorry, I haven't read carefully enough

  7. #7
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    At compiling the IAP example I get the same error code as on my code:

    GetConnectionInfo is not a member of RConnection.

    Any ideas?

    solved: I just copied the method from the SDKs help documentation into the es_sock.h?! Now it works, could it be, that they simply forgot to put it there?
    Last edited by ArneH; 2004-11-10 at 13:19.

  8. #8
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Now the first 3 problems are solved. Last one number 4.

    But there's one new, too: I can't attach to a connection. The given error is -34 means "Can't connect". My code is mainly the same as the code in the SDKs example for attaching a connection, but it doesn't seem to work.

    Where is my mistake:

    //
    TInt Err(KErrNone);

    // Open a session with the socket server
    Err = socketServer.Connect();
    if(Err != KErrNone)
    return Err;
    else
    CEikonEnv::Static()->AlertWin(_L("Socket Open"));

    // Open a subsession with the socket server for the RConnection
    Err = myConnection.Open(socketServer);
    if(Err != KErrNone)
    return Err;
    else
    CEikonEnv::Static()->AlertWin(_L("Connection Open"));

    // Attach the RConnection to an interface on the server
    TUint connectionCount;
    // Enumerate currently active connections across all socket servers
    Err = myConnection.EnumerateConnections(connectionCount);
    if(Err != KErrNone)
    return Err;
    else
    CEikonEnv::Static()->AlertWin(_L("Enumerate:"));

    if(connectionCount != 0) // if connections are started
    {
    TPckgBuf<TConnectionInfoV2> connectionInfo;
    Err = myConnection.GetConnectionInfo(1, connectionInfo); // 1 = first active connection
    if(Err!=KErrNone)
    return Err;
    else
    CEikonEnv::Static()->AlertWin(_L("ConnectionInfo"));
    Err = myConnection.Attach(connectionInfo,RConnection::EAttachTypeMonitor);
    if(Err!=KErrNone)
    {
    TBuf<10> iTest;
    iTest.AppendNum(Err);
    CEikonEnv::Static()->AlertWin(iTest);
    return Err;
    }
    else
    CEikonEnv::Static()->AlertWin(_L("Attached"));
    }

    Thanks for your help

    Arne

  9. #9
    Regular Contributor
    Join Date
    May 2004
    Location
    NRW/ Germany
    Posts
    188
    Update: I'm now able to attach to the connection. Now I'm trying to get the information from the CommDB about the active connection.

    I tried this:

    TBuf<50> iBuf;
    myConnection.GetLongDesSetting(_L("IncomingGPRS/APN"), iBuf );
    CEikonEnv::Static()->AlertWin(iBuf);

    But the iBuf remains empty. Any ideas?

    Thanks

    Arne

  10. #10
    Registered User
    Join Date
    Oct 2004
    Posts
    6

    Re: Need Help with RConnection

    Hello,

    What did you do to get the attach working?

  11. #11
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: Need Help with RConnection

    Hi,

    could you please describe where you had problem with attaching to the connection??

    Thanks a lot
    Bye
    STeN

  12. #12
    Registered User
    Join Date
    Nov 2005
    Location
    Oregon
    Posts
    40

    Exclamation Re: How to use RConnection

    Just FYI, but the following link is broken... the updated link is: http://www.forum.nokia.com/info/sw.n..._v2_0.zip.html

    Quote Originally Posted by kjartan3129
    An example from Nokia of how to Connect to interner by using RConnection can be found at:

    http://www.forum.nokia.com/main/1,65...l&fileID=4260.

    kg.

Posting Permissions

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