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

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

@@ -83,14 +83,23 @@ if __name__ == "__main__":
83 83
         if device == None:
84 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 104
     import sys
96 105
 

Loading…
Cancel
Save