×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Possible to get notified if GPS is active?

    Hi,
    I would like to get notified, if the GPS device is physically active. Is it possible to get such kind of info?

    Regards

  2. #2
    Registered User
    Join Date
    Jun 2008
    Location
    India
    Posts
    1,048

    Re: Possible to get notified if GPS is active?

    Quote Originally Posted by neil.young View Post
    Hi,
    I would like to get notified, if the GPS device is physically active. Is it possible to get such kind of info?

    Regards
    I have already answered this question for both perception. Check this thread

    http://discussion.forum.nokia.com/fo...d.php?t=169850

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Possible to get notified if GPS is active?

    Hi sumit.rathi,

    thanks for your answer. As far as I can see, all the answers are releated to "How to determine, whether the device has GPS or not". My question was: Is it possible to determine by that way, whether the GPS is currently _active_ or not?

    Kind regards

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Possible to get notified if GPS is active?

    I haven't tried but from RPositionServer, you can use GetModuleStatus() in which you can pass reference for TPositionModuleStatus. Using TPositionModuleStatus, you can retrieve DeviceStatus() which will give you TDeviceStatus enumeration which you can check for whether GPS is active or somewhat else.

    Search all these terms in the SDK help.

    Also check this Wiki article: CS000822 - Searching for GPS devices
    Nokia Developer Wiki Moderation team

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Possible to get notified if GPS is active?

    OK, thanks a bunch. Do I catch it right: All these APIs require some action initiated by me, e.g. on behalf of a timer. There is no such a thing like: Call me back if GPS status is changed?

    Regards

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Possible to get notified if GPS is active?

    Quote Originally Posted by neil.young View Post
    OK, thanks a bunch. Do I catch it right: All these APIs require some action initiated by me, e.g. on behalf of a timer. There is no such a thing like: Call me back if GPS status is changed?

    Regards
    There is a method in the RPositionServer, NotifyModuleStatusEvent() which is an asynchronous request and you should use with Active object. After issuing NotifyModuleStatusEvent(), set it active and you will be notified in RunL when there is a change.

    Check this: http://library.forum.nokia.com/ (Search for the string: How to get module status changes in that link)
    Nokia Developer Wiki Moderation team

  7. #7
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Possible to get notified if GPS is active?

    Kiran,
    thanks for your patience (as always). The links talk about Symbian OS 9.3, isn't that S60 5th? I would need that for S60 3rd. And - sorry for bothering - all I can see is a notification on a change of position, signal quality etc. I can't see currently the "Module is on/off" status.

    However, thanks for your efforts again.
    Regards

    UPDATE: Seems to be available for 3rd to somehow...
    Last edited by neil.young; 2009-11-25 at 13:39.

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Possible to get notified if GPS is active?

    In this link: How to get module status changes, they are talking about getting the notification of change in different ways, one of them is TPositionModuleStatusEventBase::EEventDeviceStatus. Check this section: Getting module status change notifications in that link.

    As said, I haven't tried on my own but it looks promising from that link.
    Nokia Developer Wiki Moderation team

  9. #9
    Registered User
    Join Date
    Jun 2008
    Location
    India
    Posts
    1,048

    Re: Possible to get notified if GPS is active?

    The links talk about Symbian OS 9.3, isn't that S60 5th?
    No It is not 5th edition. It is 3rd edition. Symbian OS 9.4 is used for 5th edition devices.

  10. #10
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Possible to get notified if GPS is active?

    More precisely, it is S60 3rd FP2.

    Symbian OS v9.1 = S60 3rd (Initial)
    Symbian OS v9.2 = S60 3rd FP1
    Symbian OS v9.3 = S60 3rd FP2
    Symbian OS v9.4 = S60 5th
    Nokia Developer Wiki Moderation team

  11. #11
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Possible to get notified if GPS is active?

    OK, friends, probably you have once again a good hint for me.

    What I did so far:
    1) Create a class, descendant from CActive
    2) In ConstructL I'm doing:

    Code:
    void CGPSStateObserver::ConstructL()
    	{
    	CActiveScheduler::Add(this);
    	User::LeaveIfError(iServer.Connect());
    	}
    3) iServer is a class element
    Code:
    RPositionServer iServer;
    as well as
    Code:
    	TPositionModuleStatus modStatus;
    	TPositionModuleStatusEvent modEvents;
    	TRequestStatus Status;
    4) My class has a "starter" function
    Code:
    void CGPSStateObserver::DoAsyncAction()
    	{
    	TPositionModuleStatusEventBase::TModuleEvent requestedEvents =
    			TPositionModuleStatusEventBase::EEventDeviceStatus;
    	modEvents.SetRequestedEvents(requestedEvents);
    	iServer.NotifyModuleStatusEvent(modEvents, Status);
    	SetActive();
    	}
    which is called from the menu

    5) I was hoping to get a notification in RunL

    Code:
    void CGPSStateObserver::RunL()
    	{
    	TPositionModuleStatusEventBase::TModuleEvent occurredEvents =
    			modEvents.OccurredEvents();
    	modEvents.GetModuleStatus(modStatus);
    	TPositionModuleStatus::TDeviceStatus deviceStatus =
    			modStatus.DeviceStatus();
    
    	}
    But after start (in emulator) nothing happens. Would be OK, I'm not doing anything with GPS. The only log output in emulator is:

    84.525 EPos: Server: EPositionServerNotifyModuleStatusEvent
    84.530 EPos: Server: ValidateRequestL in
    84.535 EPos: Server: ValidatePositionClassBufferL in
    84.535 EPos: Server: ValidatePositionClassBufferL out
    84.535 EPos: Server: ValidatePositionClassTypeL in
    84.540 EPos: Server: ValidatePositionClassTypeL out
    84.540 EPos: Server: Reading event object
    84.540 EPos: Server: Reading module id
    84.540 EPos: Server: ValidateRequestL out


    If I try to send my app to the background (hitting one of the "phone" buttons responsible for that), the last thing I see in the emulator is this:

    105.060 Thread GPSTest::GPSTest Panic E32USER-CBase 46

    Seems, I'm missing something. But what?

    Regards

  12. #12
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Possible to get notified if GPS is active?

    You can safely remove this line from your header file. TRequestStatus Status; And use iStatus which is available in CActive class.
    Code:
    iServer.NotifyModuleStatusEvent(modEvents, iStatus);
    * Check for iStatus value in the RunL before accessing it.
    Code:
    void CGPSStateObserver::RunL()
    {
        User::LeaveIfError(iStatus.Int());
    	TPositionModuleStatusEventBase::TModuleEvent occurredEvents =
    			modEvents.OccurredEvents();
    	modEvents.GetModuleStatus(modStatus);
    	TPositionModuleStatus::TDeviceStatus deviceStatus =
    			modStatus.DeviceStatus();
    	DoAsyncAction(); // Call again to be notified again
    }
    * Check if the request is already active before issueing another one.
    Code:
    void CGPSStateObserver::DoAsyncAction()
    {
    	if (IsActive())
            {
    		Cancel();
    	}
    	TPositionModuleStatusEventBase::TModuleEvent requestedEvents =
    			TPositionModuleStatusEventBase::EEventDeviceStatus;
    	modEvents.SetRequestedEvents(requestedEvents);
    	iServer.NotifyModuleStatusEvent(modEvents, iStatus);
    	SetActive();
    }

    * Implement DoCancel() as follows which will be called by Cancel(). You should not call DoCancel() directly, instead call Cancel() always.
    Code:
    void CGPSStateObserver::DoCancel()
    {
    	iServer.CancelRequest(EPositionServerNotifyModuleStatusEvent);
    }

    * Call Cancel() in the destructor to cancel any outstanding request.
    Code:
    CGPSStateObserver::~CGPSStateObserver()
    {
    	Cancel();
    	....
    	....
    }
    EDIT: Also please check it on read device for reliable results.
    Nokia Developer Wiki Moderation team

  13. #13
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Possible to get notified if GPS is active?

    Ah. OK. Will give it a try later on. Right now I just can say, that RunL wasn't called. But this could also be caused by the wrong status value used...
    Keep you informed.

    Thanks for your great help!
    Regards

  14. #14
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Possible to get notified if GPS is active?

    Cool. Works perfectly. At least on the emulator. Will test it on the phone ASAP.

    BTW: What do you mean by that?
    EDIT: Also please check it on read device for reliable results.
    Typo?

    Regards

  15. #15
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Possible to get notified if GPS is active?

    Quote Originally Posted by neil.young View Post
    Typo?
    Yes, it was a typo but it is really surprising that how could I write "d"(read) instead of "l"(real) when they are placed far from each other on the keyboard.

    So again, please test it on real device for reliable results.

    PS: Make sure to have Location capability when playing with GPS.
    Nokia Developer Wiki Moderation team

Similar Threads

  1. Run Symbian console app as a "daemon"
    By zumbo_oxinia in forum Symbian
    Replies: 6
    Last Post: 2010-01-20, 10:57
  2. Questions on Active Objects
    By schrecklichkeit in forum Symbian
    Replies: 4
    Last Post: 2009-09-09, 17:14
  3. E32User -CBase 42 in GPS positioning Active Object
    By chandran.biju007 in forum Symbian
    Replies: 3
    Last Post: 2009-08-03, 08:10
  4. Replies: 13
    Last Post: 2009-02-06, 11:56
  5. Wrong implementation of active object
    By petr_kovar in forum Symbian
    Replies: 20
    Last Post: 2008-12-04, 00:28

Posting Permissions

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