-
Notifications
You must be signed in to change notification settings - Fork 0
/
backprofile.sh
2330 lines (2054 loc) · 86.4 KB
/
backprofile.sh
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
# /root/.profile - main EZ-Wifibroadcast script
# (c) 2017 by Rodizio. Licensed under GPL2
#
#
# functions
#
function tmessage {
if [ "$QUIET" == "N" ]; then
echo $1 "$2"
fi
}
function collect_errorlog {
sleep 3
echo
if nice dmesg | nice grep -q over-current; then
echo "ERROR: Over-current detected - potential power supply problems!"
fi
# check for USB disconnects (due to power-supply problems)
if nice dmesg | nice grep -q disconnect; then
echo "ERROR: USB disconnect detected - potential power supply problems!"
fi
nice mount -o remount,rw /boot
# check if over-temp or under-voltage occured
if vcgencmd get_throttled | nice grep -q -v "0x0"; then
TEMP=`cat /sys/class/thermal/thermal_zone0/temp`
TEMP_C=$(($TEMP/1000))
if [ "$TEMP_C" -lt 75 ]; then # it must be under-voltage
echo
echo " ---------------------------------------------------------------------------------------------------"
echo " | ERROR: Under-Voltage detected on the TX Pi. Your Pi is not supplied with stable 5 Volts. |"
echo " | Either your power-supply or wiring is not sufficent, check the wiring instructions in the Wiki. |"
echo " | Video Bitrate will be reduced to 1000kbit to reduce current consumption! |"
echo " ---------------------------------------------------------------------------------------------------"
echo
echo " ---------------------------------------------------------------------------------------------------" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | ERROR: Under-Voltage detected on the TX Pi. Your Pi is not supplied with stable 5 Volts. |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | Either your power-supply or wiring is not sufficent, check the wiring instructions in the Wiki. |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | Video Bitrate will be reduced to 1000kbit to reduce current consumption! |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | When you have fixed wiring/power-supply, delete this file and make sure it doesn't re-appear! |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " ---------------------------------------------------------------------------------------------------" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
fi
fi
mv /boot/errorlog.txt /boot/errorlog-old.txt > /dev/null 2>&1
mv /boot/errorlog.png /boot/errorlog-old.png > /dev/null 2>&1
echo -n "Camera: "
nice /usr/bin/vcgencmd get_camera
uptime >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
echo -n "Camera: " >>/boot/errorlog.txt
nice /usr/bin/vcgencmd get_camera >>/boot/errorlog.txt
echo
nice dmesg | nice grep disconnect
nice dmesg | nice grep over-current
nice dmesg | nice grep disconnect >>/boot/errorlog.txt
nice dmesg | nice grep over-current >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
echo
NICS=`ls /sys/class/net/ | nice grep -v eth0 | nice grep -v lo | nice grep -v usb`
for NIC in $NICS
do
iwconfig $NIC | grep $NIC
done
echo
echo "Detected USB devices:"
lsusb
nice iwconfig >>/boot/errorlog.txt > /dev/null 2>&1
echo >>/boot/errorlog.txt
nice ifconfig >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice iw reg get >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice iw list >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice ps ax >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice df -h >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice mount >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice fdisk -l /dev/mmcblk0 >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice lsmod >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice lsusb >>/boot/errorlog.txt
nice lsusb -v >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice ls -la /dev >>/boot/errorlog.txt
nice ls -la /dev/input >>/boot/errorlog.txt
echo
nice vcgencmd measure_temp
nice vcgencmd get_throttled
echo >>/boot/errorlog.txt
nice vcgencmd measure_volts >>/boot/errorlog.txt
nice vcgencmd measure_temp >>/boot/errorlog.txt
nice vcgencmd get_throttled >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice vcgencmd get_config int >>/boot/errorlog.txt
nice /root/wifibroadcast_misc/raspi2png -p /boot/errorlog.png
echo >>/boot/errorlog.txt
nice dmesg >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice cat /etc/modprobe.d/rt2800usb.conf >> /boot/errorlog.txt
nice cat /etc/modprobe.d/ath9k_htc.conf >> /boot/errorlog.txt
nice cat /etc/modprobe.d/ath9k_hw.conf >> /boot/errorlog.txt
echo >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice cat /boot/wifibroadcast-1.txt | egrep -v "^(#|$)" >> /boot/errorlog.txt
echo >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice cat /boot/osdconfig.txt | egrep -v "^(//|$)" >> /boot/errorlog.txt
echo >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice cat /boot/joyconfig.txt | egrep -v "^(//|$)" >> /boot/errorlog.txt
echo >>/boot/errorlog.txt
echo >>/boot/errorlog.txt
nice cat /boot/apconfig.txt | egrep -v "^(#|$)" >> /boot/errorlog.txt
sync
nice mount -o remount,ro /boot
}
function collect_debug {
sleep 25
DEBUGPATH=$1
if [ "$DEBUGPATH" == "/boot" ]; then # if debugpath is boot partition, make it writeable first and move old logs
nice mount -o remount,rw /boot
mv /boot/debug.txt /boot/debug-old.txt > /dev/null 2>&1
fi
uptime >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
echo -n "Camera: " >>$DEBUGPATH/debug.txt
nice /usr/bin/vcgencmd get_camera >>$DEBUGPATH/debug.txt
nice dmesg | nice grep disconnect >>$DEBUGPATH/debug.txt
nice dmesg | nice grep over-current >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice tvservice -s >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice tvservice -m CEA >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice tvservice -m DMT >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice iwconfig >>$DEBUGPATH/debug.txt > /dev/null 2>&1
echo >>$DEBUGPATH/debug.txt
nice ifconfig >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice iw reg get >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice iw list >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice ps ax >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice df -h >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice mount >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice fdisk -l /dev/mmcblk0 >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice lsmod >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice lsusb >>$DEBUGPATH/debug.txt
nice lsusb -v >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice ls -la /dev >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice ls -la /dev/input >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice vcgencmd measure_temp >>$DEBUGPATH/debug.txt
nice vcgencmd get_throttled >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice vcgencmd get_config int >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice dmesg >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice cat /etc/modprobe.d/rt2800usb.conf >> $DEBUGPATH/debug.txt
nice cat /etc/modprobe.d/ath9k_htc.conf >> $DEBUGPATH/debug.txt
nice cat /etc/modprobe.d/ath9k_hw.conf >> $DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice cat /boot/wifibroadcast-1.txt | egrep -v "^(#|$)" >> $DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice cat /boot/osdconfig.txt | egrep -v "^(//|$)" >> $DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice cat /boot/joyconfig.txt | egrep -v "^(//|$)" >> $DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
echo >>$DEBUGPATH/debug.txt
nice cat /boot/apconfig.txt | egrep -v "^(#|$)" >> $DEBUGPATH/debug.txt
nice top -n 3 -b -d 2 >>$DEBUGPATH/debug.txt
if [ "$DEBUGPATH" == "/boot" ]; then # if debugpath is boot partition, sync and remount ro
sync
nice mount -o remount,ro /boot
fi
}
function prepare_nic {
DRIVER=`cat /sys/class/net/$1/device/uevent | nice grep DRIVER | sed 's/DRIVER=//'`
if [ "$DRIVER" != "rt2800usb" ] && [ "$DRIVER" != "mt7601u" ] && [ "$DRIVER" != "ath9k_htc" ]; then
tmessage "WARNING: Unsupported or experimental wifi card: $DRIVER"
fi
tmessage -n "Setting up $1: "
if [ "$DRIVER" == "ath9k_htc" ]; then # set bitrates for Atheros via iw
ifconfig $1 up || {
echo
echo "ERROR: Bringing up interface $1 failed!"
collect_errorlog
sleep 365d
}
sleep 0.2
$CAM = 1
if [ "$CAM" == "0" ]; then # we are RX, set bitrate to uplink bitrate
#tmessage -n "bitrate $UPLINK_WIFI_BITRATE Mbit "
if [ "$UPLINK_WIFI_BITRATE" != "19.5" ]; then # only set bitrate if something else than 19.5 is requested (19.5 is default compiled in ath9k_htc firmware)
iw dev $1 set bitrates legacy-2.4 $UPLINK_WIFI_BITRATE || {
echo
echo "ERROR: Setting bitrate on $1 failed!"
collect_errorlog
sleep 365d
}
fi
sleep 0.2
#tmessage -n "done. "
else # we are TX, set bitrate to downstream bitrate
tmessage -n "bitrate "
if [ "$VIDEO_WIFI_BITRATE" != "19.5" ]; then # only set bitrate if something else than 19.5 is requested (19.5 is default compiled in ath9k_htc firmware)
tmessage -n "$VIDEO_WIFI_BITRATE Mbit "
iw dev $1 set bitrates legacy-2.4 $VIDEO_WIFI_BITRATE || {
echo
echo "ERROR: Setting bitrate on $1 failed!"
collect_errorlog
sleep 365d
}
else
tmessage -n "$VIDEO_WIFI_BITRATE Mbit "
fi
sleep 0.2
tmessage -n "done. "
fi
ifconfig $1 down || {
echo
echo "ERROR: Bringing down interface $1 failed!"
collect_errorlog
sleep 365d
}
sleep 0.2
tmessage -n "monitor mode.. "
iw dev $1 set monitor none || {
echo
echo "ERROR: Setting monitor mode on $1 failed!"
collect_errorlog
sleep 365d
}
sleep 0.2
tmessage -n "done. "
ifconfig $1 up || {
echo
echo "ERROR: Bringing up interface $1 failed!"
collect_errorlog
sleep 365d
}
sleep 0.2
if [ "$2" != "0" ]; then
tmessage -n "frequency $2 MHz.. "
iw dev $1 set freq $2 || {
echo
echo "ERROR: Setting frequency $2 MHz on $1 failed!"
collect_errorlog
sleep 365d
}
tmessage "done!"
else
echo
fi
fi
if [ "$DRIVER" == "rt2800usb" ] || [ "$DRIVER" == "mt7601u" ] || [ "$DRIVER" == "rtl8192cu" ] || [ "$DRIVER" == "8812au" ]; then # do not set bitrate for Ralink, Mediatek, Realtek, done through tx parameter
tmessage -n "monitor mode.. "
iw dev $1 set monitor none || {
echo
echo "ERROR: Setting monitor mode on $1 failed!"
collect_errorlog
sleep 365d
}
sleep 0.2
tmessage -n "done. "
#tmessage -n "bringing up.. "
ifconfig $1 up || {
echo
echo "ERROR: Bringing up interface $1 failed!"
collect_errorlog
sleep 365d
}
sleep 0.2
#tmessage -n "done. "
if [ "$2" != "0" ]; then
tmessage -n "frequency $2 MHz.. "
iw dev $1 set freq $2 || {
echo
echo "ERROR: Setting frequency $2 MHz on $1 failed!"
collect_errorlog
sleep 365d
}
tmessage "done!"
else
echo
fi
fi
}
function detect_nics {
tmessage "Setting up wifi cards ... "
echo
# set reg domain to DE to allow channel 12 and 13 for hotspot
iw reg set DE
NUM_CARDS=-1
NICSWL=`ls /sys/class/net | nice grep wlan`
for NIC in $NICSWL
do
# set MTU to 2304
ifconfig $NIC mtu 2304
# re-name wifi interface to MAC address
NAME=`cat /sys/class/net/$NIC/address`
ip link set $NIC name ${NAME//:}
let "NUM_CARDS++"
#sleep 0.1
done
if [ "$NUM_CARDS" == "-1" ]; then
echo "ERROR: No wifi cards detected"
collect_errorlog
sleep 365d
fi
if [ "$CAM" == "0" ]; then # only do relay/hotspot stuff if RX
# get wifi hotspot card out of the way
if [ "$WIFI_HOTSPOT" == "Y" ]; then
if [ "$WIFI_HOTSPOT_NIC" != "internal" ]; then
# only configure it if it's there
if ls /sys/class/net/ | grep -q $WIFI_HOTSPOT_NIC; then
tmessage -n "Setting up $WIFI_HOTSPOT_NIC for Wifi Hotspot operation.. "
ip link set $WIFI_HOTSPOT_NIC name wifihotspot0
ifconfig wifihotspot0 192.168.2.1 up
tmessage "done!"
let "NUM_CARDS--"
else
tmessage "Wifi Hotspot card $WIFI_HOTSPOT_NIC not found!"
sleep 0.5
fi
else
# only configure it if it's there
if ls /sys/class/net/ | grep -q intwifi0; then
tmessage -n "Setting up intwifi0 for Wifi Hotspot operation.. "
ip link set intwifi0 name wifihotspot0
ifconfig wifihotspot0 192.168.2.1 up
tmessage "done!"
else
tmessage "Pi3 Onboard Wifi Hotspot card not found!"
sleep 0.5
fi
fi
fi
# get relay card out of the way
if [ "$RELAY" == "Y" ]; then
# only configure it if it's there
if ls /sys/class/net/ | grep -q $RELAY_NIC; then
ip link set $RELAY_NIC name relay0
prepare_nic relay0 $RELAY_FREQ
let "NUM_CARDS--"
else
tmessage "Relay card $RELAY_NIC not found!"
sleep 0.5
fi
fi
fi
NICS=`ls /sys/class/net/ | nice grep -v eth0 | nice grep -v lo | nice grep -v usb | nice grep -v intwifi | nice grep -v relay | nice grep -v wifihotspot`
# echo "NICS: $NICS"
if [ "$TXMODE" != "single" ]; then
for i in $(eval echo {0..$NUM_CARDS})
do
if [ "$CAM" == "0" ]; then
prepare_nic ${MAC_RX[$i]} ${FREQ_RX[$i]}
else
prepare_nic ${MAC_TX[$i]} ${FREQ_TX[$i]}
fi
sleep 0.1
done
else
# check if auto scan is enabled, if yes, set freq to 0 to let prepare_nic know not to set channel
if [ "$FREQSCAN" == "Y" ] && [ "$CAM" == "0" ]; then
for NIC in $NICS
do
prepare_nic $NIC 2484
sleep 0.1
done
# make sure check_alive function doesnt restart hello_video while we are still scanning for channel
touch /tmp/pausewhile
/root/wifibroadcast/rx -p 0 -d 1 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEOBLOCKLENGTH $NICS >/dev/null &
sleep 0.5
echo
echo -n "Please wait, scanning for TX ..."
FREQ=0
if iw list | nice grep -q 5180; then # cards support 5G and 2.4G
FREQCMD="/root/wifibroadcast/channelscan 245 $NICS"
else
if iw list | nice grep -q 2312; then # cards support 2.3G and 2.4G
FREQCMD="/root/wifibroadcast/channelscan 2324 $NICS"
else # cards support only 2.4G
FREQCMD="/root/wifibroadcast/channelscan 24 $NICS"
fi
fi
while [ $FREQ -eq 0 ]; do
FREQ=`$FREQCMD`
done
echo "found on $FREQ MHz"
echo
ps -ef | nice grep "rx -p 0" | nice grep -v grep | awk '{print $2}' | xargs kill -9
for NIC in $NICS
do
echo -n "Setting frequency on $NIC to $FREQ MHz.. "
iw dev $NIC set freq $FREQ
echo "done."
sleep 0.1
done
# all done
rm /tmp/pausewhile
else
for NIC in $NICS
do
prepare_nic $NIC $FREQ
sleep 0.1
done
fi
fi
touch /tmp/nics_configured # let other processes know nics are setup and ready
echo
echo "setup v4l2"
#modprobe v4l2loopback video_nr=1,2,3
modprobe bcm2835-v4l2
#sleep 1
#v4l2-ctl --list-devices
echo
echo "FUCK V4L2 THE FUCKING BITCH ASS CUNT OF A SOFTWARE"
#echo "set fps and output fomat"
#v4l2loopback-ctl set-fps 30/1 /dev/video1
#v4l2loopback-ctl set-fps 30/1 /dev/video2
#v4l2loopback-ctl set-fps 30/1 /dev/video3
#v4l2loopback-ctl set-caps "video/x-raw,width=250,height=80" /dev/video1
#v4l2loopback-ctl set-caps "video/x-raw,width=250,height=200" /dev/video2
#v4l2loopback-ctl set-caps "video/x-raw,width=250,height=200" /dev/video3
rw
sleep 0.5
echo
echo "v4l2 is fucked"
echo
echo "RAM drive"
sudo mount ramfs ~/ramdrive -t ramfs -o size=450M
sleep 1
#mount ramfs ~/images -t ramfs -o size=60M
echo
echo "Hippy time"
#nice -n -9 python3 ~/HipPy/src/HipPy.py &
nice -n -9 python3 ~/HipPy/src/testing/Over9000procs/HipPy.py &
nice -n -9 python3 ~/HipPy/src/testing/Over9000procs/OCR.py &
#nice -n -12 python3 ~/HipPy/src/testing/Alltheimages/HipPy.py &
#nice -n -12 python3 ~/HipPy/src/testing/Alltheimages/OCR.py &
sleep 5
}
function check_alive_function {
# function to check if packets coming in, if not, re-start hello_video to clear frozen display
while true; do
# pause while saving is in progress
pause_while
ALIVE=`nice /root/wifibroadcast/check_alive`
if [ $ALIVE == "0" ]; then
echo "no new packets, restarting hello_video and sleeping for 5s ..."
ps -ef | nice grep "cat /root/videofifo1" | nice grep -v grep | awk '{print $2}' | xargs kill -9
ps -ef | nice grep "$DISPLAY_PROGRAM" | nice grep -v grep | awk '{print $2}' | xargs kill -9
ionice -c 1 -n 4 nice -n -10 cat /root/videofifo1 | ionice -c 1 -n 4 nice -n -10 $DISPLAY_PROGRAM > /dev/null 2>&1 &
sleep 5
else
echo "received packets, doing nothing ..."
fi
done
}
function check_exitstatus {
STATUS=$1
case $STATUS in
9)
# rx returned with exit code 9 = the interface went down
# wifi card must've been removed during running
# check if wifi card is really gone
NICS2=`ls /sys/class/net/ | nice grep -v eth0 | nice grep -v lo | nice grep -v usb | nice grep -v intwifi | nice grep -v relay | nice grep -v wifihotspot`
if [ "$NICS" == "$NICS2" ]; then
# wifi card has not been removed, something else must've gone wrong
echo "ERROR: RX stopped, wifi card _not_ removed! "
else
# wifi card has been removed
echo "ERROR: Wifi card removed! "
fi
;;
2)
# something else that is fatal happened during running
echo "ERROR: RX chain stopped wifi card _not_ removed! "
;;
1)
# something that is fatal went wrong at rx startup
echo "ERROR: could not start RX "
#echo "ERROR: could not start RX "
;;
*)
if [ $RX_EXITSTATUS -lt 128 ]; then
# whatever it was ...
#echo "RX exited with status: $RX_EXITSTATUS "
echo -n ""
fi
esac
}
function tx_function {
killall wbc_status > /dev/null 2>&1
/root/wifibroadcast/sharedmem_init_tx
if [ "$TXMODE" == "single" ]; then
echo -n "Waiting for wifi card to become ready ..."
COUNTER=0
# loop until card is initialized
while [ $COUNTER -lt 10 ]; do
sleep 0.5
echo -n "."
let "COUNTER++"
if [ -d "/sys/class/net/wlan0" ]; then
echo -n "card ready"
break
fi
done
else
# just wait some time
echo -n "Waiting for wifi cards to become ready ..."
sleep 3
fi
echo
echo
detect_nics
sleep 1
echo
if [ -e "$FC_TELEMETRY_SERIALPORT" ]; then
echo "Configured serial port $FC_TELEMETRY_SERIALPORT found ..."
else
echo "ERROR: $FC_TELEMETRY_SERIALPORT not found!"
collect_errorlog
sleep 365d
fi
echo
RALINK=0
if [ "$TXMODE" == "single" ]; then
DRIVER=`cat /sys/class/net/$NICS/device/uevent | nice grep DRIVER | sed 's/DRIVER=//'`
if [ "$DRIVER" != "ath9k_htc" ]; then # in single mode and ralink cards always, use frametype 1 (data)
VIDEO_FRAMETYPE=0
RALINK=1
fi
else # for txmode dual always use frametype 1
VIDEO_FRAMETYPE=1
RALINK=1
fi
#echo "Wifi bitrate: $VIDEO_WIFI_BITRATE, Video frametype: $VIDEO_FRAMETYPE"
if [ "$VIDEO_WIFI_BITRATE" == "19.5" ]; then # set back to 18 to make sure -d parameter works (supports only 802.11b/g datarates)
VIDEO_WIFI_BITRATE=18
fi
if [ "$VIDEO_WIFI_BITRATE" == "5.5" ]; then # set back to 6 to make sure -d parameter works (supports only 802.11b/g datarates)
VIDEO_WIFI_BITRATE=5
fi
DRIVER=`cat /sys/class/net/$NICS/device/uevent | nice grep DRIVER | sed 's/DRIVER=//'`
if [ "$CTS_PROTECTION" == "auto" ] && [ "$DRIVER" == "ath9k_htc" ]; then # only use CTS protection with Atheros
echo -n "Checking for other wifi traffic ... "
WIFIPPS=`/root/wifibroadcast/wifiscan $NICS`
echo -n "$WIFIPPS PPS: "
if [ "$WIFIPPS" != "0" ]; then # wifi networks detected, enable CTS
echo "Wifi traffic detected, CTS enabled"
VIDEO_FRAMETYPE=1
TELEMETRY_CTS=1
CTS=Y
else
echo "No wifi traffic detected, CTS disabled"
CTS=N
fi
else
if [ "$CTS_PROTECTION" == "N" ]; then
echo "CTS Protection disabled in config"
CTS=N
else
if [ "$DRIVER" == "ath9k_htc" ]; then
echo "CTS Protection enabled in config"
CTS=Y
else
echo "CTS Protection not supported!"
CTS=N
fi
fi
fi
# check if over-temp or under-voltage occured before bitrate measuring
if vcgencmd get_throttled | nice grep -q -v "0x0"; then
TEMP=`cat /sys/class/thermal/thermal_zone0/temp`
TEMP_C=$(($TEMP/1000))
if [ "$TEMP_C" -lt 75 ]; then # it must be under-voltage
echo
echo " ---------------------------------------------------------------------------------------------------"
echo " | ERROR: Under-Voltage detected on the TX Pi. Your Pi is not supplied with stable 5 Volts. |"
echo " | Either your power-supply or wiring is not sufficent, check the wiring instructions in the Wiki. |"
echo " | Video Bitrate will be reduced to 1000kbit to reduce current consumption! |"
echo " ---------------------------------------------------------------------------------------------------"
echo
mount -o remount,rw /boot
echo " ---------------------------------------------------------------------------------------------------" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | ERROR: Under-Voltage detected on the TX Pi. Your Pi is not supplied with stable 5 Volts. |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | Either your power-supply or wiring is not sufficent, check the wiring instructions in the Wiki. |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | Video Bitrate will be reduced to 1000kbit to reduce current consumption! |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | When you have fixed wiring/power-supply, delete this file and make sure it doesn't re-appear! |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " ---------------------------------------------------------------------------------------------------" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
mount -o remount,ro /boot
UNDERVOLT=1
echo "1" > /tmp/undervolt
else # it was either over-temp or both undervolt and over-temp, we set undervolt to 0 anyway, since overtemp can be seen at the temp display on the rx
UNDERVOLT=0
echo "0" > /tmp/undervolt
fi
else
UNDERVOLT=0
echo "0" > /tmp/undervolt
fi
# if yes, we don't do the bitrate measuring to increase chances we "survive"
if [ "$UNDERVOLT" == "0" ]; then
if [ "$VIDEO_BITRATE" == "auto" ]; then
echo -n "Measuring max. available bitrate .. "
BITRATE_MEASURED=`/root/wifibroadcast/tx_measure -p 77 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS`
BITRATE=$((BITRATE_MEASURED*$BITRATE_PERCENT/100))
BITRATE_KBIT=$((BITRATE/1000))
BITRATE_MEASURED_KBIT=$((BITRATE_MEASURED/1000))
echo "$BITRATE_MEASURED_KBIT kBit/s * $BITRATE_PERCENT% = $BITRATE_KBIT kBit/s video bitrate"
else
BITRATE=$(($VIDEO_BITRATE*1000))
echo "Using fixed bitrate: $VIDEO_BITRATE kBit"
fi
else
BITRATE=$((1000*1000))
BITRATE_KBIT=1000
BITRATE_MEASURED_KBIT=2000
echo "Using reduced bitrate: 1000 kBit due to undervoltage!"
fi
# check again if over-temp or under-voltage occured after bitrate measuring (but only if it didn't occur before yet)
if [ "$UNDERVOLT" == "0" ]; then
if vcgencmd get_throttled | nice grep -q -v "0x0"; then
TEMP=`cat /sys/class/thermal/thermal_zone0/temp`
TEMP_C=$(($TEMP/1000))
if [ "$TEMP_C" -lt 75 ]; then # it must be under-voltage
echo
echo " ---------------------------------------------------------------------------------------------------"
echo " | ERROR: Under-Voltage detected on the TX Pi. Your Pi is not supplied with stable 5 Volts. |"
echo " | Either your power-supply or wiring is not sufficent, check the wiring instructions in the Wiki. |"
echo " | Video Bitrate will be reduced to 1000kbit to reduce current consumption! |"
echo " ---------------------------------------------------------------------------------------------------"
echo
mount -o remount,rw /boot
echo " ---------------------------------------------------------------------------------------------------" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | ERROR: Under-Voltage detected on the TX Pi. Your Pi is not supplied with stable 5 Volts. |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | Either your power-supply or wiring is not sufficent, check the wiring instructions in the Wiki. |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | Video Bitrate will be reduced to 1000kbit to reduce current consumption! |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " | When you have fixed wiring/power-supply, delete this file and make sure it doesn't re-appear! |" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
echo " ---------------------------------------------------------------------------------------------------" >> /boot/UNDERVOLTAGE-ERROR!!!.txt
mount -o remount,ro /boot
UNDERVOLT=1
echo "1" > /tmp/undervolt
BITRATE=$((1000*1000))
BITRATE_KBIT=1000
BITRATE_MEASURED_KBIT=2000
else # it was either over-temp or both undervolt and over-temp, we set undervolt to 0 anyway, since overtemp can be seen at the temp display on the rx
UNDERVOLT=0
echo "0" > /tmp/undervolt
fi
else
UNDERVOLT=0
echo "0" > /tmp/undervolt
fi
fi
# check for over-current on USB bus (due to card being powered via usb instead directly)
if nice dmesg | nice grep -q over-current; then
echo "ERROR: Over-current detected - potential power supply problems!"
collect_errorlog
sleep 365d
fi
# check for USB disconnects (due to power-supply problems)
if nice dmesg | nice grep -q disconnect; then
echo "ERROR: USB disconnect detected - potential power supply problems!"
collect_errorlog
sleep 365d
fi
echo $BITRATE_KBIT > /tmp/bitrate_kbit
echo $BITRATE_MEASURED_KBIT > /tmp/bitrate_measured_kbit
if [ "$CTS" == "N" ]; then
echo "0" > /tmp/cts
else
if [ "$VIDEO_WIFI_BITRATE" == "11" ] || [ "$VIDEO_WIFI_BITRATE" == "5" ]; then # 11mbit and 5mbit bitrates don't support CTS, so set to 0
echo "0" > /tmp/cts
else
echo "1" > /tmp/cts
fi
fi
if [ "$DEBUG" == "Y" ]; then
collect_debug /boot &
fi
/root/wifibroadcast/rssitx $NICS &
echo
echo "Starting transmission in $TXMODE mode, FEC $VIDEO_BLOCKS/$VIDEO_FECS/$VIDEO_BLOCKLENGTH: $WIDTH x $HEIGHT $FPS fps, video bitrate: $BITRATE_KBIT kBit/s, Keyframerate: $KEYFRAMERATE"
# nice -n -9 raspivid -w $WIDTH -h $HEIGHT -fps $FPS -b $BITRATE -g $KEYFRAMERATE -t 0 $EXTRAPARAMS -o - | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
#THIS IS OLD BOI nice -n -9 /gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=250,height=200,framerate=30/1 ! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
#nice -n -9 gst-launch-1.0 videomixer name = mix ! xvimagesink sync=false multifilesrc location=~/img1.png caps=image/png,framerate=30/1 ! pngdec ! "video/x-raw,format=BGRA,width=1280,height=720,framerate=30/1" ! mix. v4l2src device=/dev/video0 ! qtdemux ! "video/x-raw,format=BGRA,width=1280,height=720,framerate=30/1" ! mix.
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720,framerate=30/1 ! timeoverlay halignment=right valignment=bottom shaded-background=true ! clockoverlay halignment=left valignment=bottom text="M/D/Y:" shaded-background=true time-format="%m/%d/%Y %H:%M:%S" ! videoconvert ! tee v4l2sink device=/dev/video3
############################### MIXER STUFF #########################################
#nice -n -9 raspivid -w 1280 -h 720 -fps 30/1 -b $BITRATE -g $KEYFRAMERATE -t 0 $EXTRAPARAMS -o - | gst-launch-1.0 -v fdsrc ! video/x-raw,format=BGR4,width=1280,height=720 ! videoconvert ! tee ! v4l2sink device=/dev/video2
#nice -n -9 gst-launch-1.0 v4l2src do-timestamp=true device=/dev/video1 ! video/x-raw,width=250,height=200,framerate=30/1 ! videobox border-alpha=0 top=0 bottom=0 ! videomixer name=mix sink_0::xpos=400 sink_0::ypos=400 sink_0::zorder=10 ! videoconvert ! v4l2sink device=/dev/video3 sync=false v4l2src device=/dev/video0 ! video/x-raw,framerate=30/1,width=1280,height=720 ! mix. &
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=250,height=200,framerate=30/1 ! videobox border-alpha=0 top=-70 bottom=-70 right=-220 ! videomixer name=mix sink_0::alpha=0.7 sink_1::alpha=0.5 ! videoconvert ! v4l2sink device=/dev/video3 v4l2src device=/dev/video0 ! video/x-raw,framerate=40/1,width=1280,height=720 ! videoconvert ! mix.
##############################
#nice -n -9 gst-launch-1.0 -v videotestsrc pattern=snow ! video/x-raw,width=1280,height=720 ! v4l2sink device=/dev/video3
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video1 ! videobox border-alpha=0,bottom=-70,top=-70,right=-220 ! videoconvert ! vl42sink device=/dev/video2
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,width=720,framerate=30/1 ! textoverlay text="HELLO" ! v4l2sink device=/dev/video3
#nice -n -9 gst-launcg-1.0 videotestsrc ! v4l2sink device=/dev/video3
#sleep 5
########################### Telemetry Output ############################################
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=1280,height=720,framerate=30/1 ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-h264,width=1280,height=720,framerate=30/1 ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=250,height=200,framerate=30/1 ! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video0 ! compositor name=mix sink_0::alpha=1 sink_1::alpha = 1 ! videoconvert ! v4l2sink device=/dev/video3 filesrc location=img1.png ! pngdec ! video/x-raw,width=200,height=250 ! mix.
#nice -n -9 gst-launch-1.0 multifilesrc location="~/img1.png" start-index=0 loop=0 ! pngdec ! videoscale ! imagefreeze ! v4l2sink /dev/video3
#nice -n -9 gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw,width=1280,height=720,framerate=30/1! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
##############################
######################## YaBoi JJ on the case ##############################
#gst-launch-1.0 multifilesrc location=notramdrive/"img%d.png" start-index=1 loop=1 caps="image/png,framerate=5/1,width=250,height=80" ! pngdec ! videoconvert ! 'video/x-raw,format=YUY2' ! v4l2sink device=/dev/video1
#sleep 5
#gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=250,height=80,framerate=30/1 ! videoconvert ! omxh264enc control-rate=1 target-bitrate=600000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
sleep 1
nice -n -13 gst-launch-1.0 multifilesrc location=ramdrive/"img%d.bmp" start-index=0 loop=0 caps="image/bmp,framerate=30/1" ! avdec_bmp ! videoconvert ! 'video/x-raw,framerate=30/1' ! omxh264enc control-rate=1 target-bitrate=6000000 ! h264parse config-interval=3 ! fdsink fd=1 | nice -n -9 /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
# legacy WIFI broadcast
# v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat='H264' -p 48 --set-ctrl video_bitrate=7000000,repeat_sequence_header=1,h264_i_frame_period=7,white_balance_auto_preset=5
# nice -n -9 cat /dev/video0 | /root/wifibroadcast/tx_rawsock -p 0 -b $VIDEO_BLOCKS -r $VIDEO_FECS -f $VIDEO_BLOCKLENGTH -t $VIDEO_FRAMETYPE -d $VIDEO_WIFI_BITRATE -y 0 $NICS
TX_EXITSTATUS=${PIPESTATUS[1]}
# if we arrive here, either raspivid or tx did not start, or were terminated later
# check if NIC has been removed
NICS2=`ls /sys/class/net/ | nice grep -v eth0 | nice grep -v lo | nice grep -v usb | nice grep -v intwifi | nice grep -v relay | nice grep -v wifihotspot`
if [ "$NICS" == "$NICS2" ]; then
# wifi card has not been removed
if [ "$TX_EXITSTATUS" != "0" ]; then
echo "ERROR: could not start tx or tx terminated!"
fi
collect_errorlog
sleep 365d
else
# wifi card has been removed
echo "ERROR: Wifi card removed!"
collect_errorlog
sleep 365d
fi
}
function rx_function {
/root/wifibroadcast/sharedmem_init_rx
# start virtual serial port for cmavnode and ser2net
ionice -c 3 nice socat -lf /wbc_tmp/socat1.log -d -d pty,raw,echo=0 pty,raw,echo=0 & > /dev/null 2>&1
sleep 1
ionice -c 3 nice socat -lf /wbc_tmp/socat2.log -d -d pty,raw,echo=0 pty,raw,echo=0 & > /dev/null 2>&1
sleep 1
# setup virtual serial ports
stty -F /dev/pts/0 -icrnl -ocrnl -imaxbel -opost -isig -icanon -echo -echoe -ixoff -ixon 57600
stty -F /dev/pts/1 -icrnl -ocrnl -imaxbel -opost -isig -icanon -echo -echoe -ixoff -ixon 115200
echo
# if USB memory stick is already connected during startup, notify user
# and pause as long as stick is not removed
# some sticks show up as sda1, others as sda, check for both
if [ -e "/dev/sda1" ]; then
STARTUSBDEV="/dev/sda1"
else
STARTUSBDEV="/dev/sda"
fi
if [ -e $STARTUSBDEV ]; then
touch /tmp/donotsave
STICKGONE=0
while [ $STICKGONE -ne 1 ]; do
killall wbc_status > /dev/null 2>&1
nice /root/wifibroadcast_status/wbc_status "USB memory stick detected - please remove and re-plug after flight" 7 65 0 &
sleep 4
if [ ! -e $STARTUSBDEV ]; then
STICKGONE=1
rm /tmp/donotsave
fi
done
fi
killall wbc_status > /dev/null 2>&1
sleep 1
detect_nics
echo
sleep 0.5
# videofifo1: local display, hello_video.bin
# videofifo2: secondary display, hotspot/usb-tethering
# videofifo3: recording
# videofifo4: wbc relay
if [ "$VIDEO_TMP" == "sdcard" ]; then
touch /tmp/pausewhile # make sure check_alive doesn't do it's stuff ...
tmessage "Saving to SDCARD enabled, preparing video storage ..."
if cat /proc/partitions | nice grep -q mmcblk0p3; then # partition has not been created yet
echo
else
echo
echo -e "n\np\n3\n3674112\n\nw" | fdisk /dev/mmcblk0 > /dev/null 2>&1
partprobe > /dev/null 2>&1
mkfs.ext4 /dev/mmcblk0p3 -F > /dev/null 2>&1 || {
tmessage "ERROR: Could not format video storage on SDCARD!"
collect_errorlog
sleep 365d
}
fi
e2fsck -p /dev/mmcblk0p3 > /dev/null 2>&1
mount -t ext4 -o noatime /dev/mmcblk0p3 /video_tmp > /dev/null 2>&1 || {
tmessage "ERROR: Could not mount video storage on SDCARD!"
collect_errorlog
sleep 365d
}
VIDEOFILE=/video_tmp/videotmp.raw
echo "VIDEOFILE=/video_tmp/videotmp.raw" > /tmp/videofile
rm $VIDEOFILE > /dev/null 2>&1
else
VIDEOFILE=/wbc_tmp/videotmp.raw
echo "VIDEOFILE=/wbc_tmp/videotmp.raw" > /tmp/videofile
fi
#/root/wifibroadcast/tracker /wifibroadcast_rx_status_0 >> /wbc_tmp/tracker.txt &
#sleep 1
killall wbc_status > /dev/null 2>&1
if [ "$AIRODUMP" == "Y" ]; then
touch /tmp/pausewhile # make sure check_alive doesn't do it's stuff ...
echo "AiroDump is enabled, running airodump-ng for $AIRODUMP_SECONDS seconds ..."
sleep 3
# strip newlines
NICS_COMMA=`echo $NICS | tr '\n' ' '`
# strip space at end
NICS_COMMA=`echo $NICS_COMMA | sed 's/ *$//g'`
# replace spaces by comma
NICS_COMMA=${NICS_COMMA// /,}
if [ "$FREQ" -gt 3000 ]; then
AIRODUMP_CHANNELS="5180,5200,5220,5240,5260,5280,5300,5320,5500,5520,5540,5560,5580,5600,5620,5640,5660,5680,5700,5745,5765,5785,5805,5825"
else
AIRODUMP_CHANNELS="2412,2417,2422,2427,2432,2437,2442,2447,2452,2457,2462,2467,2472"
fi
airodump-ng --showack -h --berlin 60 --ignore-negative-one --manufacturer --output-format pcap --write /wbc_tmp/wifiscan --write-interval 2 -C $AIRODUMP_CHANNELS $NICS_COMMA &
sleep $AIRODUMP_SECONDS
sleep 2
ionice -c 3 nice -n 19 /root/wifibroadcast_misc/raspi2png -p /wbc_tmp/airodump.png >> /dev/null
killall airodump-ng