469,892 Members | 2,127 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,892 developers. It's quick & easy.

Detecting insertion into/removal from cradle.

Are there events that are fired when I insert the handheld into or I remove
it from the cradle?

*OpenNETCF.Desktop.Communication.ActiveSync* class has *Active* (indicates
that a connection is established between
the client application and the connection manager) and *Inactive* (indicates
a disconnection, or disconnected state, between the
desktop computer and the Windows CE-based device) events, but I don't know
if I can use them:
"the OpenNETCF.Desktop.Communication namespace contains classes for working
remotely with devices through ActiveSync and RAPI" so I can use ActiveSync
class on an handheld to detect communication with a PC or only on a PC to
detect communication with the handheld?
Thanks,
Luigi.
May 14 '07 #1
7 5445
Luigi,

Well, does the documentation for the classes that you are using indicate
that there are events that are being fired?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"BLUE" <bluewrote in message news:uD**************@TK2MSFTNGP06.phx.gbl...
Are there events that are fired when I insert the handheld into or I
remove it from the cradle?

*OpenNETCF.Desktop.Communication.ActiveSync* class has *Active* (indicates
that a connection is established between
the client application and the connection manager) and *Inactive*
(indicates a disconnection, or disconnected state, between the
desktop computer and the Windows CE-based device) events, but I don't know
if I can use them:
"the OpenNETCF.Desktop.Communication namespace contains classes for
working remotely with devices through ActiveSync and RAPI" so I can use
ActiveSync class on an handheld to detect communication with a PC or only
on a PC to detect communication with the handheld?
Thanks,
Luigi.

May 14 '07 #2
The RAPI API is for code running on the PC side. That's why it's separate
from the OpenNETCF Smart Device Framework which runs on the device. You can
use some network calls on the device side to see if there's an ActiveSync
connection. If you try to resolve "ppp_peer" from the device, that should
only resolve if ActiveSync is connected (or maybe if the unit is dialed into
a network over a modem, but that doesn't show up very often). I'm sure that
we've discussed this in the Compact Framework group previously. Use
GoogleGroups to search microsoft.public.dotnet.framework.compactframework on
suitable key words and I'm sure you'll find something useful...

Paul T.

"BLUE" <bluewrote in message news:uD**************@TK2MSFTNGP06.phx.gbl...
Are there events that are fired when I insert the handheld into or I
remove it from the cradle?

*OpenNETCF.Desktop.Communication.ActiveSync* class has *Active* (indicates
that a connection is established between
the client application and the connection manager) and *Inactive*
(indicates a disconnection, or disconnected state, between the
desktop computer and the Windows CE-based device) events, but I don't know
if I can use them:
"the OpenNETCF.Desktop.Communication namespace contains classes for
working remotely with devices through ActiveSync and RAPI" so I can use
ActiveSync class on an handheld to detect communication with a PC or only
on a PC to detect communication with the handheld?
Thanks,
Luigi.

May 14 '07 #3
Hi,

Post in the Compactframework NG, you will get answers there from the very
same people that wrote OpenNetCF :)

"BLUE" <bluewrote in message news:uD**************@TK2MSFTNGP06.phx.gbl...
Are there events that are fired when I insert the handheld into or I
remove it from the cradle?

*OpenNETCF.Desktop.Communication.ActiveSync* class has *Active* (indicates
that a connection is established between
the client application and the connection manager) and *Inactive*
(indicates a disconnection, or disconnected state, between the
desktop computer and the Windows CE-based device) events, but I don't know
if I can use them:
"the OpenNETCF.Desktop.Communication namespace contains classes for
working remotely with devices through ActiveSync and RAPI" so I can use
ActiveSync class on an handheld to detect communication with a PC or only
on a PC to detect communication with the handheld?
Thanks,
Luigi.

May 14 '07 #4
using OpenNETCF.Win32

// ...
string key = "Comm\\tcpip\\hosts\\ppp_peer";

regKey = Registry.LocalMachine;

regKey = regKey.OpenSubKey(key, false);

