Skip to content

Commit a573fdf

Browse files
committed
port changes to RF24Mesh.check_connection()
per nRF24/RF24Mesh#240
1 parent c6c5569 commit a573fdf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

circuitpython_nrf24l01/rf24_mesh.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,15 @@ def _lookup_2_master(self, number: int, lookup_type: int) -> int:
162162
return struct.unpack("<H", self.frame_buf.message[:2])[0]
163163
return self.frame_buf.message[0]
164164

165-
def check_connection(self) -> bool:
165+
def check_connection(self, attempts: int = 3) -> bool:
166166
"""Check for network connectivity (not for use on master node)."""
167-
# do a double check as a manual retry in lack of using auto-ack
168-
if self.lookup_address(self._id) < 1:
169-
if self.lookup_address(self._id) < 1:
167+
for _ in range(attempts):
168+
result = self.lookup_address(self._id)
169+
if result in (-2, 0):
170170
return False
171-
return True
171+
if result == self.node_address:
172+
return True
173+
return False
172174

173175
def update(self) -> int:
174176
"""Checks for incoming network data and returns last message type (if any)"""

0 commit comments

Comments
 (0)