Xamarin.Android Xamarin.Android - Bluetooth communication

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

In Xamarin.Android the BluetoothSocket.InputStream and BluetoothSocket.OutputStream properties are by design automatically converted to System.IO.Stream. In case of so called interactive communication protocol, when server responds only when client talks to it, System.IO.Stream is not good because it has no method or property to get the number of available response bytes before reading the response.

Parameters

ParameterDetails
socketAn instance of BluetoothSocket object. Socket must be opened before call this method.
cmdCommand as a byte array to send to BT device.
_mxSince this method uses a hardware resource, it is better to call it from a separate worker thread. This parameter is an instance of System.Threading.Mutex object and is used to synchronize the thread with other threads optionally calling this method.
timeOutWait time in milliseconds between Write and Read operations.


Got any Xamarin.Android Question?