Thanks very much for the tutorial about how stdout/stdin/stderr works on linux, that will be very useful to me if/when I start digging into this in the "everything on the empeg" mode at some point. It is also good general knowledge to have about linux coding.

In other news, I have updated the example code here:
https://create.arduino.cc/editor/tfabris/4c5eea9a-1462-45d7-908d-81a5bb6b0d90/preview
(I'm considering making a GitHub for it instead, that kinda makes more sense, maybe I'll get around to that soon).

Changes in the most recent version:

- Some more code comment cleanup.

- Implemented your suggestion about making the playback state change if it detects that the track timestamp has been changing recently. It does indeed do the thing I feared: Making it look like the track is playing if you FF while the track is paused. But this is not a big deal and is better than the alternative.

- Implemented fast forward and rewind for car stereo headunits that support FF/REW over Bluetooth. My Honda factory stereo doesn't, but my roommate's aftermarket Kenwood stereo does, so I was able to get something working in that area.

- More details about track playback position indication are now in the code.


In other news:

I realized that my roommate's car stereo was an aftermarket Kenwood unit with a bluetooth input and track titles on the screen. So I could test out my code with a second stereo finally!

To my surprise, almost everything worked correctly. And his stereo can do FF/REW over bluetooth (something my Honda inexplicably refuses to do at all) and so I was able to implement FF/REW in the code now.

However there is one interesting thing about his stereo that is different from my Honda. And it's a pretty big bug that I am stumped by and now I need to know how to fix. Googling for it isn't helping yet, so I'm not sure about how to handle this. Here's the issue...

The bluetooth code depends upon the host car stereo headunit to query us for the track metadata. In other words, we can't "push" track titles up to the car stereo screen until the car stereo asks us for them. They are implemented only as a response to the query.

I have been using the following command, sending this up to the car stereo to make it turn around and re-query us for the new track titles. This command works on the Honda stereo:

Code:
      SendBlueGigaCommand(F("AVRCP NFY CHANGED 1 2 1"));  
      // Where:
      //      AVRCP NFY   - The notification command to send to the head unit.
      //      CHANGED     - Indicate to the head unit that there was a change to the track.
      //      1           - Send this message with transaction label 1 (an arbitrary sequence number).
      //      2           - The notification message we will send contains event ID 2, which is "TRACK_CHANGED".
      //      1           - The sole parameter value for the TRACK_CHANGED, with a "1" indicating that there is indeed a track selected.


When I issue that command to the bluetooth chip when it is paired with the Honda stereo, it responds instantly and re-queries for new track metadata. Unfortunately, on the Kenwood unit, the command does nothing and the Kenwood unit doesn't re-query for new track metadata.

I know that sometimes the Kenwood unit successfully queries for track data. Immediately after first connection to the bluetooth chip, it does query for the track information and my code responds as expected. The track titles appear on the screen of the Kenwood, and all is well. Then when I go to change to another track on the Empeg, and it issues the "AVRCP NFY CHANGED 1 2 1", nothing happens, and the Kenwood keep displaying the same song title, though now a different song is coming out of the speakers.

I know that there must be a standardized way to make this work, because all the cell phones that we pair up with this Kenwood unit correctly display track titles when tracks get changed. But I don't know how to sniff their communications to find out how this is done.

Anyone have any ideas of how to kick the headunit to make it re-query for new track metadata?
_________________________
Tony Fabris