diff --git a/software/raspberry pi/btserver.py b/software/raspberry pi/btserver.py index 01d74cc..65e7641 100644 --- a/software/raspberry pi/btserver.py +++ b/software/raspberry pi/btserver.py @@ -28,6 +28,8 @@ import socket from threading import Thread import json +import os + class BluetoothServer(Thread): ERROR = -1 @@ -47,6 +49,12 @@ class BluetoothServer(Thread): with open('./config.json', 'r') as read_file: self.config = json.load(read_file) + stream = os.popen('hciconfig hci0') + output = stream.read() + device_id = "hci0" + bt_mac = output.split("{}:".format(device_id))[1].split( + "BD Address: ")[1].split(" ")[0].strip() + # import commands # cmd = "hciconfig" # device_id = "hci0" @@ -54,7 +62,7 @@ class BluetoothServer(Thread): # bt_mac = output.split("{}:".format(device_id))[1].split("BD Address: ")[1].split(" ")[0].strip() # print bt_mac - self.mac = '192.168.1.127' + self.mac = bt_mac self.port = 10 self.bt_socket = socket.socket( socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) diff --git a/software/raspberry pi/hexapod.py b/software/raspberry pi/hexapod.py index e928c6f..8501489 100644 --- a/software/raspberry pi/hexapod.py +++ b/software/raspberry pi/hexapod.py @@ -49,6 +49,8 @@ from threading import Thread from tcpserver import TCPServer from btserver import BluetoothServer +import os + class Hexapod(Thread): @@ -379,6 +381,12 @@ class Hexapod(Thread): def main(): + stream = os.popen('hciconfig hci0') + output = stream.read() + device_id = "hci0" + bt_mac = output.split("{}:".format(device_id))[1].split("BD Address: ")[1].split(" ")[0].strip() + + print(bt_mac) q = Queue() tcp_server = TCPServer(q)