SetPowerRequirement

J

Jorge

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
 
P

pieri.federico

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:
 
J

Jorge

Thanks Federico! :)->)

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
 
J

Jorge

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

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
 
F

Federico

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
 
J

Jorge

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

Thanks,
Jorge
 
J

Jorge

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
 
F

Federico

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top