Xamarin.Android Xamarin.Android - Bluetooth communication


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.


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.