locked
GPS power management on windows ce RRS feed

  • Question

  • hello to every body

    I`m developing a program that get the GPS data and i used the GPS library of Microsoft.

    My problem is when the device into the sleep mode, the GPS device get the same position for 7 minute and then does not get any position, 

    for solve this i used this code : 

     CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, -1);
     const int POWER_NAME = 0x00000000;
     int notify = CoreDLL.DevicePowerNotify(GpsDeviceName, CEDEVICE_POWER_STATE.D0, POWER_NAME);
     IntPtr power = CoreDLL.SetDevicePower(GpsDeviceName, DevicePowerFlags.POWER_NAME, CEDEVICE_POWER_STATE.D0);
    

    and this code: 

     

     CEDEVICE_POWER_STATE state = CEDEVICE_POWER_STATE.D0;
     CoreDLL.GetDevicePower(GpsDeviceName, DevicePowerFlags.POWER_NAME, out state);
     CoreDLL.SetPowerRequirement(GpsDeviceName, CEDEVICE_POWER_STATE.D0,
                  DevicePowerFlags.POWER_NAME | DevicePowerFlags.POWER_FORCE,
                  IntPtr.Zero, 0);
    

     

    but this work in HTC touch2 and acer E101,s200 and Xperia and .....

    but doesn`t work on HTC HD2,,,, 

    What can i do??

     

     

    Please Help.. 

    Thanks



    Wednesday, July 13, 2011 4:33 AM

Answers

  • I found a solution : 

     When I deleted the IClass string out of the following keys,:

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\GPSID]
    "IClass"="{A32942B7-920C-486b-B0E6-92A702A99B35}"


    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\gpsdriver]
    "IClass"="{A32942B7-920C-486b-B0E6-92A702A99B35}"

     

    and work very well!!!! 

    I have to test to another device 

     


    • Marked as answer by Yves.Z Monday, July 25, 2011 8:35 AM
    Thursday, July 21, 2011 6:12 PM

All replies

  • I have to use this code for solve this... : 
    <code>
    CoreDLL.SetSystemPowerState(null, PowerState.POWER_STATE_ON, DevicePowerFlags.POWER_NAME);
    </code>
    Wednesday, July 13, 2011 7:18 AM
  • This behavior is by design. When the device is suspended, most components are turned off to conserve power. It looks like your solution is to keep the device from suspending. This will annoy your users.

    You can specify a maximum age for GPS coordinates with the dwMaximumAge parameter in GPSGetPosition. That will prevent it from showing the same location for 7 minutes.

    Consider if your program actually need to know where it is at all times. If it does, you could try using the Notification functions to wake the device every minute or so to record the position. That would be a better use of power.

    -PaulH

    Wednesday, July 13, 2011 1:51 PM
  • Thanks for your reply,

    See, I used these function for my app, but i need power gps, i think these function use for application and not use for because gps is a hardware, is true?



    Wednesday, July 13, 2011 1:55 PM
  • Yes, GPS is hardware and requires power. I don't understand the rest of your question, though. Can you rephrase it?

     

    Wednesday, July 13, 2011 9:49 PM
  • That functions doesnt work for gps device,,,

     

    what can i do that?

     

    Tuesday, July 19, 2011 10:42 AM
  • Which function doesn't work for GPS?

    Understand that power management for each device is more or less implemented by the manufacturer. What you're attempting to do is probably not a supported use-case by any manufacturer. So, techniques that work for one device may not work for another.

    -PaulH

    Tuesday, July 19, 2011 1:33 PM
  • I did used CeRunAppAtEvent and CeRunAppAtTime , both of them use for app , and i think does not work for hard hardware,, 

    That`s right,, for example my app work very well for Touch2 and Acer and Xperia X2.. but doesn`t work for HD2,,,

    Even i did used this code but doesn`t work for HD2 : 

     private const string GPS_DEVICE_NAME_PATH = "DRIVERS\\Builtin\\GPSID";

    private string _gpsDeviceName;

    //this is for get gps device name

            public string GpsDeviceName

            {

                get

                {

                    if (_gpsDeviceName == null)

                    {

                        RegistryKey gpsInfoKey = Registry.LocalMachine.OpenSubKey(GPS_DEVICE_NAME_PATH);

     

                        if (gpsInfoKey != null)

                        {

                            try

                            {

                                _gpsDeviceName = String.Format("{0}{1}:", gpsInfoKey.GetValue("Prefix"),

                                                               gpsInfoKey.GetValue("Index"));

                            }

                            catch

                            {

                            }

                        }

                    }

                    return _gpsDeviceName;

                }

            }

     

                CEDEVICE_POWER_STATE state = CEDEVICE_POWER_STATE.D0;

                CoreDLL.GetDevicePower(GpsDeviceName, DevicePowerFlags.POWER_NAME| DevicePowerFlags.POWER_FORCE, out state);

                

                requirement = CoreDLL.SetPowerRequirement(GpsDeviceName, CEDEVICE_POWER_STATE.D0,

                                                         DevicePowerFlags.POWER_NAME | DevicePowerFlags.POWER_FORCE,

                                                         IntPtr.Zero, 0);

    What can i do for solve this??

    Please Help Paul... 

    Tuesday, July 19, 2011 5:39 PM
  • What does SetPowerRequirement() return when you use it on a device that doesn't work as expected like the HD2?

    The GpsDeviceName you have assumes the manufacturer is using the default "Generic Power Manageable" class for the GPS. If they implemented a different profile for it, what you have there won't work.

    Enumerate the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Power\Interfaces key to see if they added any other power management classes.

    Read this document for more information: http://msdn.microsoft.com/en-us/library/aa447462.aspx

    -PaulH

    Wednesday, July 20, 2011 1:49 PM
  •  

    Thanks for your reply,, 

    I doesn`t check return value of SetPowerRequirement(), but this is not good.

    For GpsDeviceName  , i did checked both of devices and both of them are same, and the GpsDeviceName  is gpd0.

     

    and what is the  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Power\Interfaces??

     


    And the GetDevicePower and DevicePowerNotify functions, return 0, that`s mean success!! but doesn`t work!!!
    Wednesday, July 20, 2011 2:19 PM
  • That's the registry key listing power classes. It's described in the article I linked to in my last post.

    Returning 0 means it didn't have an error. For OEM implemented things, that doesn't necessarily mean it's working the way you want.

    -PaulH

    Thursday, July 21, 2011 5:28 PM
  • I found a solution : 

     When I deleted the IClass string out of the following keys,:

    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\GPSID]
    "IClass"="{A32942B7-920C-486b-B0E6-92A702A99B35}"


    [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\gpsdriver]
    "IClass"="{A32942B7-920C-486b-B0E6-92A702A99B35}"

     

    and work very well!!!! 

    I have to test to another device 

     


    • Marked as answer by Yves.Z Monday, July 25, 2011 8:35 AM
    Thursday, July 21, 2011 6:12 PM