-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ temp.py for testing; adjust read/peek overloads
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import time, struct | ||
import RF24 as pyRF24 | ||
import RF24Network as pyRF24Network | ||
|
||
this_node = [ | ||
int( | ||
input("What is this node's logical address? ") or 0, | ||
8 | ||
) | ||
] | ||
|
||
other_node = [ | ||
int( | ||
input("What is the target node's logical address? ") or 1, | ||
8 | ||
) | ||
] | ||
|
||
radio = pyRF24.RF24(22, 0) | ||
if not radio.begin(): | ||
print("radio mot respoding") | ||
|
||
network = pyRF24Network.RF24Network(radio) | ||
network.begin(90, this_node[0]) | ||
|
||
head_out = pyRF24Network.RF24NetworkHeader(other_node[0], 0) | ||
head_in = pyRF24Network.RF24NetworkHeader() | ||
|
||
def master(count=1, interval=1): | ||
for _ in range(count): | ||
msg = bytes(range(count)) # using dynamic payload sizes | ||
count -= 1 | ||
print("message", msg, end=" ") | ||
if network.write(head_out, msg): | ||
print("sent successfully") | ||
else: | ||
print("failed to transmit") | ||
|
||
def slave(timeout=10): | ||
end_timer = time.monotonic() + timeout | ||
while time.monotonic() <= end_timer: | ||
# let SERIAL_DEBUG output do the printing to stdout | ||
network.update() | ||
# let dev do post-reception work in REPL (using `head_in`) | ||
|
||
def print_details(): | ||
radio.printPrettyDetails() | ||
print("node address\t:", oct(this_node[0])) | ||
|
||
print("""\n | ||
testing script for RF24Network python wrapper\n\n | ||
run `master(<msg_count>)` to transmit\n | ||
run `slave(<timeout_seconds>)` to receive""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters