×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Automatic refresh of Wi-Fi hotspots and RSSI

    Hi,

    I wrote an application that detects Wi-fi hotspots as well as their RSSI. I was able to display these values on the phone already but my problem is that I need to constantly refresh the values. I am not exactly sure how to approach this problem. Below are questions I have in mind:

    1. Is the use of active objects a MUST in this case?
    2. I'm trying to implement the automatic refresh via event handlers (NotifyEventL(), EConnMonSignalStrengthChange, etc.) but I'm not sure where in the GENERATED code (I used Carbide's UI designer) to insert these.
    3. Do I just call DrawNow() to automatically refresh?
    4. I know it's a long shot but the use of loops (quick and dirty way) is not exactly the way to implement the automatic refresh, right?

    I have been programming in C and C++ for quite some time but it's only been two weeks since I picked up on Symbian C++ so I'm still on my training wheels as far as learning the framework, SDKs, and Carbide, in general, is concerned.

    Would really appreciate your help. Thanks.

  2. #2
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hello Amaguyon,

    Welcome to Forum Nokia!

    The solution to your problem is quite a simple one!

    All you need is a timer in your application. The RunL function of the timer class is invoked when the timer expires. Decide after what interval you need to refresh and simply call your function from RunL().

    Check this link to find a simple implementation of the timer.

    I hope it helps!
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hello Kishore,

    Thanks for the reply and the welcome, I appreciate it! There's a slight complication with my implementation though. My function (ListWlanAndSignals) is being called from the Draw() method as shown below:


    void CMyAppContainer::Draw( const TRect& aRect ) const
    {
    ...
    CDesCArraySeg* hotspot = new (ELeave) CDesCArraySeg(128);
    ListWlanAndSignals(hotspot); // --> This is the function that scans for hotspots and returns the names and RSSI

    for(TInt i=0; i<hotspot->Count(); i++)
    {
    rssiStrTmp.Copy((*hotspot)[i]);
    rssiStrOut.Format(KRssiFmtString,&rssiStrTmp);
    gc.DrawText(rssiStrOut,aRect,(i*25)+10,CGraphicsContext::ECenter,0);
    }
    ...
    }

    So, even if I have timer class where the RunL method calls ListWlanAndSignals(), it will not display the updated values since it is Draw() that refreshes the display. I read somewhere that programmers cannot directly call the Draw() method. Was it not a good idea to call the method within Draw() in the first place? Is there a way to trigger Draw()?

    Thanks again.

    Regards,
    Ariel Maguyon (Ariel)

  4. #4
    Registered User
    Join Date
    Dec 2005
    Posts
    1,236

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hi,

    Call DrawNow() on your Container it should solve your problem.
    Regards,
    Sriky

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hi Sriky,

    Thank you for your suggestion. I'm thinking of implementing the following code:

    // within RunL() of the timer suggested by Kishore
    {
    ...
    CMyAppContainer* activeContainer;
    // How do I point "activeContainer" to the active container?
    activeContainer->DrawNow();
    ...
    }

    I've still very new to Symbian C++ so I'm not sure if this code is correct. Am I on the right track?

    Thanks and regards,
    Ariel

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,697

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    You may benefit from storing a pointer to the view as a member variable of your active object... And initialize it in the constructor.

  7. #7
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hello Ariel,

    I have a rather simple solution again to your problem.

    You can use another static variable to hold the Container's pointer which can be initialized in the ConstructL() method. In your AppContainer class add a public static method that would return the additional pointer.

    Code:
    CMyAppContainer* CMyAppContainer::GetAppContainer()
    {
         return iAppContainerPointer; // The static variable that also holds the App Container pointer
    }
    In the RunL() function of the timer class do the following,

    Code:
    void TimerClass :: RunL()
    {
    ...
    CMyAppContainer* activeContainer = CMyAppContainer::GetAppContainer();
    activeContainer->DrawNow();
    ...
    }
    The solution might violate some of the Symbian Programming principles but it will do the job.
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hello Kishore,

    Thanks to your and Wizard_Hu's proposed solution on this. I tried working on it for a about a day or so. Unfortunately, I couldn't get it to work and I kept getting into into all sorts of problems. Anyway, I found an alternative solution here (GIF animation using CExample timer) that fit well into my application. I modified the code and got it to execute. Everything seems to be working EXCEPT the timer itself. Here's what I did:

    1. Used the CExampleTimer code without modification
    2. Tried sticking to the GIF animation code as much as I could
    3. Called GetNetworkList() in the Draw() method of the container

    The networks and RSSI values displayed correctly but the refresh that's supposed to be done by the timer was not happening. Events that triggered redraw of screen display (i.e. change in screen orientation) properly refreshed the values.

    I attached my CListWlanAndSignals.cpp code below.

    Thanks again!

    Regards,
    Ariel


    === Code for CListWlanAndSignals.cpp ===

    #include "CListWlanAndSignals.h"


    const TInt KFrameTimeOut = 3000000; // 3 sec frame timeout


    CListWlanAndSignals::CListWlanAndSignals(CCoeControl& aParent)
    :
    CActive(0), iParent(aParent)
    {
    }

    CListWlanAndSignals::~CListWlanAndSignals()
    {
    Cancel();
    delete iExampleTimer;
    iNetName->Reset();
    ...
    }

    void CListWlanAndSignals::ConstructL()
    {
    CActiveScheduler::Add(this);
    iNetName = new (ELeave) CDesCArraySeg(128);
    }

    void CListWlanAndSignals::GetNetworkList()
    {
    ...
    iMonitor.ConnectL();
    ...
    iMonitor.Close();
    }

    void CListWlanAndSignals::TimerExpired(TAny* /*aTimer*/, TInt /*aError*/)
    {
    Cancel();
    GetNetworkList();
    }

    void CListWlanAndSignals::RunL()
    {
    iParent.DrawNow();

    if(iStatus.Int() != KErrCancel)
    {
    if(!iExampleTimer)
    iExampleTimer = CExampleTimer::NewL(CActive::EPriorityStandard, *this);
    iExampleTimer->After(KFrameTimeOut);
    }
    }

    void CListWlanAndSignals::DoCancel()
    {
    }
    Last edited by amaguyon; 2008-09-28 at 04:20.

  9. #9
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: Automatic refresh of Wi-Fi hotspots and RSSI

    Hi guys,

    Just got my app working! I revised the methods below. Thanks to everyone who contributed. I really appreciate the help!

    Regards,
    Ariel

    == Revised methods ==

    void CListWlanAndSignals::ConstructL()
    {
    iNetName = new (ELeave) CDesCArraySeg(128);
    if(!iExampleTimer)
    iExampleTimer = CExampleTimer::NewL(CActive::EPriorityStandard, *this);
    iExampleTimer->After(KFrameTimeOut);
    }

    void CListWlanAndSignals::TimerExpired(TAny* aTimer, TInt aError)
    {
    iParent.DrawNow();
    iExampleTimer->After(KFrameTimeOut);
    }

    void CListWlanAndSignals::RunL()
    {
    }

Posting Permissions

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