2019-06-02 14:55:15 +00:00
|
|
|
# This is rpi only
|
|
|
|
|
|
|
|
- name: "Install rpi bluetooth packages"
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- bluetooth
|
|
|
|
- bluez
|
|
|
|
- bluez-tools
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create bluetooth services
|
|
|
|
template:
|
|
|
|
backup: no
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
|
|
|
- { src: 'bt-agent.service.j2', dest: '/etc/systemd/system/bt-agent.service' }
|
|
|
|
- { src: 'bt-pan.service.j2', dest: '/etc/systemd/system/bt-pan.service' }
|
|
|
|
- { src: 'bt-term.service.j2', dest: '/etc/systemd/system/bt-term.service' }
|
2019-06-03 15:51:40 +00:00
|
|
|
- { src: 'network.conf.j2', dest: '/etc/bluetooth/network.conf' }
|
|
|
|
|
|
|
|
- name: Create bluetooth utility scripts
|
|
|
|
template:
|
|
|
|
backup: no
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
with_items:
|
2019-06-02 14:55:15 +00:00
|
|
|
- { src: 'iiab-bt-pan-on.j2', dest: '/usr/bin/iiab-bt-pan-on' }
|
|
|
|
- { src: 'iiab-bt-pan-off.j2', dest: '/usr/bin/iiab-bt-pan-off' }
|
2019-06-19 13:12:05 +00:00
|
|
|
- { src: 'iiab-bt-pan-discoverable-on.j2', dest: '/usr/bin/iiab-bt-pan-discoverable-on' }
|
2019-06-02 14:55:15 +00:00
|
|
|
- { src: 'iiab-bt-term-on.j2', dest: '/usr/bin/iiab-bt-term-on' }
|
|
|
|
- { src: 'iiab-bt-term-off.j2', dest: '/usr/bin/iiab-bt-term-off' }
|
|
|
|
|
2019-06-02 19:50:50 +00:00
|
|
|
# Bluetooth service needs /usr/lib/bluetooth/bluetoothd -C --noplugin=sap
|
2019-06-15 19:13:59 +00:00
|
|
|
# Copy and patch it
|
|
|
|
|
|
|
|
- name: Copy the bluetooth service
|
|
|
|
template:
|
|
|
|
dest: /etc/systemd/system/bluetooth.service
|
|
|
|
src: /lib/systemd/system/bluetooth.service
|
|
|
|
|
2019-06-02 19:50:50 +00:00
|
|
|
- name: Add -C --noplugin=sap to execStart of bluetooth service
|
|
|
|
lineinfile:
|
2019-06-15 19:13:59 +00:00
|
|
|
path: /etc/systemd/system/bluetooth.service
|
2019-06-02 19:50:50 +00:00
|
|
|
regexp: '^ExecStart=/usr/lib/bluetooth/bluetoothd'
|
|
|
|
line: 'ExecStart=/usr/lib/bluetooth/bluetoothd -C --noplugin=sap'
|
|
|
|
|
2019-06-03 15:51:40 +00:00
|
|
|
- name: Set discoverable not to timeout
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/bluetooth/main.conf
|
|
|
|
regexp: '^#DiscoverableTimeout'
|
|
|
|
line: 'DiscoverableTimeout = 0'
|
|
|
|
|
|
|
|
- name: Enable & Restart 'bt-agent' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bluetooth
|
|
|
|
enabled: yes
|
|
|
|
state: restarted
|
|
|
|
|
2019-06-02 14:55:15 +00:00
|
|
|
# enable or disable bt-agent
|
|
|
|
- name: Enable & Restart 'bt-agent' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bt-agent
|
|
|
|
enabled: yes
|
|
|
|
state: restarted
|
|
|
|
when: bluetooth_enabled or bluetooth_term_enabled
|
|
|
|
|
|
|
|
- name: Disable 'bt-agent' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bt-agent
|
|
|
|
enabled: no
|
|
|
|
state: stopped
|
|
|
|
when: not bluetooth_enabled and not bluetooth_term_enabled
|
|
|
|
|
|
|
|
# enable or disable bt-pan
|
|
|
|
- name: Enable & Restart 'bt-pan' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bt-pan
|
|
|
|
enabled: yes
|
|
|
|
state: restarted
|
|
|
|
when: bluetooth_enabled | bool
|
|
|
|
|
|
|
|
- name: Disable 'bt-pan' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bt-pan
|
|
|
|
enabled: no
|
|
|
|
state: stopped
|
|
|
|
when: not bluetooth_enabled | bool
|
|
|
|
|
|
|
|
# enable or disable bt-term
|
|
|
|
- name: Enable & Restart 'bt-term' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bt-term
|
|
|
|
enabled: yes
|
|
|
|
state: restarted
|
|
|
|
when: bluetooth_term_enabled | bool
|
|
|
|
|
|
|
|
- name: Disable 'bt-term' service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
name: bt-term
|
|
|
|
enabled: no
|
|
|
|
state: stopped
|
|
|
|
when: not bluetooth_term_enabled | bool
|
|
|
|
|
|
|
|
- name: Add 'bluetooth' variable values to {{ iiab_ini_file }}
|
|
|
|
ini_file:
|
|
|
|
path: "{{ iiab_ini_file }}"
|
|
|
|
section: bluetooth
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
with_items:
|
|
|
|
- option: name
|
|
|
|
value: Bluetooth
|
|
|
|
- option: description
|
|
|
|
value: '"Bluetooth services for pan and terminal."'
|
|
|
|
- option: bluetooth_enabled
|
|
|
|
value: "{{ bluetooth_enabled }}"
|
|
|
|
- option: bluetooth_term_enabled
|
|
|
|
value: "{{ bluetooth_term_enabled }}"
|