Skip to content

Instantly share code, notes, and snippets.

@pbzweihander
Created August 19, 2020 06:32
Show Gist options
  • Save pbzweihander/6e9ca7dd62d1d783dc0d67316361c8e1 to your computer and use it in GitHub Desktop.
Save pbzweihander/6e9ca7dd62d1d783dc0d67316361c8e1 to your computer and use it in GitHub Desktop.
Enable phonesim to use bluetooth headset's mic (e.g. AirPods Pro)
#!/usr/bin/env bash
# Use i3-msg or something that can spawn to background
i3-msg exec "phonesim -p 12345 /usr/share/phonesim/default.xml"
sudo systemctl start ofono.service
dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:true
dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Online" variant:boolean:true
@MiguelGCanton
Copy link

hey, i new with linux and i am trying to enable the mode HSP/HFP,
im using this guide https://wiki.archlinux.org/index.php/bluetooth_headset
and where i used the command in the line five i get the message "Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.ofono was not provided by any .service files" would you help me?

@pbzweihander
Copy link
Author

@MiguelGCanton Make sure ofono is properly installed and started with systemctl!

@Flabonv
Copy link

Flabonv commented Mar 16, 2021

I'm getting the same error. I'm trying to make my bluetooth mic work and I saw that it can be done with ofono. However, I can't run the enable-modem or any of the other scripts. I followed this procedure to try and configure ofono but I can't get it to work. I've been surfing around the web to find and solution but couldn't find many threads concerning this issue.
I launched :
ofono-phonesim -p 12345 /usr/share/phonesim/default.xml & and I can see that it's running in the background
ps:
3228 pts/0 00:00:00 ofono-phonesim

I'm still getting the same error:
Connecting modem /phonesim...
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 175, in activate_name_owner
return self.get_name_owner(bus_name)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 361, in get_name_owner
's', (bus_name,), **keywords)
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.ofono': no such name

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./enable-modem", line 17, in
modem = dbus.Interface(bus.get_object('org.ofono', path),
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 241, in get_object
follow_name_owner_changes=follow_name_owner_changes)
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 248, in init
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 180, in activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 278, in start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.ofono was not provided by any .service files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment