PC Review


Reply
Thread Tools Rate Thread

[DESPERATE] Turn on/off Bluetooth, WiFi and an RFID tag reader.

 
 
BLUE
Guest
Posts: n/a
 
      27th Apr 2007
Psion WorkAbout Pro with Windows CE .NET 4.2

Dealer gave me PowerAPIOn.exe and PowerAPIOff.exe to turn on/off tag reader,
but I want to do it programmatically and do the same with WiFi and Bluetooth
as I can do from Control Panel ("Network and dialup connections" and
"Power").

Googling I've found that I should:


- search all devices in
HKEY_LOCAL_MACHINE / System / CurrentControlSet / Control / POWER /
State / {98C5250D-C29A-4985-AE5F-AFE5367E5006} / <DEVICE_NAME>

I've found no devices under POWER.
In Control Panel I've found that I've a Cambridge Silicon Bluetooth chip.
Under HKEY_LOCAL_MACHINE/Comm I've found:
- an unknown CF8385PN1 device
- an Agere WLAGS46B1 WiFi compact flash


- use "SetDevicePower" but I don't know <DEVICE_NAME> and Microsoft
discourages application developers from calling this function:
http://msdn2.microsoft.com/en-us/library/ms889607.aspx


- use "SetPowerRequirement" in this way:

