Skip to content

Commit 3450f8f

Browse files
authored
Merge pull request #215 from bitcraze/bugfix-powerswitch
Fix regression where power_switch does not work with Python backend
2 parents 69b25ca + 3876f9b commit 3450f8f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cflib/utils/power_switch.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ def __init__(self, uri):
3939
self.uri = uri
4040
uri_augmented = uri+'?safelink=0&autoping=0&ackfilter=0'
4141
self.link = cflib.crtp.get_link_driver(uri_augmented)
42-
# Switch to legacy mode, if uri options are not available
43-
if not self.link:
42+
# Switch to legacy mode, if uri options are not available or old Python backend is used
43+
if not self.link or self.link.get_name() == 'radio':
4444
uri_parts = cflib.crtp.RadioDriver.parse_uri(uri)
4545
self.devid = uri_parts[0]
4646
self.channel = uri_parts[1]
4747
self.datarate = uri_parts[2]
4848
self.address = uri_parts[3]
49+
if self.link:
50+
self.link.close()
51+
self.link = None
4952

5053
def platform_power_down(self):
5154
""" Power down the platform, both NRF and STM MCUs.

0 commit comments

Comments
 (0)