← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorEdvin <[email protected]>2025-04-09 15:40:25 +0200
committerEdvin <[email protected]>2025-04-09 15:40:25 +0200
commit1a837cbe411b4522582d323454a03ef02e9dd292 (patch)
treeeaa25999305acf4198cf2825149a4fb3d8943c60 /main.py
parentf52ccfbd1644d3059e67c6e04a91b2c275b307f8 (diff)
Functional two-way communication
Diffstat (limited to 'main.py')
-rw-r--r--main.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/main.py b/main.py
index 3f07b8a..b22dc6c 100644
--- a/main.py
+++ b/main.py
@@ -32,18 +32,15 @@ recv_sock, client_info = server_sock.accept()
print("Connected to %s." % client_info[0])
-send_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
-send_sock.connect((client_info[0], 2))
+read = "0"
-print("Created sending socket to %s" % client_info[0])
-
-while read != "a":
+while read != "1000":
read = recv_sock.recv(1024)
read = read.decode("utf-8").strip('\n')
print("Received: %s" % read)
- send_sock.send("Acknowledge: " + read)
- print("Sent acknowledge")
+ print(f"Sending: 'Acknowledge: {read}'")
+ client_sock.send(f"Acknowledge: {read}\n".encode()) # Remember NEW LINE for ÖS to be able to read lines.
if read == "0": # Do nothing
GPIO.output(P1, False)