react-native-bluetooth-serial icon indicating copy to clipboard operation
react-native-bluetooth-serial copied to clipboard

RFCOMM Support

Open axtscz opened this issue 7 years ago • 15 comments

Will this library connect an Android phone and an RFCOMM server?

axtscz avatar May 09 '17 01:05 axtscz

@axtscz Yes it will, I am currently connecting to a raspberry pi running a RFCOMM server based on this

storerjeremy avatar Jul 06 '17 15:07 storerjeremy

Is there anything magical about that UUID (in the Pi python app)? I have a very similar example but I can't get the library to list() my device. My own service uses the SERIAL_PORT class and profile (it's based on the same example).

mvellon avatar Sep 05 '17 22:09 mvellon

@mvellon I don't think there is anything magical about the UUID you should be able to use any. But to get my pi python app to work, be discoverable and use SERIAL_PORT I had to do a few things.

First I had to run the bluetooth daemon in compatibility mode by adding a "-C" after the bluetoothd line in /etc/systemd/system/dbus-org.bluez.service and then enable serial profile by running "sudo sdptool add SP"

Then to make the device visible run "sudo hciconfig hci0 piscan"

I got this info from here and here

Hope that helps.

storerjeremy avatar Sep 06 '17 00:09 storerjeremy

Yep, I've done all that. I can connect to it from another Pi, but not iOS. I will continue to experiment.

Thanks for the quick response tho!

Sent from my iPad

On Sep 5, 2017, at 5:11 PM, Jeremy Storer [email protected] wrote:

@mvellon I don't think there is anything magical about the UUID you should be able to use any. But to get my pi python app to work, be discoverable and use SERIAL_PORT I had to do a few things.

First I had to run the bluetooth daemon in compatibility mode by adding a "-C" after the bluetoothd line in /etc/systemd/system/dbus-org.bluez.service and then enable serial profile by running "sudo sdptool add SP"

Then to make the device visible run "sudo hciconfig hci0 piscan"

I got this info from here and here

Hope that helps.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mvellon avatar Sep 06 '17 00:09 mvellon

No worries. I've only used it with Android so far. I feel like SPP may not be supported on IOS

storerjeremy avatar Sep 06 '17 00:09 storerjeremy

@mvellon Did you end up getting it to work with IOS?

storerjeremy avatar Sep 11 '17 16:09 storerjeremy

No. I think that iOS has limited support for classic Bluetooth. If you’re not a “blessed” iOS perisperhal, you generally need to go the BLE route with GATT advertisements/services/characteristics.

-- Manny Vellon, CTO/Partner

1501 Fourth Avenue Suite 2900 Seattle, Washington 98101 425-241-2796 Direct Level11.com

On Sep 11, 2017, at 9:14 AM, Jeremy Storer [email protected] wrote:

@mvellon https://github.com/mvellon Did you end up getting it to work with IOS?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rusel1989/react-native-bluetooth-serial/issues/40#issuecomment-328579724, or mute the thread https://github.com/notifications/unsubscribe-auth/ACXW6mNNbx2RJIJ8c9LGwqDPDpn0iTPkks5shVxJgaJpZM4NUtKU.

mvellon avatar Sep 11 '17 16:09 mvellon

Oh, and iOS doesn’t seem to support RFCOMM in its BLE stack.

-- Manny Vellon, CTO/Partner

1501 Fourth Avenue Suite 2900 Seattle, Washington 98101 425-241-2796 Direct Level11.com

On Sep 11, 2017, at 9:15 AM, Manny Vellon [email protected] wrote:

No. I think that iOS has limited support for classic Bluetooth. If you’re not a “blessed” iOS perisperhal, you generally need to go the BLE route with GATT advertisements/services/characteristics.

-- Manny Vellon, CTO/Partner

<UNADJUSTEDNONRAW_thumb_5.jpg>

1501 Fourth Avenue Suite 2900 Seattle, Washington 98101 425-241-2796 Direct Level11.com http://level11.com/

On Sep 11, 2017, at 9:14 AM, Jeremy Storer <[email protected] mailto:[email protected]> wrote:

@mvellon https://github.com/mvellon Did you end up getting it to work with IOS?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rusel1989/react-native-bluetooth-serial/issues/40#issuecomment-328579724, or mute the thread https://github.com/notifications/unsubscribe-auth/ACXW6mNNbx2RJIJ8c9LGwqDPDpn0iTPkks5shVxJgaJpZM4NUtKU.

mvellon avatar Sep 11 '17 16:09 mvellon

what do i have to do to connect RFCOMM correctly? my remote RFCOMM service works fine with other bluetooth terminal apps (such as) however, after adding a TextInput to the example app, and then calling BluetoothSerial.write(text), nothing gets through to the other end... help appreciated.

pstanton avatar Nov 19 '17 05:11 pstanton

@pstanton BluetoothSerial.write() should definitely work. Is your RFCOMM server expecting a delimiter such a \n? Give this RFCOMM server a go.

storerjeremy avatar Nov 19 '17 19:11 storerjeremy

i'll try appending "\r\n" .. like i said the server seems to work with other android terminals so was expecting it to be easy. there's no character encoding necessary?

also, have you had any luck with iOS? using BLE perhaps? we're trying to BLE/uart/serial if RFCOMM doesn't work...

pstanton avatar Nov 20 '17 04:11 pstanton

ah, the line break! that works .. for the TX anyway. I cant seem to read data, i have set up listeners:

		BluetoothSerial.on("data", data => {
			console.log("data", data);
		});

		BluetoothSerial.withDelimiter("\n").then(res => {
			console.log("delimiter setup", res);
			BluetoothSerial.on("read", data => {
				console.log("data", data);
			});
		});

but nothing is logged

pstanton avatar Nov 20 '17 06:11 pstanton

I am using essentially the python RFCOMM server I posted above and all I am doing in my RN app after connecting is setting up a listener with a newline delimiter, very similar to you and this all works fine for me.

BluetoothSerial.on('read', (data) => { console.log(data); }); BluetoothSerial.withDelimiter('\n').then(() => { console.log('Bluetooth subscribed with delimiter'); });

I use text written to my bluetooth server to stop/start my sending of data. ie.

BluetoothSerial.write('start');

Then as the RN app is listening for a newline delimiter from my RFCOMM server I am sending my data with a \n appended to it ie.

client_sock.send("some data to send to react native from rfcomm server\n")

Regarding using IOS and RFCOMM I haven't tried doing it myself yet but I did find this issue talking about adding in your specific service UUID in the IOS code. I will be testing this out soon once an iphone arrives in the mail.

storerjeremy avatar Nov 20 '17 16:11 storerjeremy

@storerjeremy Hey, I am trying to communicate with the raspberry pi with my RN application over a serial connection but i am not getting the pairing and connecting part of the RN code. I have a similar code for the RFCOMM server but still I am not able to find the solution. Can u please help me out with the RN side code.

Thank you!!

Satyam-code143 avatar Mar 19 '21 06:03 Satyam-code143

@pstanton Hey, did the BluetoothSerial.write() work?? Please help me with that!!

Satyam-code143 avatar Mar 19 '21 06:03 Satyam-code143