Debugging device cellular connection code without ActiveSync interference

You Can Take it With You

Syndication

News

I had a situation today where I needed to debug some code that used Connection Manager to establish a cellular connection. The challenge was that the connectivity problem was only observed on certain devices therefore I couldn't use the Device Emulator & Cellular Emulator to debug … I needed to debug on a real device.

This all sounds simple enough until you start to try and do it… In order to debug application code using Visual Studio, I have to connect the device to my desktop using ActiveSync or WMDC.

Now here's the problem…

I want my application to establish a cellular connection but ActiveSync/WMDC provide the device with network connectivity … as a result any call to ConnMgrEstablishConnection or ConnMgrEstablishConnectionSync to establish the network connection returns with a successful connection but not a cellular connection because Connection Manager is recognizing that the current ActiveSync/WMDC connection meets the application's network connectivity requirements.

I could modify my code to explicitly establish a cellular connection but I want to debug the application code as it will run in real life. In real life, I want Connection Manager to choose the appropriate connection … I just need to debug the cellular scenario right now.

I have to say that I did stare at my screen for a minute or so wondering what kind of kludge I could come up with to get the device to not use ActiveSync/WMDC and then I realized … the answer is quite simple.

Windows Mobile manages connections as connecting to Work Network or connecting to The Internet. Since I'm trying to create a cellular connection, I want an Internet connection. All I need to do is tell the device that ActiveSync/WMDC doesn't provide Internet connections.

On the ActiveSync Connection Settings dialog there's a selection that reads "This computer is connected to:" with a default value of Automatic. Simply changing that setting from Automatic to Work Network solves all my problems.

Now when I call connection manager requesting a connection that reaches a location on the Internet, Connection Manager looks at the ActiveSync/WMDC setting and determines that ActiveSync/WMDC connection cannot meet that requirement; therefore, Connection Manager looks for other choices which then initiates a new Cellular Connection just as it would in the field when not connected to ActiveSync.

Viola … I can debug my cellular connectivity code J

Like many of us, I've often found the whole Windows Mobile Work Network vs. The Internet connectivity handling to be a bit of a pain but in this case it did make my life easier. Of course what would be even better is to have a way to explicitly do what I really wanted to do… setup an application debugging scenario that let's one choose whether ActiveSync should be considered a viable connection route during application debugging.


Posted Jul 16 2008, 08:43 AM by jim-wilson

Add a Comment

(required)  
(optional)
(required)  
Remember Me?