Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Page 1 of 6 1 2 3 4 5 6 >
Topic Options
#367442 - 26/08/2016 09:28 I made a Bluetooth interface.
FieroSTi
member

Registered: 07/05/2007
Posts: 104


Check it out here. Is this something people are interested in? Do people even use their empegs any more?

If I were so inclined, how would I go about writing to the screen every so often to display current track data? Maybe be able to intercept button presses and send rewind/skip commands to the bluetooth source? This would all take place in AUX mode, and with the sled serial connector.

On a somewhat related note; can anyone tell me more about the tuner serial port? I'd like to be able to control the empeg from there like a wired remote as I'm using the other for the Bluetooth interface. I feel like I remember getting a bunch of garbage from the tuner serial port when I was trying to connect to it one day, though. Is it RS232 or TTL? Basically, I'm trying to bypass the tuner so I can have a wired remote.

Top
#367450 - 26/08/2016 19:40 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Interested!

Right now I have a cheap third party A2DP interface plugged into the AUX port on my empeg. The idea is for when my girlfriend wants to play stuff from her phone in the car. It works, but it doesn't allow for the buttons on the face of the player to send play/pause/skip commands to the phone.

An integrated solution (with onscreen track data and rewind/skip controls on the player) would be amazing, if you can get that working. I would buy one if it worked. I'd be willing to help you test the software, though I can't help you write it.

Would there be a way so that your device could have an AUX passthrough, to mix the actual AUX plug audio with your bluetooth audio, so that I could have my free AUX jack back? The idea would be that you'd resistance-mix the two sources, i.e., it wouldn't matter whether audio is coming in from the passthrough aux jack or from the bluetooth interface, either one or both will play sound. (I like being able to have my AUX jack available for a portable CD player for those super-rare situations when I buy a CD and want to hear it right away before I rip it.)

Regarding how to get the programming done: You'd need to interface with the kernel somehow. If you were already planning on having a connection to the serial port, you could submit a change to the hijack kernel which outputted some "coded" information on the serial port when buttons on the face of the player were pressed. Then your interface could read the serial port. Commands could be like simple ASCII text output on the serial port:
#E2DP:AUXMODE_SELECTED
#E2DP:LEFTPRESS_DOWN
#E2DP:LEFTPRESS_UP
#E2DP:AUXMODE_DESELECTED
You'd also want to do the same thing for commands from the Rio remote control.

Unless... Does hijack already have a secret setting for outputting button press information on the serial console? If so then no hacking needed for that part, you'd just activate that feature.

The Hijack kernel could also be hacked to interpret incoming coded data from your interface, containing track information, and put that up on the screen. That *would* need to be a hijack hack. But I'll bet it's doable.

Oh by the way, did you like how I already suggested a name for your product in my message samples up there above? "E2DP"? Cute, huh?
_________________________
Tony Fabris

Top
#367453 - 26/08/2016 22:41 Re: I made a Bluetooth interface. [Re: FieroSTi]
FieroSTi
member

Registered: 07/05/2007
Posts: 104
I'm pretty sure I've read posts from Mark about the wonderful things Hijack can help me do with this little fellow, I'm just not exactly sure how to use them.

I don't really want to do anything complicated. I want to use the AUX-in for audio and the sled serial port for basic two way control. Only need skip/rewind and pause/play, really. The 8-pin Molex on this interface will receive a custom extension harness with the required RCA jacks, DB9 serial port and tuner connecter on the empeg end for power and tuner Rx/Tx. Current Track information is on the wish list and is fully possible. Just need to connect the dots. It's all done by sending ASCII commands to the RN52 to which it will respond with either a HEX value or an ASCII string, depending on what you asked of it. I would just need to write a little userland 'thingie' to parse that information and write it to the screen, hence the difficulty for me as a non-programmer. I'll be working on that this winter, I suspect. I ordered 6 of those boards to test with, but I have a feeling that I'll be revising it once or twice before I've got a 'final' product. For what it's worth, I had a working prototype on the breadboard. The RN52 is a pretty amazing little chip. It's $25, but it's pretty much fully self contained. All I added was an i2s DAC for better sound and a level shifter for comms.



I'm also working on a microcontroller as an ADC for the 'steering wheel control' buttons. It's supposed to emulate the controller used in the original tuner to add a steering wheel interface as well. That might be somewhat challenging. I'm working with an Arduino Nano as I'm somewhat familiar with the architecture. Anyway, the 4-pin Molex connecter carries 12V/GND and the tuner Rx/Tx wires for running to the remote panel. The remote panel is basically the empeg face without the screen. Basically, I want to mount an empeg face in my center console, but leave the screen on the dash. I have two sets of display extender boards, but I don't think they're applicable here.

Name's decent. Hah. I like it.

Top
#367454 - 26/08/2016 22:49 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Quote:
I would just need to write a little userland 'thingie' to parse that information and write it to the screen, hence the difficulty for me as a non-programmer.


I don't know if it'll be easier to write a userland program or to make changes to hijack. Certainly hijack already has a lot of the plumbing for what you need to do. Those who have written code in both areas would probably be able to answer that more definitively.
_________________________
Tony Fabris

Top
#367459 - 29/08/2016 01:57 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Unfortunately my empeg is not used in a car any more - this would have interested me back when I did.. This should work quite well. It shouldn't be too hard to get some button presses one way to it and track data from it on to the screen.

Have you tried it in a running car? Whilst experimenting with other interfaces I found they were a bit susceptible to ground loops etc and so alternator whine and other interference might be a problem.

Nice one.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#367460 - 29/08/2016 17:17 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Yeah that's a big deal. Takes a lot of work to get the whine out when you add stuff to Aux.

Hm. I wonder if you could make this "E2DP" unit an internal thing? Inline insert into the connector where the dock wires plug into the mainboard. Mount it in the slot where a second disk drive would go....
_________________________
Tony Fabris

Top
#367465 - 29/08/2016 19:12 Re: I made a Bluetooth interface. [Re: FieroSTi]
FieroSTi
member

Registered: 07/05/2007
Posts: 104
I'm not terrifically worried about ground loops as I'm using one of Stu's S/PDIF cards with digital coax running back through the car to my amps. Absolutely nothing I did when I installed the unit into this car would get rid of the terribly loud alternator whine that I had. Nothing. Except's the Eutronix card, that is. I suppose I could still induct noise on the analog AUX signal before going back to digital, but that's not likely to happen. Also, in this board I used a completely isolated i2s DAC chip [PCM5102A] external to the RN52 with it's own highly regulated 3v3 power supply, as I found that the internal audio processing is very poor and highly susceptible to noise, even from UART activity.

I absolutely could make this an internal thing, basically replacing the second hard drive. I suppose that I had never really considered that. The smaller analog/digital Molex connectors at the logic board for the docking connector are still available from Mouser/DigiKey, so I could fairly easily make this a plug and play sort of thing as all of the required connections are in those two harnesses.


Edited by FieroSTi (29/08/2016 19:16)

Top
#367466 - 29/08/2016 20:32 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I know that if it were an internal add-on to the Empeg, it'd end up installed quicker than if it were external. For me, it's easier to sit down at my desk and open up the player than it is to dig into the rat's nest in my car's dashboard.

Though that might not be the case for all folks.

I also like the idea that the module and a kernel upgrade would basically "make the player bluetooth capable" as if it were integrated. There's some awesomeness associated with that.
_________________________
Tony Fabris

Top
#367467 - 29/08/2016 23:13 Re: I made a Bluetooth interface. [Re: FieroSTi]
FieroSTi
member

Registered: 07/05/2007
Posts: 104
Tell you what. I've got a MendelMax 1.5 3D printer sitting on my desk that I've assembled, but not yet gotten working quite right. I could potentially make cases and boards for either application, should I sort that monster out. A board like I've already designed [or a future revision] with matching enclosure for external tuner-type connection and one for internal HDD tray mounting and direct Molex harness integration. Everything is fully open source and boards are/will be be available directly from OSHPark. All components are SMD save for the Molex connectors to save costs and shrink overall size. All is available from the usual suspects, i.e. Mouser, DigiKey, JameCo, etc. The discretes are all 0805 package, so; easily solderable. The RN52 and PCM5102A are a bit tighter pitch, but I managed to hand solder 5 of the latter for Raspberry Pi DACs back-to-back and didn't muck up a single pin. I have a Weller WESD51 iron with ETS 1/64" conical tips for the dirty work. They're wonderful for tight pitch soldering.

EDIT: I'm not sure if I mentioned this or not, but this RN52 piece is also capable of HFP and HSP profiles as well, so I could potentially add a microphone buffer into the next rev board to handle really bringing this little engineering miracle up to current standards.


Edited by FieroSTi (29/08/2016 23:18)

Top
#367468 - 29/08/2016 23:48 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Yeah, I'd totally buy that kit and source the components myself and do the soldering.

But the software would need to be mostly worked out (ie, to a testable/alpha point) before I went to all that trouble; I'd want to know I'd have something working on the other end of the journey. smile

I'm in the middle of a time-consuming project right now which I expect to take me until ~November 7th to finish, but after that I'll probably be dying for projects like this one to tinker with.
_________________________
Tony Fabris

Top
#367480 - 31/08/2016 09:38 Re: I made a Bluetooth interface. [Re: FieroSTi]
julf
veteran

Registered: 01/10/2001
Posts: 1307
Loc: Amsterdam, The Netherlands
I am interested, but also realize this project is overkill for my needs. Yes, being able to control an external device from the empeg, but most of all I just need audio pass-through/override to accommodate sat-nav audio interrupting music as needed.

Top
#367488 - 31/08/2016 18:30 Re: I made a Bluetooth interface. [Re: julf]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Originally Posted By: julf
I just need audio pass-through/override to accommodate sat-nav audio interrupting music as needed.


If it just resistance-mixed the existing Aux Input with the bluetooth Aux input, would that solve your needs?
_________________________
Tony Fabris

Top
#367492 - 01/09/2016 09:44 Re: I made a Bluetooth interface. [Re: tfabris]
julf
veteran

Registered: 01/10/2001
Posts: 1307
Loc: Amsterdam, The Netherlands
It would have to include the override functionality (muting/pausing the music when the satnav tries to speak).

Top
#369049 - 07/08/2017 00:12 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I came back to this thread now that I'm working on integrating the empeg into my new car that doesn't have an aux-in. When this thread was started it looked like something I'd totally want, but now, it looks like what I would really need is the opposite. smile

This project is, from what I can tell, about adding a bluetooth input to the empeg, but what I really need now, since my situation has changed, is a bluetooth output from the empeg to a factory car stereo, with controls integration.

I've already bought a bluetooth transmitter which seems like it will work for my needs: Empeg LR RCA output -> BT Transmitter -> Factory stereo. Took me three tries to find a model that would successfully pair with my stereo, but I have a working one now.

That's the audio part taken care of, but then it means that my steering wheel controls, which normally successfully change tracks on my phone when bluetooth-paired, wouldn't change tracks on the empeg. So now I itch for a way to do that via a direct interface module in the empeg. Of course at the moment I don't have the skill or time to do that. smile

Wishes are great aren't they? smile
_________________________
Tony Fabris

Top
#369053 - 07/08/2017 01:28 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
So.. for integration with other in-car controls, the question is always.. what electrical/wireless interfaces does the car head unit support for such, and is there documentation for the protocols it expects? smile

EDIT:
In this case, there appears to be some kind of bluetooth thingie.. so I guess you're looking for a suitable transceiver for the empeg end, and then some kind of support for whatever protocol it uses. A problem with iFruit stuff, is that it does tend towards the non-standard/proprietary/highly-profitable side of things. wink


Edited by mlord (07/08/2017 01:31)

Top
#369054 - 07/08/2017 10:24 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
I think you'll find it quite difficult to get your car to receive A2DP (audio) from one device but also be paired with another device so it can send AVRCP commands (play/pause/next etC).

Maybe try looking for a CAN BUS monitor that can pick up button presses. There's no USB host on the empeg though right (it's been so long)?

Either way is a long road I think you'll find.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369060 - 07/08/2017 18:16 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Agreed, the type of thing that I'm describing would be really complex to make, and I don't see it happening any time soon unless I learn how to do it myself. smile

Though I want to clarify that I'm not talking about two different device pairings. I mean a single A2DP+AVRCP module added to the empeg. That doesn't make it an easy thing to create, but at least I'm not talking about pairing two different devices. smile
_________________________
Tony Fabris

