1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Bluetooth PAN and Terminal servers

This commit is contained in:
Tim Moody 2019-06-02 10:55:15 -04:00
parent 61910b5e06
commit 49871b37ab
11 changed files with 165 additions and 0 deletions

View file

@ -0,0 +1,9 @@
================
Bluetooth README
================
This role provides two services, pan or Personal Area Network, and term, terminal emulation.
They may be turned on or off with iiab-bt-pan-on(off) and iiab-bt-term-on(off), respectively.
The role is only available for the Raspberry Pi.

View file

@ -0,0 +1,3 @@
bluetooth_install: False
bluetooth_enabled: False
bluetooth_term_enabled: False

View file

@ -0,0 +1,4 @@
# This is rpi only
- include_tasks: rpi_bluetooth_install.yml
when: is_rpi | bool

View file

@ -0,0 +1,93 @@
# 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' }
- { 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' }
- { 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' }
# 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 }}"

View file

@ -0,0 +1,10 @@
[Unit]
Description=Bluetooth Auth Agent
[Service]
ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
Type=simple
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,11 @@
[Unit]
Description=Bluetooth NEP PAN
After=br0.network
[Service]
ExecStart=/usr/bin/bt-network -s nap br0
Type=simple
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,13 @@
[Unit]
Description=RFCOMM service
After=bluetooth.service
Requires=bluetooth.service
[Service]
Type=oneshot
ExecStart=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 piscan
ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,7 @@
#!/bin/bash
systemctl disable bt-agent
systemctl stop bt-agent
systemctl disable bt-pan
systemctl stop bt-pan

View file

@ -0,0 +1,7 @@
#!/bin/bash
systemctl enable bt-agent
systemctl start bt-agent
systemctl enable bt-pan
systemctl start bt-pan

View file

@ -0,0 +1,4 @@
#!/bin/bash
systemctl disable bt-term
systemctl stop bt-term

View file

@ -0,0 +1,4 @@
#!/bin/bash
systemctl enable bt-term
systemctl start bt-term