-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathetherify2.sh
executable file
·110 lines (89 loc) · 3.18 KB
/
etherify2.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
#!/bin/bash
# Etherify 2 - silly hack to send data wirelessly by generating load on
# the ethernet interface.
#
# (c) 2020 Jacek Lipkowski SQ5BPF <[email protected]>
# https://lipkowski.com/etherify
#
# Tested on 2 raspberry pi 4 connected together via 2m ethernet cable
# This probably works by loading the supply voltage when the packets
# are generated. A change of voltage probably changes the frequency
# of some clock slightly, thus generating FSK (F1A to be exact).
#
# This enables one to leak data out via morse code.
# Please tune the receiver to around 125MHz in CW mode with a
# very narrow filter.
#
# During tests the signal could be received at a distance of 30m.
#
# Notice:
# - conduct the tests in an electromagnetically quiet area
# - software decodera are very bad at decoding morse code in the presence
# of interference, and with imperfect timing. If you want to asess if the
# signal is decodable, then get someone who can receive by ear
# (such as an experienced amateur radio operator).
# Humans are way better at this.
# - make sure that you can ping the other raspberry pi before running this demo
# - run this as root (could be made to run non-root with udp)
#
# This script is licensed under GPL v3
#
# I disclaim any liability for things that this software does or doesn't do.
# Everything is the responsibility of the user.
#
#etherify2 settings:
# a pingable address (of the second raspberry pi 4)
IP=192.168.1.1
#this gives around 17wpm on a raspberry pi 4
#modify these if you need faster/slower cw
DOTLEN=350
DASHLEN=$((${DOTLEN}*3))
SLEEPDOT=0.05
SLEEPDASH=0.15
SLEEPSPACE=0.10
#simple cw encoder --sq5bpf
declare -A cw=( [0]='-----' [1]='.----' [2]='..---' [3]='...--' [4]='....-' [5]='.....' [6]='-....' [7]='--...' [8]='---..' [9]='----.' [a]='.-' [b]='-...' [c]='-.-.' [d]='-..' [e]='.' [f]='..-.' [g]='--.' [h]='....' [i]='..' [j]='.---' [k]='-.-' [l]='.-..' [m]='--' [n]='-.' [o]='---' [p]='.--.' [q]='--.-' [r]='.-.' [s]='...' [t]='-' [u]='..-' [v]='...-' [w]='.--' [x]='-..-' [y]='-.--' [z]='--..' ['/']='-..-.' ['.']='.-.-.-' ['!']='--..--' ['?']='..--..' ['=']='-...-' [kn]='-.--.' [sk]='...-.-' [ar]='.-.-.' [bk]='-...-.-' )
text2morse() {
IN="${1,,}"
OUT=""
for (( pos=0 ; pos < ${#IN} ; pos++ ))
do
ch="${IN:$pos:1}"
[ "$ch" = " " ] && OUT+=" " && continue
[ "${cw[$ch]}" ] && OUT+="${cw[$ch]} " || OUT+="${cw['?']} "
done
echo "$OUT"
}
etherify2_send() {
B="$1"
while [ "$B" ]; do
C="${B:0:1}"
B="${B:1}"
echo -n "$C"
case "$C" in
"-") ping -f -s 1440 -c $DASHLEN $IP >/dev/null 2>&1 ;;
".") ping -f -s 1440 -c $DOTLEN $IP >/dev/null 2>&1 ;;
" ") sleep $SLEEPSPACE ;;
esac
sleep $SLEEPDOT
done
echo
}
TEXT=" etherify 2 demo="
[ "$1" -a -f "$1" ] && TEXT=`tr '\n' ' ' < $1 | sed -re 's/ */ /g'`
CWTEXT=`text2morse "$TEXT"`
cat <<EOF
Etherify 2 , sending wireless by generating traffic to ${IP}
Please tune around 125MHz CW with a narrow filter.
(c) 2020 Jacek Lipkowski SQ5BPF
Sending: "${TEXT}"
$CWTEXT
EOF
if ping -c 2 -W 1 -i 1 $IP >/dev/null 2>&1 ; then
while : ; do
etherify2_send "$CWTEXT"
sleep $SLEEPSPACE ; sleep $SLEEPSPACE ; sleep $SLEEPSPACE ; sleep $SLEEPSPACE
done
else
echo "Aborting, I can't ping $IP"
fi