Top
#369061 - 07/08/2017 19:14 Re: I made a Bluetooth interface. [Re: tfabris]
elperepat
enthusiast

Registered: 11/01/2002
Posts: 211
Loc: Qc, Canada
Being in the same boat, I took a look and found the BC127 module which might do both the A2DP and the AVRCP. This, coupled with a simple arduino translating the AVRCP commands to empeg commands for the serial port, we might be on to something.


I'll try to find some time soon to dig into the datasheet and the example programs.
_________________________
Patrick

Top
#369063 - 07/08/2017 19:46 Re: I made a Bluetooth interface. [Re: elperepat]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Wow, that looks like just the ticket. Connect that chip to an Arduino chip with an RS-232 output, and that might just work. Wow. All it would need is the software to send the serial commands to the empeg for next track (I think it's "n <cr>" for example), previous track, and play/pause (I forget which one is "p <cr>" and which one is something else).

You could either implement it internally to the empeg (soldering to the serial pins and to the aux output pins inside the player), or, if you could condense the whole thing to a single PCB that was small enough, make it a single flat module that plugs into the lower back portion of the player on the outside, connecting to the external serial port and aux plugs, tucking in just beneath the dock connector. If it were just the right size and shape, it could still fit even when docked. I think there's a pretty good amount of space in that area between the player and the dock.

Super interesting idea. This takes it from a realm of "this is out of my league" to "within my grasp if I only had the time". I've created Arduino interface circuits before, including all the PCB design and prototyping, and found the process fascinating and fun.
_________________________
Tony Fabris

Top
#369065 - 08/08/2017 01:49 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Why do you need an Arduino? Just connect module serial port to empeg serial port (need level shifter) and run code on empeg.

Admittedly Arduino would probably be easier programming wise to get going.

Be aware noise, ground loops etc might be an issue. Looks like it should do I2S which might be cool to get running keeping it digital all the way through to the car headunit.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369133 - 24/08/2017 22:50 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Current status of project:
- Sparkfun Purpletooth Jamboree board acquired after a bit of a wait for it to come back into stock (thanks, elperepat!).
- Purpletooth board tested, successfully pairs with my Honda stereo and survives power cycles and re-pairs automatically afterward. Empeg's output into the bluetooth into the car stereo sounds good.
- Confirmed that it accepts bluetooth commands from my factory car stereo. At least I think it does. It should. Though the empeg doesn't yet accept serial commands from the sparkfun board, I can at least press "pause" on my car stereo touchscreen and the sparkfun board mutes its output. I'm pretty sure that's what it's doing at least, since the pause button on the board itself also does the same thing.

To do:
- Figure out how to get the serial output of the Sparkfun board to change tracks and play/pause on the empeg itself.
- Options are: (a) Additional arduino piggyback board to translate sparkfun board's output into empeg-serial-input-compatible commands, or (b) Hijack kernel patch as Shonky suggested.
- Since I know how to do (a) but not (b), I might go that route.
- I need to learn the stuff in the undertanding the BC127 guide to do either of the above.




Attachments
IMG_2624.JPG (1998 downloads)

_________________________
Tony Fabris

Top
#369135 - 24/08/2017 23:18 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
You shouldn't need to patch the kernel. So the Sparkfun board has a USB from the photo. That will probably just give you a virtual COM port if you plug it into a PC. I would expect from that you would/could/should get the skip/play/pause type messages. You can probably test and do that with some fairly simple (AT?) commands.

Now the empeg doesn't have a USB host port but does have a regular serial port. I'm assuming the white square in the middle of the red board is the actual BT module doing all the work. It will likely have a regular serial port on which with some level shifting should talk to the empeg serial port.

Then it's a case of an application or script that sits on the empeg talking to the BT module via the empeg serial port for commands and also talking to the player software (or kernel) to control the empeg player software. Passing the track info back to the car is likely even possible.

Or an Arduino that can do the USB host to the sparkfun board and then convert it to empeg serial commands. Arduino just seems a bit superfluous to me although is likely and easier method to program if low level stuff isn't your thing.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369136 - 24/08/2017 23:21 Re: I made a Bluetooth interface. [Re: Shonky]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
I wasn't going to look at details but I just did. The BC127 has both USB and serial interfaces, so there's no interface module on the red board to do that. If you can get access to that serial port, with a level shifter, it should connect direct to the empeg.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369149 - 29/08/2017 05:22 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I've currently got the Sparkfun Jamboree board successfully getting its power from, and outputting its serial output to, an Arduino Uno that I had lying around, but I think I need to get a different Arduino board that includes two serial ports.

What I think I need is:

Sparkfun serial ->
Arduino serial input 1 ->
Arduino code to translate sparkfun messages into Empeg serial commands ->
Arduino serial output 2 ->
Arduino RS-232 Add-on board ->
Empeg RS-232 input.
_________________________
Tony Fabris

Top
#369150 - 29/08/2017 05:26 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Any particular reason to not just join the two serial interfaces together and do the work on the empeg?
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369151 - 29/08/2017 05:32 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
A few reasons:

- Programming on the empeg itself is something I never ended up doing, so I don't even have the necessary compilers and toolchains installed, and now with Riocar,org down, there's not a lot of online help documentation for learning that anew. I know I could bug y'all here on the forum, but it'd be pretty slow going.

- I am comfortable with Arduino programming, having done some of it before, and the tools and online support is strong. I could get things done much more quickly that way.

- I like the idea that I might be able to make a module that is entirely external to the empeg and just plugs in. At that point, I could put it all together in a kit for anyone who wants to do the same thing.

In the end I might find my current method too limited and have to go the on-the-empeg route later anyway. smile
_________________________
Tony Fabris

Top
#369152 - 29/08/2017 05:34 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
By the way, anyone have any docs of all the serial commands you can send to the empeg player to control playback?

For instance I know that "n" <cr> will go to the next track. But what about play/pause and previous track? Are there any others, like for FF/REW that sort of thing?

I would look in the FAQ but it's down. smile
_________________________
Tony Fabris

Top
#369154 - 29/08/2017 08:09 Re: I made a Bluetooth interface. [Re: tfabris]
mtempsch
pooh-bah

Registered: 02/06/2000
Posts: 1996
Loc: Gothenburg, Sweden
Originally Posted By: tfabris
By the way, anyone have any docs of all the serial commands you can send to the empeg player to control playback?

For instance I know that "n" <cr> will go to the next track. But what about play/pause and previous track? Are there any others, like for FF/REW that sort of thing?

I would look in the FAQ but it's down. smile


No idea if current but Google found me this at Roger's blog, http://blog.differentpla.net/blog/2003/04/02/empeg-serial-port-commands :

2003-04-02 10:29:00 +0000

You can send the empeg player commands using the serial port. This is a list.

Case is ignored. Some commands do different things, depending on state. Each command usually needs to see LF afterwards.

Menu Navigation
Command Action
M Open menu/select menu item
* Cancel menu
N Next menu item
P Previous menu item

Track Navigation
Command Action
Space Play
C Play
W Pause
N Track Forward
P Track Back
F Start Fast Forward
B Start Rewind
A Cancel FFWD/REW

Visuals/Info
Command Action
V Next Visual
S Next Info
D Next Info
Quitting/Restarting
Command Action
Q Quit the player.
R Restart the player.

Volume Control
Command Action
+ CONTROL_VOLUMEUP
- CONTROL_VOLUMEDOWN
K CONTROL_LOUDNESSDOWN
L CONTROL_LOUDNESSUP

Input Selector
Command Action
[ CONTROL_EMPEG
] CONTROL_TUNER
= CONTROL_AUX

