Community
cancel
Showing results for 
Search instead for 
Did you mean: 
msoni1
New Contributor I
1,460 Views

Bluetooth Configuration

Jump to solution

hello, I have done bluetooth communication with Intel edison to my android phone.

But after i power off and again on Intel edison every time i have to configure bluetooth of edion using putty command.

Is there any way to program edison like when i power it on it start searching for available bluetooth and start communicating with the paired device.

I am planning to make stand-aloe device with the help of Intel edison so its not possible everytime to configure it using terminal.

I hope you understand my problem and help me out with this.

Thanks,

Malay Soni

1 Solution
Pedro_M_Intel
Employee
119 Views

Hello Malay_soni,

I was able to automatically connect to my phone (which was previously paired and trusted through bluetoothctl) using the following shell script and then creating a service that starts it automatically:

rfkill unblock bluetooth

sleep 2

bluetoothctl << EOF

connect XX:XX:XX:XX:XX:XX

EOF

sleep 2

I called the script setconnectBT.sh and made it executable with the command:

chmmod +x setconnectBT.sh

Then I created a service called setconblu.service in /lib/systemd/system/ which looked like this:

# !/bin/sh

[Unit]

Description=sets bluetooth and connects the board to a paired device

[Service]

ExecStart=/home/root/setconnectBT.sh

Type=idle

[Install]

WantedBy=basic.target

Then you can enable it with:

systemctl enable setconblu.service

After you reboot your board, it should connect to your phone automatically.

Peter.

View solution in original post

8 Replies
Pedro_M_Intel
Employee
120 Views

Hello Malay_soni,

I was able to automatically connect to my phone (which was previously paired and trusted through bluetoothctl) using the following shell script and then creating a service that starts it automatically:

rfkill unblock bluetooth

sleep 2

bluetoothctl << EOF

connect XX:XX:XX:XX:XX:XX

EOF

sleep 2

I called the script setconnectBT.sh and made it executable with the command:

chmmod +x setconnectBT.sh

Then I created a service called setconblu.service in /lib/systemd/system/ which looked like this:

# !/bin/sh

[Unit]

Description=sets bluetooth and connects the board to a paired device

[Service]

ExecStart=/home/root/setconnectBT.sh

Type=idle

[Install]

WantedBy=basic.target

Then you can enable it with:

systemctl enable setconblu.service

After you reboot your board, it should connect to your phone automatically.

Peter.

View solution in original post

msoni1
New Contributor I
119 Views

hey .. thank for your help.

But this code is specific for the device address mentioned in the script.

How to configure it so that it automatically detects the available devices and can communicate with the connected device.

Thanks,

Malay Soni

msoni1
New Contributor I
119 Views

I tried this same code.

but it is not working for me.

can you guide me in detail step by step..?

Thanks,

Malay Soni

Pedro_M_Intel
Employee
119 Views

Sorry for the delay in my reply.

I believe you will find what you need in . Take a look at this thread, I think it will help you a lot.

Peter.

msoni1
New Contributor I
119 Views

hey, Peter,

thanks for your help.

But i think in my case the issue is with hciconfig hci0 up & hciconfig hci0 piscan coomand.

I am unable to connect bluetooth with these commannds manually also.

Can you tell me how to configure bluetooth with the help of hciconfig commands.

Thanks,

Malay

msoni1
New Contributor I
119 Views

hey, my code is working now.

Thanks for your help

thanks,

Malay

Pedro_M_Intel
Employee
119 Views

Great to hear Malay. If you ever encounter any other issue, don't hesitate to come back to the community.

Peter.

msoni1
New Contributor I
119 Views

yeah sure...!!

Malay

Reply