[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr SetPowerRequirement
(
string pvDevice,
CEDEVICE_POWER_STATE DeviceState,
uint DeviceFlags,
IntPtr pvSystemState,
uint StateFlags
);

...
string deviceName = ...;
CEDEVICE_POWER_STATE deviceState = ...;
uint devFlags = POWER_NAME | POWER_FORCE;
SetPowerRequirement(deviceName, deviceState, devFlags, IntPtr.Zero, 0);

MSDN says "DeviceFlags = Bitwise-or of the following flags POWER_NAME,
POWER_FORCE".
This mean Bitwise-or of all the flags or Bitwise-or of the needed ones?

MSDN says "pvDevice Must be a valid LPWSTR device name, for example,
"COM1:". The actual meaning is determined by the DeviceFlags parameter."
As mentioned above for "SetDevicePower" I don't know <DEVICE_NAME>.
In which way DeviceFLags modify the meaning???

MSDN says "POWER_NAME specifies the name of the device whose power should
be maintained at or above the DeviceState level."
I've found in Pm.h that POWER_NAME is a DWORD whose value is 1:
how can it specify a name???
Maybe MSDN means that if I use POWER_NAME will be used the name of the
device that is calling SetPowerRequirement?

If I import the dll why I have to define CEDEVICE_POWER_STATE again in
C#???


 
Reply With Quote
 
 
 
 
Jim.Neave@googlemail.com
Guest
Posts: n/a
 
      1st May 2007
On Apr 27, 9:47 am, "BLUE" <blue> wrote:
> PsionWorkAboutProwith Windows CE .NET 4.2
>
> Dealer gave me PowerAPIOn.exe and PowerAPIOff.exe to turn on/off tag reader,
> but I want to do it programmatically and do the same with WiFi and Bluetooth
> as I can do from Control Panel ("Network and dialup connections" and
> "Power").
>
> Googling I've found that I should:
>
> - search all devices in
> HKEY_LOCAL_MACHINE / System / CurrentControlSet / Control / POWER /
> State / {98C5250D-C29A-4985-AE5F-AFE5367E5006} / <DEVICE_NAME>
>
> I've found no devices under POWER.
> In Control Panel I've found that I've a Cambridge Silicon Bluetooth chip.
> Under HKEY_LOCAL_MACHINE/Comm I've found:
> - an unknown CF8385PN1 device
> - an Agere WLAGS46B1 WiFi compact flash
>
> - use "SetDevicePower" but I don't know <DEVICE_NAME> and Microsoft
> discourages application developers from calling this function:
> http://msdn2.microsoft.com/en-us/library/ms889607.aspx
>
> - use "SetPowerRequirement" in this way:
>
> [DllImport("coredll.dll", SetLastError = true)]
> private static extern IntPtr SetPowerRequirement
> (
> string pvDevice,
> CEDEVICE_POWER_STATE DeviceState,
> uint DeviceFlags,
> IntPtr pvSystemState,
> uint StateFlags
> );
>
> ...
> string deviceName = ...;
> CEDEVICE_POWER_STATE deviceState = ...;
> uint devFlags = POWER_NAME | POWER_FORCE;
> SetPowerRequirement(deviceName, deviceState, devFlags, IntPtr.Zero, 0);
>
> MSDN says "DeviceFlags = Bitwise-or of the following flags POWER_NAME,
> POWER_FORCE".
> This mean Bitwise-or of all the flags or Bitwise-or of the needed ones?
>
> MSDN says "pvDevice Must be a valid LPWSTR device name, for example,
> "COM1:". The actual meaning is determined by the DeviceFlags parameter."
> As mentioned above for "SetDevicePower" I don't know <DEVICE_NAME>.
> In which way DeviceFLags modify the meaning???
>
> MSDN says "POWER_NAME specifies the name of the device whose power should
> be maintained at or above the DeviceState level."
> I've found in Pm.h that POWER_NAME is a DWORD whose value is 1:
> how can it specify a name???
> Maybe MSDN means that if I use POWER_NAME will be used the name of the
> device that is calling SetPowerRequirement?
>
> If I import the dll why I have to define CEDEVICE_POWER_STATE again in
> C#???


Hi,

This is what I use, although you could also register as a developer at
PsionTeklogic's Teknet and download the SDK, that has lots of control
libraries.

Make this registry change (I use the OpenNETCF libraries)

HKLM\Drivers\PsionTeklogix\Bluetooth\PowerEnable = 0x1 (DWord)
Also in that Bluetooth section
resetdelay = 0x1388 (DWord)
baud = 0x1C200 (DWord)
name = "COM2:" (String)
driver = "bthuart.dll" (String)

Check for those settings at application load and reboot if you need to
change any of them.
If you use OpenNETCF, don't forget to call
Registry.LocalMachine.Flush();

To reboot:

[DllImport("coredll.dll")]
internal static extern bool KernelIoControl(UInt32 dwIoControlCode,
IntPtr lbInBuf, UInt32 nInBufSize, ref IntPtr lpOutBuf, ref UInt32
nOutBufSize, ref IntPtr lpBytesReturned);

public static void WarmReset()
{
IntPtr lpOutBuf = IntPtr.Zero;
UInt32 nOutBufSize = 0;
IntPtr lpBytesReturned = IntPtr.Zero;
UInt32 dwIocontrolCode = 0;

dwIocontrolCode = CTL_CODE(WinCEDeviceTypes.FILE_DEVICE_HAL,
WinCECTL_CODEFunctions.FUNCTION_REBOOT,
WinCEBufferMethodCodes.METHOD_BUFFERED,
WinCEKernelAccessors.FILE_ANY_ACCESS);

KernelIoControl(dwIocontrolCode, IntPtr.Zero, 0, ref lpOutBuf, ref
nOutBufSize, ref lpBytesReturned);
}

private static UInt32 CTL_CODE(WinCEDeviceTypes DeviceType,
WinCECTL_CODEFunctions Function, WinCEBufferMethodCodes Method,
WinCEKernelAccessors Access)
{
return (uint) DeviceType << 16 | (uint) Access << 14 | (uint)
Function << 2 | (uint) Method;

}

Regards,

James Neave.

 
Reply With Quote
 
Jim.Neave@googlemail.com
Guest
Posts: n/a
 
      1st May 2007
On Apr 27, 9:47 am, "BLUE" <blue> wrote:
> PsionWorkAboutProwith Windows CE .NET 4.2
>
> Dealer gave me PowerAPIOn.exe and PowerAPIOff.exe to turn on/off tag reader,
> but I want to do it programmatically and do the same with WiFi and Bluetooth
> as I can do from Control Panel ("Network and dialup connections" and
> "Power").
>
> Googling I've found that I should:
>
> - search all devices in
> HKEY_LOCAL_MACHINE / System / CurrentControlSet / Control / POWER /
> State / {98C5250D-C29A-4985-AE5F-AFE5367E5006} / <DEVICE_NAME>
>
> I've found no devices under POWER.
> In Control Panel I've found that I've a Cambridge Silicon Bluetooth chip.
> Under HKEY_LOCAL_MACHINE/Comm I've found:
> - an unknown CF8385PN1 device
> - an Agere WLAGS46B1 WiFi compact flash
>
> - use "SetDevicePower" but I don't know <DEVICE_NAME> and Microsoft
> discourages application developers from calling this function:
> http://msdn2.microsoft.com/en-us/library/ms889607.aspx
>
> - use "SetPowerRequirement" in this way:
>
> [DllImport("coredll.dll", SetLastError = true)]
> private static extern IntPtr SetPowerRequirement
> (
> string pvDevice,
> CEDEVICE_POWER_STATE DeviceState,
> uint DeviceFlags,
> IntPtr pvSystemState,
> uint StateFlags
> );
>
> ...
> string deviceName = ...;
> CEDEVICE_POWER_STATE deviceState = ...;
> uint devFlags = POWER_NAME | POWER_FORCE;
> SetPowerRequirement(deviceName, deviceState, devFlags, IntPtr.Zero, 0);
>
> MSDN says "DeviceFlags = Bitwise-or of the following flags POWER_NAME,
> POWER_FORCE".
> This mean Bitwise-or of all the flags or Bitwise-or of the needed ones?
>
> MSDN says "pvDevice Must be a valid LPWSTR device name, for example,
> "COM1:". The actual meaning is determined by the DeviceFlags parameter."
> As mentioned above for "SetDevicePower" I don't know <DEVICE_NAME>.
> In which way DeviceFLags modify the meaning???
>
> MSDN says "POWER_NAME specifies the name of the device whose power should
> be maintained at or above the DeviceState level."
> I've found in Pm.h that POWER_NAME is a DWORD whose value is 1:
> how can it specify a name???
> Maybe MSDN means that if I use POWER_NAME will be used the name of the
> device that is calling SetPowerRequirement?
>
> If I import the dll why I have to define CEDEVICE_POWER_STATE again in
> C#???


Hi,

Another quick point, I found all this out by the following process:

1) Install embedded visual C++ 4 and all relevant service packs and
psion SDKs
2) Set the Bluetooth OFF
3) Take a copy of the CR Registry using the eVC++ Remote Registry
editor
4) Set the Bluetooth ON
5) Take a second copy of the Registry
6) Compare the to *.reg files using a text comparing application (I
use KDiff3)
7) Write code to make those registry changes progamatically.