Tuner
Command Action
] CONTROL_TUNER
` CONTROL_RADIO_STORE
; CONTROL_TUNEUP
. CONTROL_TUNEDOWN

Miscellaneous
Command Action
* Mark Track
0-9 CONTROL_NUMBER0-CONTROL_NUMBER9
\ CONTROL_SLUMBER
| M_COMMAND_CACHE_NOW
#_fid_ REPLACE
#_fid_- ENQUEUE
#_fid_+ APPEND
#_fid_! INSERT
~ SuggestDiskSpinning
@ EnsureDiskSpinning
% CONTROL_SHUFFLE
_________________________
/Michael

Top
#369155 - 29/08/2017 08:57 Re: I made a Bluetooth interface. [Re: tfabris]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Sure, just seems rather complex to put something inline in the serial port. You wouldn't necessarily need to compile code on the empeg. A script should be able to do it.

You could probably bitbang a suitable UART with your Arduino that you already have couldn't you? I'm not much of an Arduino guy, but I'm pretty sure it's feasible particularly for a reasonably dedicated device.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369156 - 29/08/2017 12:22 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Yeah, all Arduino chips have "Software Serial" that enables multiple additional serial ports, in addition to the usual "hardware" port. So all that's needed is just a simple Atmega-328p chip, and a MAX RS232 interface chip.


Edited by mlord (29/08/2017 12:26)

Top
#369160 - 29/08/2017 15:07 Re: I made a Bluetooth interface. [Re: mtempsch]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Thanks for the command listing, mtempsch! smile
_________________________
Tony Fabris

Top
#369161 - 29/08/2017 15:12 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Hm, interesting thought about making a software serial driver to turn some of the extra pins into new serial ports.

Arduino boards are cheap and plentiful, though, and the programming is much simpler with an arduino that has extra dedicated ports.

Maybe I'll experiment with software serial just a little bit, though.
_________________________
Tony Fabris

Top
#369162 - 29/08/2017 15:21 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
hm, the software serial library looks really simple to use, I'll definitely experiment with that, thanks guys!
_________________________
Tony Fabris

Top
#369169 - 30/08/2017 10:02 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Yeah, software serial works real good and I didn't need to buy another Arduino, the one I had lying around is doing well. I even tried two different Software Serial libraries, the default one and the AltSoftSerial one.

I have a pretty good working program which will theoretically translate the AVRCP commands from the bluetooth into play/pause/next/previous on the Empeg serial port. But I only have it runnig in debug mode tethered to my computer right now: I'm awaiting an RS-232 shield for the Arduino to come in the mail to make its true functionality a reality.

My only issue with the BC127 purpletooth jamboree board is that when I send an AVRCP command from my stereo (for instance "next track" on the car stereo touchscreen or the steering wheel control), then there is sometimes a significant timing delay before the module receives it and notifies me on its serial port that it has received the command. Not sure how to fix this.

Next question:

Did anyone ever get a thing working on the empeg itself which would display MP3 track titles and artists on the serial port output? I don't recall if that ever happened. The reason I ask is that I now also know the commands and protocols to tell the purpletooth board to send that stuff up to the car stereo to display on its LCD screen. I could scrape that stuff with the Arduino and send it up.
_________________________
Tony Fabris

Top
#369170 - 30/08/2017 12:55 Re: I made a Bluetooth interface. [Re: tfabris]
BartDG
carpal tunnel

Registered: 20/05/2001
Posts: 2616
Loc: Bruges, Belgium
Originally Posted By: tfabris

Did anyone ever get a thing working on the empeg itself which would display MP3 track titles and artists on the serial port output? I don't recall if that ever happened.

Yes. Hugo did. Though the link in that post is dead now...

I remember it worked quite well, even though with small bit of delay, but not too bad. AFAIK, Hugo never released it though...
_________________________
Riocar 80gig S/N : 010101580 red
Riocar 80gig (010102106) - backup

Top
#369177 - 30/08/2017 20:13 Re: I made a Bluetooth interface. [Re: BartDG]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Cool! Maybe Hugo will post it here some time? :-)
_________________________
Tony Fabris

Top
#369178 - 30/08/2017 20:15 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
By the way my code work in progress is here:
https://create.arduino.cc/editor/tfabris/38e25c63-7a46-4939-8d7b-b8db19bf91fd/preview

This is totally not done and I haven't even tested it against the empeg yet (my RS-232 shield arrives tomorrow). But I'll keep updating it as I go along. That link theoretically will update with all my latest code changes.
_________________________
Tony Fabris

Top
#369180 - 31/08/2017 00:00 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Hugo mentions in that thread that the best place for a hack like that is in the kernel. Perhaps if you asked Mark really, really nicely smile
_________________________
~ John

Top
#369181 - 31/08/2017 01:51 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
cat /proc/empeg_notify

That has most stuff one might want. It's pretty simple to select/send that to the serial port.

Top
#369193 - 01/09/2017 00:35 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Hmmm!!!

Next question:

Serial port data rate in car and in A/C mode.

Config.ini:
[Serial]
car_rate=9600

I know that one. What's the corresponding one for the A/C mode? Is it just...

[Serial]
rate=9600

?

I'd look it up in the FAQ, but, y'know...
_________________________
Tony Fabris

Top
#369194 - 01/09/2017 00:50 Re: I made a Bluetooth interface. [Re: tfabris]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Just set your Arduino to whatever the empeg defaults to? Unless there are limitations on the Arduino port but I doubt there would be any of significance. Maybe on the bit bash serial port?
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369195 - 01/09/2017 00:57 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
That's the problem. I think it defaults to 115200 and I am working on software serial which can't reliably go that high on an arduino.
_________________________
Tony Fabris

Top
#369196 - 01/09/2017 05:26 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Yeah, "rate=9600" doesn't seem to have worked in my case. Can't remember how to set it without the FAQ. Someone contact the guy who wrote that thing. smile
_________________________
Tony Fabris

Top
#369197 - 01/09/2017 16:50 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
It occurs to me that the player will, in the final installation, be using the DC/Car mode because it will be in a sled. So car_rate=9600 will be just fine. As I'm debugging on the bench, I can force DC/Car mode for testing. So that's fine.

But now I have what I think might be another problem. I think that the player might have serial turned off or disabled by default when in DC/Car mode. Is that true? Trying to search old threads about other serial projects talked about needing to re-enable that functionality but I'm not clear on the details. Anyone have any more data about that, for example, whether that's still true in recent versions of Hijack, and what the config.ini commands are for that purpose?
_________________________
Tony Fabris

Top
#369198 - 01/09/2017 17:58 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
That's the problem. I think it defaults to 115200 and I am working on software serial which can't reliably go that high on an arduino.


That wouldn't be an issue at all for the "send commands to the empeg" direction. Software serial should keep up just fine for that. It's the other direction (receiving track info from the empeg) that might be troublesome.

Cheers

Top
#369199 - 01/09/2017 21:37 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Originally Posted By: mlord
It's the other direction (receiving track info from the empeg) that might be troublesome.


Yeah, at 115200, all text coming in from the empeg is very glitchy. Though this page says 115200 should work, this page has a different opinion.

Do you remember anything about whether or not serial control for the player software is disabled during DC/Car mode? I think there might be some Hijack commands in config.ini related to it.
_________________________
Tony Fabris

Top
#369200 - 02/09/2017 01:28 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
I don't recall anything about that. But easy enough to suss out: just connect the empeg to a PC over serial, verify that serial commands are working in AC/Home mode, then force (Hijack) the empeg into DC/Car mode and try again!

Cheers

Top
#369201 - 02/09/2017 03:20 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Indeed, tried that. Serial commands are not being received by the player in DC/Car forced mode, but are being received in AC/Home mode. Both cases with the rate at 115200 bps.

There's some discussion of it here:
http://empegbbs.com/ubbthreads.php/ubb/showflat/Number/144723
http://empegbbs.com/ubbthreads.php/ubb/showflat/Number/173872
http://empegbbs.com/ubbthreads.php/ubb/showflat/Number/183322

I *think* what these are telling me is that I need to enter Config.ini settings like this:
[Hijack]
suppress_notify=0

[Output]
notify=1
_________________________
Tony Fabris

Top
#369202 - 02/09/2017 03:30 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Hm. I put in both of those settings into config.ini, along with car_rate=115200, and indeed I see more stuff coming out on the serial port in DC/Car mode but it's still not accepting the N, P, W and C commands when in DC/Car mode.
_________________________
Tony Fabris

Top
#369203 - 02/09/2017 03:32 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
To be more specific, I have tried it both with suppress_notify=0 and suppress_notify=1, and in both cases the player doesn't respond to my serial commands when in DC/Car mode.
_________________________
Tony Fabris

Top
#369204 - 02/09/2017 03:36 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
FOUND IT:

http://empegbbs.com/ubbthreads.php/ubb/showflat/Number/237094

Quote:
There is a setting in the Hijack menu. Go into "Serial Port Assignment" and set to "Apps Use Serial Port"


I had to change that to "Player uses serial port".

Works perfectly now!

smile
_________________________
Tony Fabris

Top
#369205 - 02/09/2017 04:04 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Well done! I had a search earlier and couldn't come up with the right mix of search terms to find that thread. Your search-fu is strong.
_________________________
~ John

Top
#369206 - 02/09/2017 08:47 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Well it was right under my nose in the hijack settings and I should have known it and remembered it. smile
_________________________
Tony Fabris

Top
#369208 - 02/09/2017 16:51 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Well, don't feel too bad. Mark wrote it and didn't even remember it smile
_________________________
~ John

Top
#369213 - 03/09/2017 23:58 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Current status:

The Sparkfun Purpletooth Jamboree board with the BC127 bluetooth chip is being a pain the ass.

It's primary problem at first was that, when I would press a control on the car stereo, such as "next track", there would be a long delay before the command would get sent to the BC127 chip and show up on its serial port. For example "AVRCP_NEXT" would arrive on the BC127 serial port anywhere from 5-30 seconds after I press the button on the stereo.

That's problematic. Especially since I'm sure the problem isn't the car stereo: It does fine when I pair it with a smartphone, commands are instantaneous then.

I tried digging through all the docs on the web, about commands for the BC127, and tried adding a bunch of commands which disabled features that I wasn't using. I trimmed it down to just using an A2DP and AVRCP profile only, and yet I still had the same problem.

After getting confused about how some commands in the docs worked and some commands didn't work, I realized it was because the BC127 chip that ships on that Sparkfun Purpletooth Jamboree board has a way old firmware version on it. It was an old 5.x release candidate from four years ago and they're up to version 6.x now. There are multiple places to get docs on the BC127 on the web, some are PDF and some are interactive web sites, and they're all contradictory because they all refer to different versions. Once I realized that, things started to make more sense.

So I set out to upgrade the BC127 chip to the newest firmware, in hopes that it would fix the slowness problem. This turned out to be a bit of a pain because the sparkfun board does not contain a USB-to-Serial interface. I first tried making the Arduino be a direct-pass-through program that just exchanged data directly back and forth between the BC127 software serial port and the Arduino hardware serial port. Essentally using the Arduino as a USB-serial converter. However that didn't work: The firmware updater initially connected to the board, reported the version, and started the update, but shortly thereafter would die with an error message, no matter what I did to fix it.

So I overnighted an FTDI Basic Board to connect to the Sparkfun board, so I could update it directly. Initially it didn't work and failed to connect to the updater program at all, and displayed nothing on the serial port. I thought I had done something wrong, or that it was just never going to work at all. But then as a last ditch effort, I reflowed the solder on some of the chip mount points on the FTDI basic board and then boom it worked! I could update the BC127 with the latest firmware!

So now I was able to get the BC127 upgraded to the latest firmware, which is version 6.1.5 from this site: https://www.bluecreation.com/firmwareupdates.php - The commandset is different than the 5.x command set, but I dug through their docs and learned the new commands and updated my Arduino sketch with the new commands.

However, now the slowness problem is actually *worse* than before. If I press a command on the car stereo, it's many seconds before those commands show up on the BC127 serial port. Sometimes now they don't even show up at all.

But here's something funny. If I issue the following commands:
SET MUSIC_OLD_AVRCP=ON
WRITE
RESET

Then it's really interesting because the commands are now instantaneous! If I press Next Track, the command instantly shows up on the BC127! Unfortunately there are still problems:

1. The car stereo's user interface changes so that the track metadata (artist/title/etc) are not displayed any more. The metadata is not supported in the "OLD_AVRCP" mode.

2. The car stereo is permanently stuck in "pause" mode. Pressing the "Play" button on the car stereo does not work and does not send the AVRCP_PLAY to the BC127.

3. No sound comes out of the audio because it's stuck in pause mode. The audio is muted.

So I'm really stumped here. Anyone have any ideas?

I'm going by this manual:
https://www.bluecreation.com/MelodyAudio6/docs/melody_commands.html

In particular, the configuration section here:
https://www.bluecreation.com/MelodyAudio6/docs/melody_configuration/general_configuration.html

Anyone see anything in there that might allow this thing to work correctly with my Honda?

smile
_________________________
Tony Fabris

Top
#369214 - 04/09/2017 02:20 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
One guess (without reading the docs) is that the board (in "new" mode) is expecting a command termination character of some kind (eg. a '\n' or ';' or something), and the head unit is not sending it. So it sits there until a timeout, and then processes what it has seen to that point.


Top
#369216 - 04/09/2017 03:19 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Interesting guess. Though I would think that the AVRCP protocol would be extremely specific and would preclude that simple of an error. But it's certainly worth investigating.

Other factors that might be relevant:

1. The amount of delay is variable. Could be a couple seconds, could be 30 seconds.

2. In "new" mode there is an on-screen indication on the car stereo's touch screen that gives a hint that it has something to do with the handshaking. Here's my rough description of why I think that:

When I use the car's touchscreen to play and pause, the car has two icons on the screen: A play icon and a pause icon. This is different from most user interfaces where there is a single icon that toggles between play and pause. On this car, it's two separate icons.

Its user interface tells me whether it's in play mode or pause mode by *highlighting* the corresponding icon. For instance, if I press the play icon, then when it goes into play mode, the play icon becomes highlighted. And if I press the pause icon, then when it goes into pause mode, then the pause icon becomes highlighted.

Normally that process is instantaneous. If I have my cell phone paired with the car stereo, if I press pause, then two things happen instantly: The music pauses instantly and the pause icon becomes highlighted instantly.

However, with the BC127, there is a significant delay in *both* actions: When I press the pause icon, it does *not* highlight right away. There is a pause of a few seconds before it becomes highlighted. And at the exact same instant which it *does* become highlighted, that is the same instant that the "AVRCP_PAUSE" message appears on the BC127's serial port!

In other words, there is some reason that the car stereo think that the BC127 hasn't received the pause command yet, and it doesn't update its UI until it gets confirmation back that the BC127 received the command.

So there is something going on here where the handshaking with the BC127 itself is being slow and problematic
_________________________
Tony Fabris

Top
#369224 - 04/09/2017 11:07 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
1. The amount of delay is variable. Could be a couple seconds, could be 30 seconds.


Perhaps the two devices are re-pairing on each command?

Top
#369235 - 04/09/2017 18:03 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Originally Posted By: mlord
Perhaps the two devices are re-pairing on each command?


Excellent guess. I would have thought something similar.

But the results of pairing and unpairing are clearly seen in the serial debugging output screen from the BC127. I can tell when it pairs and unpairs because there are immediate open and close notifications on the screen, and I can get a pairing state report any time.
_________________________
Tony Fabris

Top
#369236 - 04/09/2017 18:11 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
In fact, you made me think to try something.

Ever since I upgraded the firmware on the BC127, it has had a new problem:
- In either "new" or "old" mode both...
- It always is stuck in pause mode forever, and pressing the Play button on the car stereo does nothing.
- Also presing the pause button never sends the pause or stop command (probably because of the above).

However...
- in either "new" or "old" mode both...
- When I unpair the device from the car stereo using the car stereo's touchscreen controls to perform the unpairing...
- An AVRCP_STOP command is sent to the BC127 instantly with no delay, and then the unpairing occurs instantly thereafter.

So the stereo itself, and the handshaking system, actually have no compunctions about sending AVRCP commands at their core. It can do it.

So the delay is introduced somewhere else for some other reason. Something about the BC127's configuration or protocol is confusing the car stereo. Not sure what, yet.
_________________________
Tony Fabris

Top
#369238 - 04/09/2017 20:36 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Now I'm down a weird-ass rabbit hole with the code and the behavior.

So there's this problem where the headunit stays stuck in "pause" mode all the time now with the V6 version of the BC127 firmware. This is an issue because, not only do certain commands not work in pause mode, but also the headunit mutes the audio. So even if I decide to live with some of the other problems, I still get no sound so I can't use the Purpletooth Jamboree board as an audio-only bluetooth streamer board.

Now keep in mind that I'm trying to use the board in what they call "Source" mode right now. Meaning: It's the audio source material (ie the empeg's line audio) which streams up to the car stereo head unit. So in this case, it should never have to send AVRCP commands, it should only receive them, right?

But I found out through experimentation why it stays stuck in pause mode. It's because after it pairs up, it needs to send a "play" command to get the stereo to unmute and go into play mode. It won't allow the headunit to even send it a play command, it has to initiate that command itself. Whaaaaaat?

So here's what I'm seeing:
- Head unit pairs with BC127, at which point a few messages appear including this one:
OPEN_OK 11 AVRCP
(note: 11 is the Link ID, in this case "10" would be Link 1, A2DP, and "11" would be Link 1, AVRCP)
- At that point the headunit is stuck in PAUSE mode.
- So at that point I must send the following command to the BC127:
MUSIC 11 PLAY
- This brings the headunit instantly out of "stuck in pause" mode and it starts streaming good audio.

So I added that to my code. But then something else weird.

So now it's booted, paired, I sent the play command, I'm listening to music. Now I want to pause the music.

When I press the Pause button on the headunit touchscreen, then it goes back into "stuck forever in pause mode" again after sending the AVRCP_PAUSE command to the BC127. (Which still has a weird delay and/or never gets sent in "new" mode, but no delay in "old" mode.)

So one thing I can do, is re-send it a "MUSIC 11 PLAY" command again after that. But then my code gets the "AVRCP_PLAY" command looped back and tries to reprocess that as if the user had pressed play. Catch-22 at that point. So I'm having to swallow the inputs right after I send the "MUSIC 11 PLAY".

But here's what I'm wondering: Why the heck doesn't the BC127 do that shit AUTOMATICALLY? In fact, my recollection is that Version 5 of the BC127 firmware did indeed handle that all automatically and never got stuck in pause mode.

Then I'm getting a weirder thing. Might be bugs in my code constantly looping and sending pause/play back and forth (doubt that, though I'm double checking), but I think it's more likely that it might be a symptom of the "delay" problem under the hood. It goes like this: sometimes when I'm playing music and I press the PLAY button on the headunit, then the music turns into staccato noise, basically sounding similar to what a video game sounds like when there is CPU overloading and the game music turns crackly because it can't update the audio output quickly enough. Like this:

"la la la la lakkkkkkkkkklklklklklklkakakakakakakakakakakaka lklklklklklklklkakakakakakaka la al la la la "

So that sounds to me like, whatever is causing the delays is also causing the CPU to hang up and glitch even on the audio stream. Can't tell if it's the headunit's CPU or if it's the BC127's CPU.

Still futzing with it. Really interesting. And frustrating.
_________________________
Tony Fabris

Top
#369277 - 08/09/2017 21:17 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Current state of the code:
- My first Purpletooth board stopped working, stopped responding on the serial port, and I had to get another one.
- It still has the slowness problem in standard AVRCP mode.
- I can switch it to AVRCP "Old" mode, which is pre-AVRCP-1.3 without track metadata, and that makes the slowness problem "mostly" go away.
- But even with "Old" mode there are still problems...
- The Play/Pause buttons don't work, only the next/prev track buttons work.
- FF/REW are nonexistent.
- The headunit starts off stuck in "pause" mode and won't come out of it.
- I can work around it by sending the play command up to the headunit after bootup, and and then the headunit goes into play mode and then it plays.
- But then after that the pause button works... Exactly once and then it gets stuck in pause mode again until I send another Play command up the chain.
- I have coded a somewhat flaky workaround in which my code always sends up the Play command to the the head unit. This tricks the head unit into always thinking it's in "play" mode and then you, the user, can use the pause button if you want. It tries to keep track of what state the player is in (either playing or pausing) and then sends the necessary command to toggle the state. But it doesn't work super reliably.

I've finally found out how to talk to the chip people on the Sierra Wireless forum and I'm getting some response, though they don't have a Honda to test with and are unable to reproduce my problem so far.
_________________________
Tony Fabris

Top
#369278 - 08/09/2017 23:39 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Have you thought about trying a different module (perhaps Qualcomm CSR8645?) Maybe you could find something that's less buggy.

Perhaps you could get the Arduino module instead of a separate development board to simplify things.
_________________________
~ John

Top
#369279 - 09/09/2017 02:49 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I have certainly already thought about that. I very much want to ditch the BC127 at this point, but I also don't want to have to roll my own audio support circuitry. That's one of the reasons I went with that Sparkfun board was because it had all the audio stuff built in. It's hard to find anything else with the audio part built in. If you find something, definitely let me know.

In case the problem is the sparkfun board itself and not the BC127 chip, there's this but it's 250 Euros and no guarantee it'll fix the issues.

Like the new pic, by the way.
_________________________
Tony Fabris

Top
#369281 - 09/09/2017 03:18 Re: I made a Bluetooth interface. [Re: tfabris]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Originally Posted By: tfabris

Like the new pic, by the way.


The old one was on a server at the company I left 9 years ago and they finally decommissioned the server. In the mean time, all the hair migrated from my head to my face. smile
_________________________
~ John

Top
#369282 - 09/09/2017 03:20 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Ah yes, the conservation of hair principle.
_________________________
Tony Fabris

Top
#369284 - 09/09/2017 13:40 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Yeah, great new photo!

Top
#369340 - 14/09/2017 04:24 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I've nearly given up on the BC127 route at this point.

I bought one of Sierra Wireless' BC-127 DiscKit boards which is about 3-4 times more expensive than that SparkFun board.

I bought it because the Sierra Wireless guy on their forum was having no trouble with his BC127, and so I wondered if maybe it was the sparkfun board that was the problem, and using Sierra's own board would solve my problem.

It didn't: The same problems are there. I think that the BC127 is just incompatible with the Honda stereo, or vice-versa. I'm wondering if there is another different place I can source a similar board that's easy to mess with at a hobbyist level.

SparkFun has an RN-52 breakout board. I'd have to roll my own audio connection, but I wonder if the RN-52 is any better? Sigh.
_________________________
Tony Fabris

Top
#369341 - 14/09/2017 16:37 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Quote:
I'd have to roll my own audio connection

According to that page, it has built-in audio, no? Would it not be sufficient to feed a line level input on the empeg?
_________________________
~ John

Top
#369342 - 14/09/2017 16:46 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I'm going to find out, I ordered one and I'll give it a try.
_________________________
Tony Fabris

Top
#369343 - 14/09/2017 19:46 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Also, because I'm curious, I was reading the comments on the RN-52 board page and there's some good info in there, especially that first comment about how to update the firmware. Just wanted to point that out.
_________________________
~ John

Top
#369344 - 14/09/2017 20:10 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Cool, thanks for that info. They have their "instructions" page which says how to update the firmware, but I'll also read through those user comments too and see if there's better information in there.
_________________________
Tony Fabris

Top
#369345 - 15/09/2017 01:15 Re: I made a Bluetooth interface. [Re: JBjorgen]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: JBjorgen
Quote:
I'd have to roll my own audio connection

According to that page, it has built-in audio, no? Would it not be sufficient to feed a line level input on the empeg?


I think we want the other direction.. empeg feeding head unit over BT?

Top
#369346 - 15/09/2017 05:09 Re: I made a Bluetooth interface. [Re: mlord]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Originally Posted By: mlord

I think we want the other direction.. empeg feeding head unit over BT?

It has a Microphone input too. Not sure how well that will work for a line in, but I guess we'll find out.

EDIT: Apparently, the current firmware for this module doesn't work in "Master" mode to send audio to another device. It only works in slave mode to receive audio. Perhaps this is a "no go."

EDIT2: It appears that there's a different firmware RN52SRC that is designed for this, so perhaps this is, in fact, a "go". demo.


Edited by JBjorgen (15/09/2017 06:53)
_________________________
~ John

Top
#369347 - 15/09/2017 06:27 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
It's super helpful that you noticed those pieces of information before I ran into those same frustrations on my own. Thanks!

Regarding the audio input, I was hoping that the RN-52 inputs could be made into a stereo line-in, like the BC127. On the Purpletooth board, that part at least worked perfectly. there was a small switch on the board which switched it between mic input and line input. Stereo audio was great. I admit that I didn't look closely to be certain that this could be done with the RN-52 before I ordered it. I was hoping to dig up the docs on it after it arrived.

I'm crossing my fingers really hard about the RN-52 chip, because I think I've taken that BC127 chip about as far as I can go with it unless Sierra finds and fixes the incompatibilities. I've got all the special cases and problem workarounds coded in, and they work (I can hear the empeg through the car stereo, change tracks on it with the car stereo and steering wheel controls, play and pause, etc,), but there are still problems:

- It's only working in "old avrcp" mode without track data. So I can never get the empeg to report track titles to the car stereo with it.

- There is that really weird problem where it has the overloaded CPU issue where the audio turns into KrKrKrKrKrkrkrkrkrkrKrKrKrKrKrKrkkkkkk for several seconds. It mostly only occurs after I use the head unit to switch to another source (such as CD) and then back again. But still, that's a bug in the protocol handling, out of my control.

- The workarounds I've done are not 100 percent reliable or pretty, and have some odd behavioral quirks. Such as, the startup/connection time to the bluetooth is longer than it should be, the play/pause doesn't look right on the car touchscreen (it has to always be in "play" mode and then you use the "pause" button to toggle on/off).

- The workarounds don't handle edge cases well, in regards to timing of things connecting/disconnecting and source switching.

So I'm hoping the RN-52 is more stable and I won't have to do any kludgy work arounds, and I can just do a 1:1 translation of input to output without any special case code.
_________________________
Tony Fabris

Top
#369348 - 15/09/2017 06:33 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Also thanks to the link to the RN-52 demo of audio source connection. It shows me that they have a devkit board which already contains the necessary line input plugs:
http://www.microchipdirect.com/ProductSearch.aspx?Keywords=RN-52-EK

Not cheap, but still only about half the price of the corresponding one from the company that makes the BC127. smile
_________________________
Tony Fabris

Top
#369349 - 15/09/2017 06:52 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Apparently it's all the same hardware and the only difference is the firmware.

I think I found the correct firmware file and put it here.

And regarding "line in mode":

Quote:
The microphone gain can be changed from -3dB to 42dB in linear steps. If the gain is set to less than 24dB using the ‘SM’ command the line in mode is automatically entered.


That eval kit is tempting, considering it's only $35 more than the Sparkfun breakout board and it would save a lot of soldering and figuring how to mount everything securely
_________________________
~ John

Top
#369350 - 15/09/2017 07:07 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Dude, so cool, thank you! smile
_________________________
Tony Fabris

Top
#369351 - 15/09/2017 07:16 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
I find the project interesting, so I was doing a little reading (at 2am...I'm going to be hating life when the alarm to get the the kids ready for school goes off tomorrow.)

But yeah, it can be difficult to find some of this info. The hope is that if you succeed, there's an upgrade path somewhere in my future too smile
_________________________
~ John

Top
#369413 - 26/09/2017 01:55 Re: I made a Bluetooth interface. [Re: JBjorgen]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Originally Posted By: JBjorgen
I think I found the correct firmware file and put it here.


I had to take a break from the project for a week to GOH at an SF convention in Dallas, but I'm back at it this week a bit. Before having to leave for the trip I was successfully able to DFU it onto the RN-52 but haven't had a chance to play with it yet. I'm concerned about that firmware, though, because it's version 1.00. In your research did you notice whether the 1.00 was the only available version of "Source" mode firmware for that RN-52?

I plan to do a lot of googling about it when I dig into it this week.
_________________________
Tony Fabris

Top
#369419 - 26/09/2017 21:39 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
I am now watching this thread with more interest than before. My Impreza got destroyed this past Saturday morning by another car whose driver didn't notice his red light until wayyyyyyyyy too late.

I've retrieved the empeg from it, but fitting it into the latest vehicles looks much more difficult than it was in the 2013 Impreza.

It's likely to end up under a seat, and having a BT connection might make it easier to access for the driver -- passenger can of course just use the Android empeg app from a smartphone.

EDIT: Say.. I wonder if "Android Auto" can run/display the empeg app on the in-car display?

Cheers

Top
#369420 - 26/09/2017 22:07 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I'm so sorry your car got crunched! Sad to hear we ended up in the same boat. I hope you're physically OK.

I certainly had thought of the idea of going with an app-only way of getting to the empeg's display. I even considered writing an iOS version of my old "EmpegFace" utility.

But it would have meant:
- Getting ethernet+wifi working inside the vehicle.
- Writing the app. smile
- Using the Apple Car Play and/or Android Auto features. Though I haven't tried Android Auto, I have so many problems with the way the car UI handles Apple Car Play with my phone, that I've disabled it and I'm going bluetooth-only for the phone and I find it much better than Apple Car Play. One day I'll try out Android Auto and see if it's any better.
_________________________
Tony Fabris

Top
#369430 - 27/09/2017 20:47 Re: I made a Bluetooth interface. [Re: mlord]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Originally Posted By: mlord
My Impreza got destroyed this past Saturday morning by another car whose driver didn't notice his red light until wayyyyyyyyy too late.
Ouch. Sorry to hear that -- I hope everyone's okay!

Top
#369432 - 28/09/2017 12:01 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
All good. The rear end of the Impreza got completely destroyed, and the bumper got torn off a second car that was in the lane beside me. The guy who hit us pretty much wrote off his own vehicle too.

But.. no injuries to speak of -- I have a very small hicky from either the seat-belt or the side-curtain airbag, but that's pretty much it for everyone involved.

Thinking about maybe the Subaru Crosstrek as a replacement, as it appears to have space for the empeg in the dash. Unfortunately, it is model-year changeover time, and they're in extremely tight supply. As in, waiting for another ship to arrive from Japan. Might take months if I go for that.

The only other small-ish vehicle with ground clearance, AWD, sunroof, and canoe capability seems to be the Mazda CX-3. That one ticks all of the boxes nicely, and is extremely well equipped for the price.

No place for an empeg though, very little in the way of storage within the passenger areas, and it has a rather annoying touchscreen which disables its touch interface when the vehicle is in motion --> they'd rather I have to switch my eyes back and forth between a combination of joystick and buttons, and the screen, and the road, instead of just touching the screen directly. Duh. Clueless.

Cheers

Top
#369433 - 28/09/2017 12:19 Re: I made a Bluetooth interface. [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: mlord
The only other small-ish vehicle with ground clearance, AWD, sunroof, and canoe capability seems to be the Mazda CX-3 ... it has a rather annoying touchscreen which disables its touch interface when the vehicle is in motion

Or maybe not. I googled and found a youtube video showing how to enter the factory menus and "fix" that mis-feature. Gotta go try it on the demo car now.

EDIT: The video's method no longer succeeds, but a more flexible USB-stick procedure still works like a charm. All kinds of tweaks possible!


Edited by mlord (28/09/2017 18:50)

Top
#369434 - 28/09/2017 12:58 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Mmmm... there appears to be a whole multiverse of hacks for the Mazda (and similar) touchscreens. It runs Linux internally, and has built-in wifi but also supports USB ethernet dongles.

Getting the empeg interface onto the touchscreen looks perfectly doable in those vehicles!

Top
#369447 - 01/10/2017 07:47 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Current status of project:

- BC-127 chip: Great sound, AVRCP commands not working due to the slowness/lockup bug.

- RN-52 chip: Perfect AVRCP implementation with instantaneous command transmission. Iffy/buggy pairing that requires some custom software fiddling in order to make it work reliably. Iffy UART command interface which only accepts commands intermittently. Worst of all: Tons of static and ground loop noise on the line inputs, regardless of which devboard I use or how everything is connected and grounded.

So I've tried two bluetooth chips and run into show-stopper problems with both of them. Anyone know of a third bluetooth A2DP/AVRCP chip I can try? :-)
_________________________
Tony Fabris

Top
#369449 - 02/10/2017 13:25 Re: I made a Bluetooth interface. [Re: FieroSTi]
Happy Birthday larry818
old hand

Registered: 01/10/2002
Posts: 1033
Loc: Fullerton, Calif.
Try the Broadcom module. From my experience, they are the only one that actually works.

Top
#369455 - 02/10/2017 19:12 Re: I made a Bluetooth interface. [Re: larry818]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Would love to try one. Any suggestions on a particular one to use? Trying to find one in a form factor with a breakout board.

Something like any of these?
http://bluetoothgpsmodule.wholesale.coquegalaxyfr.com/pz6d427e8-broadcom-bluetooth-module-a2dp.html
http://bluetoothgpsmodule.wholesale.coqu...n-low-cost.html
_________________________
Tony Fabris

Top
#369458 - 03/10/2017 01:50 Re: I made a Bluetooth interface. [Re: FieroSTi]
Happy Birthday larry818
old hand

Registered: 01/10/2002
Posts: 1033
Loc: Fullerton, Calif.
That first link is the one I found as well.

Top
#369461 - 03/10/2017 07:38 Re: I made a Bluetooth interface. [Re: larry818]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Unfortunately that's not a hobbyist reseller that will send me only the 1 or 2 units I need. Still looking for a supplier that I can actually buy one from.
_________________________
Tony Fabris

Top
#369462 - 03/10/2017 09:48 Re: I made a Bluetooth interface. [Re: FieroSTi]
Happy Birthday larry818
old hand

Registered: 01/10/2002
Posts: 1033
Loc: Fullerton, Calif.
Ask for a sample?

Top
#369468 - 04/10/2017 10:08 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
WT32i? No experience with them, but one I had as a bookmark.

https://www.silabs.com/products/wireless...th-audio-module

Not sure how you'll go using it as the dev board looks a little hard to get. You want a dev board type unit to make it easier to connect to, power etc right?


Edited by Shonky (04/10/2017 10:08)
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369495 - 05/10/2017 23:41 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Thanks, Shonky, I'll have a closer look at that one too.
_________________________
Tony Fabris

Top
#369496 - 06/10/2017 00:04 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Current status of support for RN-52 chip:

Have managed to get the ground loop noise fixed by being more careful about power and grouding in my breadboard layout, and also by specifically grounding the "Mic -" connections.

There is still a problem with the gain settings on the chip. The empeg line level outputs are way overdriving the RN-52 inputs and making them clip by a large amount.

Trying to solve the gain problem:

- Turning down the Empeg's volume helps, but not completely. Can't turn it down quiet enough to stop it from clipping.

- There is discussion of the mic/line gain here: http://www.microchip.com/forums/m770128.aspx which says "The microphone gain can be changed from -3dB to 42dB in linear steps. If the gain is set to less than 24dB using the ‘SM’ command the line in mode is automatically entered."

- There is indeed an "SM,xxxxxxxx" command which is supposed to adjust the microphone gain, but it does nothing, no matter what I set it to the gain never changes. I can set it to all zeroes and reboot the unit and... still the same volume, gain still clipping.

- Datasheet on the chip says "MIC_BIAS requires a minimum load to maintain regulation. MIC_BIAS maintains regulation within 0.199 and 1.229 mA. Therefore, if you use a microphone with specifications below these limits, the microphone output must be pre-loaded with a large value resistor to ground." - I tried a 10k ohm resistor from Mic_Bias to ground, no change.

- This page: http://www.microchip.com/forums/m843896.aspx hints that there is an "SL" command to set line level to go with that "SM" command but I cannot get it to work, even based on the information that the person in that thread said to set it to. I try to do a "GL" command and it just says "ERR", and all variants of the "SL" command that I try give me "ERR".

- There is also at that same page http://www.microchip.com/forums/m843896.aspx a schematic for converting speaker level to line level using a couple of resistors. I may try that. But I feel like I shouldn't have to if the chip is supposed to support it directly.
_________________________
Tony Fabris

Top
#369497 - 06/10/2017 00:22 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Though the speaker-to-line circuit (with the 10k and the 1k resistor) seems to work to reduce the gain, I'm concerned about overall quality of doing that. Basically now I'm still using the chip at mic-level and bringing down the empeg's output to match. I still have the keep the empeg down at about -15db to keep it from overdriving the RN-52 input even with that circuit.
_________________________
Tony Fabris

Top
#369498 - 06/10/2017 00:34 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
As long as the input impedance of the device is high enough, a resistor divider should be fine but you're right regarding the gain settings that should work and you shoudl be using the line level inputs and you shouldn't have the bias issues as it really should be simple voltage output from the empeg into a high impedance line level input

However you say -3dB to +42dB "gain" which is basically an amplifier. You're saying the empeg is overdriving by some 15dB so -3dB isn't going help that enough.

There's an empeg setting to limit the output isn't there?
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369499 - 06/10/2017 02:02 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Yes, there's an empeg setting to limit the output, but my idea is that I want the best audio quality so I want everything to be at line level with the correct dynamic range. My feeling is that I should be able to set the empeg at 0db and then control the gain at the bluetooth chip's input. So I'm not sure what to be expecting from this thing.
_________________________
Tony Fabris

Top
#369500 - 06/10/2017 02:09 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
0dB at the empeg is referenced against what it considers maximum output. 0dB on its own means not a lot. Was that 4Vpp lineouts? RMS? I don't remember

What is the input maximum for the device? It won't be 4V pp
or RMS.

It's unlikely you'll be able to input a high signal and have a significant negative internal gain as the input circuitry will still need to accept the higher input. So you'll ultimately need to limit or reduce the output of the empeg.

Yes it's best to have the highest output possible, particularly in car audio, but you're not going to hear (or lose) any significantly quality IMO between running the empeg at full and reduce it vs running it at a lower level *unless* the cable between the empeg and the BT device are picking up significant noise.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369507 - 06/10/2017 11:43 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Yeah, the audio out through the dock connector should be a different level than that on the RCA line-out jacks. Tried the former yet?

Top
#369512 - 06/10/2017 20:27 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Thanks for that information, Shonky!

Currently what I'm trying is a circuit like this, except where it says "speaker" it's the empeg line outs, and where it says "line out" is where I'm plugging it into the RN-52 chip. (obtained from here.)

Do you think that would work, or do you think there is a better way?

Maybe I should really just put a variable stereo pot on it so that I can adjust the attenuation?


Attachments
speaker_to_line.gif


_________________________
Tony Fabris

Top
#369513 - 06/10/2017 20:30 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Something else I noticed that I'm wondering about...

I think the RN-52 might have some sort of "auto gain" on its mic input that I need to figure out how to turn off. For example, on a song that fades out, it appears to be playing the music at full volume all the way to the very end of the song.
_________________________
Tony Fabris

Top
#369514 - 06/10/2017 20:44 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Regarding the Silicon Labs WT32i, I found this interesting thing:

https://www.youtube.com/watch?v=oVwzLz0dO1w

This looks real interesting to me. Look at all that audio I/O on that dev board. Haven't looked up pricing on it yet, but wow.

Edit:
http://www.semiconductorstore.com/cart/pc/viewPrd.asp?idproduct=49919
https://www.ebay.com/i/263156265565?chn=ps&dispItem=1
https://www.silabs.com/products/wireless...th-audio-module
_________________________
Tony Fabris

Top
#369522 - 07/10/2017 20:37 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I think I'm going to abandon the RN-52 and try that BlueGiga WT32i module. I've ordered one of those fancy reference kits with all the RCA plugs.

I figure that the RN-52 seems to have had only one firmware release of the "Source" mode firmware, and that firmware is really half baked. Their gain control command doesn't do anything. Also I noticed that the command reference has no way of entering track metadata at runtime in source mode, so I wouldn't ever get to have track data in there.

So I think I have a better bet with that BlueGiga module since clearly their refernce kit has RCA inputs and it's intended to be a high quality audio interface.
_________________________
Tony Fabris

Top
#369530 - 09/10/2017 16:37 Re: I made a Bluetooth interface. [Re: FieroSTi]
Daria
carpal tunnel

Registered: 24/01/2002
Posts: 3937
Loc: Providence, RI
Despite my fear that doing literally anything to improve my car will surely result in its death, one of these would probably convince me to figure out how to dissemble the dash and get the empeg in... and probably replace the dead speakers too.

Top
#369531 - 09/10/2017 18:07 Re: I made a Bluetooth interface. [Re: Daria]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Cool, thanks! This is encouraging. I'm hoping to get the prototype working, and then refine it into an easy-to-duplicate kit. Maybe Stu would want to sell the kits once it's ready?

I'm deeply disappointed that I'm now on my third bluetooth chipset trying to get this thing working. Should have had it done by now. Honestly that BC127 should have done the trick if it didn't have that weird bug where it's incompatible with my car stereo.

I have high hopes for the BlueGiga chip set based on how audio-focused that dev board looks. The datasheet and docs are also very audio-quality focused, down to the level of describing how to run the audio/ground traces for the best noise rejection. So, crossing my fingers.
_________________________
Tony Fabris

Top
#369563 - 15/10/2017 22:02 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I made some good breakthroughs with the BlueGiga development board today. It initially had some of the same problems as the other two chipsets, but it has a much more complex and flexible commandset, so I was able to fix them the right way with the right commands.

This one doesn't have dox about how to set the Track Metadata on the A2DP/AVRCP channel (it shows how to receive that data but not how to set it). I haven't experimented with that yet but that's the last hurdle. Crossing my fingers.

More later. Optimistic about this one.
_________________________
Tony Fabris

Top
#369565 - 16/10/2017 03:19 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
I'm just waiting on deck for this to go through! I want to try the same in the new Subaru.

Top
#369566 - 16/10/2017 10:06 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Sorry it's taking so long. :-)

I hope to have finished example Arduino code, prototype assembly instructions, and prototype bill of materials within the next week or so if I'm lucky. That might be enough on its own to get you going.

Then after that, the next step is a custom "sandwich" PCB board to connect all the parts, instead of using a bunch of jumper wires, and a custom housing box for housing all the parts, to turn it from a messy prototype assembly into a buildable kit.

First version of the firmware will be Bluetooth A2DP audio and AVRCP controls, but no track titles on the car's screen yet.

Assuming that everything above works, and I can find the correct commands to get this chipset to send track titles to the car screen, would you be interested in helping with the necessary empeg-side code to get it to spit out parseable track metadata on the serial port? I think you'd be able to do that part much faster than me.
_________________________
Tony Fabris

Top
#369569 - 16/10/2017 19:55 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
I would likely be inclined to skip the Arduino and just have the empeg talk directly to the BT adapter. In which case I'll add a "BT mode" to the existing Hijack menu for the Serial Port, along with anything necessary to make it work there. smile

Mostly just need to know if it really can do track data on the HU display or not.

Top
#369572 - 17/10/2017 00:13 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
That makes sense. I have a lot of information about how this thing works, and also a lot of information about things that are still not working about it, I could send you what I've got privately.

I'm finding that there are quirks about its initial handshaking with a device right after you pair with it, and it may work fine on one device and not on another, and I'm trying to figure out how to configure and program the thing so that it works in all cases. This is really tricky.

Example: I found that if I pair up with my car stereo and wait for the pairing to complete, I get a certain set of messages on the console. It doesn't work properly until after I issue an "A2DP STREAMING START" command to the chip, at which point everything works well. Except unless I get the timing wrong of exactly when I send that command. If I send it too soon then it has the old "30 seconds delay" problem on the steering wheel controls. But if I send it later it still has the same problem. And there's no documentation telling me how to do the initial handshaking. Also on my bluetooth headset, audio doesn't stream until I issue the "CALL <btaddr>" command but on the car stereo it streams fine and the "CALL" is automatic. Issuing the CALL command on the car stereo doesn't fix any issues.

Another example, the docs for the A2DP/AVRCP communication seem like they have a lot of good syntax examples, but in practice none of the examples work as expected and the entire system is almost completely inscrutable: https://www.silabs.com/documents/login/application-notes/AN986.pdf (link won't unlock for you until after you sign up for an account at their web site).

For instance, in the document linked above, for the track titles, it looks like what you are supposed to do is register with the headunit to respond to notifications where it requests to get the track titles from you, and then you respond with the track titles. But the syntax is poorly documented and only a single non-working example is given for doing it.

So I'm pulling my hair out on this one. :-)
_________________________
Tony Fabris

Top
#369588 - 19/10/2017 03:59 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Mark, here's my current information about the BlueGiga WT32i board, all contained in comments within my work-in-progress code.
https://create.arduino.cc/editor/tfabris/4c5eea9a-1462-45d7-908d-81a5bb6b0d90/preview

If you're planning to connect one of thse WT32i ports directly to the empeg serial port, and write all the code on the empeg, then all you'd need is:
- RCA cables to the Line In ports of the WT32i.
- 5v power to one particular pin of the WT32i.
- Ground (of course).
- Serial RX and TX in a crossover configuration to the WT32i's RX/TX pins.
- The latter will have to go through the one of those usual RS-232 chips that allows you to connect a UART to an RS-232 cable. I forget what you call that thing. In my case, I'm using an RS-232 shield for the Arduino that has that little chip in it. I expect you'd roll your own there.

I have it paring and working on the following things:
- My Honda car stereo.
- A plantronics mono headset/earpiece.
- A cheap third party stereo bluetooth headset.

With the BlueGiga WT32i development board, the audio quality from the empeg is immaculate. Playing the same song direct-digital from my phone to the car stereo, versus playing the song through the empeg using the line-inputs on that BlueGiga WT32i board (into its ADC and then to the car stereo), the audio quality of those two sources are indistinguishable from each other. I have to strain to hear any differences at all, and then I can't tell which one is objectively "better". Also: No detectable ground loop noise that I could hear (but I don't have my power supply working yet so maybe that'll come later).

It processes play/pause/next/prev commands from the bluetooth devices (ie the car stereo screen or steering wheel, or the pushbuttons on the headsets) and changes the tracks on the empeg as expected. That's enough to get me going, but not quite everything that we want yet...

I haven't been able to get track titles to work yet. In theory the car stereo should be querying my bluetooth chip for the track titles, and then my code is supposed to respond, but it doesn't seem to do that: I don't see the query for the track titles ever showing up on the bluetooth chip's serial port. There must be some configuration tweak that I'm missing.

Sometimes (not always) the car stereo will query for other data unrelated to the track titles. But I can't even seem to get those queries to show up reliably, even when I try. (Right now my code tries to shut off the queries but I'm not even sure about those.)

Their documentation supports it all though:
Command reference: https://www.silabs.com/documents/login/reference-manuals/iWRAP6-API-RM.pdf
AVRCP command reference: https://www.silabs.com/documents/login/application-notes/AN986.pdf
(You have to set up and log in to an account at the silabs web site to get those files.)

From their docs:
Quote:

6.4.2 Examples
Controller asks for three 3 attributes of the current song: 1 (the title), 2 (artist) and 3 (album). Target responses with track details:

Controller (ed: That's the car stereo asking):
AVRCP 0 PDU_GET_ELEMENT_ATTRIBUTES 3 1 2 3

Target (ed: That's me, that's my bluetooth chip supposed to be responding):
AVRCP RSP 3 1 “Some Title” 2 “Some Artist” 3 “Some Album”


The problem is knowing how to configure the chip so that the car stereo even knows to send the queries in the first place. Not sure how to do that, the documentation is extremely hard to follow. Maybe you can look at those docs and see how it's done?

I'm in Ohio for several days and I'll come back to this late next week.
_________________________
Tony Fabris

Top
#369591 - 19/10/2017 07:32 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Documents are not protected by a login. smile

Have you played around a bit with the arguments for the commands:

SET PROFILE AVRCP TARGET 7
SET BT CLASS 280428

I suspect you need to enable a bit in the second one. Maybe just try setting all the bits? The car audio system will/should probably only look for ones it cares about.

You've selected "Car Audio" but that's not what *your* device is so sounds a bit strange but I'm not an expert.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369594 - 19/10/2017 19:56 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Very cool, and very generous of you Tony!

I'm actually not quite ready for it on this end -- techie things are indoor winter projects up here, so not until January most likely.

Meanwhile, I am hunting for the A/C clutch relay in my new 2018 XV Crosstrek, so I can wire up a kill switch for the A/C. Unfortunately, nobody seems to know where such relay is located on the vehicle, or even if it exists. The service documentation shows a location clearly labelled as "A/C relay", but in fact that slot in the relay box is empty from the factory. Duh..

Top
#369595 - 19/10/2017 21:04 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Shonky, those are excellent suggestions, I'll give that a shot.

Mark, good luck with finding that info about the relay. :-)
_________________________
Tony Fabris

Top
#369597 - 20/10/2017 00:17 Re: I made a Bluetooth interface. [Re: FieroSTi]
Happy Birthday larry818
old hand

Registered: 01/10/2002
Posts: 1033
Loc: Fullerton, Calif.
Did you check your compressor to see if it even has a clutch? A lot of new cars don't, they have a modulating valve built into the compressor and just allow it to bypass when not needed.

Top
#369598 - 20/10/2017 00:25 Re: I made a Bluetooth interface. [Re: larry818]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: larry818
Did you check your compressor to see if it even has a clutch? A lot of new cars don't, they have a modulating valve built into the compressor and just allow it to bypass when not needed.


Dunno, but it could be something like that. Just weird that the factory service manual at the dealership shows a (non-existent) relay.

The compressor has two electrical connectors attached to it. One has two wires, the other has three wires. Both disappear into a massive wiring harness.

EDIT: Ah, found this description:
Quote:
No clutches in the newer compressors. They are "variable displacement". The compressor pistons are moved by a "wobble plate" attached to the input shaft which is driven continuously by the accessory drive belt. When the AC is off, the plate is perpendicular to the input shaft; it spins with the shaft but the compressor pistons don't move. The spinning shaft and wobble plate put little or no load on the engine. When the AC is turned on, a solenoid in the compressor assembly, controlled by the ECU, moves the plate so that it's no longer perpendicular to the shaft. This causes it to "wobble" as it rotates. This wobbling causes the pistons to move back and forth in their cylinders, compressing the refrigerant. The solenoid can vary the degree to which the plate wobbles, and therefore, the amount of compression. This allows the compressor load on the engine to be better matched to the AC need and engine operating conditions.


Apparently some Subaru vehicles began using those in 2010, though my deceased 2013 Impreza still had a clutch. Looks like perhaps the new Crosstrek has one of these newfangled beasts. Effectively, the "clutch relay" equivalent is built-in, so I just need to figure out which wires for for that part, and install my kill switch onto one of those.

EDIT2: Yup. Denso TSE14F: ECV Compressor. Thanks for the hint!

EDIT3: Good description: https://axleaddict.com/auto-repair/Variable-Displacement-Compressors


Edited by mlord (20/10/2017 12:15)

Top
#369599 - 20/10/2017 01:52 Re: I made a Bluetooth interface. [Re: FieroSTi]
Happy Birthday larry818
old hand

Registered: 01/10/2002
Posts: 1033
Loc: Fullerton, Calif.
In the early days of the variable displacement compressor, some still had clutches. My '06 Volvo is that way, the clutch engages just once, the first time the compressor is needed, and stays on 'till you turn off the car.

The variable compressor is a "first world" thing, probably in other markets they use the simpler old stuff, which is why you would still have a place for the relay.

Given this new info, do you still think you need a kill switch?

Top
#369601 - 20/10/2017 02:27 Re: I made a Bluetooth interface. [Re: larry818]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: larry818
Given this new info, do you still think you need a kill switch?


Yes. Like most other vehicles of this era, the car automatically turns on A/C whenever I direct internal air flow at the inside of the windshield. On most of the planet, this is an okay idea.

In Canada, in winter, at -20C, it is a very bad idea. We need hot air directed at the windscreen to melt the friggin ice, snow, and freezing rain while driving. If the A/C is cooling that heated air by 5-10C, then the system cannot keep up with ice accumulation, and visibility suffers.

Having A/C on in the dead of winter gives another problem too: damp air in the ventilation system after A/C has been on and the ice it created has melted. Next time one starts the car, this damp air blows onto the windshield and instantly freezes, icing up the inside of the window. Which then requires running the A/C to get rid of it, thus perpetuating the cycle. smile

Top
#369602 - 20/10/2017 04:16 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Interesting!

My old Honda would default to turning on the compressor in defrost mode, but I could turn it off with a single button press. The new one, I honestly haven't had a chance to even think to try yet. Hasn't been cold enough in Seattle this year yet.
_________________________
Tony Fabris

Top
#369609 - 20/10/2017 11:18 Re: I made a Bluetooth interface. [Re: FieroSTi]
Happy Birthday larry818
old hand

Registered: 01/10/2002
Posts: 1033
Loc: Fullerton, Calif.
This is something GM cars did back in the '70s and everyone copied. I dislike it as well. My cars have a vent selector and one of the choices is the defrost vents, so I can get hot air on the windshield and not run the compressor.

Top
#369639 - 23/10/2017 22:33 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I think that Shonky's suggestions helped the device to have a more consistent communication with host stereo.

I now have the correct magic incantations to get the track titles sent from my code up to the host stereo. Right now they all say the same thing because I don't yet have a way to pull track titles off the empeg. But I will try to clean up my example code and provide that information to Mark.

:-)
_________________________
Tony Fabris

Top
#369640 - 24/10/2017 00:55 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
Right now they all say the same thing because I don't yet have a way to pull track titles off the empeg. But I will try to clean up my example code and provide that information to Mark.


At the moment at least, that information is available to scripts/programs from /proc/empeg_notify .. if that helps(?)

Top
#369644 - 24/10/2017 17:58 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Thanks, Mark!

I have updated my example code here:
https://create.arduino.cc/editor/tfabris/4c5eea9a-1462-45d7-908d-81a5bb6b0d90/preview

It contains code that successfully gets track/album titles up on the car stereo's screen using the BlueGiga WT32i development board. I still don't have anything implemented on the Empeg side to actually get those titles, but the bluetooth side of it is functional.

I highly recommend getting one of those WT32i modules and using it to interface your empeg with your new car. Now that I've got most of the quirks worked out, I think this is the best bluetooth module for this task.

Here's what I've learned, and it's all incorporated in to the current state of the example code linked above:

- As Shonky pointed out, there are some important settings for configuring the bluetooth chip to identify itself as a certain class of device. Without that being set correctly, there will be unexpected behavior.

- Once those settings are correct, then the bluetooth module will receive certain notification queries from the host stereo. Your code must correctly respond to all of those queries in turn, and if your responses are wrong, you won't get the next query in the chain.

- The host stereo has to query you for the track title metadata. It comes late in the initial flurry of messages after first connection. If you don't answer all of the messages correctly then there is a chance that it might not ever get around to querying you for the track titles.

- The problem where the AVRCP communications seems to "hang" for 30 seconds or more seems to be related to the class-of-device settings and the message responses. Once I got my code correctly identifying the class of device and responding to the messages, I no longer had a problem with the "hung" AVRCP messages.

- There are other pieces of handshaking you have to do. Pairing with a new device can sometimes be tricky for example. I have code in there which mostly works for these purposes but I don't have a wide range of devices to test it out on.

- You'll need an external way to command it to erase the bluetooth chip's paired devices and start over again. I have implemented this as a button in my prototype, but if you're doing it, it could be a hijack menu command for example. This is all in the example code linked above.
_________________________
Tony Fabris

Top
#369645 - 24/10/2017 19:16 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Okay, great!

I scored a full dev board off of eBay(*) for about USD$100 delivered to me -- about half of what it otherwise might have cost. Those certainly aren't cheap. But convenient.

The raw BT module itself is a more reasonable CAD$28 at DigiKey, and wouldn't need too much glue to get going -- the datasheet shows the necessary "glue" bits. smile If I get this one working, I might try a simplified design around the raw BT module later.

(*) WARNING: eBay search for DKWT32i is NSFW!! wink


Edited by mlord (24/10/2017 19:44)

Top
#369646 - 24/10/2017 19:24 Re: I made a Bluetooth interface. [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
So.. for getting track data from the empeg:
Two scenarios:

(1) Arduino manages BT module: Hijack needs to intercept serial input, and respond to requests for track info, otherwise leaving the serial port as-was (passing everything else to the player).

(2) Empeg (Hijack) manages BT module: Hijack can safely dedicate the serial port to only the BT module; no need to worry about player commands or anything other than BT passing through.

EDIT: Or perhaps somewhat simpler for number (1): Hijack could just periodically broadcast track info over the serial port, unsolicited. The Arduino could listen for this and cache it for later response if/when queried by the head unit.

Does the Arduino sketch currently wait-for/read anything else on the serial port?



Edited by mlord (24/10/2017 19:37)

Top
#369647 - 24/10/2017 19:27 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
As Shonky pointed out, there are some important settings for configuring the bluetooth chip to identify itself as a certain class of device. Without that being set correctly, there will be unexpected behavior.


Based on what you now know, I wonder if the issues with the earlier board might be fixable?

Top
#369648 - 24/10/2017 19:47 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Originally Posted By: mlord
Based on what you now know, I wonder if the issues with the earlier board might be fixable?


Very astute of you to point that out. That thought had crossed my mind as well.

Though none of it helps with the RN52 chip, it's potentially possible that I could go back to the BC127 chip and work from there, to see if I can solve the problems I encountered with it. However, I'm planning to move forward with the BlueGiga chip instead, for the following reasons:

- The development board and the chip features seems more directly geared towards high quality audio, including the multiple RCA inputs/outputs, and specific instructions in their datasheet about ways to design the board for high quality audio. Also, if I choose to make the final module out of their dev board instead of rolling my own, most of that work is already done for me. Though the existing BlueGiga dev board is massive overkill for what I'm trying to build, at the moment I don't mind that.

- The control language for the BlueGiga chip is more detailed (though harder to understand), and I feel like I have more flexibility with it.

- I have already got working code with the BlueGiga chip and I would prefer to move forward rather than trying to double back to the older code at this time.
_________________________
Tony Fabris

Top
#369661 - 26/10/2017 03:38 Re: I made a Bluetooth interface. [Re: FieroSTi]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3582
Loc: Columbus, OH
Thanks for asking and answering that. That was my immediate thought as well when I read your update the other day.
_________________________
~ John

Top
#369662 - 26/10/2017 08:38 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Mark, I am responding to your earlier message in this thread that somehow I missed in the scrollback.

If you can get option 2 working (the “no Arduino at all” version) that would clearly be the best option. I just don’t have any experience coding for Linux or coding on the empeg, so I went for a system that I knew I could develop and iterate on quickly. Also, having multiple independently addressable serial ports made it easy to see everything all at once for debugging (not sure how you’d handle monitoring and debugging that if you were developing directly on the empeg with only the single serial port). But if you felt like tackling the “everything on the empeg” version, I’d offer any knowledge and help I can give.

Regarding your other question: Right now my Arduino sketch does not yet interpret strings coming in from the empeg serial port, but it certainly was my intent to make it do so, and the code is already structured in such a way that I could add it easily. It already reads and displays the text from the empeg serial port without parsing it, and it would only take a small amount of parsing code to start making use of any specially-formatted strings which appear on the empeg serial port which contain track data.

If going for the “Arduino Middleman” approach, the best option would be, as you said, to have the empeg periodically spit data out on the serial port about the current track and leave it up to the Arduino to interpret it continuously. I think the empeg already spits out regular data about the currently playing track, it just doesn’t have any track metadata in that output yet. In any case, I had planned on that scheme in my Arduino sketch: it would keep in memory the most recent information it saw from the empeg about the current track, and then when the Bluetooth module requested that information from the empeg, then my sketch would supply that information in response to the query.

If you decide to try to go the “Arduino middleman” route, i have some ideas about how the track titles should be formatted on the empeg serial port for easiest parsing.

By the way, the things that the query can respond to are already stubbed out in my Arduino sketch example code. They include the usual track title stuff, but also the current song position in MS, the total song length in MS, the current track number and the total number of tracks. It remains an open question as to what the correct answer is for the track number and total tracks. Do you give it the track’s canonical position in its album (ie the MP3’s tracknr field), or the track’s current position in the playback order (ie the playlist position or the running order position)? That’s a personal choice I guess.

Finally, I think that whatever we do, it should use the track titles as they appear in the empeg database, rather than trying to re-parse the MP3s for their tags. That would ensure all file formats work the same and ensure the titles on the car touchscreen match the empeg VFD screen.
_________________________
Tony Fabris

Top
#369663 - 26/10/2017 17:50 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Okay. I am going for the empeg-direct-to-BT method here. But won't be doing anything for it until some time after the BT dev board arrives.

An Arduino sketch is a C++ program, and I may cut and paste from yours into a native C program for the empeg. Probably just a couple of days to get it working once I begin, benefiting hugely from your efforts! smile

In the meanwhile though, if you want track data for the Arduino sketch to parse, I can certainly provide that.

Cheers

Top
#369664 - 26/10/2017 18:48 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Excellent!

My Arduino code isn't that great, so when you convert it, you might want to, you know, write the code better than I did. :-)

And I'd love some track data on the serial port! Ideally the output could be something like this (with an appropriate line terminator at the end of each, on the empeg that's a linefeed 0x10 right? Or is it a CRLF?):

currentTrackData_TrackName: Some Song Title
currentTrackData_Artist: Some Artist Name
currentTrackData_Album: Some Album Title
currentTrackData_Genre: Some Genre Name
currentTrackData_TrackNr: Ascii track number in decimal (probably current playlist playback position)
currentTrackData_TracksTotal: Ascii total number of tracks in decimal (probably current playlist length)
currentTrackData_TrackPos: Ascii current single track playback position in decimal, in milliseconds
currentTrackData_TrackLen: Ascii total single track playback length in decimal, in milliseconds

The exact preface strings aren't hugely important, as long as they're unique and all start with a common name so that I can detect when I need to drop into the parsing routine. The idea is: Don't surround the data with any delineating symbols like quotes or chevrons, because then we'd need to figure out a way to escape them and I don't want to deal with escaping in my parsing code. It's easier to parse on the unique phrase at the start of the line, then split them at the first colon-space, then take everything after that up to the first line terminator character.

You could spit them out on the serial port at whatever frequency you think appropriate. And I could write the parsing code so that it doesn't care which ones it gets or when it gets them, it merely interprets the ones that it sees whenever it sees them. So you could output some of them more frequently than others. For instance, only outputting the track titles and position at startup and when the tracks change, but outputting the track position and length every 500 milliseconds or so. Or output all of them every second to simplify your code, or whatever you like.

I don't know if that'd be too much data for the serial port at its default settings. I think 115200 speed shouldn't slow down the empeg too much, but I could see that, for example, if the serial port were running at 9600bps might be a bit too slow to be sending all that data all the time. My intention is to set the empeg to car_rate 115200 for this, but perhaps the serial port track data should be disabled by default in case someone's player is set to something less than that.
_________________________
Tony Fabris

Top
#369665 - 26/10/2017 19:10 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
The usual line terminator is a LF (newline) '\n' 0x10 character. smile

You presumably realize that you can use scanf() and sscanf() in C/C++ on the Arduino, right? Makes parsing things REALLY easy!

Cheers

Top
#369666 - 26/10/2017 22:30 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Good point.

But strings are a bit tricky on the Arduino because the String class takes up too much memory and you're constantly having to do little workarounds that you wouldn't normally do on a full computer. The Arduino, when it runs out of memory, starts having random undefined behavior instead of showing a nice error message. I've had it happen a bunch of times already, so I'm trying to keep a rein on how much string processing I do in the Arduino code.
_________________________
Tony Fabris

Top
#369667 - 26/10/2017 22:34 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
By the way I've updated my example code again. I found another secret incantaion in the BlueGiga module's command set that took care of an important piece of the command/response chain.

Basically, until now, the BlueGiga module would query for the track metadata just once after first connecting, and then after that, it wouldn't ever query for it again. It would keep checking playback status once per second (asking only for play/pause state and track playback position), but it wouldn't query for the changing of the track metadata.

So I found the command that I need to send to the bluetooth module which MAKES it go "hey something changed and I should query to find out what the new track looks like". The command in question was "AVRCP NFY CHANGED 1 2 1" by the way.
_________________________
Tony Fabris

Top
#369670 - 27/10/2017 11:53 Re: I made a Bluetooth interface. [Re: FieroSTi]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Good. My dev board is still 2-3 weeks away from arriving here (coming from USA, so very slow). I'll grab a fresh snapshot from you when I start on it.

Yeah, String is bulky. I just use char[] arrays whenever possible.

Top
#369674 - 28/10/2017 09:52 Re: I made a Bluetooth interface. [Re: mlord]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
Originally Posted By: mlord
The usual line terminator is a LF (newline) '\n' 0x10 character. smile

LF is decimal 10 or 0x0A (hex) smile
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369677 - 29/10/2017 05:08 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Silly me, I got my hex and decimal mixed up. smile
_________________________
Tony Fabris

Top
#369689 - 02/11/2017 18:35 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I just noticed that there is already track data on the serial port. I didn't see it before but I'm seeing it now. I don't know why I didn't see it before. I was sure I looked for it and it wasn't there. I saw the VCB messages before but they didn't contain any track text. Now suddenly there's track text there. WTF?

Anyway!!!!

I just need to decipher what's there. Anyone got any tips? Is there a list somewhere of what all the messages mean?

Code:
Sending to empeg:N

  serial_notify_thread.cpp: 116:@@ N1
  serial_notify_thread.cpp: 117:@@ F0xbfd0
  serial_notify_thread.cpp: 118:@@ TThe Camera Eye
  serial_notify_thread.cpp: 119:@@ ARush
  serial_notify_thread.cpp: 120:@@ GProgressive Rock
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:00
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:01
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:02
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:03
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:04
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:05

Sending to empeg: P

  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:00
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:00
  serial_notify_thread.cpp: 116:@@ N1
  serial_notify_thread.cpp: 117:@@ F0xbfd0
  serial_notify_thread.cpp: 118:@@ TThe Camera Eye
  serial_notify_thread.cpp: 119:@@ ARush
  serial_notify_thread.cpp: 120:@@ GProgressive Rock
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:01
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:02
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:03
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:04
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:05
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:06
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:07
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:08
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:09

Sending to empeg: W

  serial_notify_thread.cpp: 170:@@ S0
  serial_notify_thread.cpp: 170:@@ S0



There appear to be numeric indicators such as "180:@@" and I'm hoping each one has a defined meaning and that the numbers don't change. For instance maybe "180" is always an ASCII track playback position timestamp and 170 is always indicating that the track has been paused. Or something like that.

Fun stuff!
_________________________
Tony Fabris

Top
#369690 - 02/11/2017 18:48 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Here's what I've deciphered so far. Seems like we don't get album titles on the serial port, maybe there's something we can do about that later.

Code:
  
Track playback position:
180:@@ #<fid> <Track time position in ASCII H:MM:SS format>
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:00
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:01
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:02
  serial_notify_thread.cpp: 180:@@ #bfd0  0:00:03


Pause/play state:
170:@@ S<1><0>   (1=playing 0=paused)
  serial_notify_thread.cpp: 170:@@ S1
  serial_notify_thread.cpp: 170:@@ S0


Track metadata:
116:@@ N<tracknumber, actually playlist position, starts at zero>
117:@@ F<fid>
118:@@ T<track title>
119:@@ A<artist>
120:@@ G<genre>
  serial_notify_thread.cpp: 116:@@ N0
  serial_notify_thread.cpp: 117:@@ F0x10c90
  serial_notify_thread.cpp: 118:@@ TBlue Jean
  serial_notify_thread.cpp: 119:@@ AWorld Trio
  serial_notify_thread.cpp: 120:@@ GJazz
  serial_notify_thread.cpp: 180:@@ #10c90  0:00:00
  serial_notify_thread.cpp: 170:@@ S1
  serial_notify_thread.cpp: 180:@@ #10c90  0:00:01
  serial_notify_thread.cpp: 180:@@ #10c90  0:00:02
  serial_notify_thread.cpp: 116:@@ N1
  serial_notify_thread.cpp: 117:@@ F0xe520
  serial_notify_thread.cpp: 118:@@ TKeep Hope Alive
  serial_notify_thread.cpp: 119:@@ AThe Crystal Method
  serial_notify_thread.cpp: 120:@@ GTechno
  serial_notify_thread.cpp: 180:@@ #e520  0:00:00
  serial_notify_thread.cpp: 180:@@ #e520  0:00:01
  serial_notify_thread.cpp: 180:@@ #e520  0:00:02
  serial_notify_thread.cpp: 116:@@ N2
  serial_notify_thread.cpp: 117:@@ F0x9cc0
  serial_notify_thread.cpp: 118:@@ TKind and Generous
  serial_notify_thread.cpp: 119:@@ ANatalie Merchant
  serial_notify_thread.cpp: 120:@@ GRock
  serial_notify_thread.cpp: 180:@@ #9cc0  0:00:00
  serial_notify_thread.cpp: 180:@@ #9cc0  0:00:01
  serial_notify_thread.cpp: 116:@@ N3
  serial_notify_thread.cpp: 117:@@ F0xd780
  serial_notify_thread.cpp: 118:@@ TRock Steady
  serial_notify_thread.cpp: 119:@@ ASting
  serial_notify_thread.cpp: 120:@@ GRock
  serial_notify_thread.cpp: 180:@@ #d780  0:00:00
  serial_notify_thread.cpp: 180:@@ #d780  0:00:01
  serial_notify_thread.cpp: 170:@@ S0
_________________________
Tony Fabris

Top
#369691 - 02/11/2017 19:13 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Not sure what the 136:@@ Vxx messages mean:
Code:
  serial_notify_thread.cpp: 136:@@ V25
  serial_notify_thread.cpp: 136:@@ V28
  serial_notify_thread.cpp: 136:@@ V31
  serial_notify_thread.cpp: 136:@@ V34
  serial_notify_thread.cpp: 136:@@ V37
  serial_notify_thread.cpp: 136:@@ V39
  serial_notify_thread.cpp: 136:@@ V42
  serial_notify_thread.cpp: 136:@@ V45
  serial_notify_thread.cpp: 136:@@ V48
  serial_notify_thread.cpp: 136:@@ V51
  serial_notify_thread.cpp: 136:@@ V53
  serial_notify_thread.cpp: 136:@@ V56
  serial_notify_thread.cpp: 136:@@ V59
  serial_notify_thread.cpp: 136:@@ V62
_________________________
Tony Fabris

Top
#369692 - 02/11/2017 19:22 Re: I made a Bluetooth interface. [Re: FieroSTi]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Next question. Anyone know about this?

I'm rolling my own serial interface now, using a MAX232 and some capacitors, instead of using a third party shield. I have this working so far. It works at 115200 even with only the TX, RX, and GND pins connected to the serial port.

Most of the schematics I see indicate that I must also loopback some of the pins on the RS-232 serial plug back to other pins on the same plug.

Some say I should loopback connect pin 7 to pin 8, and also loopback connect pin 6 to pin 4. Example: https://www.avrprogrammers.com/articles/max232-arduino

Others say I should do the same as the above but also loopback connect pin 1 to pins 6 and 4. Example: http://justanotherlanguage.org/content/building-max232-circuit-serial-port-communication

What is the purpose of these connections on the RS-232 plug? And are they required for the Empeg? I'm not even sure those pins are hooked up at all on the Empeg side of things. I don't think there's enough wires on the empeg serial connector for those.
_________________________
Tony Fabris

Top
#369693 - 02/11/2017 21:00 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Ahh, good. I was hoping I might not need to do anything special here for your setup. Hijack itself intercepts that same serial output for use in constructing the contents of /proc/empeg_notify.

See this file in the empeg/Hijack kernel tree:

arch/arm/special/notify.c

In that small file (part of hijack), we find this:
Code:
unsigned char *notify_names[NOTIFY_MAX_LINES]
        = {"FidTime", "Artist", "FID", "Genre", "MixerInput", "Track", "Sound", "Title", "Volume", "L", "Other"};
unsigned char  notify_chars[NOTIFY_MAX_LINES] = "#AFGMNSTVLO";


Which is basically a guide to what you are seeing on the serial port. The notify_chars[] are the single character prefixes (Eg. 'A' for 'Artist') and the notify_names[] tells what they stand for. Got it?

Also inside that source file is the hijack_serial_notify() function for parsing/collecting that information. The rest of the file deals with mostly unrelated stuff.


Top
#369694 - 02/11/2017 21:06 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
Not sure what the 136:@@ Vxx messages mean:
Code:
  serial_notify_thread.cpp: 136:@@ V25
  serial_notify_thread.cpp: 136:@@ V28
  serial_notify_thread.cpp: 136:@@ V31
  serial_notify_thread.cpp: 136:@@ V34
  ...

So based on my post about notify.c, it follows that what you are seeing above is the result of adjusting playback volume. Right?

Top
#369695 - 02/11/2017 21:08 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
Most of the schematics I see indicate that I must also loopback some of the pins on the RS-232 serial plug back to other pins on the same plug.


Those other pins mostly have to do with flow control. CTS/RTS are "hardware flow control". DTR/DSR are a way of detecting whether something is ready for more data at the other end of the cable (more flow control). DCD (aka. CD) tells whether or not the cable is plugged into a compliant device, etc.

All optional, and all mostly ignored at the empeg end.

Top
#369696 - 02/11/2017 21:12 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: tfabris
There appear to be numeric indicators such as "180:@@"


I forget what the numbers are for.
They seem to only increase, so a timestamp (in seconds) of some kind?



Edited by mlord (02/11/2017 21:15)

Top
#369697 - 02/11/2017 21:32 Re: I made a Bluetooth interface. [Re: tfabris]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
My DKWT32i board arrived here today. Just a board. Nothing else: no docs, no dongle for reflashing firmware, or anything else. Shouldn't be an issue, but we'll see.

Originally Posted By: tfabris

- Serial RX and TX in a crossover configuration to the WT32i's RX/TX pins.
- The latter will have to go through the one of those usual RS-232 chips that allows you to connect a UART to an RS-232 cable. I forget what you call that thing. In my case, I'm using an RS-232 shield for the Arduino that has that little chip in it.


So, you had to use full RS-232 levels to connect to the RX/TX pins on the header on the board? I would have guessed that the board would already be operating at 5V or 3.3V levels for those pins, but perhaps not.

In other words, no MAX chip / serial converters required when connecting directly to an Arduino.

What I need to find first, I guess, is hardware documentation for the dev board. Got any? EDIT: found lots on their web site, but still nothing about signal levels on that header where RX/TX are. I'll put the scope on it later to see, but probably just 3.3V for the serial port.

My board works -- paired with my phone and played audio out over BT through the board to an amp/speakers.



Edited by mlord (02/11/2017 22:04)

Top
#369698 - 02/11/2017 22:12 Re: I made a Bluetooth interface. [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14472
Loc: Canada
Originally Posted By: mlord
So, you had to use full RS-232 levels to connect to the RX/TX pins on the header on the board? I would have guessed that the board would already be operating at 5V or 3.3V levels for those pins


Okay, the pins on that large header (top left on board) are supposedly direct from the WT32i module itself, so everything (digital) there is 3.3V CMOS logic.

So Tony, why all of the fuss with an RS232 "shield" etc for communicating with your Arduino? It should instead just be directly wired to the RX/TX pins on the Arduino (or to any other chosen pins if using "software serial").

Oh, unless all of your RS232 stuff is for the empeg side of things. In which case it makes sense now. (?)


Edited by mlord (02/11/2017 22:14)

Top
#369699 - 02/11/2017 22:17 Re: I made a Bluetooth interface. [Re: FieroSTi]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
He's talking about the empeg side, yes.

And as for looping back, ignore all that and just leave them open circuit.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#369702 - 03/11/2017 04:18 Re: I made a Bluetooth interface. [Re: mlord]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Originally Posted By: mlord
Oh, unless all of your RS232 stuff is for the empeg side of things. In which case it makes sense now.


Precisely correct.

The connection from the BlueGiga WT32i board to the Arduino is merely four wires:

- 5v regulated power, the same power rail that is powering the Arduino (and/or the Arduino's 5v power)
- Ground.
- TX pin on the BlueGiga connected to RX2 pin on the Arduino.
- RX pin on the BlueGiga connected to TX2 pin on the Arduino.

The RS-232 shield (which I tossed out and now I'm rolling my own with a MAX232 chip and some caps) was only to connect the Arduino's RX1/TX1 output to the empeg serial port.

In other words, the BlueGiga board is UART-level, not RS-232 level. It can connect to another UART but not to an actual RS-232 port without a MAX232 in between.

smile
_________________________
Tony Fabris

Top
#369703 - 03/11/2017 04:19 Re: I made a Bluetooth interface. [Re: Shonky]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Thanks for the loop back information, Shonky! I'll do that.

In other news:

- This thread has gotten too big and I'm going to start a new thread... With a nice cool thing in the thread...
_________________________
Tony Fabris

Top
#370568 - 23/02/2018 22:14 Re: I made a Bluetooth interface. [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
Final version of BlueGigaEmpeg now here:
http://empegbbs.com/ubbthreads.php/topics/370560/1
_________________________
Tony Fabris

Top
Page 1 of 6 1 2 3 4 5 6 >