Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Bluetooth for Microsoft Device Emulator

0.00/5 (No votes)
31 Jul 2009 3  
Bluetooth for Microsoft Device Emulator enables Bluetooth communication from and to the emulator.

Introduction

Bluetooth for Microsoft Device Emulator enables Bluetooth communication from and to the emulator.

Bluetooth connectivity with the Microsoft Device Emulator has been tested with the following SDKs images:

  • Windows Mobile 5.0 Pocket PC SDK
  • Windows Mobile 5.0 Smartphone SDK
  • Windows Mobile 6 Professional SDK
  • Windows Mobile 6 Standard SDK

Background 

Once I heard that Nokia has released S60 SDK Bluetooth Driver for Windows XP. Many of my Windows Mobile projects use Bluetooth, but Windows Mobile emulator doesn't support it. I realized if Nokia has done it, why I could not. Please notice I'm not a Microsoft employee and I'm here not to advertise either Microsoft or anyone else.  

After a lot of investigations, I realized that Windows Mobile images have included 100% working Microsoft Bluetooth stack implementation. The only missing part was a Bluetooth hardware. Thus all to be done is to develop a Bluetooth HCI Transport Driver that carries HCI/ACL requests and responses to and from the real Bluetooth USB device connected to the desktop. But there were a few problems to address. The first one was how to access the HCI level of the Bluetooth Device. The only acceptable Bluetooth stack available for Windows that allows access to the HCI level is FreeBT stack. It's freeware and comes with source code. It's indeed the one I was looking for. The second problem was how to connect the device emulator and the desktop. I decided not to use the ActiveSync related methods. Also the Serial port sharing prevents me from using the Cellular Emulator. There is a CoreConn interface, but it has been introduced in Visual Studio 2008 and isn't available in Visual Studio 2005 which is my primary development platform. Thus the choice was quite obvious - Microsoft Remote Tools Framework. It uses the CoreCon interface either. Exactly the same the Visual Studio Smart Device Native Debugger uses. This way you get fully functional Bluetooth support on the emulator. You can write applications using managed or unmanaged code, use third party Bluetooth utilities and so on.

Requirements

Please notice that you MUST have installed ALL the following:

  • Windows XP or Windows Vista 32-bit with the latest service packs.
  • Microsoft Visual Studio 2005 or 2008 with the latest service packs. Your Visual Studio installation must include the Smart Device Programmability feature.
  • Windows Mobile 5.0 Pocket PC SDK and/or Windows Mobile 5.0 Smartphone SDK and/or Windows Mobile 6 Professional SDK and/or Windows Mobile 6 Standard SDK emulator images 
  • Microsoft Device Emulator (Recommended: Version 3.0)
  • Microsoft Remote Tools Framework 1.00

Also you should have an available Bluetooth USB dongle.

Note

This version of Bluetooth for Microsoft Device Emulator uses FreeBT project to access the Bluetooth USB dongle.

Architecture Overview

The project consists of the followings components:

  1. Device side
  2. Desktop side
    • Microsoft Remote Tools Framework desktop plugin
    • FreeBT USB Driver runtime
    • FreeBT USB Driver
    • Connected Bluetooth USB device

Bluetooth USB Driver Installation

  1. Open the Windows Device Manager.
  2. In the Device Manager, locate the Bluetooth device to be used as the FreeBT USB device.
  3. Click the right mouse button and select "Update Driver..." in the popup-menu.
  4. Select "No, not this time" and click "Next >".
  5. Select "Install from a list or specific location" and click "Next >".
  6. Select "Don't search. I will choose the driver to install" and click "Next >".
  7. Select the device driver and click the "Have Disk...".
  8. In the Locate File dialog, browse to fbtusb.inf file and click "Next >".
  9. When a "Hardware Installation warning" appears, click "Continue Anyway".
  10. Once the installation has been completed, click "Finish".
  11. The Device Manager should now display "FreeBT USB Driver" in the list of USB controllers.

Please refer to FreeBT documentation for more details.

Installation

  1. Install the Visual Studio 2005 or 2008 with the latest service packs. Your Visual Studio installation should include the Smart Device Programmability feature.
  2. Install the Microsoft Device Emulator. You should have already installed one along with the VS installation. Update it to the Microsoft Device Emulator 3.0.
  3. Install emulator images you need.
  4. You must have an USB Bluetooth dongle available. Plugin in it an available USB port.
  5. Install the FreeBT USB driver as described in the BLUETOOTH USB DRIVER INSTALLATION section.
  6. Install the Microsoft Remote Tools Framework 1.00.

