I have a python app that waits for messages to be send over ble. It works to recieve messages but while it's not recieving the app freezes and goes back to normal when it detects a new message. Anyone know what can cause this?
This is the start of bluetooth:
def startBT():
server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]
uuid = "a8d52687-55bb-4b1b-b8f5-a1b17cdb0e59"
advertise_service( server_sock, "SampleServer",
service_id = uuid,
service_classes = [ uuid, SERIAL_PORT_CLASS ],
profiles = [ SERIAL_PORT_PROFILE ],
# protocols = [ OBEX_UUID ]
)
print("Waiting for connection on RFCOMM channel %d" % port)
global client_sock
client_sock, client_info = server_sock.accept()
global isConnected
isConnected = "true"
print("Accepted connection from ", client_info)
receiveMSG()
loadData()
This here is the recieving part of messages:
def receiveMSG():
if isConnected == "true":
GLineEdit_692["state"] = "normal"
print("it be working")
ready = select.select([client_sock], [], [], 1)
if ready[0]:
data = client_sock.recv(1024)
message = "%s" % data
message = message.replace("b", "")
message = message.replace("'", "")
print(message)
if("Stop" in message):
GLineEdit_692.insert(tk.END, "Kart #" + message.replace("Stop", "") + " has been stopped.\n")
elif("Res" in message):
GLineEdit_692.insert(tk.END, "Kart #" + message.replace("Res", "") + " has been resumed.\n")
elif("Pen" in message):
messagelist = message.split()
GLineEdit_692.insert(tk.END, "Kart #" + messagelist[0].replace("Pen", "") + " has been given a penalty of " + messagelist[1] + " seconds.\n")
GLineEdit_692["state"] = "disabled"
root.after(2000, receiveMSG)