V4L304

Untitled

Jun 28th, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public void CommandExecute(){
  2. BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;
  3. BluetoothDevice device = (from bd in adapter.BondedDevices
  4. where bd.Name == "devicename"
  5. select bd).FirstOrDefault();
  6. BluetoothSocket bluetoothSocket = device.CreateRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"));
  7.  
  8. ConnectAsync(BluetoothSocket bluetoothSocket).Wait();
  9. }
  10. public async Task ConnectAndWriteAsync(BluetoothSocket bluetoothSocket)
  11. {
  12. try
  13. {
  14. await bluetoothSocket.ConnectAsync();
  15.  
  16. }catch(Exception ex)
  17. {
  18.  
  19. }
  20.  
  21. }
Add Comment
Please, Sign In to add comment