2015-07-04 12 views
6

Sto sviluppando l'app XAML (Windows Phone 8.1) che deve essere stampata sulla stampante Bluetooth.Telefono Windows 8.1 streamsocket.connectAsync genera "Non sono disponibili altri dati. (Eccezione da HRESULT: 0x80070103)"

Il dispositivo si trova con successo con i primi due metodi:

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) 

e non si trova in:

  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"))) 

Purtroppo, solo l'ultimo metodo darà a me il "RemoteServiceName" per l'utilizzo di StreamSocket.ConnectAsync

Ho provato una combinazione diversa per StreamSocket.ConnectAsync:

dim _soc = New StreamSocket() 
Await _soc.ConnectAsync(dev.HostName, "1") 

"Nessun altro dato disponibile. (Eccezione da HRESULT: 0x80070103)"

Lo stesso vale per

dim _soc = New StreamSocket() 
Await _soc.ConnectAsync(dev.HostName, "{00001101-0000-1000-8000-00805F9B34FB}" 

E come si può immaginare lo stesso per

dim _soc = New StreamSocket() 
Await _soc.ConnectAsync(btdv.HostName, "{00001101-0000-1000-8000-00805F9B34FB}" 

Sono davvero a corto di idee, dopo alcuni giorni di sbattere la testa. E ciò che mi infastidisce di più è che la prima combinazione di codice funziona perfettamente per Windows Phone 8.0

E sì, in AppManifest è impostato tutto:

<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> 

Tutte le idee saranno molto apprezzate.

risposta

1

Sto anche lavorando su questo problema mentre parliamo e ho fatto buoni progressi. Per me, il problema si è verificato dopo l'aggiornamento da WP8 a WP8.1 (silverlight).

Assicurati che il tuo appxmanifest disponga delle seguenti autorizzazioni impostate: (!, Almeno, fino ad ora nella mia prova)

<m2:DeviceCapability Name="bluetooth.rfcomm"> 
    <m2:Device Id="any"> 
    <m2:Function Type="serviceId:00001101-0000-1000-8000-00805f9b34fb" /> 
    <m2:Function Type="name:serialPort" /> 
    </m2:Device> 
</m2:DeviceCapability> 

Qui di seguito è il mio codice di esempio visualizzato per consentire le connessioni attraverso

   PeerFinder.AlternateIdentities["Bluetooth:SDP"] = "{00001101-0000-1000-8000-00805f9b34fb}"; 

       //find the device from the device list we are trying to connect to 
       var selector = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort); 
       var dev = await DeviceInformation.FindAllAsync(selector, null); 
       var devA = dev.Where(f => f.Name.Equals(_item.Device.DisplayName)).FirstOrDefault(); 

       //get the service 
       RfcommDeviceService service = await RfcommDeviceService.FromIdAsync(devA.Id); 

       //create the connection 
       await Common.Instance.Socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName); 
       MetaData.Instance.BlueBoxRef = _item.Device.DisplayName.Substring(8); 
       NavigationService.Navigate(new Uri("/OpenDevice.xaml", UriKind.RelativeOrAbsolute)); 

Devo ancora controllare se funziona su altri dispositivi, ma per favore fammi sapere come vai avanti!