icrosoft owes a large part of its success to the various development tools it has offered to the developer community. If you have experiences developing on other platforms, you would no doubt feel that Visual Studio is one of the most productive tools a platform can offer. This is even truer for Windows Mobile developers. For the past few iterations of the Windows Mobile SDK, Microsoft has progressively added new features to the SDKs to make development and testing as painless as possible. In the latest version of the Windows Mobile 6 Professional and Standard SDKs, you can now test phone and SMS functionalities using the built-in Cellular Emulator&3151;without needing to use a physical device.
To be successful in Windows Mobile development, you should first get yourself familiarized with the emulators and tools provided. This article will show you how to use the various emulators and tools available to make your development life cycle as effective as possible.
Launching the Emulators
The easiest way to launch the Windows Mobile Emulators is to use the Device Emulator Manager. The Device Emulator Manager can be launched from Visual Studio 2008 by selecting Tools?Device Emulator Manager. Once Device Emulator Manager is launched, you will see a list of the available emulators. What devices are on this list depends on the version of Visual Studio on your machine as well as the SDKs you have installed. To launch an emulator, right-click on the emulator you want and select Connect. Note that you can launch multiple emulators at the same time.
Within Visual Studio 2008, you will see the Device toolbar when you are editing a Smart Device application project. There are three items that will be of interest to you, shown in Figure 1.
To deploy your application to a particular emulator/device, simply select the target device and press F5 to debug your application. The selected emulator/device will be launched automatically and your application deployed into it. If you want to launch an emulator without deploying your application, click the Connect to device button. The Device options button allows you to make copies of the various emulators and as well as configure their properties (see Figure 2).
For example, you may wish to test your application on a custom emulator without affecting the original emulator shipped with Visual Studio. In this case, you’d save a copy of the selected emulator (click the Save As… button) and give it a new name. The newly copied emulator will be located in the device list as well as in the Device Emulator Manager.
Now, you can customize the emulator copy and henceforth test all your applications on this modified emulator. To customize an emulator, launch the copy of the emulator that you have just created.
Suppose you wish to remove the various items in the Start menu (see Figure 3). This is useful if you are using the Hopper tool to test your applications. To preserve the state of the emulator, simply shut down the emulator and when asked if you want to save its state, click Yes.
When an emulator is running, you can save its configuration information to a file. For example, you may have configured an emulator to simulate low battery power as well as mapped the serial port 0 to COM3 (see Figure 4).
|Figure 5. The Configuration File: The .decfg configuration file stores the settings of the emulator.|
To save this configuration, right-click on the emulator in the Device Emulator Manager and select Save-As. You will be asked to give a name for the configuration file, for example, LowBatConfig.decfg. When the emulator settings are saved, you will be able to find it under the category My Device Emulators in the Device Emulator Manager.
The LowBatConfig.decfg configuration file will be saved in the C:Documents and Settings
To apply the saved settings to another emulator, right-click on another emulator (it must be connected first, i.e. running) and select Reconfigure. Select the previously saved LowBatConfig.decfg file and the emulator will inherit the previously saved settings. In this example, the emulator will now have its serial port 0 mapped to COM3 and have its battery level dropped to 20 percent.
Network Access within the Emulator
One of the most commonly performed tasks in a Windows Mobile application is network access. For example, your Windows Mobile application may connect to a web service, so you need Internet access in order to test this feature. Fortunately, the latest version of the device emulator makes it easy to connect to the Internet via the following ways:
- Network card mapping
The first way to get connectivity in the emulator is to cradle the emulator to ActiveSync and use ActiveSync toconnect to the Internet.
First, you need to prepare ActiveSync. In ActiveSync, go to File?>Connection Settings…. Check the Allow connections to one of the following checkbox and select the DMA option. Click OK. To cradle an emulator to ActiveSync, right-click on the emulator in the Device Emulator Manager and select Cradle. When the emulator is successfully cradled to ActiveSync, its icon will change accordingly–and so will the icon on the Home screen.
The emulator will now connect to ActiveSync and you will be brought through a series of steps to synchronize the emulator with ActiveSync. If your sole intention is to allow the emulator to access the network, click Cancel. Clicking the emulator’s icon will display that ActiveSync is connected (see Figure 6).
The second way to connect your emulator to the network is to enable the NE2000 PCMCIA network adapter in the emulator and bind it to the network card on your computer. To use this option, go to the File?>Settings option in the emulator, click on the Network tab, check the Enable NE2000 PCMCIA network adapter, and bind it to the checkbox (see Figure 7). Select the Connected network card option and click OK.
In order to use this option, you’ll need to install Virtual PC 2007. Download a free copy here.
Once the network card is successfully mapped, click on the network icon in the Home screen. This should show that the Network Card is connected.
The third way to connect is to emulate a GPRS connection on the emulator. In order to use this option, you need to use the Cellular Emulator (the next section shows how you use the Cellular Emulator with your Windows Mobile emulator). Once the Cellular Emulator is up and running, click the Start?>Settings options within the Windows Mobile emulator. Select the Connections tab and click the Connections icon. You will see the Connections screen. Click the Add a new modem connection link (under the My ISP) section. In the next screen, give a name to the connection and select Cellular Line (GPRS).
Click Next and leave the Access point name blank. In the next screen, leave out the User name, Password, and Domain and click Finish.
Now, you can test to see if the connection works. Launch Pocket Internet Explorer and try to navigate to a site. You will see the “G” icon located at the top of the Windows Mobile emulator. At the same time, in the Cellular Emulator you will also see the number of bytes transferred listed in the Network tab (see Figure 8).
You can also emulate a 3G connection by clicking on the Switch to 3G button in the Cellular Emulator (see Figure 9).
The Windows Mobile 6 SDKs shipped with a very useful tool that allows developers to test phone and SMS applications without using a real device.
To launch the Cellular Emulator, click the Start?>Programs?>Windows Mobile 6 SDK?>Tools?>Cellular Emulator. Observe the COM port number located at the bottom left of the screen. Most computers should either display either COM3 or COM4.
To enable your Windows Mobile emulator to connect to the Cellular Emulator, go to the Properties page of your Windows Mobile emulator (File?>Settings) and select the Peripherals tab. Under Serial Port 0, enter the COM port that you have observed in your Cellular Emulator. Click OK.
|Author’s Note: Only Windows Mobile 6 Professional emulators can connect to the Cellular Emulator; Classic emulators cannot be used as they do not have phone radios.|
You need to perform a soft reset on the Windows Mobile Emulator (File?>Reset?>Soft). After the reset, you should now observe that the Windows Mobile emulator now has a full-signal indicator (see Figure 10).
You can now make a phone call from the Cellular Emulator and the Windows Mobile emulator will receive an incoming call (see Figure 11).
|Figure 12. Fake SMS Messages: The Cellular Emulator messages the Windows Mobile emulator.|
Likewise, the Windows Mobile emulator can also make an out-going call and the call will be displayed in the Cellular Emulator. The Cellular Emulator also shows a list of numbers (7272024, 7272020, etc) that you can use to simulate different phone conditions (such as busy line, call reject, and so on).
You can also use the Cellular Emulator to send SMS messages to the Windows Mobile emulator (see Figure 12). You can send a chain of messages by checking the Repeatedly checkbox and specifying the intervals between messages. SMS messages sent by the Windows Mobile Emulator will also be displayed in the Cellular Emulator.
Now you’ve seen how to use the Windows Mobile emulator and how to lend it Internet access using the various available methods. You’ve also seen how to connect a Windows Mobile emulator to the Cellular Emulator so that you can enable phone and SMS functionalities in your emulator.