Tôi đang phát triển ứng dụng Windows Phone 8.1 cửa hàng (XAML) phải in trên máy in Bluetooth.Điện thoại Windows 8.1 streamsocket.connectSync tạo "Không có thêm dữ liệu. (Ngoại lệ từ HRESULT: 0x80070103)"
Thiết bị này được tìm thấy thành công với hai phương pháp đầu tiên:
PeerFinder.AllowBluetooth = True
PeerFinder.Role = PeerRole.Client
PeerFinder.AlternateIdentities.Item("Bluetooth:SDP") = "{00001101-0000-1000-8000-00805F9B34FB}"
'PeerFinder.AlternateIdentities.Item("Bluetooth:Paired") = ""
Dim devs = Await PeerFinder.FindAllPeersAsync()
Dim dev As PeerInformation = devs(0)
Dim btdevs = Await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelector())
Dim btdv = btdevs(0)
Và không tìm thấy trong:
Dim dfdevs1 = Await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort))
' same result with Await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(New Guid("00001101-0000-1000-8000-00805F9B34FB")))
Thật không may, chỉ có phương pháp cuối cùng sẽ cung cấp cho tôi "remoteServiceName" cho việc sử dụng trong StreamSocket.ConnectAsync
Tôi đã thử kết hợp khác nhau cho StreamSocket.ConnectAsync:
dim _soc = New StreamSocket()
Await _soc.ConnectAsync(dev.HostName, "1")
"Không có thêm dữ liệu. (Ngoại lệ từ HRESULT: 0x80070103)"
Tương tự cho
dim _soc = New StreamSocket()
Await _soc.ConnectAsync(dev.HostName, "{00001101-0000-1000-8000-00805F9B34FB}"
Và như bạn có thể tưởng tượng giống nhau cho
dim _soc = New StreamSocket()
Await _soc.ConnectAsync(btdv.HostName, "{00001101-0000-1000-8000-00805F9B34FB}"
Tôi thực sự ra khỏi ý tưởng sau một ngày kể từ khi đập đầu của tôi. Và điều khiến tôi khó chịu nhất là kết hợp mã đầu tiên hoạt động hoàn hảo cho Windows Phone 8.0
Và có, trong AppManifest mọi thứ được đặt:
<DeviceCapability Name="proximity" />
<m2:DeviceCapability Name="bluetooth.rfcomm">
<m2:Device Id="any">
<!--<m2:Function Type="name:serialPort" />-->
<m2:Function Type="serviceId:00001101-0000-1000-8000-00805F9B34FB" />
</m2:Device>
</m2:DeviceCapability>
Bất kỳ ý tưởng nào cũng sẽ được đánh giá cao.