-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpingTest.py
More file actions
57 lines (46 loc) · 1.66 KB
/
pingTest.py
File metadata and controls
57 lines (46 loc) · 1.66 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
import board
import busio
import digitalio
import adafruit_rfm9x
RADIO_FREQ_MHZ = 915.0
groundStation = False;
CS = digitalio.DigitalInOut(board.D6)
RESET = digitalio.DigitalInOut(board.D5)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ)
if (groundStation):
print("Starting Ping Test as Ground Station")
while (True):
inputKey = input("Press a key to send a packet ")
if (inputKey == 'q'):
break
else:
rfm9x.send(bytes("Ping Test: Ground Station", 'utf-8'))
print("Sent Ground Station Ping!")
print()
packet = rfm9x.receive(timeout=5.0)
if packet is None:
pass
else:
print('Received (raw bytes): {0}'.format(packet))
packet_text = str(packet, 'ascii')
print('Received (ASCII): {0}'.format(packet_text))
rssi = rfm9x.rssi
print('Received signal strength: {0} dB'.format(rssi))
print()
else:
print("Starting Ping Test as Satellite")
while (True):
packet = rfm9x.receive()
if packet is None:
pass
else:
print('Received (raw bytes): {0}'.format(packet))
packet_text = str(packet, 'ascii')
print('Received (ASCII): {0}'.format(packet_text))
rssi = rfm9x.rssi
print('Received signal strength: {0} dB'.format(rssi))
print()
rfm9x.send(bytes("Ping Test: Ground Station", 'utf-8'))
print("Sent Ground Station Ping!")
print()