Skip to content

Commit db364b7

Browse files
authored
Merge pull request #7 from Association-INTech/bluetooth
Bluetooth
2 parents 6ed24a7 + 5ca0f44 commit db364b7

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C4:5D:FD:05:06:07 #adresse mac de la manette ps4
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Vérifie que bluetoothctl est dispo
4+
if ! command -v bluetoothctl &>/dev/null; then
5+
echo "Erreur : bluetoothctl n'est pas installé."
6+
exit 2
7+
fi
8+
9+
# Lecture du fichier ligne par ligne
10+
while read -r line; do
11+
# Ignore les lignes vides ou commençant par #
12+
[[ -z "$line" || "$line" =~ ^# ]] && continue
13+
14+
# Récupère le premier mot (adresse MAC)
15+
mac=$(echo "$line" | awk '{print $1}')
16+
17+
echo "-----------------------------------------"
18+
echo " Traitement de l'appareil : $mac"
19+
echo "-----------------------------------------"
20+
21+
bluetoothctl remove "$mac"
22+
bluetoothctl -t 8 scan on &
23+
scan_pid=$!
24+
sleep 7
25+
kill "$scan_pid" 2>/dev/null
26+
27+
bluetoothctl pair "$mac"
28+
sleep 1
29+
bluetoothctl trust "$mac"
30+
sleep 1
31+
bluetoothctl connect "$mac"
32+
33+
echo
34+
done < ./bluethoot_mac.txt

0 commit comments

Comments
 (0)