How to turn On and Off bluetooth visibility mode?

Solution 1:

In BlueZ >= 5 command line control of a device can be done with btmgmt tool:

sudo btmgmt
[mgmt]# help         # list commands
[mgmt]# info         # list device(s)
[mgmt]# select hciX  # select a known device by index X eg. hci0
[hci0]# discov yes   # make hci0 visible/discoverable
[hic0]# discov no    # make hci0 invisible

In older version of BlueZ we can control our Bluetooth device with the command line tool hciconfig.

To enable visibility:

sudo hciconfig hciX piscan

To disable visibility:

sudo hciconfig hciX noscan

Replace hciX with your device (usually hci0)

To query your Bluetooth device(s):

sudo hciconfig -a