question

SubashSubramaniNaranamalpuramHarih-0017 avatar image
0 Votes"
SubashSubramaniNaranamalpuramHarih-0017 asked ·

USB & Bluetooth Connection in Xamarin.Forms Code Samples

Hi All,

I am exploring option to connect to USB and Bluetooth for Xamarin. Forms should support Android, IOS, UWP. Please share reverent code samples

dotnet-xamarinforms
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

For bluetootu connection in xamarin forms, you can try to use following nuget package to achieve it.

https://github.com/xabre/xamarin-bluetooth-le

For demo or blog about BLE, you can Google: Integrate and use the BLE Plugin for Xamarin by Rebai Hamida

For USB connection, I cannot found Forms plugin to achieve it, but you can achieve it with dependence service for different platforms.

https://github.com/anotherlab/UsbSerialForAndroid#compatible-devices

2 Votes 2 ·


Sample code :
adapter.ScanExtra().Subscribe(scans => {
adapter.StopScan();
scanResults = scans;


          scanResults.Device.ConnectWait();
                
      });

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.things.permission.MANAGE_BLUETOOTH" />

please let me know any thing i missed from my end

0 Votes 0 ·

0 Answers