Connecting a Firefly module to a Linux workstation

From Onda Technology Institute Wiki
Jump to: navigation, search

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:

  1. user@workstation:~$ hcitool dev

You'll get something like this:

  1. Devices
  2. 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):

  1. user@workstation:~$ hcitool scan

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

  1. Scanning ...
  2. 00:11:22:33:44:55 Phone1
  3. 11:22:33:44:55:66 Phone2
  4. 22:33:44:55:66:77 MouseX
  5. 33:44:55:66:77:88 Onda Technology P1
  6. 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.

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

If successful you should get something along these lines:

  1. Connected /dev/rfcomm0 to ii:jj:kk:ll:mm:nn on channel 1
  2. 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.