-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathecho.py
More file actions
98 lines (66 loc) · 2.96 KB
/
echo.py
File metadata and controls
98 lines (66 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from pycubed import cubesat
import time
yagiMode = True
#testMsg = "According to all known laws of aviation, there is no way a bee should be able to fly."
#testMsg = "Its over Anakin I have the high ground!"
#testMsg = "I have brought peace, freedom, justice, and security to my new empire. Your new empire!?"
#testMsg = "Hello There!"
testMsg = "ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"
cubesat.radio1.spreading_factor=8
cubesat.radio1.tx_power=13
cubesat.radio1.low_datarate_optimize=False
cubesat.radio1.node=0xfb
cubesat.radio1.destination=0xfa
cubesat.radio1.receive_timeout=15
cubesat.radio1.enable_crc=False
if cubesat.radio1.spreading_factor>8:
cubesat.radio1.low_datarate_optimize=True
def yagiSide():
print("Listening for transmissions, 5s")
heard_something = cubesat.radio1.await_rx(timeout=10)
if heard_something:
response = cubesat.radio1.receive(keep_listening=True)
if response is not None:
print("packet received")
print('msg: {}, RSSI: {}'.format(response,cubesat.radio1.last_rssi-137))
cubesat.radio1.send('Echo:{}'.format(cubesat.radio1.last_rssi-137))
print("Echo sent")
time.sleep(1)
time.sleep(2)
def cop_yagiSide():
print("Listening for transmissions, 5s")
heard_something = cubesat.radio1.await_rx(timeout=10)
if heard_something:
response = cubesat.radio1.receive(keep_listening=True)
if response is not None:
print("packet received")
print('msg: {}, RSSI: {}'.format(response,cubesat.radio1.last_rssi-137))
cubesat.radio1.send('Echo:{}'.format(cubesat.radio1.last_rssi-137))
print("Echo sent")
time.sleep(1)
time.sleep(2)
def fieldSide():
print("Sending test message:")
cubesat.radio1.send(testMsg + " SF: " + str(cubesat.radio1.spreading_factor), keep_listening=True)
print("Listening for transmissions, 5s")
heard_something = cubesat.radio1.await_rx(timeout=2)
if heard_something:
response = cubesat.radio1.receive(keep_listening=True)
if response is not None:
print("packet received")
print('msg: {}, RSSI: {}'.format(response,cubesat.radio1.last_rssi-137))
time.sleep(2)
def banger():
print("Banging away")
cubesat.radio1.send(testMsg + " SF: " + str(cubesat.radio1.spreading_factor))
response = cubesat.radio1.receive(keep_listening=True)
if response is not None:
print("packet received")
print('msg: {}, RSSI: {}'.format(response,cubesat.radio1.last_rssi-137))
time.sleep(2)
while True:
#banger()
if yagiMode:
yagiSide()
else:
fieldSide()