Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MMoha16
New Contributor I
3,752 Views

Bluetooth Client/Server Communication

Hello all,

Has anyone succeeded in making an rfcomm communication between the edison board as the rfcomm server and another device being the client and exchange messages between them.

As i am having a problem in the client to connect to the server on the board.

Thanks in advance.

Tags (1)
13 Replies
FBlai
Valued Contributor I
212 Views

Are your devices paired? (Use Bluetoothctl for that)

MMoha16
New Contributor I
212 Views

I am using rfcomm client and server , the server is listening on port 1 and i provide the client with the exact port and the address of the edison board so i guess no pairing is needed right ?

FBlai
Valued Contributor I
212 Views

I guess it would not hurt to try. Try to pair it, and make your Edison "trust" the other device. (all in bluetoothctl, just type help)

You used the code there right? http://people.csail.mit.edu/albert/bluez-intro/x232.html Communicating with RFCOMM

That is the reason I stopped using Classic Bluetooth for communication. When it does not work, you don't know why. When it works you don't know why either. There just no clear step and making it work. Bluetooth low energy is much more sane in my opinion.

MMoha16
New Contributor I
212 Views

Yes I see ur point but can i make a client/server model using BLE ? Because what i am more concerned of is doing the connection between the 2 devices using BLE .

FBlai
Valued Contributor I
212 Views

what is the other device? To make it work with LE it would need to have a GATT server like the Arduino 101 or Adafruit bluefriend

MMoha16
New Contributor I
212 Views

I want to make the edison as the server and an android app the client, what i am testing now is Edison to Edison communication with the rfcomm server and client python codes

FBlai
Valued Contributor I
212 Views

Just tried this morning rfcomm bewteen my Edison and a Udoo Neo (similar to raspberry Pi) device and it worked.

I used the code there : https://github.com/karulis/pybluez/tree/master/examples/simple pybluez/examples/simple at master · karulis/pybluez · GitHub

To make it work on the Edison side as a server, I had to modify the bluetooth startup script a little bit :

in this file : /lib/systemd/system/bluetooth.service

add the -C flag to this command

ExecStart=/usr/lib/bluez5/bluetooth/bluetoothd -C

PS (It worked without having to do any pairing)

MMoha16
New Contributor I
212 Views

Thank you for your reply, But i am a little bit confused ,Where would the GATT server be allocated as the client and the server are rfcomm ?

FBlai
Valued Contributor I
212 Views

Sorry, my post was confusing!

what I meant is that bluez is shipped with a working gatt server.

you would need to add custom characteristics to that GATT server to make a communication between your Android phone working as a BLE Central.

If you want to test the current Gatt server, just get on your android device a bluetooth low energy browser.

On your Edison run this command:

hciconfig hci0 leadv 0 (this will start advertising and will let other central connect to the Edison)

there is a couple services already defined like the current time service

Fred

MMoha16
New Contributor I
212 Views

Thank you for ur reply once again , So i guess there is no relation between the rfcomm communication and the GATT server and client right ??

Also to create a gatt server on the edison do i write a code or is only a matter of commands ? Sorry for my many questions and thank you for always replying

FBlai
Valued Contributor I
212 Views

Nope, there is no relation with RFCOMM and GATT.

If you take a look there, you can see commands for setting advertising data :

http://stackoverflow.com/questions/21124993/is-there-a-way-to-increase-ble-advertisement-frequency-i... http://stackoverflow.com/questions/21124993/is-there-a-way-to-increase-ble-advertisement-frequency-i...

But I think that adding characteristics is more a matter of writing code/plugin. Take a look at this tutorial :

http://gaiger-programming.blogspot.ca/2015/01/bluetooth-low-energy-customizing-gatt.html programming, mostly : BLE in Linux One : Bluez GATT Server Concept

I investigated yesterday how to add custom characteristics to the GATT server in Bluez. I tried several Bluez Versions.

The current Edison firmware is using Bluez 5.24

In the latest version (5.37) there is some interesting binary included in the test directory

example-gatt-server

example-gatt-client

example-advertisement

test-gatt-profile

from there, I'm a bit lost, I cant find and dont understand the doc and the example code.

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt bluez.git - Bluetooth protocol stack for Linux

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/plugins/gatt-example.c bluez.git - Bluetooth protocol stack for Linux

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/tools/btgatt-server.c bluez.git - Bluetooth protocol stack for Linux

--------------------

If you would like to experiment with different Bluez Version, it is really easy to compile.

Just get the version you want there : https://www.kernel.org/pub/linux/bluetooth/ https://www.kernel.org/pub/linux/bluetooth/

wget --no-check-certificate https://www.kernel.org/pub/linux/bluetooth/bluez-5.37.tar.gz https://www.kernel.org/pub/linux/bluetooth/bluez-5.37.tar.gz

tar -xvf bluez-5.37.tar.gz

cd bluez-5.37

./configure --enable-maintainer-mode --enable-experimental --disable-systemd --disable-udev --disable-cups --disable-obex --enable-library

make

make install

cp src/bluetoothd /usr/lib/bluez5/bluetooth/bluetoothd

systemctl restart bluetooth

You can also run

/usr/lib/bluez5/bluetooth/bluetoothd -v

to make sure you have the version of Bluez you want to try

I'm sorry that I cant help you more than that.

MMoha16
New Contributor I
212 Views

Thank you so much for your time,Appreciate it.

Reply