[Tuto] [obsolète]Connecter vos manettes bluetooth au démarrage du rpi
-
Bonjour à tous, il est possible de faire connecter vos manettes bluetooth au démarrage de votre rpi. Source : Open-Console - Retrogaming rpi - Merci SpikeSpiegel. Il y a deux méthodes pour connecter votre manette bluetooth à votre rpi
hidd --connect xx:xx:xx:xx:xx
bluez-test-input connect xx:xx:xx:xx:xx
Ma manette est une snakebyte idroid:con , elle se connecte uniquement avec la commande hidd. Trouver les adresses mac de vos manettes : Sortir d'emultationstation - touche clavier F4 ALT+F2
Login : root password login : recalboxroot
Taper dans le terminal :
hcitool scan
Le résultat vous donne :
aa:bb:cc:ee:dd:ff idroid xx:xx:xx:xx:xx:xx idroid xx:xx:xx:xx:xx:xx keyboard
Placer le fichier btDaemon.sh dans le dossier /recalbox/scripts/ Remplacer les valeurs BT1 et BT2 par les adresses mac que vous avez obtenu dans le terminal ou via putty Ou le télécharger : https://app.box.com/s/xm4wfpf0dyoezlz5a2hh8p9f6cjdimip btDaemon.sh - Respecter le nom des fichiers
#!/bin/bash #REMPLACER BT1 ET BT2 PAR VOS ADRESSES MAC #hcitool scan #Joystick 1 BT1='20:73:AB:01:98:76' #Joystick 2 - supprimer le caractère # pour activer BT2 #BT2='20:73:AB:01:16:3E' BT1_STATUS='unknown' BT2_STATUS='unknown' #initialize VERBOSE=0 NO_LOG=0 COUNT_LINES_LOGGER=0 MAX_LINES_LOGGER=100 DELAI=10 LOGGER_FILE=/var/log/btDaemonLogger.log [ "$1" = '-v' ] && VERBOSE=1 #END initialize #functions logger() { #no logger [ $NO_LOG -eq 1 ] && return [[ $2 -eq 1 ]] && COUNT_LINES_LOGGER=0 COUNT_LINES_LOGGER=$(($COUNT_LINES_LOGGER + 1)) now=$(date +"%m-%d-%y %r") if [ $VERBOSE -eq 1 ]; then echo "[$now]" $1 fi if [[ $2 -eq 1 ]]; then #RESET Logger File echo "[$now]" $1 > $LOGGER_FILE else echo "[$now]" $1 >> $LOGGER_FILE fi } auto_connect() { local index=$1 local bt=$2 [ ! -s /tmp/btcheck ] && [ $(ls /dev/input/js0 2> /dev/null) ] && logger "USB device js0 is already connected" && return if [ ! -z "$bt" ]; then if grep -q $bt /tmp/btcheck; then logger "[OK] bluetooth device $index [$bt] is already connected" else logger "[KO] bluetooth device $index [$bt] not connected" connect $index $bt fi else logger "no configuration found for bluetooth device $index (check mac address)" fi } connect() { local index=$1 local bt=$2 local btStatus='notconnected' local tryPing=1 local tryCon=1 local maxRetry=1 #priority to gamepad 1 #[ $index -eq 0 ] && maxRetry=10 logger "try connecting bluetooth device $index [$bt] maxRetry=$maxRetry..." #10 attempts for connecting device while [ $tryPing -le $maxRetry ]; do l2ping $bt -c 3 > /dev/null 2>&1 RESPING=$? if [ $RESPING = 0 ]; then logger "[OK][$RESPING] ping bluetooth device $index [$bt]" tryCon=1 while [ $tryCon -le $maxRetry ]; do hidd --connect $bt &> /dev/null RESCON=$? if [ $RESCON = 0 ]; then #logger "[OK][$RESCON] bluetooth device $index [$bt] connected" btStatus='connected' #xd_init $index $bt else logger "[KO][$RESCON][$tryCon] bluetooth device $index [$bt] connected" btStatus='notconnected' fi [ $btStatus = 'connected' ] && break tryCon=$(($tryCon + 1)) done else logger "[KO][$RESPING][$tryPing] ping bluetooth device $index [$bt]" btStatus='noping' fi [ $btStatus = 'connected' ] && break tryPing=$(($tryPing + 1)) done [ $index -eq 0 ] && BT1_STATUS=$btStatus && logger "bluetooth device $index [$bt] [$BT1_STATUS]" [ $index -eq 1 ] && BT2_STATUS=$btStatus && logger "bluetooth device $index [$bt] [$BT2_STATUS]" } #END functions #MAIN logger "[START] bluetooth devices monitoring..." 1 while [ 1 ]; do #COUNT_LINES_LOGGER=$(wc -l $LOGGER_FILE | cut -f1 -d" ") if [ $COUNT_LINES_LOGGER -gt $MAX_LINES_LOGGER ]; then #RESET Logger logger "--- bluetooth devices check connections [delai=$DELAI] ---" 1 else logger "--- bluetooth devices check connections [delai=$DELAI] ---" fi #check bluetooth devices status hcitool con|grep -v "^Connections:" > /tmp/btcheck auto_connect 0 $BT1 auto_connect 1 $BT2 logger "------------------------------------------------------" sleep $DELAI done logger "[STOP] bluetooth devices monitoring." #END MAIN exit 0
Attribuer les droits d’exécution au fichier btDaemon.sh
chmod +X /recalbox/scripts/btDaemon.sh
Placer le fichier S92btService dans le dossier suivant /etc/init.d/ Téléchargeable via : https://app.box.com/S92btservice Donner les droits d’exécutionchmod +X /etc/init.d/S92btService
Redémarrer votre rpi - allumer vos manettes. Après quelques secondes , vos manettes devraient se connecter toutes seules . Démarrer le service :/etc/init.d/S92btService start
Arrêter le service :/etc/init.d/S92btService stop
Status du service :(A noter que chez moi , le status ne s'affiche pas)/etc/init.d/S92btService status
En cas de soucis consulter le rapport :tail /var/log/btDaemonLogger.log
Pour les manettes ne connectant avec bluez Télécharger ce fichier : https://app.box.com/s/u10nvaxu9zt2zcqzaimpcp9la7xg61rt ou Utiliser ce script via copier/coller :#!/bin/bash #REMPLACER BT1 ET BT2 PAR VOS ADRESSES MAC #hcitool scan #Joystick 1 BT1='20:73:AB:01:98:76' #Joystick 2 supprimer le caractère # pour activer BT2 #BT2='20:73:AB:01:16:3E' BT1_STATUS='unknown' BT2_STATUS='unknown' #initialize VERBOSE=0 NO_LOG=0 COUNT_LINES_LOGGER=0 MAX_LINES_LOGGER=100 DELAI=10 LOGGER_FILE=/var/log/btDaemonLogger.log [ "$1" = '-v' ] && VERBOSE=1 #END initialize #functions logger() { #no logger [ $NO_LOG -eq 1 ] && return [[ $2 -eq 1 ]] && COUNT_LINES_LOGGER=0 COUNT_LINES_LOGGER=$(($COUNT_LINES_LOGGER + 1)) now=$(date +"%m-%d-%y %r") if [ $VERBOSE -eq 1 ]; then echo "[$now]" $1 fi if [[ $2 -eq 1 ]]; then #RESET Logger File echo "[$now]" $1 > $LOGGER_FILE else echo "[$now]" $1 >> $LOGGER_FILE fi } auto_connect() { local index=$1 local bt=$2 [ ! -s /tmp/btcheck ] && [ $(ls /dev/input/js0 2> /dev/null) ] && logger "USB device js0 is already connected" && return if [ ! -z "$bt" ]; then if grep -q $bt /tmp/btcheck; then logger "[OK] bluetooth device $index [$bt] is already connected" else logger "[KO] bluetooth device $index [$bt] not connected" connect $index $bt fi else logger "no configuration found for bluetooth device $index (check mac address)" fi } connect() { local index=$1 local bt=$2 local btStatus='notconnected' local tryPing=1 local tryCon=1 local maxRetry=1 #priority to gamepad 1 #[ $index -eq 0 ] && maxRetry=10 logger "try connecting bluetooth device $index [$bt] maxRetry=$maxRetry..." #10 attempts for connecting device while [ $tryPing -le $maxRetry ]; do l2ping $bt -c 3 > /dev/null 2>&1 RESPING=$? if [ $RESPING = 0 ]; then logger "[OK][$RESPING] ping bluetooth device $index [$bt]" tryCon=1 while [ $tryCon -le $maxRetry ]; do bluez-test-input connect $bt &> /dev/null RESCON=$? if [ $RESCON = 0 ]; then #logger "[OK][$RESCON] bluetooth device $index [$bt] connected" btStatus='connected' #xd_init $index $bt else logger "[KO][$RESCON][$tryCon] bluetooth device $index [$bt] connected" btStatus='notconnected' fi [ $btStatus = 'connected' ] && break tryCon=$(($tryCon + 1)) done else logger "[KO][$RESPING][$tryPing] ping bluetooth device $index [$bt]" btStatus='noping' fi [ $btStatus = 'connected' ] && break tryPing=$(($tryPing + 1)) done [ $index -eq 0 ] && BT1_STATUS=$btStatus && logger "bluetooth device $index [$bt] [$BT1_STATUS]" [ $index -eq 1 ] && BT2_STATUS=$btStatus && logger "bluetooth device $index [$bt] [$BT2_STATUS]" } #END functions #MAIN logger "[START] bluetooth devices monitoring..." 1 while [ 1 ]; do #COUNT_LINES_LOGGER=$(wc -l $LOGGER_FILE | cut -f1 -d" ") if [ $COUNT_LINES_LOGGER -gt $MAX_LINES_LOGGER ]; then #RESET Logger logger "--- bluetooth devices check connections [delai=$DELAI] ---" 1 else logger "--- bluetooth devices check connections [delai=$DELAI] ---" fi #check bluetooth devices status hcitool con|grep -v "^Connections:" > /tmp/btcheck auto_connect 0 $BT1 auto_connect 1 $BT2 logger "------------------------------------------------------" sleep $DELAI done logger "[STOP] bluetooth devices monitoring." #END MAIN exit 0
-
@acris Bonjour, cette astuce fonctionne toujours sur recalbox 4.0.2 ? Ou une autre méthode existe depuis ?
-
Bonjour
le bluetooth est géré nativement maintenant dans recalbox 4.0.2 et 4.1 pour le bluetooth interne du rpi3ce tutoriel est complètement obsolète. Merci d'eviter de remonter des sujets vieux de 2 ans