Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9867 Discussions

How to automatically power on the bluetooth

OSh
Novice
1,360 Views

Hi guys,

I am using XDK IoT edition and Sparkfun Arduino block, I was wondering that is it possible to turn on the Bluetooth service in Intel Edison when it is power on without keying in the command :

rfkill unblock bluetooth bluetoothctl

Thanks

0 Kudos
5 Replies
idata
Community Manager
120 Views

Hello chaos39,

 

 

Yes, it is indeed possible and it is actually really easy. You can do it through a system service, I wrote a document on how to create one. I suggest you to read it and if you have any doubt, please let me know and I'll be glad to help you. The guide can be found in https://communities.intel.com/docs/DOC-111103 https://communities.intel.com/docs/DOC-111103.

 

 

-Peter.
OSh
Novice
120 Views

Hi Peter, I have read the link that you have given, however I am confused as the example is a program to auto- start instead of power on the Bluetooth, not sure if you have an example code to automatically power on the Bluetooth.

Thanks !

idata
Community Manager
120 Views

Sure, I can give you simple example on how to do it. This is the configuration I would use:

 

 

turn_on_bt.sh:

 

 

# !/bin/sh

 

rfkill unblock bluetooth

 

 

turn_on_bt.service

 

 

# !/bin/sh

 

[Unit]

 

Description=turn on BT

 

[Service]

 

ExecStart=/home/root/turn_on_bt.sh

 

Type=idle

 

[Install]

 

WantedBy=basic.target

 

 

Try that and let me know.

 

-Peter.
OSh
Novice
120 Views

Hi Peter, It may sound like a stupid question to ask but do I need to put the # !/bin/sh ?

idata
Community Manager
120 Views

It's not, in fact it's a more than valid question.

 

 

The line # !/bin/sh in that code is the shebang, in simple words, it lets the parent shell know which interpreter has to be used to run the script.

 

 

Or as Wikipedia mentions, under Unix-like operating systems, when a script with a shebang is run as a program, the program loader parses the rest of the script's initial line as an interpreter directive; the specified interpreter program is run instead, passing to it as an argument the path that was initially used when attempting to run the script.

 

 

If you would like to learn more about shebang, I'd suggest you to read the following documents:

 

 

https://en.wikipedia.org/wiki/Shebang_(Unix)

 

https://bash.cyberciti.biz/guide/Shebang

 

 

-Peter.
Reply