5

Alright guys I am having some issues. I have setup a bluetooth configuration (well setup is being generous, I ran a few lines of code as described here: http://www.instructables.com/id/Enhance-your-Raspberry-Pi-media-center-with-Blueto/). I am able to connect to my phone on each reboot by going to my iPhone setting and clicking connect to my known bluetooth connection points. I am also able to connect to my phone via bluetoothctl.

With bluetoothctl it connects but I havent found a way for it to automatically connect without having to manually type in connect AA:BB:CC:DD:EE:FF . Even if I could find a way I am guessing that I would be unable to run a shutdown script that is used for my car when ignition is turned off with a mausberrycircuit car switch. Info here: http://mausberrycircuits.com/pages/car-setup

Would there be a way for that script to take precedence even over an open bluetoothctl?

The second way I have found to connect and "works" is

$ sudo rfcomm connect 0 AA:BB:CC:DD:EE:FF 1

attached at the end of /etc/rc.local file and it works in the sense that in the bluetooth settings of my phone it says connected but when I play music is still plays on the phone. I have to manually click the connected button for it to start playing over the raspberry pi output.

What is going to be a way for me to automatically (needing no input other than me turning the key to my ignition) connect the pi to my iPhone 6.

Additional information: Running Raspbian Wheezy on BerryBoot.

Thank you for any input. I have learned a lot but I feel like there is a lot I am not understanding and still have to learn.

2

I guess I was able to answer my own question. At the end of my

/etc/rc.local

File I added the following line after of course I manually trusted my MAC address

echo "connect AA:BB:CC:DD:EE:FF \nquit" | bluetoothctl

Which connects to my already paired and trusted device and exits bluetoothctl allowing for a shutdown script to be initiated at the proper times.

I thought it was necessary at first to use the following line but the previous one was the one that didn't cause any errors

echo -e "connect AA:BB:CC:DD:EE:FF \nquit" | bluetoothctl 

I will be working on using a python script to catch a specific device and managing the rc.local file to possibly add more possible inputs but for now this will suffice for my desires and needs.

alternatively, continuing with the rfcomm command you can use

sudo rfcomm connect 0 AA:BB:CC:DD:EE:FF 1 &

1 designates the channel, I typically keep this blank but I included it in case someone looking back needs to connect on a specific channel.

EDIT:

While this isn't directly related to the question it is an option I would have opted for had it been available. This will allow the user to simply click connect to the bluetooth device and it automatically pairs. The following link allows for a completely automated install and allows for A2DP, AirPlay, and Aux cable input. You can still use the above to completely automate the connection upon boot, or choose to connect via AirPlay. Just follow the install on the README.md

https://github.com/BaReinhard/Raspberry-Pi-Audio-Receiver-Install-Car-Install

  • As usual with a Raspberry PI the best way to avoid complicated methods to control a proper shut-down it is best to investigate how to make it immune to unexpected power-down events by making it run from a read-only file system. I've done that with Raspbian and I'm about to do the exact same thing in a few weeks or so with OSMC. I'll share my experience when I get there if you're interested... – user29510 May 22 '16 at 8:22
  • Also note cars do have a permanent +12V wire from the battery in spite of the key control. I've already come across power supply modules that send a signal to a car-PC motherboard when the ignition key is turned off. It is possible to do the same with a Raspberry Pi but it requires a specifically-crafted 5V power supply unit built with those features in mind. It would also require dedicating a GPIO line from the Pi to sense a POWER_GOOD signal from the PSU. Just some random thoughts. – user29510 May 22 '16 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.