Testing the Application
|Figure 4: Make a Connection. Use the Bluetooth Manger on the Pocket PC device connected to your development machine to make it recognize another Bluetooth device.|
To test the application, you need to install the sample application on both Pocket PCs. The easiest way to do this is to connect one of the Pocket PCs to your development machine and use Visual Studio .NET 2003 to deploy the application on the device. Then press F5 to automatically copy the application onto the device.
The next step is to copy the application onto the other Pocket PC. There are two steps involved here. First, you need to generate a CAB file for the application so that it can be copied and installed on the target Pocket PC. Second, you need to install the .NET Compact Framework on it (this only needs to be done once).
But before you can do either task, you need to establish a Bluetooth connection between the two Pocket PCs using the Bluetooth Manager to create a bond between them (see Figure 4
Now that the two devices recognize each other, you can go about sending the CAB file and the framework to the remote device. To generate a CAB file for your application, click on the "Build Cab File" button in Visual Studio .NET 2003 (see Figure 5):
|Figure 6: Pick a CAB. Visual Studio.NET will automatically generate CAB files for all platforms supported by the Compact Framework.|
When the CAB file is generated, you can locate it in the "Cab\Debug" folder of your application. Visual Studio .NET 2003 will generate the CAB files for the various platforms that are supported by the .NET Compact Framework (see Figure 6
. Make sure to identify the right one for your platform.
To copy the CAB file to your Pocket PC, connect your Pocket PC to your machine and use Microsoft ActiveSync's Explore option. Drag and drop the CAB file onto the desired directory (see Figure 7).
Once the CAB file is copied to the device, you can use Bluetooth to send the CAB file to the other Pocket PC, as shown in Figure 8
The next step is to copy the .NET Compact Framework to the Pocket PC. You can find the CAB file for the .NET Compact Framework in the following directory on your development machine (with Visual Studio .NET 2003 installed):
C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE\wce300
Choose the appropriate platform for your Pocket PC (see Figure 9
). For example, my second Pocket PC is an iPaq 3630, so I chose the "arm" platform as it runs on an ARM processor. (To find out the type of processor your Pocket PC is running on, go to Start>Settings and tap on the System tab, and click on the About icon. Under the "Processor" category, you should see the processor type. Both my Pocket PCs runs on the ARM SA1110 processor.)
Copy the "netcf.core.ppc3.arm" file (or the appropriate one for your device) to the Pocket PC via ActiveSync. Again, use Bluetooth to send the file from one device to the other.
On the other Pocket PC, you can now install the .NET Compact Framework and the application by tapping on the two CAB files (see Figure 10
). The order of installation is importantinstall the .NET CF first.
Once the application is installed, you should find a BluetoothChat application icon in the Programs folder (see Figure 11).
Before you load the application, make sure that you have a Bluetooth bond between the two Pocket PCs. Tap on the Settings>Connect menu item to establish a serial connection. The other Pocket PC will receive an authorization request for the use of the serial port. Click on Accept to start chatting!
|Figure 12: Chat Away. The two screens show the dialog between the two Pocket PCs using the sample chat application in this article.|
In this article, you have seen how to you can program Bluetooth applications using serial communication programming. The initial release of the .NET Compact Framework is not expected to contain classes for Bluetooth communications. However, expect to see Bluetooth managed classes and APIs appearing in Windows CE .NET and the next release of the .NET Compact Framework.