【发布时间】:2014-05-15 23:16:45
【问题描述】:
所以我正在尝试从脚本连接蓝牙扬声器。我正在使用 32feet.net 并且我已成功找到该设备,但是当我尝试配对并连接它时它不起作用。
这是我用来与设备配对的代码,这总是失败,不知道为什么:
private static void connected(BluetoothDeviceInfo[] dev)
{
// dev[foundIndex];
bool paired=false;
paired = BluetoothSecurity.PairRequest(dev[foundIndex].DeviceAddress, "1166");
if (paired)
Console.WriteLine("Passed, Device is connected.");
else
Console.WriteLine("Failed....");
}
这是连接后调用的代码以实际连接到设备:bc 是我的蓝牙客户端 var。
bc.BeginConnect(devInfo[foundIndex].DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), devInfo[foundIndex]);
private static void Connect(IAsyncResult result)
{
if (result.IsCompleted)
{
Console.Write("Connected... ");
}
}
任何帮助将不胜感激。我是 32feet.net 的新手,所以我对此不太了解,我尝试在线跟踪代码以了解我所在的位置。
【问题讨论】: