Skip to content

Commit 6a356e8

Browse files
author
Rudolfs Osins
committed
Add remove_all_devices method
1 parent c2ee9f8 commit 6a356e8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gatt/gatt_linux.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,24 @@ def remove_device(self, mac_address):
209209
# TODO: Implement
210210
pass
211211

212+
def remove_all_devices(self, skip_alias=None):
213+
self.update_devices()
214+
215+
keys_to_be_deleted = []
216+
for key, device in self._devices.items():
217+
if skip_alias and device.alias() == skip_alias:
218+
continue
219+
mac_address = device.mac_address.replace(':', '_').upper()
220+
path = '/org/bluez/%s/dev_%s' % (self.adapter_name, mac_address)
221+
self._adapter.RemoveDevice(path)
222+
keys_to_be_deleted.append(key)
223+
224+
for key in keys_to_be_deleted:
225+
del self._devices[key]
226+
227+
self.update_devices()
228+
229+
212230

213231
class Device:
214232
def __init__(self, mac_address, manager, managed=True):

0 commit comments

Comments
 (0)