Can any one give me an example for turning on and off WLAN on pocket pc? in
particular, C# code would be most helpful.

Thanks,
Jorge

Re: SetPowerRequirement by pieri

pieri
Tue Dec 20 10:16:11 CST 2005

I use the following class:

public class PowerAPI
{
[DllImport("coredll.dll", SetLastError = true)]
public static extern int SetDevicePower(
string pvDevice,
int dwDeviceFlags,
DevicePowerState DeviceState);

[DllImport("coredll.dll", SetLastError = true)]
public static extern int GetDevicePower(
string pvDevice,
int dwDeviceFlags,
ref DevicePowerState DeviceState);

[DllImport("coredll.dll", SetLastError = true)]
public static extern int DevicePowerNotify(
string device,
DevicePowerState state,
int flags);

public enum DevicePowerState : int
{

Unspecified = -1,

D0 = 0, // Full On: full power, full functionality

D1, // Low Power On: fully functional at low
power/performance

D2, // Standby: partially powered with automatic wake

D3, // Sleep: partially powered with device initiated wake

D4, // Off: unpowered

}

public const int POWER_NAME = 0x00000001;
}

To turning on use the following code:
int res1 = PowerAPI.DevicePowerNotify(deviceName,
PowerAPI.DevicePowerState.D4, PowerAPI.POWER_NAME);
int res2 = PowerAPI.SetDevicePower(deviceName, PowerAPI.POWER_NAME,
PowerAPI.DevicePowerState.D0);

to check the current device state use:
PowerAPI.DevicePowerState deviceState = new
PowerAPI.DevicePowerState();PowerAPI.GetDevicePower(deviceName,
PowerAPI.POWER_NAME, ref deviceState);

I use for Device name this string:
"{98C5250D-C29A-4985-AE5F-AFE5367E5006}\\TIACXWLN1".

HTH,
Federico


Jorge ha scritto:

> Can any one give me an example for turning on and off WLAN on pocket pc? in
> particular, C# code would be most helpful.
>
> Thanks,
> Jorge


Re: SetPowerRequirement by Jorge

Jorge
Tue Dec 20 10:38:51 CST 2005

Thanks Federico! (:->)

<pieri.federico@gmail.com> wrote in message
news:1135095371.330968.85880@o13g2000cwo.googlegroups.com...
>I use the following class:
>
> public class PowerAPI
> {
> [DllImport("coredll.dll", SetLastError = true)]
> public static extern int SetDevicePower(
> string pvDevice,
> int dwDeviceFlags,
> DevicePowerState DeviceState);
>
> [DllImport("coredll.dll", SetLastError = true)]
> public static extern int GetDevicePower(
> string pvDevice,
> int dwDeviceFlags,
> ref DevicePowerState DeviceState);
>
> [DllImport("coredll.dll", SetLastError = true)]
> public static extern int DevicePowerNotify(
> string device,
> DevicePowerState state,
> int flags);
>
> public enum DevicePowerState : int
> {
>
> Unspecified = -1,
>
> D0 = 0, // Full On: full power, full functionality
>
> D1, // Low Power On: fully functional at low
> power/performance
>
> D2, // Standby: partially powered with automatic wake
>
> D3, // Sleep: partially powered with device initiated wake
>
> D4, // Off: unpowered
>
> }
>
> public const int POWER_NAME = 0x00000001;
> }
>
> To turning on use the following code:
> int res1 = PowerAPI.DevicePowerNotify(deviceName,
> PowerAPI.DevicePowerState.D4, PowerAPI.POWER_NAME);
> int res2 = PowerAPI.SetDevicePower(deviceName, PowerAPI.POWER_NAME,
> PowerAPI.DevicePowerState.D0);
>
> to check the current device state use:
> PowerAPI.DevicePowerState deviceState = new
> PowerAPI.DevicePowerState();PowerAPI.GetDevicePower(deviceName,
> PowerAPI.POWER_NAME, ref deviceState);
>
> I use for Device name this string:
> "{98C5250D-C29A-4985-AE5F-AFE5367E5006}\\TIACXWLN1".
>
> HTH,
> Federico
>
>
> Jorge ha scritto:
>
>> Can any one give me an example for turning on and off WLAN on pocket pc?
>> in
>> particular, C# code would be most helpful.
>>
>> Thanks,
>> Jorge
>



Re: SetPowerRequirement by Jorge

Jorge
Tue Dec 20 15:17:31 CST 2005

Federico, this code is not working on this Dell Axim X50 device. The only
one that works is the GetDevicePower API. the others always return an error
code #2. Is there anything I might not understand about these devices or
this code?

Thanks,
Jorge

