2
我對Windows Phone的8.0的Visual Studio 2013 C#.net 4.5項目中,我試圖與藍牙打印機連接。手機已經與打印機配對。無法連接到藍牙打印機
我已經試過兩種方法。在這兩個示例中,只有一個設備與手機配對,該設備可通過FindAllPeersAsync
正確找到。每個產生一個不同的例外。
方法1:
PeerFinder.AllowBluetooth = true;
PeerFinder.Start();
PeerFinder.AlternateIdentities["Bluetooth:SDP"] = "{00001101-0000-1000-8000-00805F9B34FB}"; // Serial
var peers = await PeerFinder.FindAllPeersAsync();
// System.Exception: The connection was refused. (Exception from HRESULT: 0x8063010B)
using (var ss = await PeerFinder.ConnectAsync(peer))
{
await ss.OutputStream.WriteAsync(System.Text.Encoding.UTF8.GetBytes("this is a test").AsBuffer());
}
方法2:
PeerFinder.AllowBluetooth = true;
PeerFinder.Start();
PeerFinder.AlternateIdentities["Bluetooth:SDP"] = "{00001101-0000-1000-8000-00805F9B34FB}";
var peers = await PeerFinder.FindAllPeersAsync();
using (StreamSocket ss = new StreamSocket())
{
// System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
await ss.ConnectAsync(peers[0].HostName, "1", SocketProtectionLevel.PlainSocket);
await ss.OutputStream.WriteAsync(System.Text.Encoding.UTF8.GetBytes("this is a test").AsBuffer());
}
我有ID_CAP_PROXIMITY和ID_CAP_NETWORKING激活。
什麼我需要做的,能夠與藍牙設備連接?
您是否找到解決問題的方法? –
是的。我將手機更新爲更新的AK並開始工作。 – PaulH