大家知道, Windows Mobile 6.0 SDK 自带了 cellular emulator fake GPS ,使得我们可以在模拟器上调试 radio 级的 phone call 和基于 GPS 的地理位置应用。前几天,一位 MVP Dmitry Klionsky 撰写了文章《 Bluetooth for Microsoft Device Emulator 》,讲述了在 Windows Mobile 模拟器上使用蓝牙的方法,我觉得这对于开发移动设备上蓝牙通信的朋友来说,是非常有用的。

我们来看看实现 Bluetooth 的架构,参考图 1( 来源于 Bluetooth for Microsoft Device Emulator ) ,主要包括 emulator 端和 PC 端:

1 Emulator PC 上实现 Bluetooth 通信的架构

1. Emulator

Bluetooth HCI Transport Driver

Serial Port Driver

Microsoft Remote Tools Framework remote agent

2.  PC

Microsoft Remote Tools Framework desktop plugin

FreeBT USB Driver runtime

FreeBT USB Driver

Connected Bluetooth USB device

注意:作者采用了 FreeBT 这个开源的工程来控制 Bluetooth 的接入。

在Windows Mobile 模拟器上使用蓝牙的 必要条件有:

1. Visual studio 2005 with SP1 或者 Visual studio 2008

2. Windows Mobile 5.0 Pocket PC/Smartphone SDK and/or Windows Mobile 6 Standard/Professional SDK emulator images

3. Device Emulator 3.0

4. Microsoft Remote Tools Framework 1.00

5. 一个具有 USB 接口的 Bluetooth dongle

Windows Mobile 模拟器上使用蓝牙的步骤如下(详细请参考 Bluetooth for Microsoft Device Emulator ):

1. PC 端安装下载的 FreeBT 的蓝牙驱动,方法自然是通过“ windows 设备管理器”,为新的硬件设备(也就是连接的 Bluetooth USB device )添加下载过来的驱动(主要是找到 fbtusb.inf 文件)。

2. Remote Tools Framework plugin 中运行 BthEmulManager.cetool ,将其和模拟器建立连接。

3. 连接建立以后,蓝牙设备的信息 (Address, Manufacturer, HCI Version, LMP Version) 就会显示在界面上了,如图 2 所示(来源于 Bluetooth for Microsoft Device Emulator .

2 :建立蓝牙联系以后,在模拟器上的信息

4. Microsoft Remote Tools Framework 允许我们同时开启两个模拟器,因此,如果手头有两个 Bluetooth USB dongle 的话,我们就可以在两个模拟器上调试蓝牙的收发通信了。

参考链接:

Dmitry Klionsky Bluetooth for Microsoft Device Emulator

MSDN Bluetooth HCI Transport Driver

MSDN Serial Port Driver

Open source FreeBT

Device Emulator 3.0

Microsoft Remote Tools Framework 1.00

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。