<pieri.federico@gmail.com> wrote in message
news:1135095371.330968.85880@o13g2000cwo.googlegroups.com...
>I use the following class:
>
> public class PowerAPI
> {
> [DllImport("coredll.dll", SetLastError = true)]
> public static extern int SetDevicePower(
> string pvDevice,
> int dwDeviceFlags,
> DevicePowerState DeviceState);
>
> [DllImport("coredll.dll", SetLastError = true)]
> public static extern int GetDevicePower(
> string pvDevice,
> int dwDeviceFlags,
> ref DevicePowerState DeviceState);
>
> [DllImport("coredll.dll", SetLastError = true)]
> public static extern int DevicePowerNotify(
> string device,
> DevicePowerState state,
> int flags);
>
> public enum DevicePowerState : int
> {
>
> Unspecified = -1,
>
> D0 = 0, // Full On: full power, full functionality
>
> D1, // Low Power On: fully functional at low
> power/performance
>
> D2, // Standby: partially powered with automatic wake
>
> D3, // Sleep: partially powered with device initiated wake
>
> D4, // Off: unpowered
>
> }
>
> public const int POWER_NAME = 0x00000001;
> }
>
> To turning on use the following code:
> int res1 = PowerAPI.DevicePowerNotify(deviceName,
> PowerAPI.DevicePowerState.D4, PowerAPI.POWER_NAME);
> int res2 = PowerAPI.SetDevicePower(deviceName, PowerAPI.POWER_NAME,
> PowerAPI.DevicePowerState.D0);
>
> to check the current device state use:
> PowerAPI.DevicePowerState deviceState = new
> PowerAPI.DevicePowerState();PowerAPI.GetDevicePower(deviceName,
> PowerAPI.POWER_NAME, ref deviceState);
>
> I use for Device name this string:
> "{98C5250D-C29A-4985-AE5F-AFE5367E5006}\\TIACXWLN1".
>
> HTH,
> Federico
>
>
> Jorge ha scritto:
>
>> Can any one give me an example for turning on and off WLAN on pocket pc?
>> in
>> particular, C# code would be most helpful.
>>
>> Thanks,
>> Jorge
>



Re: SetPowerRequirement by Federico

Federico
Wed Dec 21 01:50:53 CST 2005

Jorge,
could you give me more information about your pocketpc configuration?

Which type of Wireless card have you got? It is built in or is a SDIO
(or similar) one?
What is the error value returned by DevicePowerNotify and
SetDevicePower methods?

Federico


Re: SetPowerRequirement by Jorge

Jorge
Wed Dec 21 07:11:23 CST 2005

Federico, the card is built in. The error values are 2 and 2 for
DevicePowerNotify and SetDevicePower respectively.

Thanks,
Jorge

"Federico" <pieri.federico@gmail.com> wrote in message
news:1135151453.798107.282610@f14g2000cwb.googlegroups.com...
> Jorge,
> could you give me more information about your pocketpc configuration?
>
> Which type of Wireless card have you got? It is built in or is a SDIO
> (or similar) one?
> What is the error value returned by DevicePowerNotify and
> SetDevicePower methods?
>
> Federico
>



Re: SetPowerRequirement by Jorge

Jorge
Wed Dec 21 09:23:31 CST 2005

Federico, I tested your code on a Dell Axim X51 device. It worked perfectly
with that device. Unfortunately I'll need to get it to work with the X50 as
well. I've been checking for specific information concerning the Dell Axim
X50, but so far have come up empty. If you or anyone else know of any
pertinent information please let me know.

Thanks,
Jorge

"Federico" <pieri.federico@gmail.com> wrote in message
news:1135151453.798107.282610@f14g2000cwb.googlegroups.com...
> Jorge,
> could you give me more information about your pocketpc configuration?
>
> Which type of Wireless card have you got? It is built in or is a SDIO
> (or similar) one?
> What is the error value returned by DevicePowerNotify and
> SetDevicePower methods?
>
> Federico
>



Re: SetPowerRequirement by Federico

Federico
Wed Dec 21 09:52:38 CST 2005

Hi Jorge,
today I've tested it on Dell X30 device and it doesn't work... I saw
that "Power management" option is always disable for the WiFi card. In
this way it is impossible to drive with SetDevicePower API...
I don't know very well Dell device, but perhaps there is a Dell driver
to use to turn on and off the network card.

Federico


Re: SetPowerRequirement by Jorge

Jorge
Wed Dec 21 11:50:57 CST 2005

Thanks Federico, you've been very helpful. I appreciate that so much.

Jorge


"Federico" <pieri.federico@gmail.com> wrote in message
news:1135180358.159216.51750@g44g2000cwa.googlegroups.com...
> Hi Jorge,
> today I've tested it on Dell X30 device and it doesn't work... I saw
> that "Power management" option is always disable for the WiFi card. In
> this way it is impossible to drive with SetDevicePower API...
> I don't know very well Dell device, but perhaps there is a Dell driver
> to use to turn on and off the network card.
>
> Federico
>