Possible to listen for Bluetooth device button presses?

I’m looking to create a little project for a friends wedding, I need to be able to connect a Bluetooth handset to a Sailfish device and monitor the Call hang up and answer signals (providing that’s something that’s possible or even exists, I don’t know much about Bluetooth devices).

Picking up the receiver would play a pre-recorded message through the handset then record audio until the receiver is placed back on the unit.

Is this something that’s possible with current Sailfish APIs?
I took a look at MPRIS assuming it would be possible through there but I’m very rusty with SFOS development it’s been a long time.

Any tips would be appreciated!

1 Like
  1. it is not clear what is handset or why you use this term
  2. it is not clear what you call receiver - I assume the Sailfish phone
  3. IMO it is possible because,
  4. It has almost nothing to do with MPRIS, AFAIK it runs through ofono and dbus (beside bluetooth)
    but I’m not sure how exactly you can play back or record the audio - I do not know if you can use MPRIS in this context - the calling is using usually HFP and MPRIS goes via A2DP. But again, I am not exactly sure if these can play together

After reading your post I had a look at SFOS and my Linux machine. Unfortunately I do not have a bluetooth headset, just a small speaker, and my machine runs Xorg while SFOS runs wayland.

But very generally I can say that (some) bluetooth buttons are recognized like any other key press.

On Xorg, I can use xev to check for input events.

On wayland, the same should be possible with wev or libinput but neither seems to be available for SFOS.

Once that is figured out then yes, some daemon could recognize the keypresses (on my system the window manager provides this hotkey functionality, again, no idea how this works under SFOS) and send the appropriate command to MPRIS (that one I know is present and active under SFOS).

Lastly, the app(s) reacting to the key press have to be registered on the MPRIS DBus.

Maybe it’s possible to cut out the MPRIS middle man and send the commands directly to your app(s).

Sorry if all this is a bit vague.

A2DP with MPRIS and HFP/HSP with Ofono

Did you read my post? Are you sure MPRIS works with HFP/HSP, cause I am not?