Xamarin.Android - Bluetooth communication

Download xamarin.android eBook

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.

Related Examples

Stats

41 Contributors: 1
Wednesday, July 26, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook