I've done a massive amount on this now
Quick list of things that are done, in and working:
- Raspberry Pi is fitted in a small box just behind the CD Changer, behind the back wall carpet
- Creative Labs Play USB Soundcard plugged into Pi and wired up to head unit (using CD changer pins, not AUX)
- The Pi acts as a secure WiFi hotspot which also supports AirPlay
- The Pi also has a bluetooth dongle that acts as a audio reciever
- Pi is hooked into microphone positioned between the rev and speedometer
- The Pi boots up in just over 6 seconds and starts automatically when the car comes out of "sleep mode" (same as the in-car cigarette lighter, cd changer, and other devices)
- The Pi is connected to the IBus continuously when powered up
- The Pi listens to all IBus traffic and can log it to the SD card if required
- The Pi can play music stored on its internal SD card or any connected USB drive, through the car's head unit
- The Pi responds to user input either on the head unit, the MFSW controls, or voice commands
- The CD Changers connector is now plugged into the Pi box and a new custom built connector goes from the Pi box back to the CD changer
- CD Changer IBus connectivity is controlled by the Pi
- iPhone harness all soldered up, wrapped and fed from Pi box, through the firewall and down to the ashtray
- iPhone charges from Pi harness
- The Pi can communicate with the iPhone and play / pause / skip etc.
- iPhone does NOT go into "accessory" mode, so can still be used whilst connected to the Pi!
So.. a little more information
As above, the Pi now sits in a little black box from Maplins. I've mounted the Pi and a 12 volt, 6 port mini USB hub inside. Plugged into the hub we have the IBus interface device, a WiFi dongle, a Bluetooth dongle, the Creative Labs USB soundcard, a small USB extension cable and the Pi itself (for power)
On the side of the box, I've mounted a couple of connectors.These are as follows:
connector 1 (computer-style ATX power connector):
connector 2 (Female CD changer socket - RS Electronics!)
connects to the Carver cd changer power plug
- +12v Power (not connected)
connector 3 (Male iPhone connector)
used so I can easily disconnect and remove the Pi if needs be
connector 4 (USB female connector)
used so I can connect external drives to the Pi
connector 5 (dual 3.5mm jack sockets)
- First socket is for audio out
- Second socket is for audio in (from the mic)
I decided to go for connectors rather than hardwiring, as I was having to take the Pi back inside the house and do a lot of development with it, so it was much easier to just unplug connectors, than have to have a dodgy "chocolate block" terminal connector I would be forever doing and undoing.
Plus, it looks a lot neater
So - how does it all work?
Well, as soon as I unlock the car (or put the key in the ignition if it's been sat unlocked for a while), the USB hub is provided with power and thus provides power to the connected devices - which includes the Pi.
the Pi itself then starts up and after about six seconds, it's up and running. If the headunit is turned on - it briefly displays the message "Ding Pi is done!" on the head unit display.
Once the Pi is up, it begins listening to all IBus traffic (and if in debug mode, logs it all to a text file).
The CD changer is still working and the headunit can play music from it just as before (note: the Pi doesn't even need to be powered on for the changer to function).
Because the headunit is nice, when someone presses the "MODE" button, it sends a quick message to the CD changer to ask if it's available.
Because the CD changer is still connected, the Pi doesn't respond and instead allows the CD changer to do so.
When the headunit is switched to CD Changer mode, it actually sends another message to the changer telling it to prepare to play.
It's at this point the Pi starts to pay more attention to the IBUS. Specifically, it's listening for the user to press and hold the R/T MFSW control button or the "6" button on the headunit for at least one second. (I chose the R/T button, as I don't have OEM bluetooth. I chose the "6" button as it had to be a button the headunit would announce over the IBus. I chose one second as nobody accidentally presses either button for a whole second

)
When the user does press either of these buttons, the PI then sends a message to the CD Changer telling it to pause playing (exactly what the head unit does when you switch away from the CD changer).
After that, it then turns on the mini relay, cutting the CD changers connection to the IBus.
With the CD changer out of the way, it then checks to see if the iPhone is connected and if it is, tells it to start playing.
The audio coming back from the iPhone is then piped out to the soundblaster card, which then pipes it out via the 3.5mm jack in the side of the case.
This jack is connected to the cd changer pins on the back of the headunit - pins that are not used by the DSP system.
Once playing has commenced, it then reads the playing track information from the iPhone and displays it (scrolling text if needed) on the headunit.
If no iPhone is connected, it checks to see if an external drive has been connected, and plays music from that.
If no drive is connected, it checks for music on the SD card, and if found, plays music from that.
Finally, if no music is found anywhere, it displays "The Pi is a Lie" on the head unit display for two seconds, before reconnecting the CD changer's IBus connector and then telling it to start playing again.
This is all in, working and a whole lot of awesome
But that's not all.. Whilst making all the above work, I kept finding new things I could add.
The first of which was BlueTooth.
sometimes, I can't be arsed to connect the phone to the dock - sometimes I want to listen to music on the girlfriend's Nokia.
To achieve that, I simply added a cheap bluetooth connector to the USB hub and configured the Pi to make it work as an "audio receiver".
I then coded the pi to check and play audio from any connected bluetooth device as a priority over the iPhone cradle, usb or sd cards.
If a device is connected whilst the Pi is already playing audio, a simple press of the "next track" button on the headunit or wheel forces
the Pi to recheck for a bluetooth device and prioritise it!
Simply toasty.
Next I added a wifi connector to the hub. this is mainly used so I can SSH onto the Pi whilst it's in the car and debug / work on it in a "live" environment (with all the devices up and running and the IBus connected).
However, a colleague pointed me to a blog where someone had used the exact same wifi connector on a Pi and got it to work as an "airplay" speaker!
A quick copy+paste of their code with a bit of editing to get it to work with my code, and now I have AirPlay support!
So, the final list of music-playing capabilities of the "PiSk" (yeah, that's what I'm calling it!), in the order in which the Pi priorities them, is as follows:
But wait -that's not all!
The Pi also has voice recognition abilities! Yep - you can control the PiSK with just your voice.
To get it to work, you have to say "pi, <command>" and the available commands are "play", "pause","next", "last","on" & "off" (so far).
This all works currently, by using Google's Voice API.
That's all well and good, but the downside is that it needs an internet connection to work (something that escaped my mind when I coded it.. :headbang: ).
Not to fear tho, as we already have a Wifi connector, we can actually tether the PiSK to our phone and use it's data connection!
currently, I believe this to ONLY be available on jailbroken iPhones (other phones probably have it - I know the Nokia lumia's have it.. just not iPhones :/)
Still, this can be got around by getting a cheap 3g dongle and using that for the data connection.
Or, you can just simply not use it
So what's next?
Answering phone calls is the next challenge. I expect to get this to work via bluetooth, but I've not cracked it yet...
Once I've got that, I'd look into reading text messages and the like - maybe even be able to reply using the voice recognition.. who knows.
Anyways - this is quite a long post already.
But I've achieved it.

:evil: 8)
It took a fook load of messing about to make it all work, I also blew the dock connector on my iPhone by getting the pins wrong once (£$6 to fix, so not as bad as I had initially feared!)
But I'm well pleased with the whole thing.
My next task is to make the code more "elegant". there are times where it gets confused about things. I think there's a bug in my code that tracks the status of the headunit.
I also want to try and speed everything up. It's already fast enough to use, but I'd be much happier knowing I got it going as fast and fluidly as possible.
finally, I need to replace the box that cases the whole thing, as when gluing in the sockets, I managed to melt it and it looks horrid (not that you'll see it under the carpet.. but I expect quite a few people may be interested in seeing it at meets and the like, so I'd like to make it look "pro" :rofl:
Happy days!
If I get the chance, I'll take it out of the car and take some quick snaps.
I'll also try and get another vid of the whole thing up and running.