Windows Moible, Wince 使用.NET Compact Framework的进行蓝牙(Bluetooth)设备配对的开发
在.NET Compact Framework下的Bluetooth开发 之 32feet.NET 里讲述了如何使用32feet.net库来进行Bluetooth的开发,天机 同学在使用过程发现设备配对问题,本文讲述如何进行Bluetooth设备配对的开发。
以下是一个Bluetooth配对程序。在配对之前先扫描附近的Bluetooth设备。
Dictionary<string, BluetoothAddress> deviceAddresses = new Dictionary<string, BluetoothAddress>();
private void menuItem2_Click(object sender, EventArgs e)
{
//Turn on the bluetooth
BluetoothRadio radio = BluetoothRadio.PrimaryRadio;
radio.Mode = RadioMode.Connectable;
//Scan the nearby devices
BluetoothDeviceInfo[] devices = client.DiscoverDevices();
listBoxDevices.Items.Clear();
deviceAddresses.Clear();
foreach(BluetoothDeviceInfo device in devices)
{
listBoxDevices.Items.Add(device.DeviceName);
deviceAddresses[device.DeviceName] = device.DeviceAddress;
}
}
deviceAddresses 用于保存设备名字和设备地址的映射。当点击 Discover 菜单,先修改BluetoothRadio 的 property Mode 来打开Bluetooth设备,然后通过DiscoverDevices() 函数来扫描附近的所有Bluetooth设备。
这是扫描的结果, Jake为我的手机, AV890为Bluetooth 耳机。点击AV890 然后点击 Pair 菜单进行配对。AV890的默认配对密码为 0000。
配对的代码如下:
{
try
{
BluetoothAddress deviceAddress = deviceAddresses[listBoxDevices.SelectedItem.ToString()];
client.SetPin(deviceAddress, textBoxPin.Text.Trim());
client.Connect(deviceAddress, BluetoothService.Handsfree); //if connect ot Hands free.
//client.Connect(deviceAddress, BluetoothService.SerialPort); //if connect to cell phone and so forth.
MessageBox.Show("Pair successful.");
//transfer data..
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
由于设备有密码,所以配对的时候需要设置密码,使用 SetPin()函数设置对端设备的密码。SetPin() 函数使用了下面的API
public static extern int BthSetPIN(byte[] pba, int cPinLength, byte[] ppin);
Connect() 函数的第二个参数十分重要,天机 同学的程序配对失败可能是因为在这里没有设置正确。参数二是服务类型,通信双方必须使用同样的服务类型。如果通信双方的程序都是由我们负责开发,可以使用通用的服务类型,例如BluetoothService.SerialPort。但是如果要与第三方设备进行通信,需要查出该设备的服务类型,在设备端的通信服务类型一般编写在Firmware(固件)里面,而且会按照规范编写,例如Bluetooth耳机会使用BluetoothService.Handsfree。具体的规范可以参考下面文章。http://en.wikipedia.org/wiki/Bluetooth_profile
在32feet.net里使用BluetoothService来定义服务类型,如下:
/// <summary>
/// Represents the base Guid from which all standard Bluetooth profiles are derived - not used for connections.
/// </summary>
public static readonly Guid BluetoothBase = new Guid(0x00000000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
//Considering moving all the protocol definitions to a separate class from the profiles
public static readonly Guid SdpProtocol = new Guid(0x00000001, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid UdpProtocol = new Guid(0x00000002, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid RFCommProtocol = new Guid(0x00000003, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid TcpProtocol = new Guid(0x00000004, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid TcsBinProtocol = new Guid(0x00000005, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid TcsAtProtocol = new Guid(0x00000006, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid ObexProtocol = new Guid(0x00000008, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid IPProtocol = new Guid(0x00000009, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid FtpProtocol = new Guid(0x0000000A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid HttpProtocol = new Guid(0x0000000C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid WspProtocol = new Guid(0x0000000E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid BnepProtocol = new Guid(0x0000000F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid UpnpProtocol = new Guid(0x00000010, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid HidpProtocol = new Guid(0x00000011, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid HardcopyControlChannelProtocol = new Guid(0x00000012, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid HardcopyDataChannelProtocol = new Guid(0x00000014, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid HardcopyNotificationProtocol = new Guid(0x00000016, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid AvctpProtocol = new Guid(0x00000017, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid AvdtpProtocol = new Guid(0x00000019, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid CmtpProtocol = new Guid(0x0000001B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid UdiCPlaneProtocol = new Guid(0x0000001D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid McapControlChannelProtocol = new Guid(0x0000001E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid McapDataChannelProtocol = new Guid(0x0000001F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
public static readonly Guid L2CapProtocol = new Guid(0x00000100, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1000]
/// </summary>
public static readonly Guid ServiceDiscoveryServer = new Guid(0x00001000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1001]
/// </summary>
public static readonly Guid BrowseGroupDescriptor = new Guid(0x00001001, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1002]
/// </summary>
public static readonly Guid PublicBrowseGroup = new Guid(0x00001002, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Provides a basic Serial emulation connect over Bluetooth. [0x1101]
/// </summary>
public static readonly Guid SerialPort = new Guid(0x00001101, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Used to establish PPP connections over RFComm channels. [0x1102]
/// </summary>
public static readonly Guid LanAccessUsingPpp = new Guid(0x00001102, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1103]
/// </summary>
public static readonly Guid DialupNetworking = new Guid(0x00001103, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1104]
/// </summary>
public static readonly Guid IrMCSync = new Guid(0x00001104, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Used for sending binary objects between devices.[0x1105]
/// </summary>
public static readonly Guid ObexObjectPush = new Guid(0x00001105, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// OBEX version of an FTP server [0x1106]
/// </summary>
public static readonly Guid ObexFileTransfer = new Guid(0x00001106, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1107]
/// </summary>
public static readonly Guid IrMCSyncCommand = new Guid(0x00001107, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Supports Bluetooth headset devices.[0x1108]
/// </summary>
public static readonly Guid HSP = new Guid(0x00001108, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1109]
/// </summary>
public static readonly Guid CordlessTelephony = new Guid(0x00001109, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x110A]
/// </summary>
public static readonly Guid AudioSource = new Guid(0x0000110A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x110B]
/// </summary>
public static readonly Guid AudioSink = new Guid(0x0000110B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x110C]
/// </summary>
public static readonly Guid AVRemoteControlTarget = new Guid(0x0000110C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x110D]
/// </summary>
public static readonly Guid AdvancedAudioDistribution = new Guid(0x0000110D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x110E]
/// </summary>
public static readonly Guid AVRemoteControl = new Guid(0x0000110E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x110F]
/// </summary>
public static readonly Guid VideoConferencing = new Guid(0x0000110F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1110]
/// </summary>
public static readonly Guid Intercom = new Guid(0x00001110, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1111]
/// </summary>
public static readonly Guid Fax = new Guid(0x00001111, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1112]
/// </summary>
public static readonly Guid HeadsetAudioGateway = new Guid(0x00001112, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1113]
/// </summary>
public static readonly Guid Wap = new Guid(0x00001113, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1114]
/// </summary>
public static readonly Guid WapClient = new Guid(0x00001114, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1115]
/// </summary>
public static readonly Guid Panu = new Guid(0x00001115, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1116]
/// </summary>
public static readonly Guid Nap = new Guid(0x00001116, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1117]
/// </summary>
public static readonly Guid GN = new Guid(0x00001117, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1118]
/// </summary>
public static readonly Guid DirectPrinting = new Guid(0x00001118, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1119]
/// </summary>
public static readonly Guid ReferencePrinting = new Guid(0x00001119, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x111A]
/// </summary>
public static readonly Guid Imaging = new Guid(0x0000111A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x111B]
/// </summary>
public static readonly Guid ImagingResponder = new Guid(0x0000111B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x111C]
/// </summary>
public static readonly Guid ImagingAutomaticArchive = new Guid(0x0000111C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x111D]
/// </summary>
public static readonly Guid ImagingReferenceObjects = new Guid(0x0000111D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Supports hands free kits such as a car kits which provide audio and more advanced call control than the Headset profile. [0x111E]
/// </summary>
public static readonly Guid Handsfree = new Guid(0x0000111E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x111F]
/// </summary>
public static readonly Guid HandsfreeAudioGateway = new Guid(0x0000111F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1120]
/// </summary>
public static readonly Guid DirectPrintingReferenceObjects = new Guid(0x00001120, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1121]
/// </summary>
public static readonly Guid ReflectedUI = new Guid(0x00001121, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Used for printing simple text, HTML, vCard objects and similar. [0x1122]
/// </summary>
public static readonly Guid BasicPrinting = new Guid(0x00001122, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1123]
/// </summary>
public static readonly Guid PrintingStatus = new Guid(0x00001123, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Supports human interface devices such as keyboards and mice. [0x1124]
/// </summary>
public static readonly Guid HumanInterfaceDevice = new Guid(0x00001124, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1125]
/// </summary>
public static readonly Guid HardcopyCableReplacement = new Guid(0x00001125, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1126]
/// </summary>
public static readonly Guid HardcopyCableReplacementPrint = new Guid(0x00001126, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1127]
/// </summary>
public static readonly Guid HardcopyCableReplacementScan = new Guid(0x00001127, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Common_ISDN_Access [0x1128]
/// </summary>
public static readonly Guid CommonIsdnAccess = new Guid(0x00001128, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1129]
/// </summary>
public static readonly Guid VideoConferencingGW = new Guid(0x00001129, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// UDI_MT [0x112A]
/// </summary>
public static readonly Guid UdiMT = new Guid(0x0000112A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// UDI_TA [0x112B]
/// </summary>
public static readonly Guid UdiTA = new Guid(0x0000112B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x112C]
/// </summary>
public static readonly Guid AudioVideo = new Guid(0x0000112C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// SIM_Access [0x112D]
/// </summary>
public static readonly Guid SimAccess = new Guid(0x0000112D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Phonebook Access - PCE [0x112E]
/// </summary>
public static readonly Guid PhonebookAccessPce = new Guid(0x0000112E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Phonebook Access - PSE [0x112F]
/// </summary>
public static readonly Guid PhonebookAccessPse = new Guid(0x0000112F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Phonebook Access [0x1130]
/// </summary>
public static readonly Guid PhonebookAccess = new Guid(0x00001130, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Headset [0x1131]
/// </summary>
public static readonly Guid Headset = new Guid(0x00001131, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Message Access Server [0x1132]
/// </summary>
public static readonly Guid MessageAccessServer = new Guid(0x00001132, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Message Notification Server [0x1133]
/// </summary>
public static readonly Guid MessageNotificationServer = new Guid(0x00001133, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Message Access Profile [0x1134]
/// </summary>
public static readonly Guid MessageAccessProfile = new Guid(0x00001134, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Bluetooth Device Identification. [0x1200]
/// </summary>
public static readonly Guid PnPInformation = new Guid(0x00001200, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1201]
/// </summary>
public static readonly Guid GenericNetworking = new Guid(0x00001201, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1202]
/// </summary>
public static readonly Guid GenericFileTransfer = new Guid(0x00001202, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1203]
/// </summary>
public static readonly Guid GenericAudio = new Guid(0x00001203, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1204]
/// </summary>
public static readonly Guid GenericTelephony = new Guid(0x00001204, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1205]
/// </summary>
public static readonly Guid UPnp = new Guid(0x00001205, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// [0x1206]
/// </summary>
public static readonly Guid UPnpIP = new Guid(0x00001206, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// ESDP_UPNP_IP_PAN [0x1300]
/// </summary>
public static readonly Guid UPnpIPPan = new Guid(0x00001300, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// ESDP_UPNP_IP_LAP [0x1301]
/// </summary>
public static readonly Guid UPnpIPLap = new Guid(0x00001301, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// ESDP_UPNP_L2CAP [0x1302]
/// </summary>
public static readonly Guid UPnpIPL2Cap = new Guid(0x00001302, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Video Distribution Profile - Source [0x1303]
/// </summary>
public static readonly Guid VideoSource = new Guid(0x00001303, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Video Distribution Profile - Sink [0x1304]
/// </summary>
public static readonly Guid VideoSink = new Guid(0x00001304, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Video Distribution Profile [0x1305]
/// </summary>
public static readonly Guid VideoDistribution = new Guid(0x00001305, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Health Device Profile (HDP) [0x1400]
/// </summary>
public static readonly Guid HealthDevice = new Guid(0x00001400, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Health Device Profile (HDP) - Source [0x1401]
/// </summary>
public static readonly Guid HealthDeviceSource = new Guid(0x00001401, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
/// <summary>
/// Health Device Profile (HDP) - Sink [0x1402]
/// </summary>
public static readonly Guid HealthDeviceSink = new Guid(0x00001402, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB);
配对成功后的界面。
可以在配对成功(connection()函数)后加入相应的通信处理代码。
源代码:https://files.cnblogs.com/procoder/BluetoothPairing.rar
运行环境:VS2008 + Windows Mobile 5 Pocket PC SDK + CF.NET 2.0
出处:http://procoder.cnblogs.com
本作品由Jake Lin创作,采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。 任何转载必须保留完整文章,在显要地方显示署名以及原文链接。如您有任何疑问或者授权方面的协商,请给我留言。