Connecting a Firefly module to a Linux workstation

Fonte: TecPorto
Revisão em 15h55min de 1 de junho de 2018 por Cláudia (discussão | contribs)
Saltar para a navegação Saltar para a pesquisa

If you are developing stuff for the Arduino platform and using a Firefly bluetooth module, you may not yet know how to connect your prototype to a Linux box using Bluetooth. If you don't, here's a tutorial just for you.

This tutorial assumes you have root access, authorization for using sudo or the appropriate permissions given to you somehow.

First, you need to know what's the Bluetooth device ID of your workstation Bluetooth adapter. Fire up the console and do it like this:

user@workstation:~$ hcitool dev


You'll get something like this:

Devices
   hci0    aa:bb:cc:dd:ee:ff


So, you know the ID of the adapter is hci0.

Then you'll need to find the MAC address of the Firefly on your prototype. To do so, use this (assuming your prototype is turned on):

user@workstation:~$ hcitool scan


This will give you a list of the discoverable devices in the vicinity, like this:

Scanning ...
	00:11:22:33:44:55	Phone1
	11:22:33:44:55:66	Phone2
	22:33:44:55:66:77	MouseX
	33:44:55:66:77:88	Onda Technology P1
	ii:jj:kk:ll:mm:nn	FireFly-MMNN


Now you take the MAC address and use it on the next step. You may have noticed that the last four hexadecimal digits of the MAC address are the four hexadecimal digits on the end of the Bluetooth name of the Firefly module.

Now you need to create the RFCOMM channel. This require special permissions, root access or sudo. This example uses sudo. Adapt as necessary.

sudo rfcomm connect hci0 ii:jj:kk:ll:mm:nn


If successful you should get something along these lines:

Connected /dev/rfcomm0 to ii:jj:kk:ll:mm:nn on channel 1
Press CTRL+C for hangup


Done. Now you can use a serial terminal program like Minicom to access that /dev/rfcomm0 as a regular serial port and receive information from your prototype or use your own software to talk to your prototype over Bluetooth. But don't forget to set up the correct permissions to access the port by using sudo or getting yourself into the uucp or dialout groups.