locked
Always on WIFI RRS feed

  • Question

  • Hi

    Iam doing a POS HandHeld application and we are having a huge problem with the amount of time it takes for the PDA to reconnect to the network (its not more than 3-4 seconds, but it is a problem.)
    We would like make the PDA hold the connection at all times.

    I have seen other applications do this (I think they actually just turn off the screen or something, because one is not allowed to use the power button in those application)
    It means that you are just suposed to wait for the application to sleep by itself.
    My guess is that they are constantly calling the command to prevent Windows Mobile to do its sleep and then at some point turning of the screen themselves.

    I have tried this, however it does not work on our Symbol MC50's
    http://www.dionysopoulos.me/en/articles/winmobile/38-keeping-wifi-always-on-windows-mobile.html


    Tuesday, September 8, 2009 6:34 PM

Answers

  • Hi MorSchmidt,
    I think you need to prevent the device going in Unattended mode. In this mode WiFi is switched off (contrary to Bluetooth). So maybe you simply need to use SystemIdleTimerReset function (http://msdn.microsoft.com/en-us/library/aa930260.aspx) and just after some time "simulate" going device asleep by turning the backlight off? You can achieve the latter using SetPowerRequiremen function. Here's some sample:
    http://msdn.microsoft.com/en-us/library/aa455153.aspx

    Of course in this scenario you'll probably also need to take care of pressing any hardware buttons by for example locking the keypad.
    For more about power states take a look at:
    http://blogs.msdn.com/windowsmobile/archive/2005/08/10/450186.aspx
    http://www.codeproject.com/KB/mobile/WiMoPower1.aspx

    Regards,
    Pawel
    • Proposed as answer by Pawel Koselski Tuesday, September 8, 2009 7:29 PM
    • Marked as answer by warrentang Tuesday, September 15, 2009 2:04 AM
    Tuesday, September 8, 2009 7:29 PM
  • Hi,

    do the following

    define you function like this,

    [DllImport("CoreDll.dll")]
    public static extern int SetSystemPowerState(string psState, int StateFlags, int Options);

    define the values you need

    const int Power_STATE_IDLE = 0x00100000;
    const int POWER_FORCE = 4096;

    now call the function like this

    SetSystemPowerState(null, POWER_STATE_IDLE, POWER_FORCE);

    if you want to set to any other powerstates see

    http://msdn.microsoft.com/en-us/library/aa929708.aspx

    to get the values for each power state you have to look them up in the headerfile

    to save you the trouble These are the ones I use

        const int POWER_STATE_ON = 0x00010000;
        const int POWER_STATE_OFF = 0x00020000;
        const int Power_STATE_IDLE = 0x00100000;
        const int POWER_STATE_SUSPEND = 0x00200000;
        const int POWER_STATE_RESET = 0x00800000;
    • Proposed as answer by badasschris Saturday, September 12, 2009 10:58 AM
    • Marked as answer by warrentang Tuesday, September 15, 2009 2:04 AM
    Saturday, September 12, 2009 10:57 AM

All replies

  • Hi,

    Have you seen the following thread, it seems to similar to your requirement :-

    http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/2c5cd329-6434-441a-957d-3caef77bda8b

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Tuesday, September 8, 2009 6:38 PM
  • Hi MorSchmidt,
    I think you need to prevent the device going in Unattended mode. In this mode WiFi is switched off (contrary to Bluetooth). So maybe you simply need to use SystemIdleTimerReset function (http://msdn.microsoft.com/en-us/library/aa930260.aspx) and just after some time "simulate" going device asleep by turning the backlight off? You can achieve the latter using SetPowerRequiremen function. Here's some sample:
    http://msdn.microsoft.com/en-us/library/aa455153.aspx

    Of course in this scenario you'll probably also need to take care of pressing any hardware buttons by for example locking the keypad.
    For more about power states take a look at:
    http://blogs.msdn.com/windowsmobile/archive/2005/08/10/450186.aspx
    http://www.codeproject.com/KB/mobile/WiMoPower1.aspx

    Regards,
    Pawel
    • Proposed as answer by Pawel Koselski Tuesday, September 8, 2009 7:29 PM
    • Marked as answer by warrentang Tuesday, September 15, 2009 2:04 AM
    Tuesday, September 8, 2009 7:29 PM
  • Hi MorSchmidt,

    I only have time for a quick message but just post if you need more help, anyway.

    pretty much what you need PawelUsers Medals has said, in screen off mode the phone will still have full functionality.

    The problems

    1) phone will suspend after some time
    2) pressing the power button automatically puts the phone in suspended mode

    solutions

    1) Pawel's solution for this would counter it i.e. dont let it suspend by using SystemIdleTimerReset
    2) This is the big problem and there is no fullproof answer I'm afraid, what you can do is first make sure your application asks for unatended mode that way when the power button is pressed your code will still run. The next thing you can do is whenever you phone is put into suspended/unatended mode immediately change it to screen off mode(using SetPowerRequirement), to check for this use RequestPowerNotification http://msdn.microsoft.com/en-us/library/aa932427.aspx

    One other thing to note is that to keep the phone in ScreenOff mode you will want to call SystemIdleTimerReset periodically

    As you can tell the phone will switch to unatended mode if the power button is pressed, it will probably one be for a few miliseconds but that might be enough time for the phone to lose wifi connection.

    Hope that helps
    Tuesday, September 8, 2009 8:01 PM
  • Hi

    The SystemIdleTimerReset is easy enough i have that running, however i am having problems turning of the screen only.

    Does SetPowerRequirement turn of the Screen ?
    Do you maybe have a sample of how you turn of the Screen ?
    Saturday, September 12, 2009 9:42 AM
  • Hi,

    do the following

    define you function like this,

    [DllImport("CoreDll.dll")]
    public static extern int SetSystemPowerState(string psState, int StateFlags, int Options);

    define the values you need

    const int Power_STATE_IDLE = 0x00100000;
    const int POWER_FORCE = 4096;

    now call the function like this

    SetSystemPowerState(null, POWER_STATE_IDLE, POWER_FORCE);

    if you want to set to any other powerstates see

    http://msdn.microsoft.com/en-us/library/aa929708.aspx

    to get the values for each power state you have to look them up in the headerfile

    to save you the trouble These are the ones I use

        const int POWER_STATE_ON = 0x00010000;
        const int POWER_STATE_OFF = 0x00020000;
        const int Power_STATE_IDLE = 0x00100000;
        const int POWER_STATE_SUSPEND = 0x00200000;
        const int POWER_STATE_RESET = 0x00800000;
    • Proposed as answer by badasschris Saturday, September 12, 2009 10:58 AM
    • Marked as answer by warrentang Tuesday, September 15, 2009 2:04 AM
    Saturday, September 12, 2009 10:57 AM
  • Hi

    Thanks alot, this is great.
    Works very will turning of the screen and i have deactivated the PDAs automatic sleep using SystemIdleTimerReset().
    However when the user presses the Power button to turn back on the Device, the Power on the screen is very low and i have to press somewhere on the screen to make it turn all the way on.
    Is there any solution for making it turn on instantly ?
    Tuesday, September 15, 2009 7:16 AM
  • Actually i solved the part with the Powerbutton now.
    This :

    PowerPolicyNotify(

    PowerMode.UnattendedMode,1);

    Together with the

    SystemIdleTimerReset()

    This solves my issue completely.
    It seems that the Symbol MC50's i use dont turn of the Wifi when in UnattendedMode.

    However comming out of unattended mode still returns me to a state where the Backlight is off.
    Does anyone have an idea how to overrule this ?

    Saturday, September 19, 2009 8:48 AM