-
Notifications
You must be signed in to change notification settings - Fork 86
/
config
executable file
·1483 lines (1144 loc) · 31 KB
/
config
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
function transmit_command_aprs {
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Stopping command and control"
sudo systemctl stop command
echo "Transmit DTMF start"
gpio write 28 0 # ptt
gpio write 2 1 # tx LED
timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-aprs.conf -t 0l
gpio write 2 0 # tx LED
gpio write 28 1 #ptt
echo "Transmit stop"
echo "Resuming command and control"
sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=a"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
echo $STRING > /home/pi/CubeSatSim/t.txt
echo
echo -n "Sending APRS packet to change mode to APRS "
echo $STRING
sudo touch /home/pi/CubeSatSim/ready
sleep 3
fi
exit
}
function transmit_command_fsk {
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Stopping command and control"
sudo systemctl stop command
echo "Transmit DTMF start"
gpio write 28 0 # ptt
gpio write 2 1 # tx LED
timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-fsk.conf -t 0l
gpio write 2 0 # tx LED
gpio write 28 1 #ptt
echo "Transmit stop"
echo "Resuming command and control"
sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
echo $STRING > /home/pi/CubeSatSim/t.txt
echo
echo -n "Sending APRS packet to change mode to FSK"
echo $STRING
sudo touch /home/pi/CubeSatSim/ready
sleep 3
fi
exit
}
function transmit_command_bpsk {
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Stopping command and control"
sudo systemctl stop command
echo "Transmit DTMF start"
gpio write 28 0 # ptt
gpio write 2 1 # tx LED
timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-bpsk.conf -t 0l
gpio write 2 0 # tx LED
gpio write 28 1 #ptt
echo "Transmit stop"
echo "Resuming command and control"
sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
echo $STRING > /home/pi/CubeSatSim/t.txt
echo
echo -n "Sending APRS packet to change mode to BPSK"
echo $STRING
sudo touch /home/pi/CubeSatSim/ready
sleep 3
fi
exit
}
function transmit_command_sstv {
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Stopping command and control"
sudo systemctl stop command
echo "Transmit DTMF start"
gpio write 28 0 # ptt
gpio write 2 1 # tx LED
timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-sstv.conf -t 0l
gpio write 2 0 # tx LED
gpio write 28 1 #ptt
echo "Transmit stop"
echo "Resuming command and control"
sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=s"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
echo $STRING > /home/pi/CubeSatSim/t.txt
echo
echo -n "Sending APRS packet to change mode to SSTV"
echo $STRING
sudo touch /home/pi/CubeSatSim/ready
sleep 3
fi
exit
}
function transmit_command_cw {
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Stopping command and control"
sudo systemctl stop command
echo "Transmit DTMF start"
gpio write 28 0 # ptt
gpio write 2 1 # tx LED
timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-cw.conf -t 0l
gpio write 2 0 # tx LED
gpio write 28 1 #ptt
echo "Transmit stop"
echo "Resuming command and control"
sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=m"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
echo $STRING > /home/pi/CubeSatSim/t.txt
echo
echo -n "Sending APRS packet to change mode to CW"
echo $STRING
sudo touch /home/pi/CubeSatSim/ready
sleep 3
fi
exit
}
function transmit_command_beacon {
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Stopping command and control"
sudo systemctl stop command
echo "Transmit DTMF start"
gpio write 28 0 # ptt
gpio write 2 1 # tx LED
timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-beacon.conf -t 0l
gpio write 2 0 # tx LED
gpio write 28 1 #ptt
echo "Transmit stop"
echo "Resuming command and control"
sudo systemctl start command
else
STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=o"
sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1
echo $STRING > /home/pi/CubeSatSim/t.txt
echo
echo -n "Sending APRS packet to toggle Beacon"
echo $STRING
sudo touch /home/pi/CubeSatSim/ready
sleep 3
fi
exit
}
echo "CubeSatSim v2.0 configuration tool"
echo
# echo $1
# echo $2
# echo
sudo modprobe snd-aloop
# if [ "$2" = "n" ] ; then
if [ -z "$2" ] ; then
noreboot=0
else
noreboot=1
echo "Reboot disabled"
fi
# echo "No reboot"
# echo $noreboot
reboot=0
restart=0
if [ "$1" = "" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" = "a" ]; then
echo "Mode is APRS"
elif [ "$1" = "m" ]; then
echo "Mode is CW"
elif [ "$1" = "f" ]; then
echo "Mode is FSK"
elif [ "$1" = "b" ]; then
echo "Mode is BPSK"
elif [ "$1" = "s" ]; then
echo "Mode is SSTV"
elif [ "$1" = "e" ]; then
echo "Mode is Repeater"
elif [ "$1" = "n" ]; then
echo -n "Mode is Transmit Commands with "
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo -n "DTMF"
else
echo -n "APRS"
fi
else
echo
fi
echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
if [ "$5" = "y" ] || [ "$5" = "yes" ] ; then
# sim="yes"
echo "Simulated Telemetry is ON"
else
# sim="no"
echo "Simulated Telemetry is OFF"
fi
echo
if [ "$9" = "yes" ] || [ "$9" = "y" ]; then
echo "Balloon mode is ON"
else
echo "Balloon mode is OFF"
fi
echo
echo -n "Current command count is: "
cat /home/pi/CubeSatSim/command_count.txt
echo
# echo
# echo "Current beacon transmit mode is:"
# cat /home/pi/CubeSatSim/command_tx
# echo
echo -n "Squelch level is: "
echo $6
echo
FILE=/home/pi/CubeSatSim/command_control
if [ -f "$FILE" ]; then
if [[ $(arecord -l | grep card) ]]; then
FILE=/home/pi/CubeSatSim/command_control_direwolf
if [ -f "$FILE" ]; then
echo "Radio DTMF/APRS command and control is ON"
else
echo "Radio carrier command and control is ON"
fi
else
echo "Radio carrier command and control is ON"
fi
else
echo "Radio command and control is OFF"
fi
echo
echo -n "RX PL code is: "
echo -n ${10}
# echo
echo -n " TX PL code is: "
echo ${11}
echo
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
echo "Safe Mode! Battery saver mode is ON"
else
echo "Battery saver mode is OFF"
fi
echo
FILE=/home/pi/CubeSatSim/beacon_off
if [ -f "$FILE" ]; then
echo "Transmit beacon telemetry is OFF"
else
echo "Transmit beacon telemetry is ON"
fi
echo
echo -e "Current sim.cfg configuration file:"
# echo
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo
echo "To change, include an OPTION"
echo "To see options, type config -h"
# echo
# set -- "-h"
# fi
elif [ "$1" = "-i" ]; then
restart=1
elif [ "$1" = "-a" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" == "n" ]; then
transmit_command_aprs
else
echo "changing CubeSatSim to AFSK mode"
sudo echo "a" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi
elif [ "$1" = "-m" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" == "n" ]; then
transmit_command_cw
else
echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi
elif [ "$1" = "-f" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" == "n" ]; then
transmit_command_fsk
else
echo "changing CubeSatSim to FSK mode"
sudo echo "f" > /home/pi/CubeSatSim/.mode
restart=1
fi
elif [ "$1" = "-b" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" == "n" ]; then
transmit_command_bpsk
else
echo "changing CubeSatSim to BPSK mode"
sudo echo "b" > /home/pi/CubeSatSim/.mode
restart=1
fi
elif [ "$1" = "-s" ]; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" == "n" ]; then
transmit_command_sstv
else
echo "changing CubeSatSim to SSTV mode"
sudo echo "s" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
restart=1
else
reboot=1
fi
else
restart=1
fi
fi
elif [ "$1" = "-t" ]; then
echo
echo "Editing the Simulated Telemetry setting in"
echo "the configuration file for CubeSatSim"
echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
if [ "$5" = "yes" ] || [ "$5" = "y" ]; then
echo "Simualted Telemetry is ON"
else
echo "Simualted Telemetry is OFF"
fi
echo
# $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
echo "Do you want Simulated Telemetry ON (y/n) "
read sim
echo
if [ "$sim" = "y" ] || [ "$sim" = "yes" ] ; then
sim="yes"
echo "Simulated Telemetry is ON"
else
sim="no"
echo "Simulated Telemetry is OFF"
fi
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11}
echo $1 $2 $3 $4 $sim $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
reboot=1
## sudo reboot now
# sudo restart cubesatsim
elif [ "$1" = "-c" ]; then
echo
echo "Editing the CALLSIGN in the"
echo "configuration file for CubeSatSim"
echo
echo "Return keeps current value."
# echo -e "Current sim.cfg configuration file:"
# echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo "Current value of CALLSIGN is"
echo $1
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
echo "Enter callsign in all capitals: "
read callsign
if [ -z $callsign ] ; then
callsign="$1"
echo "Keeping value of" $callsign
norestart=1
else
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
fi
if [ "$norestart" = "1" ]; then
echo
else
echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
reboot=1
## sudo reboot now
# sudo systemctl restart cubesatsim
fi
elif [ "$1" = "-r" ]; then
echo
echo "Editing the Reset Count in the"
echo "configuration file for CubeSatSim"
echo
echo "Return keeps current value."
# echo -e "Current sim.cfg configuration file:"
# echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo
echo "Current value of Reset Count is"
echo $2
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
echo -e "Enter Reset Count (integer): "
read resets
if [ -z $resets ] ; then
resets="$2"
echo "Keeping value of" $resets
fi
if ! [[ $resets =~ ^[0-9]+$ ]] ; then
echo "Error: not an integer!"
resets="$2"
echo "Keeping value of" $resets
norestart=1
else
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo $1 $resets $3 $4 $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
fi
if [ "$norestart" = "1" ]; then
echo
else
## echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
reboot=1
## sudo reboot now
# sudo systemctl restart cubesatsim
fi
elif [ "$1" = "-l" ]; then
echo
echo "Editing latitude and longitude in the"
echo "configuration file for CubeSatSim"
echo "(Only used for APRS telemetry)"
echo
echo "Return keeps current value."
# echo -e "Current sim.cfg configuration file:"
# echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo
echo "Current value of latitude is"
echo $3
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
echo -e "Enter latitude (decimal degrees, positive is north): "
read lat
if [ -z $lat ] ; then
lat="$3"
echo "Keeping value of" $lat
fi
if ! [[ $lat =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Error: not a number!"
lat="$3"
echo "Keeping value of" $lat
fi
echo
echo "Current value of longitude is"
echo $4
echo
echo -e "Enter longitude (decimal degrees, positive is east): "
read long
if [ -z $long ] ; then
long="$4"
echo "Keeping value of" $long
fi
if ! [[ $long =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Error: not a number!"
long="$4"
echo "Keeping value of" $long
fi
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11}
echo $1 $2 $lat $long $5 $6 $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
if [ "$norestart" = "1" ]; then
echo
else
## echo
## echo "Rebooting CubeSatSim with new configuration file"
## echo
reboot=1
## sudo reboot now
# sudo systemctl restart cubesatsim
fi
elif [ "$1" = "-S" ]; then
echo
echo "Scan both I2C buses on the Raspberry Pi"
echo
echo "I2C Bus 1"
echo
i2cdetect -y 1
echo
echo "I2C Bus 1"
echo
i2cdetect -y 3
echo
elif [ "$1" = "-C" ]; then
echo
echo "Clear logs"
echo
sudo systemctl stop cubesatsim
sudo systemctl stop transmit
sudo systemctl stop command
sudo mv -f /home/pi/CubeSatSim/telem.txt /home/pi/CubeSatSim/telem.txt.bk
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
reboot=1
## sudo systemctl reboot now
## echo "rebooting"
elif [ "$1" = "-T" ]; then
echo
echo "Change command and control state"
echo
FILE=/home/pi/CubeSatSim/command_control
if [ -f "$FILE" ]; then
echo "Radio command and control is ON"
echo
echo "Do you want to turn command and control to OFF (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Command and control set to OFF"
sudo rm /home/pi/CubeSatSim/command_control > /dev/null 2>&1
# reboot=1
echo "restarting command and control"
sudo systemctl restart command
## sudo reboot now
fi
else
echo "Radio command and control is OFF"
echo
echo "Do you want to set command and control to ON (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Command and control set to ON"
sudo touch /home/pi/CubeSatSim/command_control
echo "restarting command and control"
# reboot=1
sudo systemctl restart command
## sudo reboot now
fi
fi
elif [ "$1" = "-d" ]; then
echo
echo "Change command and control Direwolf state"
echo
if [[ $(arecord -l | grep card) ]]; then
:
else
echo "Note: No USB Sound Card is plugged in!"
echo "Direwolf will not run unless one is plugged in."
fi
FILE=/home/pi/CubeSatSim/command_control_direwolf
if [ -f "$FILE" ]; then
echo "Radio command and control with Direwolf for DTMF and APRS is ON"
echo
echo "Do you want to turn Direwolf OFF and do Carrier command and control (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Command and control Direwolf set to OFF"
sudo rm /home/pi/CubeSatSim/command_control_direwolf > /dev/null 2>&1
# reboot=1
## echo "rebooting"
sudo systemctl restart command
## sudo reboot now
fi
else
echo "Radio command and control with Direwolf for DTMF and APRS is OFF so carrier command and control is enabled"
echo
echo "Do you want to set command and control with Direwolf for DTMF and APRS to ON (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Command and control Direwolf set to ON"
sudo touch /home/pi/CubeSatSim/command_control_direwolf
## echo "rebooting"
# reboot=1
sudo systemctl restart command
if [[ $(arecord -l | grep card) ]]; then
restart=1
### echo "restarting cubesatsim software"
### sudo systemctl restart cubesatsim
fi
## sudo reboot now
fi
fi
FILE=/home/pi/CubeSatSim/command_control
if [ -f "$FILE" ]; then
echo
else
echo "Radio command and control is OFF"
echo
echo "Do you want to set command and control to ON (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Command and control set to ON"
sudo touch /home/pi/CubeSatSim/command_control
echo "restarting command and control"
# reboot=1
sudo systemctl restart command
## sudo reboot now
fi
fi
elif [ "$1" = "-D" ]; then
echo
echo "Change Transmit Commands state"
echo
FILE=/home/pi/CubeSatSim/transmit_dtmf
if [ -f "$FILE" ]; then
echo "Transmit Commands in DTMF is set"
echo
echo "Do you want to Transmit Commands in APRS (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Transmit Commands in APRS"
sudo rm /home/pi/CubeSatSim/transmit_dtmf > /dev/null 2>&1
fi
else
echo "Transmit Commands in APRS is set"
echo
echo "Do you want to Transmit Commands in DTMF (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Transmit Commands in DTMF"
touch /home/pi/CubeSatSim/transmit_dtmf
fi
fi
elif [ "$1" = "-R" ]; then
echo
echo "Reset the Commands Count in the file command_count.txt"
echo
echo "Current commands count is:"
cat /home/pi/CubeSatSim/commands_count.txt
echo
echo "Do you want to reset the commands count to zero (y/n) "
read reset
echo
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
sudo rm /home/pi/CubeSatSim/command_count.txt > /dev/null 2>&1
echo "Commands count reset to 0"
echo "0\n" > /home/pi/CubeSatSim/command_count.txt
else
echo "Commands count not reset"
fi
elif [ "$1" = "-B" ]; then
echo
echo "Manually setting Safe Mode (battery saver mode)"
echo
FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then
echo "Safe Mode! Battery saver mode is ON."
mode=1
else
echo "Safe Mode is OFF."
echo "Battery saver mode is OFF."
mode=0
fi
echo
echo "Do you want Safe Mode (battery saver mode) ON (y/n) "
read saver
echo
## reboot=0
if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then
if [ "$mode" = "0" ] ; then
echo "Safe Mode will be turned on! Battery saver will be turned ON"
sudo touch /home/pi/CubeSatSim/battery_saver
reboot=1
fi
else
if [ "$mode" = "1" ] ; then
echo "Safe Mode will be turned OFF. Battery saver mode will be turned OFF"
sudo rm /home/pi/CubeSatSim/battery_saver > /dev/null 2>&1
reboot=1
fi
fi
if [ "$reboot" = "1" ] ; then
value=`cat /home/pi/CubeSatSim/.mode`
echo "$value" > /dev/null
set -- $value
if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then
reboot=1
## echo "rebooting"
## sudo reboot now
else
restart=1
## echo "restarting"
## sudo systemctl restart cubesatsim
fi
fi
elif [ "$1" = "-q" ]; then
echo
echo "Editing the Squelch setting in"
echo "the configuration file for CubeSatSim"
echo
value=`cat /home/pi/CubeSatSim/sim.cfg`
echo "$value" > /dev/null
set -- $value
echo
echo "Current value of squelch is"
echo $6
echo
# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
echo -e "Enter squelch (integer 1 - 8): "
read sq
if [ -z $sq ] ; then
sq="$6"
echo "Keeping value of" $lat
fi
if ! [[ $sq =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then
echo "Error: not a number!"
sq="$6"
echo "Keeping value of" $sq
fi
# echo
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
# echo
echo $1 $2 $3 $4 $5 $sq $7 $8 $9 ${10} ${11}
echo $1 $2 $3 $4 $4 $sq $7 $8 $9 ${10} ${11} > /home/pi/CubeSatSim/sim.cfg
echo
echo "Restarting CubeSatSim with new configuration file"
## echo
# reboot=1
## sudo reboot now
sudo systemctl restart transmit
elif [ "$1" = "-Q" ]; then
# echo