The next frustration is Caller ID. The Bluetooth module provides a specific Caller ID event that is supposed to conveniently report the Caller ID text. In the configuration software for the Bluetooth module, there is also an option for whether the Caller ID event should provide the text representation if available (i.e., the caller's name), or if it should consistently always provide only the incoming phone number.
I selected the option to prefer the text/name if available, and here's the behavior I observed:
- For a normal incoming call, I do receive the name/text from the Caller ID event... but the event is delayed about a full second after the incoming call state change. So the phone rings for about a second before I display Caller ID.
- When in a call already, and a second call comes in (Call Waiting), the Caller ID event actually happens BEFORE the call status event indicates there is a call waiting... and the Caller ID event only provides the phone number!
This actually stopped me from creating a videos showing off Call Waiting behavior, because I didn't want to expose any of my family members' phone numbers, and I didn't want to deal with blurring the numbers in the video. It also is lame that I can get a name for a normal incoming call, but not for a call waiting.
After some time on Google, I learned about an "AT" command supported over Bluetooth HFP to request details about all current calls: "AT+CLCC"
For each call, it indicates (among other things) whether it is active, on hold, pending incoming, pending outgoing, etc., as well as the phone number and the "name" associated with the call. Search
this page for "+CLCC" to find all the details. Strangely, I can't seem to find any definitive documentation about HFP AT commands. Instead, I seem to find documentation of AT commands supported by specific implementations of modems, etc. (UPDATE: I found the official
Bluetooth HFP 1.7 specification, which details the HFP-specific AT commands, but defers to other standard for details of some commands).
So now whenever I get an incoming call or an incoming call waiting, I send the "AT+CLCC" command and scan the responses looking for a call whose status is 3 (alerting) or 5 (waiting), and parse out the name and phone number. If there's a name, I use it for Caller ID, otherwise I use the number.
This response comes in very quickly, so I can display Caller ID practically immediately when the phone starts ringing. I also get a name for call waiting calls. Here's an example of logging when placing an outgoing call, then receiving an incoming call waiting:
I'm pretty sure this is the same information the Bluetooth module is using to implement its Caller ID event. I haven't been able to find any info about any other HFP commands/events that could provide such info. So in this case, the strange behavior of the Caller ID event is probably a bug in the Bluetooth module's firmware, rather than a bug in my phone's HFP support.