我正在编写一个需要发送蓝牙包到MagicBlue发光二极管的.NET应用程序。换句话说,我想创建一个.NET应用程序,类似于它的Android应用程序:https://itunes.apple.com/us/app/led-magic-blue/id992330218?mt=8
这是一个演示:https://www.youtube.com/watch?v=5Q3aQjuiLY0
我的蓝牙适配器已经找到了灯泡并连接到它,所以它是可发现的,我也有它的MAC地址,这是我的目的所需。
我正在使用InTheHand (32Feet Bluetooth) .NET Library进行通信。灯泡需要接收字节数组,以便执行命令(更改颜色、通电/断电等)。
// I use this Write function to send an array of bytes.
private bool Write(byte[] buffer)
{
using (var bluetoothClient = new BluetoothClient())
{
try
{
var ep = new BluetoothEndPoint(_macAddress, Guid.NewGuid());
bluetoothClient.Connect(ep);
var bluetoothStream = bluetoothClient.GetStream();
if (bluetoothStream != null)
{
bluetoothStream.Write(buffer, 0, buffer.Length);
bluetoothStream.Flush();
bluetoothStream.Close();
return true;
}
}
catch (Exception ex) { }
}
}当我访问bluetoothClient.Connect(ep);时,它抛出一个异常,说明"the connected party did not properly responded after a period of time..."。
我怎样才能解决这个问题,把字节数组转换成灯泡呢?
发布于 2018-08-08 20:39:44
更改为:
var ep = new BluetoothEndPoint(_macAddress, BluetoothService.HandsFree);它将会工作的很好!
https://stackoverflow.com/questions/48194425
复制相似问题