I've gotten back to this project, and I've made some progress, but it has been slow. For testing, I've been using a receiver only, a Uniden BCT15X scanner programmed with a bunch of ham and GMRS frequencies. This has 2 advantages to my incremental approach to solving this problem: (1) It's less hassle to initially just deal with a receiver than my eventual goal of an Icom IC-7100 transceiver, (2) The BCT15X has a simple, ASCII-based remote control protocol, which can be controlled from a terminal emulator on my laptop, making program development a lot easier, versus the Icom's binary C/IV format.
The first thing I have to report is that my 2022 LEAF SV+ seems somewhat picky about what Bluetooth devices it will work with. I tried a Sennheiser BT T100 Bluetooth audio transmitter. It paired OK. I went to the Connections screen, pressed Touch to Connect and it said Connected Ready for Use. But in the Bluetooth Audio screen, it said No Bluetooth Device Connected, and it would not receive the audio from the BT T100. So my interim, short-term solution was a bust.
Going back to Pi Zero W, I was able to get it to pair with the LEAF. When I installed linux on the Pi, I named it N3TS-mobile, so that's how it shows up on the LEAF's Connections screen. With "bluez" and "pulse audio" installed on the Pi, after getting it paired and pressing Touch to Connect, on the Bluetooth Audio screen it shows N3TS-mobile at the top of the screen. (Note that it only says N3TS-mobile at the top of the center screen; it still says Bluetooth Audio at the top of the left screen.) A quick check with the pulsemixer command to get everything set, and I could send audio from the espeak command to the LEAF!
Now I needed a way to interface the radio to the Pi, and I think I've found the perfect interface, made by Digirig. Its a little USB interface, very tiny, that has both the audio and the serial in one box, for $50, what a deal! I got one configured for RS232 serial for the Uniden scanner, but when the time comes, the Icom radio already has a USB interface. (Digirig can be configured for Icom C/IV if you've got an older rig without built-in USB.) Just one word of caution: powering the Pi from the 5V USB charging outlets in the LEAF puts a bunch of noise onto the audio when the Uniden is plugged in via the Digirig, so I'm now using a Meanwell SD-15A-05 power supply for the Pi. And the other thing is that I had to install the pulseaudio loopback module to route the audio from the Digirig to the MY LEAF and set the level appropriately in pulsemixer, but now I have audio from the Uniden record-out jack coming through the LEAF's speakers!
Now, on to the control part of the project, I've made a little progress. I found that the linux bluez Bluetooth stack converts AVRCP controls into linux keypress events. These do not show up in the normal console keyboard input stream, but they can be seen using the evtest program. So I grabbed the source code of evtest.c from the linux code repository, and used what I saw there to write a little C program which successfully reads the keypress events from the LEAF. The 2 steering wheel remote buttons can generate 4 different events, because it differentiates short and long press. I also grabbed the complete source to bluez, and much of what I'm interested in seems to be in avrcp.c and avctp.c. I have not started on the serial code for talking with the receiver yet.
Another part of the project will be to build the Pi into a metal box with the Meanwell power supply and a USB hub, and whatever other interface circuitry I find necessary.
But anyway, at least at this point, I have audio from my receiver flowing by Bluetooth to the LEAF and playing through the LEAF speakers!
--de N3TS WRAT786