[mono-android] Bluetooth rfcomm

Bartosz Skalski bartosz.skalski at gmail.com
Tue Feb 7 15:18:40 UTC 2012


I read directly from the InputStream without the StreamReader and it works,
try:

socket.InputStream.Read( buffer, 0, buffer.Length )

Cheers

2012/2/7 Jonathan Pobst <monkey at jpobst.com>

> Not sure if it helps, but we have a sample that uses bluetooth:
>
> https://github.com/xamarin/**monodroid-samples/tree/master/**BluetoothChat<https://github.com/xamarin/monodroid-samples/tree/master/BluetoothChat>
>
> Jonathan
>
>
>
> On 2/7/2012 8:40 AM, ledz wrote:
>
>> I'm having some trouble on using bluetooth with rfcomm on a custom
>> device. I
>> am able to connect the socket, it seems, but I can't retrieve anything
>> from
>> the output stream; just keep on getting an io exception and the connection
>> drops. Can someone give me a few pointers if I'm doing anything wrong, or
>> if
>> there are any exceptions where this won't work?
>>
>> I'm basically connecting through a RfcommSocketToService
>>
>> private UUID ServiceUUID = UUID.FromString(
>> "00001101-0000-1000-8000-**00805F9B34FB" );
>> ...
>> socket = device.**CreateRfcommSocketToServiceRec**ord( ServiceUUID );
>> ...
>> StreamReader reader = new StreamReader( socket.InputStream );
>> ...
>> int n = reader.ReadBlock( buffer, 0, buffer.Length );
>>
>>
>> I'm running this over an Android 2.3.6 smartphone (Samsung GT-N7000).
>> I posted a sample of my code here: http://pastebin.com/j9MmdDwQ
>>
>> Cheers
>>
>>
>> --
>> View this message in context: http://mono-for-android.**
>> 1047100.n5.nabble.com/**Bluetooth-rfcomm-**tp5463305p5463305.html<http://mono-for-android.1047100.n5.nabble.com/Bluetooth-rfcomm-tp5463305p5463305.html>
>> Sent from the Mono for Android mailing list archive at Nabble.com.
>> ______________________________**_________________
>> Monodroid mailing list
>> Monodroid at lists.ximian.com
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/**mailman/listinfo/monodroid<http://lists.ximian.com/mailman/listinfo/monodroid>
>>
>>
>>
> ______________________________**_________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/**mailman/listinfo/monodroid<http://lists.ximian.com/mailman/listinfo/monodroid>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120207/0c3063e5/attachment.html>


More information about the Monodroid mailing list