Connect to Bluetooth Device / how to set the rfcomm capability

前端 未结 1 1279
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 07:48

I\'m trying to connect to a BlueTooth device

I have paired it and when I search for it I find it :

private async void Grid_DoubleTapped(object send         


        
相关标签:
1条回答
  • 2020-12-22 08:31

    So you want to know what you have to write in the manifest file, as well as how to connect?

    Manifest file:

       <m2:DeviceCapability Name="bluetooth.rfcomm">
          <m2:Device Id="any">
            <m2:Function Type="serviceId:00001101-0000-1000-8000-00805F9B34FB"/>
          </m2:Device>
        </m2:DeviceCapability>
    
    • You can keep Id at "any".
    • Function type could either be "name:serialPort" or the serviceId specified in the example.

    Connecting:

    StreamSocket _socket;    
    RfcommDeviceService service = await RfcommDeviceService.FromIdAsync(device.id);
    await _socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);
    

    Should be able to do the trick.

    0 讨论(0)
提交回复
热议问题