From b9aede3de71f0516dd2a1d0cc6d21627db8fa6a8 Mon Sep 17 00:00:00 2001 From: Zhengyu Peng Date: Tue, 22 Feb 2022 17:10:26 -0500 Subject: [PATCH 1/4] get bluetooth MAC --- software/raspberry pi/btserver.py | 10 +++++++++- software/raspberry pi/hexapod.py | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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) From f19f55a4eb8bee7ff8202ef25b69b5714e14c2bc Mon Sep 17 00:00:00 2001 From: Zhengyu Peng Date: Tue, 22 Feb 2022 17:12:50 -0500 Subject: [PATCH 2/4] update --- software/raspberry pi/hexapod.py | 1 - 1 file changed, 1 deletion(-) diff --git a/software/raspberry pi/hexapod.py b/software/raspberry pi/hexapod.py index 8501489..56bc266 100644 --- a/software/raspberry pi/hexapod.py +++ b/software/raspberry pi/hexapod.py @@ -148,7 +148,6 @@ class Hexapod(Thread): self.standby() # self.laydown() - # self.leg_0.move_junctions([90,45,135]) time.sleep(1) # self.leg_0.set_angle(1, 30) From a7955e5ebfd97ff7da88a2e7b872fd6b4ea02ed4 Mon Sep 17 00:00:00 2001 From: Zhengyu Peng Date: Tue, 22 Feb 2022 17:14:03 -0500 Subject: [PATCH 3/4] update --- software/raspberry pi/hexapod.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/software/raspberry pi/hexapod.py b/software/raspberry pi/hexapod.py index 56bc266..dbc7ac3 100644 --- a/software/raspberry pi/hexapod.py +++ b/software/raspberry pi/hexapod.py @@ -49,8 +49,6 @@ from threading import Thread from tcpserver import TCPServer from btserver import BluetoothServer -import os - class Hexapod(Thread): @@ -380,13 +378,6 @@ 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) tcp_server.start() From b2b2d5b85f7c7fe9bf015fa3034d40afb0fa9ea0 Mon Sep 17 00:00:00 2001 From: Zhengyu Peng Date: Tue, 22 Feb 2022 17:15:47 -0500 Subject: [PATCH 4/4] start bt server --- software/raspberry pi/hexapod.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/software/raspberry pi/hexapod.py b/software/raspberry pi/hexapod.py index dbc7ac3..78d967c 100644 --- a/software/raspberry pi/hexapod.py +++ b/software/raspberry pi/hexapod.py @@ -381,6 +381,10 @@ def main(): q = Queue() tcp_server = TCPServer(q) tcp_server.start() + + bt_server = BluetoothServer(q) + bt_server.start() + hexapod = Hexapod(q) hexapod.start()