Bluetooth guide for Arduino Tian

In this tutorial is shown how to enable the bluetooth and to pair a device on the Arduino Tian.

First to start the tutorial configure the board, using the Getting Started guide  and auto-expanding the file system using Pivot Overlay .

Now connect the board via SSH, it is possible to use the Terminal from Arduino OS or directly from Arduino IDE.

Arduino OS is accessible typing on the browser the IP address or hostname.local/ of the board after that it is been configured on the same network of PC.
The Terminal is available  from Utilities menu.

ssh.jpg

Instead from Arduino IDE open the MIPS console selecting the Arduino Tian (MIPS console port) from Tools>Port menu, setting the baud-rate to 115200 and clicking on Send button.

select the tian port.jpg

MIPS console.jpg

Warning:
If you are using the Arduino IDE 1.8.x then download the corresponding platform (Arduino SAMD Boards (32-bits ARM Cortex-M0+)) using the Boards Manager.

Now, Login as root  and insert the corresponding password.

Download and install Bluez-libs,  Bluez utils and Bluez daemon:

$ opkg update  

$ opkg install bluez-libs bluez-utils bluez-daemon
Install tool

Type bluetoothctl command to launch the tool:

$ bluetoothctl

Open Bluetooth tool

It is shown the identification hexadecimal code of the board.

Open the bluetooth:

$power on

Open bluetooth

To start a scanning of bluetooth device typing this command:

$scan on
Bluetooth scan

They are  shown  all bluetooth devices detected by the board.
Digit scan off to end the scanning.
If you want to pair with a device, execute the below command, specifying the corresponding hexadecimal code of the bluetooth device:

$pair XX:XX:XX:XX:XX:XX

Pair device
Wait the device pairing.
When the board is connected to device the blue BT Led on the board blinks.

Instead if you want to make visible your board  on the other devices then type the command below:

$discoverable on

Digit power off to close bluetooth and quit to exit program.

To know all other functionalities, type the help command:

Available commands:                                                          

list                                                            List available controllers                      
show [ctrl]                                               Controller information                          
select <ctrl>                                             Select default controller                       
devices                                                    List available devices                          
paired-devices                                        List paired devices                             
power <on/off>                                       Set controller power                            
pairable <on/off>                                    Set controller pairable mode                    
discoverable <on/off>                            Set controller discoverable mode                
agent <on/off/capability>                      Enable/disable agent with given capability      
default-agent                                         Set agent as the default one                    
set-scan-filter-uuids [uuid1 uuid2 ...]  Set scan filter uuids              
set-scan-filter-rssi [rssi]                       Set scan filter rssi, and clears pathloss      
set-scan-filter-pathloss [pathloss]     Set scan filter pathloss, and clears rssi                                                                            
set-scan-filter-transport [transport]    Set scan filter transport            
set-scan-filter-clear                              Clears discovery filter.                        
scan <on/off>                                        Scan for devices                                
info [dev]                                               Device information                              
pair [dev]                                               Pair with device                                
trust [dev]                                             Trust device                                    
untrust [dev]                                         Untrust device                                  
block [dev]                                            Block device                                    
unblock [dev]                                       Unblock device                                  
remove <dev>                                       Remove device                                   
connect <dev>                                     Connect device                                  
disconnect [dev]                                 Disconnect device                               
list-attributes [dev]                             List attributes                                 
select-attribute <attribute>                Select attribute                              
attribute-info [attribute]                     Select attribute                                
read                                                      Read attribute value                            
write <data=[xx xx ...]>                       Write attribute value                           
notify <on/off>                                    Notify attribute value                          
register-profile <UUID ...>                  Register profile to connect                    
unregister-profile                               Unregister profile                              
version                                                Display version                                 
quit                                                      Quit program

Note:
The bluetooth on the Tian is managed only Linux side.