Skip to content

Commit

Permalink
port changes to RF24Mesh.check_connection()
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jun 17, 2024
1 parent c6c5569 commit a573fdf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions circuitpython_nrf24l01/rf24_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ def _lookup_2_master(self, number: int, lookup_type: int) -> int:
return struct.unpack("<H", self.frame_buf.message[:2])[0]
return self.frame_buf.message[0]

def check_connection(self) -> bool:
def check_connection(self, attempts: int = 3) -> bool:
"""Check for network connectivity (not for use on master node)."""
# do a double check as a manual retry in lack of using auto-ack
if self.lookup_address(self._id) < 1:
if self.lookup_address(self._id) < 1:
for _ in range(attempts):
result = self.lookup_address(self._id)
if result in (-2, 0):

Check warning on line 169 in circuitpython_nrf24l01/rf24_mesh.py

View check run for this annotation

Codecov / codecov/patch

circuitpython_nrf24l01/rf24_mesh.py#L167-L169

Added lines #L167 - L169 were not covered by tests
return False
return True
if result == self.node_address:
return True
return False

Check warning on line 173 in circuitpython_nrf24l01/rf24_mesh.py

View check run for this annotation

Codecov / codecov/patch

circuitpython_nrf24l01/rf24_mesh.py#L171-L173

Added lines #L171 - L173 were not covered by tests

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

0 comments on commit a573fdf

Please sign in to comment.