diff --git a/software/hardware_interface.py b/software/hardware_interface.py index 1a09b2a242b4544c05f8c3429d85da6606fbc59a..495e2a33a239f2be4c9efd773db5fc289c82e4f7 100644 --- a/software/hardware_interface.py +++ b/software/hardware_interface.py @@ -42,16 +42,20 @@ class Hardware_interface: self.client_socket, self.client_info = self.server_socket.accept() print("Accepted connection from", self.client_info) - def send_data(self): - self.client_socket.send("Envio desde la PC") + #Send data using bluetooth interface + def send_data(self, data): + self.client_socket.send(data) + #Get data from Bluetooth. Returns a tuple (Bool, CharArray). Boolean = True means data was received def get_data(self): try: - while True: - data = self.client_socket.recv(1024) - print(data) - if not data: - break - print("Received", data) + data = None + dataAvaialble = True + self.client_socket.settimeout(100) + data = self.client_socket.recv(1024) + print(data) + if not data: + dataAvaialble = False except OSError: - pass \ No newline at end of file + return 0, data + return 1, data \ No newline at end of file diff --git a/software/smartwatch.py b/software/smartwatch.py index 1b64e04b2b7642b3d9c6d04ad6f804b79345ae70..8fe50a33dfc9624d1dd940055d5045765deff74a 100644 --- a/software/smartwatch.py +++ b/software/smartwatch.py @@ -28,16 +28,24 @@ def refreshUI(guiRef, model, guiQueue): model.count += 1 guiRef.entry["state"] = 'normal' guiRef.entry.delete(0,"end") - guiRef.entry.insert(0,"12") + guiRef.entry.insert(0,"Valor") guiRef.entry["state"] = 'disabled' + + btInterface.send_data("Alarma HR") - guiRef.entry_two.delete(0,"end") - guiRef.entry_two.insert(0,"Prueba") + #guiRef.entry_two.delete(0,"end") + #guiRef.entry_two.insert(0,"Prueba") except queue.Empty: pass #Other tasks... - #print("Han pasado 500 milisegundos") + print("Han pasado 500 milisegundos") + dataAvailable, data = btInterface.get_data() + + if(dataAvailable == True): + guiRef.entry_two.delete(0,"end") + guiRef.entry_two.insert(0, data) + #Class for the User Interface @@ -169,7 +177,7 @@ if __name__ == '__main__': btInterface.print_device_list() btInterface.start_server() - btInterface.send_data() + btInterface.send_data("Prueba 2") btInterface.get_data() #Thread used to separate the use interface with the front end. It is used to not slow down the GUI when processing information @@ -178,4 +186,4 @@ if __name__ == '__main__': t.start() #Uncomment to show the GUI - #app.mainloop() + app.mainloop()