Should work for the RFID and WiFi too.

Regards,

James Neave.

 
Reply With Quote
 
BLUE
Guest
Posts: n/a
 
      1st May 2007
Do you know if there is an api call monitor for handheld devices?
It would be helpful for discovering how control panel manages to turn on/off
things.

Thanks for your tips!


 
Reply With Quote
 
Jim.Neave@googlemail.com
Guest
Posts: n/a
 
      2nd May 2007
On May 1, 2:51 pm, "BLUE" <blue> wrote:
> Do you know if there is an api call monitor for handheld devices?
> It would be helpful for discovering how control panel manages to turn on/off
> things.
>
> Thanks for your tips!


Your welcome,

I don't know of anything specific for that task but there are lots of
tools built into eVC++ 4.0.
It would be bloody handy wouldn't it?
As it happens that's the only way I've ever been able to control
things on the WPro. It's effective but requires that reboot.
You can also control the security mode and lock out "dangerous" keys
on the keyboard.
I write kiosk applications, so I don't want people to be able to get
to the Start menu (disable blue+".")

Regards,

James Neave.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Turn ON/OFF Bluetooth, WiFi and other devices (what I've discovered so far) BLUE Microsoft C# .NET 0 29th Apr 2007 03:03 PM
[DESPERATE] Turn on/off Bluetooth, WiFi and an RFID tag reader. BLUE Microsoft C# .NET 0 27th Apr 2007 09:42 AM
Product Tracking by RFID Guide,RFID and Environmental Issues, Wal-Mart and RFID: A Case Study buster Windows XP General 0 30th Jul 2006 11:32 PM
RFID Cryptography, RFID and Environmental Issues, Wal-Mart and RFID: A Case Study broadbandera@gmail.com Microsoft C# .NET 1 30th Jul 2006 11:05 PM
RFID Tutorial, RFID and Environmental Issues, Wal-Mart and RFID: A Case Study (April 2006.) buster Windows XP Networking 0 1st Jun 2006 06:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:44 AM.