Gps and dot net

Last post 05-09-2008 12:23 by marcomelli. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-09-2008 8:29

    Gps and dot net

    Hello, I have a HTC cruise.

    I am writing an app that sends every 20 minutes the GPS position to a central Server. To save the battery i am using the OpenNETCF.WindowsCE.LargeIntervalTimer

    I have the problem that the GPS is switched-off when the phone is in "power saving" mode and i had'nt find a way to activate it.

    Even when the tick occurs, the devices still in power save mode and the gps is not available.

    Is there a way to switch to "full power" mode , using .net 3.5 or to activate the GPS in "idle" mode?

    Best Regards,

    Marco

  • 05-09-2008 8:59 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 1,939

    Re: Gps and dot net

    My guess is you need to call RequestPowerState (via P/Invoke) with the device GUID to have the OS change the power status from D0 to D4 and back.  No idea what the GUID would be for the device though.

  • 05-09-2008 12:23 In reply to

    Re: Gps and dot net

    Hello Ctacke,  You are right.

    i did it with

     .....

    Const POWER_STATE_ON As Integer = &H10000

    Const POWER_STATE_OFF As Integer = &H20000

    Const POWER_STATE_SUSPEND As Integer = &H200000

    Const POWER_STATE_IDLE As Integer = &H100000

    Const POWER_FORCE As Integer = 4096

    <DllImport("Coredll.dll")> _

    Private Shared Function SetSystemPowerState(ByVal psState As String, ByVal StateFlags As Integer, ByVal Options As Integer) As Integer

    End Function

    Declare Sub SystemIdleTimerReset Lib "coredll" ()

    Declare Sub SHIdleTimerReset Lib "Aygshell.dll" Alias "SHIdleTimerReset" ()

    ...... 

    and  in the code....

    SetSystemPowerState(
    Nothing, POWER_STATE_IDLE, POWER_FORCE)

    SystemIdleTimerReset()

    SHIdleTimerReset()

     

    It seems to work!

    Thank You!

Page 1 of 1 (3 items)