├── get_status.http ├── get_status.sh ├── morf_tcp.sh ├── morf_cli.sh └── readme.txt /get_status.http: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | morf_tool_dir=/moRFeus_listener 4 | source $morf_tool_dir/get_status.sh 5 | get_status 6 | 7 | 8 | -------------------------------------------------------------------------------- /get_status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Here we set the morf_toolpath variable. Adapt if you need 4 | 5 | 6 | morf_tool=/bin/morfeus_tool_linux_armv7 7 | 8 | function get_status () { 9 | 10 | dummy=$($morf_tool getCurrent) 11 | sleep 0.1 12 | 13 | echo " 14 | ****** moRFeus status 15 | 16 | Frequency : $($morf_tool getFrequency) 17 | Mode : $($morf_tool getFunction) 18 | Power : $($morf_tool getCurrent) 19 | 20 | $(date +%Y-%m-%d" "%H:%M:%S) 21 | 22 | " 23 | echo $status 24 | export morf_tool 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /morf_tcp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | killall socat >/dev/null 2>&1 3 | 4 | 5 | morf_tool_dir=/moRFeus_listener 6 | 7 | ## TCP Listener 8 | 9 | socat TCP4-LISTEN:7778,fork,crlf,reuseaddr EXEC:$morf_tool_dir/morf_cli.sh,pty,stderr,echo=0 & 10 | 11 | ### EXAMPLES: 12 | ### telnet 192.168.0.21 7778 13 | ### echo "M 6" > /dev/tcp/192.168.0.21/7778 14 | ### echo "G" | nc 192.168.0.21 7778 15 | ### nc 192.168.0.21 7778 16 | 17 | 18 | 19 | ### UDP Listener 20 | 21 | socat UDP-l:7779,fork,reuseaddr EXEC:$morf_tool_dir/morf_cli.sh & 22 | 23 | ### EXAMPLE: 24 | ### echo "M 1" | nc -u -q3 192.168.0.21 7779 25 | 26 | 27 | 28 | 29 | ### HTTP Listener 30 | 31 | socat TCP-LISTEN:7780,crlf,reuseaddr,fork SYSTEM:"echo 'HTTP/1.0 200'; echo 'Cache-Control\: no-cache'; echo 'Contentype\: text/plain'; $morf_tool_dir/get_status.http" 32 | 33 | ### EXAMPLE: 34 | ### http://192.168.0.21:7780 35 | 36 | 37 | -------------------------------------------------------------------------------- /morf_cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | morf_tool_dir=/moRFeus_listener 4 | morf_tool=/bin/morfeus_tool_linux_armv7 5 | 6 | 7 | source $morf_tool_dir/get_status.sh 8 | 9 | ####### 10 | 11 | echo " 12 | 13 | 14 | *** moRFeus remote control 15 | *** LamaBleu 05/2018 16 | 17 | 18 | moRFeus listener commands : 19 | ----------------------- 20 | 21 | S : Show Status 22 | F 123456789 : Set Frequency (hz) = (85000000-5400000000) 23 | M [n] : Mixer Mode [Power = (0-7)] 24 | G [n] : Generator Mode [Power = (0-7)] 25 | P n : Power = (0-7) 26 | Q or X : Disconnect 27 | KK : Kill Server 28 | " 29 | 30 | get_status 31 | 32 | 33 | while : 34 | do 35 | command="" 36 | freq="" 37 | arg1="" 38 | power="" 39 | mode="" 40 | 41 | read -r morf_com 42 | 43 | 44 | command=$(echo $morf_com | awk '{print $1}') 45 | arg1=$(echo $morf_com | awk '{print $2}') 46 | arg1=${arg1//[![:digit:]]} 47 | 48 | power=$($morf_tool getCurrent) 49 | 50 | case $command in 51 | [Ff]) echo " **** setFrequency $arg1" 52 | if [ -z "$arg1" ]; then arg1=""; fi 53 | $morf_tool setFrequency $((arg1)); arg1="" 54 | get_status; 55 | ;; 56 | [XxQq]) echo " **** DISCONNECT " 57 | echo " Goodbye. " 58 | exit 0; 59 | ;; 60 | [Ss]) get_status; 61 | ;; 62 | KK) echo "Disconnect and kill server - Goodbye forever !" 63 | killall socat 64 | exit 0; 65 | ;; 66 | [Mm]) if [ -z "$arg1" ]; then arg1=$power; fi 67 | echo " **** set Mixer mode - Power $arg1" 68 | $morf_tool Mixer 69 | $morf_tool setCurrent $((arg1)) 70 | get_status; 71 | ;; 72 | [Pp]) if [ -z "$arg1" ]; then arg1=$power; fi 73 | echo " **** set Current - Power $arg1" 74 | $morf_tool setCurrent $((arg1)) 75 | get_status; 76 | ;; 77 | [Gg]) if [ -z "$arg1" ]; then arg1=$power; fi 78 | echo " **** set Generator mode - Power $arg1" 79 | $morf_tool Generator 80 | $morf_tool setCurrent $((arg1)) 81 | get_status; 82 | ;; 83 | *) command="" 84 | freq="" 85 | morf_com="" 86 | arg1="" 87 | get_status; 88 | ;; 89 | esac 90 | 91 | 92 | command="" 93 | freq="" 94 | morf_com="" 95 | arg1="" 96 | 97 | done 98 | 99 | 100 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | moRFeus listener for Linux x86/x64, Raspberry Pi. 2 | by LamaBleu 05/2018 3 | 4 | Features : 5 | ========== 6 | 7 | - Remote or local access to moRFeus using TCP/IP. 8 | Nothing to install on client computer, except a telnet client (PuTTY or other terminal app) 9 | Simultaneous connections 10 | - Local use: launch CLI from console (no networking) 11 | - telnet access, moRFeus HTTP status 12 | - Send raw TCP/UDP frames to moRFeus from scripts. 13 | 14 | 15 | - Ports usage 16 | 7778 : TCP port for telnet access 17 | 7779 : UDP port 18 | 7780 : display HTTP status only. 19 | 20 | 21 | Available commands : 22 | ==================== 23 | S : display moRFeus status 24 | F 123456789 : set frequency to 123456789 Hz 25 | M [x] : switch to Mixer mode, power value = x 26 | G [x] : switch to Generator mode, power value = x 27 | P x : set Current value to x 28 | X or Q : disconnect 29 | K : disconnect and KILL server 30 | 31 | * examples : G , G 0 , M 1 , F 547854789 32 | * lowercase/UPPERCASE accepted. errors are ignored by CLI or moRFeus 33 | * x (to set power) can be omitted, power is kept unmodified 34 | 35 | 36 | - Install : 37 | =========== 38 | git clone https://github.com/LamaBleu/moRFeus_listener 39 | cd moRFeus_listener 40 | chmod +x ./setup.sh 41 | ./setup.sh 42 | 43 | Actions performed by setup.sh : 44 | - download morfeus_tool from Outernet archives website for the right platform 45 | - reconfigure files to the current working user/directory (instead of default user : pi) 46 | - set permissions 47 | 48 | For a RPi running with default user 'pi', downloading and making executable the morfeus_tools should be enough. 49 | 50 | - Launch : 51 | ========== 52 | 53 | ** Manual launch from terminal: 54 | 55 | - basic for local use, no network 56 | 57 | cd ~/moRFeus_listener 58 | sudo ./morf_cli.sh 59 | 60 | - network daemon : 61 | 62 | cd ~/moRFeus_listener 63 | sudo ./morf_tcp.sh & 64 | 65 | - kill server 66 | 67 | sudo killall socat 68 | 69 | or use 'K' command from CLI 70 | TIPS : 71 | ====== 72 | 73 | ** Enable the moRFeus server at boot (replace username and path-to-directory values) : 74 | 75 | edit /etc/rc.local file, add BEFORE 'exit 0' instruction this line : 76 | su username -c '/path_to_directory/morf_tcp.sh' & 77 | 78 | ONCE AGAIN : Be careful to add this line BEFORE 'exit 0' and set correct path ! 79 | 80 | 81 | 82 | ** Network 83 | 84 | TCP : echo "M 4" | nc -q2 192.168.0.21 7778 85 | TCP : echo "G 3" | nc -q3 192.168.0.21 7778 >&- (nd mode: no message displayed on console) 86 | UDP : echo "M 2" | nc -u 192.168.0.21 7779 87 | UDP : echo "G 2" | nc -u -q1 192.168.0.21 7779 >&- (blind mode: no message displayed on console) 88 | 89 | Telnet : telnet 192.168.0.21 7778 90 | another simple telnet "client" for linux: nc 192.168.0.21 7778 91 | 92 | Get moRFeus status from shell : 93 | get frequency : nc 192.168.0.21 7780 | grep Freq | awk '{print $3}' 94 | get mode : nc 192.168.0.21 7780 | grep Freq | awk '{print $3}' 95 | get power : nc 192.168.0.21 7780 | grep Power | awk '{print $3}' 96 | 97 | - Network checking (is the server running?) 98 | ================== 99 | sudo netstat -atupn | grep socat 100 | 101 | display listening ports : 102 | 103 | tcp 0 0 0.0.0.0:7780 0.0.0.0:* LISTEN 852/socat 104 | tcp 0 0 0.0.0.0:7778 0.0.0.0:* LISTEN 850/socat 105 | udp 0 0 0.0.0.0:7779 0.0.0.0:* 851/socat 106 | 107 | 108 | - SSH access 109 | ============ 110 | 111 | ssh username@morfeus_ip-address 'sudo /path_to_morfeus_listener/morf_cli.sh' 112 | example : 113 | ssh myname@192.168.0.11 'sudo /home/myname/moRFeus_listener/morf_cli.sh' 114 | However this is not really secure :( 115 | 116 | More secure alternative is to add a specific user (belonging to sudo group) for moRFeus device: 117 | 118 | moRFeus:x:1001:1001::/home/moRFeus:/home/moRFeus/moRFeus_listener/morf_cli.sh 119 | 120 | and give full rights through /etc/sudoers file: 121 | moRFeus ALL=NOPASSWD: /home/moRFeus/moRFeus_listener/ 122 | 123 | 124 | 125 | 126 | --------------------------------------------------------------------------------