From 7f75d32b581a467762b730a197e89a019818f1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9?= Date: Mon, 11 Jun 2018 11:54:23 +0200 Subject: [PATCH] Add Compatibility between python 2 and 3 Fixed bug if no BT adaptator is found. Made the code compatible between python 2 and 3. --- PutOnBoom.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PutOnBoom.py b/PutOnBoom.py index 56578a9..30fe199 100644 --- a/PutOnBoom.py +++ b/PutOnBoom.py @@ -3,27 +3,28 @@ #-------------------->YOUR_BOOM_MAC -----------------------------> YOUR_BTMAC(no ":")+01 # gatttool -i hci0 -b XX:XX:XX:XX:XX:XX --char-write-req -a 0x0003 -n XXXXXXXXXXXX01 # This command was found by Mathieu Tournier by reverse engineering BOOM2 bluetooth ATT traffic - +from __future__ import print_function +from builtins import input import subprocess import re -print("Please Write BOOM MAC Adress :") +print("Bluetooth devices : \n") commandRet = subprocess.check_output(['hciconfig']) print(commandRet) +## Get bluetooth adapter address (BD Adress). matches = re.findall("([0-9A-F]{2}:[0-9A-F]{2}:[0-9a-fA-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2})", commandRet) -btAdress = matches[0].translate(None,':') if (matches) : + btAdress = matches[0].translate(None,':') print ('using ' + matches[0] + ' as BT Adress adaptor') - boomAddr = raw_input("BOOM Mac Adress ?") + boomAddr = input("Please Write BOOM MAC Adress :\n") boomAddr = re.findall("([0-9A-F]{2}:[0-9A-F]{2}:[0-9a-fA-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2})", boomAddr) if (boomAddr) : commandRet = subprocess.check_output(['gatttool', '-i', 'hci0', '-b', str(boomAddr[0]), '--char-write-req', '-a', '0x0003', '-n', btAdress + '01']) else : print("Invalid Bt Adress") - else : - print("No Adaptator Found") + print("No BT Adaptator Found")