ubuntu蓝牙耳机切换到头戴式耳机

2021-03-15 11:08:31 浏览数 (1)

参考https://askubuntu.com/questions/831331/failed-to-change-profile-to-headset-head-unit 备份

  1. sudo apt install ofono
  2. Goto /etc/pulse/default.pa find the line load-module module-bluetooth-discover and change it in load-module module-bluetooth-discover headset=ofono.
  3. Add the user pulse to group bluetooth to grant the permission: sudo usermod -aG bluetooth pulse (probably it's already correct)
  4. 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>
  5. 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:
  6. 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
  7. Configure phonesim by adding the following lines to /etc/ofono/phonesim.conf: [phonesim] Driver=phonesim Address=127.0.0.1 Port=12345
  8. Restart ofono:sudo systemctl restart ofono.service
  9. Start phonesim:ofono-phonesim -p 12345 /usr/share/phonesim/default.xml
  10. 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

0 人点赞