Search code examples
bluetoothhci

Need detail explanation of Bluetooth command "hcitool con" and hcitool sr


ISSUE : To switch master/slave role between the devices.

I am trying hard to switch role between bluetooth devices but with no luck.

I know there is "hcitool sr " command which switch role for us but everytime i type this command after establishing connection I got the error shown below...

 command -> hcitool sr DC:A9:71:8D:2D:C6 m

Switch role request failed: Input/output error

I have typed 'm' or 's' or full name like master or slave but with no success and also I have typed this command when pairing has been successful and connection has been established.

To verify connection I type following command hcitool con

o/p :

Connections:

ACL DC:A9:71:8D:2D:C6 handle 43 state 1 lm SLAVE AUTH ENCRYPT

what does this mean ? Can soemone please explain me specially "SLAVE" part. What I think of this output is that my in-house device hci0 is connected with mac-address of DC:A9:71:8D:2D:C6 via ACL link and my in-house device is SLAVE. Am I right ?

Also I have noticed that when I perform test again and again then sometimes i started getting result of hcitool con as Master example

ACL DC:A9:71:8D:2D:C6 handle 43 state 1 lm MASTER AUTH ENCRYPT


Solution

  • After struggling for couple of days , I have found the solution.

    Requirment #1 ->to switch role and make it permanent till next restart.

    **

    hciconfig -a hci0 lm master 
    hciconfig -a hcio lp hold
    

    **