Thomas Buck 1 year ago
parent
commit
4c36bca1c5
2 changed files with 24 additions and 10 deletions
  1. 7
    2
      python-test/flow.py
  2. 17
    8
      python-test/poll.py

+ 7
- 2
python-test/flow.py View File

79
 
79
 
80
 if __name__ == "__main__":
80
 if __name__ == "__main__":
81
     def main(address):
81
     def main(address):
82
-        device = ble_conn(address)
82
+        client = ble_conn(address)
83
 
83
 
84
         try:
84
         try:
85
             if get_unit_is_fahrenheit(client):
85
             if get_unit_is_fahrenheit(client):
90
         except:
90
         except:
91
             print("\nTurning heater off")
91
             print("\nTurning heater off")
92
             set_state(client, (False, False)) # turn off heater and pump
92
             set_state(client, (False, False)) # turn off heater and pump
93
+
94
+            print("Disconnecting")
95
+            client.disconnect()
96
+
93
             raise
97
             raise
94
 
98
 
95
-        print("Disconnecting...")
99
+        print("Disconnecting")
100
+        client.disconnect()
96
 
101
 
97
     arg = None
102
     arg = None
98
     if len(sys.argv) > 1:
103
     if len(sys.argv) > 1:

+ 17
- 8
python-test/poll.py View File

83
         if device == None:
83
         if device == None:
84
             return
84
             return
85
 
85
 
86
-        print("Writing...")
87
-        set_target_temp(device, 190.0)
88
-
89
-        print("Reading...")
90
-        for i in range(0, 5):
91
-            test_poll(device)
92
-            print()
93
-            time.sleep(2.0)
86
+        try:
87
+            print("Writing...")
88
+            set_target_temp(device, 190.0)
89
+
90
+            print("Reading...")
91
+            for i in range(0, 5):
92
+                test_poll(device)
93
+                print()
94
+                time.sleep(2.0)
95
+        except:
96
+            print("Disconnecting")
97
+            client.disconnect()
98
+
99
+            raise
100
+
101
+        print("Disconnecting")
102
+        client.disconnect()
94
 
103
 
95
     import sys
104
     import sys
96
 
105
 

Loading…
Cancel
Save