Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFCOMM Support #40

Open
axtscz opened this issue May 9, 2017 · 15 comments
Open

RFCOMM Support #40

axtscz opened this issue May 9, 2017 · 15 comments

Comments

@axtscz
Copy link

axtscz commented May 9, 2017

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

@storerjeremy
Copy link

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

@mvellon
Copy link

mvellon commented Sep 5, 2017

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).

@storerjeremy
Copy link

@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.

@mvellon
Copy link

mvellon commented Sep 6, 2017 via email

@storerjeremy
Copy link

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

@storerjeremy
Copy link

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

@mvellon
Copy link

mvellon commented Sep 11, 2017 via email

@mvellon
Copy link

mvellon commented Sep 11, 2017 via email

@pstanton
Copy link

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.

@storerjeremy
Copy link

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

@pstanton
Copy link

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
Copy link

pstanton commented Nov 20, 2017

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

@storerjeremy
Copy link

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.

@Satyam-code143
Copy link

Satyam-code143 commented Mar 19, 2021

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants