Fixed faulty FOR loops with device removal
@@ -965,6 +965,8 @@ class Iotivity():
self.lib.py_otm_just_works.argtypes = [String]
self.lib.py_otm_just_works.restype = None
+ onboarded_devices = []
+
for device in self.unowned_devices:
device_name = self.get_device_name(device)
print ("Onboarding device :", device, device_name)
@@ -989,17 +991,26 @@ class Iotivity():
print (f"Onboarding succeeded for: {device} {device_name}")
print (f"Time taken: {time_taken:.3} seconds")
- self.unowned_devices.remove(device)
+ onboarded_devices.append(device)
else:
print (f"Onboarding failed for: {device} {device_name}")
time.sleep(1)
+ for device in onboarded_devices:
+ self.unowned_devices.remove(device)
+
print ("...done.")
def onboard_cloud_proxy(self):
print ("onboard_cloud_proxy: listing NOT onboarded devices in C:")
self.list_unowned_devices()
+ print ("onboarding...")
+ self.lib.py_otm_just_works.argtypes = [String]
+ self.lib.py_otm_just_works.restype = None
+
+ onboarded_devices = []
+
for device in self.unowned_devices:
device_name = self.get_device_name(device)
@@ -1026,11 +1037,14 @@ class Iotivity():
print (f"Onboarding succeeded for: {device} {device_name}")
print (f"Time taken: {time_taken:.3} seconds")
- self.unowned_devices.remove(device)
+ onboarded_devices.append(device)
else:
print (f"Onboarding failed for: {device} {device_name}")
time.sleep(1)
+ for device in onboarded_devices:
+ self.unowned_devices.remove(device)
+
print ("...done.")
def onboard_chili(self):
@@ -1041,6 +1055,8 @@ class Iotivity():
self.lib.py_otm_just_works.argtypes = [String]
self.lib.py_otm_just_works.restype = None
+ onboarded_devices = []
+
for device in self.unowned_devices:
device_name = self.get_device_name(device)
@@ -1067,11 +1083,14 @@ class Iotivity():
print (f"Onboarding succeeded for: {device} {device_name}")
print (f"Time taken: {time_taken:.3} seconds")
- self.unowned_devices.remove(device)
+ onboarded_devices.append(device)
else:
print (f"Onboarding failed for: {device} {device_name}")
time.sleep(1)
+ for device in onboarded_devices:
+ self.unowned_devices.remove(device)
+
print ("...done.")
@@ -1129,6 +1148,8 @@ class Iotivity():
self.lib.py_reset_device.argtypes = [String]
self.lib.py_reset_device.restype = None
+ offboarded_devices = []
+
for device in self.owned_devices:
device_name = self.get_device_name(device)
@@ -1154,10 +1175,14 @@ class Iotivity():
print (f"Offboarding succeeded for: {device} {device_name}")
print (f"Time taken: {time_taken:.3} seconds")
- self.owned_devices.remove(device)
+ offboarded_devices.append(device)
else:
print (f"Offboarding failed for: {device} {device_name}")
time.sleep(1)
+
+ for device in offboarded_devices:
+ self.owned_devices.remove(device)
+
print ("...done.")