if (regKey == null)
{
// NO ActiveSync connection available
}
else
{
// we do have an ActiveSync connection.
}
But the problem is: since there is no event, it's right to use a timer to
check it continuously or there is a better solution?
Thanks,
Luigi.
May 15 '07 #5
Check it just before you need it to be connected, if you're trying to decide
if it's OK to go ahead with some operation. If you're waiting for the
cradle to be connected and if the device is a Windows Mobile 5 device, you
could wait for the USB 'network' to indicate a change of state using the
AdapterStatusMonitor class, maybe, in SDF. Since you haven't really told us
*what* you're trying to do, just how you've been trying to do it, we don't
have much of a picture of what the right solution might be.

Paul T.

"BLUE" <bluewrote in message news:uB**************@TK2MSFTNGP04.phx.gbl...
using OpenNETCF.Win32

// ...
string key = "Comm\\tcpip\\hosts\\ppp_peer";

regKey = Registry.LocalMachine;

regKey = regKey.OpenSubKey(key, false);

if (regKey == null)
{
// NO ActiveSync connection available
}
else
{
// we do have an ActiveSync connection.
}
But the problem is: since there is no event, it's right to use a timer to
check it continuously or there is a better solution?
Thanks,
Luigi.

May 15 '07 #6
>But the problem is: since there is no event, it's right to use a timer to
>check it continuously or there is a better solution?
>Check it just before you need it to be connected, if you're trying to
decide if it's OK to go ahead with some operation. If you're waiting for
the cradle to be connected and if the device is a Windows Mobile 5 device,
you could wait for the USB 'network' to indicate a change of state using
the AdapterStatusMonitor class, maybe, in SDF. Since you haven't really
told us *what* you're trying to do, just how you've been trying to do it,
we don't have much of a picture of what the right solution might be.
Since I asked if there was an event it's obvious I do not want to do a check
before doing an operation: an event is used to react to some change.

BTW I have a method I call from time to time with a timer to send data to a
server and I want to disable the timer and send data immediately as soon as
the handheld is inserted into the cradle.
Moreover I want to roll back operation as soon as the handheld is removed
from the cradle if this happens before the end of the operation itself.

I've WinCE 4.2.
Thanks,
Luigi.
May 15 '07 #7
That sounds like you're implementing what MSMQ does automatically, but OK,
if you prefer to do it yourself to avoid having to add that component to the
OS or avoid learning another new API, you can still try the
AdapterStatusMonitor scheme. My guess is that whether this will work or not
will depend on what version of ActiveSync is on the other end of the cradle
connection, etc., but you might be able to get it to work with both 3.8 and
4.x and it would notify you when the network connection was created in
response to a cradle event.

You could also try asking for notification from the Notification Manager of
events like RS232 connection or whatever corresponds to a cradle event
(CeRunAppAtEvent). I'm sure that's how ActiveSync is getting notified of a
connect event, so it should work for you, too, although you might have to do
some checking, once you're notified, to make sure that the connection is
really ready; it won't be instantaneous. You wouldn't have to poll for
cradle connection, though.

Paul T.

"BLUE" <bluewrote in message news:OM**************@TK2MSFTNGP06.phx.gbl...
>>But the problem is: since there is no event, it's right to use a timer
to check it continuously or there is a better solution?
>>Check it just before you need it to be connected, if you're trying to
decide if it's OK to go ahead with some operation. If you're waiting for
the cradle to be connected and if the device is a Windows Mobile 5 device,
you could wait for the USB 'network' to indicate a change of state using
the AdapterStatusMonitor class, maybe, in SDF. Since you haven't really
told us *what* you're trying to do, just how you've been trying to do it,
we don't have much of a picture of what the right solution might be.

Since I asked if there was an event it's obvious I do not want to do a
check before doing an operation: an event is used to react to some change.

BTW I have a method I call from time to time with a timer to send data to
a server and I want to disable the timer and send data immediately as soon
as the handheld is inserted into the cradle.
Moreover I want to roll back operation as soon as the handheld is removed
from the cradle if this happens before the end of the operation itself.

I've WinCE 4.2.
Thanks,
Luigi.

May 15 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Anton.Nikiforov | last post: by
5 posts views Thread by John N. | last post: by
6 posts views Thread by barcaroller | last post: by
9 posts views Thread by python_newbie | last post: by
1 post views Thread by =?Utf-8?B?Sm9lIE1pbGxlcg==?= | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.