Getting Started

  1. Install the FreeBT USB Driver as described in the BLUETOOTH USB DRIVER INSTALLATION section.
  2. Install all REQUIREMENTS section as described in the INSTALLATION section.
  3. Launch the Remote Tools Framework plugin BthEmulManager.cetool from "RTFx Plugin" folder.
  4. Select an emulator image from the list.
  5. Wait for the emulator to be connected.
  6. Select "Bluetooth for Microsoft Device Emulator" node.
  7. If you have a Bluetooth device attached successfully, then the Bluetooth device info (Address, Manufacturer, HCI Version, LMP Version) will be displayed. Bluetooth should now be operational in your emulator. An error code with the description will be displayed otherwise.
  8. To clear the communication log, click the right mouse button and select "Clear All".
  9. To copy current device information to the clipboard, select "Bluetooth for Microsoft Device Emulator" node, click the right mouse button and select "Copy to Clipboard".
  10. To switch off Bluetooth on the emulator, click "Connection" menu item and select "Disconnect from ... emulator".
  11. Microsoft Remote Tools Framework allows you to start two device emulators at the same time. If you have installed two or more FreeBT USB devices, click "Windows" menu item and select "Split Windows View". Repeat steps 3-6. You will get two Bluetooth powered emulators running simultaneously.
  12. It is possible to enable/disable device side logging. If you enable "Device Logging" checkbox, then remote logging will be enabled on the emulator. Have a look at \\Temp directory on the emulator. There should be created btd_bthemul_0.txt, btd_BthEmulAgent_0.txt, btd_bthemulcom_0.txt files.
  13. It is possible to enable/disable desktop side logging. If you enable "Desktop Logging" checkbox, then local logging will be enabled. Have a look at your installation directory. There should be created BthEmulManager.txt file.
  14. It is possible to enable/disable communication logging. Communication logging allows to see communication activities between the emulator and the Bluetooth device.

Troubleshooting

Q. I've installed the FreeBT USB Driver, but after deploying the emulator Bluetooth is still not working.
A. Install the Microsoft Remote Tools Framework 1.00 if you haven't done it yet. Launch the Remote Tools Framework plugin BthEmulManager.cetool from "RTFx Plugin" folder.

Q. I'm trying to connect Pocket PC 2003 SE Emulator, but I receive an error all the time: "The device Pocket PC 2003 SE VGA Emulator has a CPU type of ARMV4 and an operating system version of 4.21."
A. Pocket PC 2003 and Smartphone 2003 aren't supported yet.

Q. Which Windows Device Manager the README refers to?
A. Win2K&XP: Start -> Settings -> Control Panel -> System -> Hardware tab -> Device Manager
Vista: Start -> Settings -> Control Panel -> Hardware and Sound -> Device Manager

Q. I have started the BthEmulManager.cetool plugin for the first time, but nothing happens. There isn't Bluetooth in the emulator.
A. Try to restart the plugin for the previously chosen emulator. Also on the emulator, go to Settings -> Connections -> Bluetooth -> Mode tab and turn on Bluetooth.

You may also have problems with the FreeBT USB Driver itself. The driver is still (and will probably remain at this stage) in alpha version. There are a number of reports saying it has problems. The problems with this driver are the following:

  1. It stops working for no reason.
  2. It may miss packets in write/read operations. The problems start when you send large packets very fast. Most probably, the problem in an incorrect using HCI buffers (Read Buffer Size Command, Number Of Completed Packets Event).
  3. It isn't stable with some chipset like CSR.

I encourage you if you have such problems and have experience in the Windows driver development to try to improve the driver and share your results.

If something goes wrong after a while with the driver start the Device Manager, select the problem FreeBT USb Driver from the USB device list, click the right mouse button and select "Disable" in the popup-menu. After that, click the right mouse button again and select "Enable" in the popup-menu.

Thanks

Thanks to Antony C. Roberts for his FreeBT open source stack. Without it, this release would not have been possible.

History 

  • 2009-05-15
    • Small improvements
  • 2009-04-13
    • Small improvements
  • 2009-04-08 
    • Original article

P.S. Sorry for my English. My native language is C++. But I also speak Russian very well. Please let me know about my mistakes.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here