From 1851ff4840b644cae5b438e084ccfe8318252172 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sat, 18 Jun 2022 02:30:08 -0700 Subject: [PATCH] update python examples per testing --- examples_RPi/RF24Mesh_Example.py | 12 ++++++------ examples_RPi/RF24Mesh_Example_Master.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples_RPi/RF24Mesh_Example.py b/examples_RPi/RF24Mesh_Example.py index b628b838..cf697d3e 100755 --- a/examples_RPi/RF24Mesh_Example.py +++ b/examples_RPi/RF24Mesh_Example.py @@ -4,7 +4,7 @@ import sys import time import struct -from RF24 import RF24, RF24_PA_MAX +from RF24 import RF24 from RF24Network import RF24Network from RF24Mesh import RF24Mesh @@ -25,7 +25,7 @@ def millis(): mesh.setNodeID(4) print("starting nodeID", mesh.getNodeID()) if not mesh.begin(): - if not radio.isChipConnected(): + if radio.isChipConnected(): try: print("Could not connect to network.\nConnecting to mesh...") while mesh.renewAddress() == 0o4444: @@ -35,7 +35,6 @@ def millis(): sys.exit() else: raise OSError("Radio hardware not responding or could not connect to mesh.") -radio.setPALevel(RF24_PA_MAX) # Power Amplifier radio.printDetails() TIMER = 0 @@ -51,9 +50,9 @@ def millis(): if not mesh.write(struct.pack("L", TIMER), ord("M")): # If a write fails, check connectivity to the mesh network if not mesh.checkConnection(): - # The address could be refreshed per a specified timeframe + # The address could be refreshed per a specified time frame # or only when sequential writes fail, etc. - print("Renewing Address...") + print("Send fail. Renewing Address...") while mesh.renewAddress() == 0o4444: print("Renewing Address...") else: @@ -62,4 +61,5 @@ def millis(): print("Send OK:", TIMER) time.sleep(0.001) # delay 1 ms except KeyboardInterrupt: - radio.powerDown() # power radio down before exiting + print("powering down radio and exiting.") + radio.powerDown() diff --git a/examples_RPi/RF24Mesh_Example_Master.py b/examples_RPi/RF24Mesh_Example_Master.py index ef70dddd..9164771b 100755 --- a/examples_RPi/RF24Mesh_Example_Master.py +++ b/examples_RPi/RF24Mesh_Example_Master.py @@ -3,7 +3,7 @@ a Mesh network master node. """ import struct -from RF24 import RF24, RF24_PA_MAX +from RF24 import RF24 from RF24Network import RF24Network from RF24Mesh import RF24Mesh @@ -17,7 +17,6 @@ # if mesh.begin() returns false for a master node, # then radio.begin() returned false. raise OSError("Radio hardware not responding.") -radio.setPALevel(RF24_PA_MAX) # Power Amplifier radio.printDetails() try: @@ -29,4 +28,5 @@ header, payload = network.read(struct.calcsize("L")) print(f"Received message {header.toString()}") except KeyboardInterrupt: - radio.powerDown() # power radio down before exiting + print("powering down radio and exiting.") + radio.powerDown()