参考https://askubuntu.com/questions/831331/failed-to-change-profile-to-headset-head-unit 备份
- sudo apt install ofono
- Goto /etc/pulse/default.pa find the line load-module module-bluetooth-discover and change it in load-module module-bluetooth-discover headset=ofono.
- Add the user pulse to group bluetooth to grant the permission: sudo usermod -aG bluetooth pulse (probably it's already correct)
- VERY IMPORTANT: To grant the permission, add this to /etc/dbus-1/system.d/ofono.conf (before ): <policy user="pulse"> <allow send_destination="org.ofono"/> </policy>
- Provide phonesim to ofono. In order to make ofono work, you have to provide a modem to it! You can install a modem emulator called phonesim (implemented by ofono) to make it work:
- install ofono-phonesim (in some distros it is called phonesim). in Ubuntu 18.04 (for Ubuntu 20.04 follow this link): sudo apt install ofono-phonesim sudo add-apt-repository ppa:smoser/bluetooth sudo apt-get update sudo apt-get install ofono-phonesim
- Configure phonesim by adding the following lines to /etc/ofono/phonesim.conf: [phonesim] Driver=phonesim Address=127.0.0.1 Port=12345
- Restart ofono:
sudo systemctl restart ofono.service
- Start phonesim:
ofono-phonesim -p 12345 /usr/share/phonesim/default.xml
- To make sure phonesim is started correctly you can clone the ofono repo and use their test scripts:cd /tmp git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git cd ofono/test ./enable-modem ./online-modem ./list-modems
20.04自动启动
/etc/systemd/system/ofono-phonesim.service
代码语言:javascript复制[Unit]
Description=Run ofono-phonesim in the background
[Service]
ExecStart=ofono-phonesim -p 12345 /usr/share/phonesim/default.xml
Type=simple
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
/etc/systemd/system/phonesim-enable-modem.service:
代码语言:javascript复制[Unit]
Description=Enable and online phonesim modem
Requires=ofono-phonesim.service
[Service]
ExecStart=/<path-to-cloned-ofono-git-repo>/test/enable-modem /phonesim
ExecStart=/<path-to-cloned-ofono-git-repo>/test/online-modem /phonesim
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Then run the following commands to run both daemons:
代码语言:javascript复制sudo systemctl daemon-reload
sudo systemctl enable ofono-phonesim.service
sudo systemctl enable phonesim-enable-modem.service
sudo service phonesim-enable-modem start
Check if the service is running with
代码语言:javascript复制sudo service phonesim-enable-modem status