Skip to content

Instantly share code, notes, and snippets.

@dragon788
Last active February 1, 2022 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dragon788/68e6e4192fbf8bc5f4aa2eef0c8eb783 to your computer and use it in GitHub Desktop.
Save dragon788/68e6e4192fbf8bc5f4aa2eef0c8eb783 to your computer and use it in GitHub Desktop.
Te-Smart TESmart Shell Script CLI interface
#!/bin/bash
echo_docs() {
cat <<'EOD'
EOD
}
# use case to echo `network` `port` `autoselect` or `LED` sections or if no arg output all of them
set_network () {
cat <<'EON'
LAN port:
IP address: 192.168.1.10
Port: 5000
Gate way: 192.168.1.1
Mask address: 255.255.255.0
EON
}
set_port () {
cat <<'EOP'
Commands (Hex format):
1) Switch input source:
Switch to PC1: 0xAA 0xBB 0x03 0x01 0x01 0xEE
Switch to PC2: 0xAA 0xBB 0x03 0x01 0x02 0xEE
Switch to PC3: 0xAA 0xBB 0x03 0x01 0x03 0xEE
Switch to PC4: 0xAA 0xBB 0x03 0x01 0x04 0xEE
Switch to PC5: 0xAA 0xBB 0x03 0x01 0x05 0xEE
Switch to PC6: 0xAA 0xBB 0x03 0x01 0x06 0xEE
Switch to PC7: 0xAA 0xBB 0x03 0x01 0x07 0xEE
Switch to PC8: 0xAA 0xBB 0x03 0x01 0x08 0xEE
Switch to PC9: 0xAA 0xBB 0x03 0x01 0x09 0xEE
Switch to PC10: 0xAA 0xBB 0x03 0x01 0x0A 0xEE
Switch to PC11: 0xAA 0xBB 0x03 0x01 0x0B 0xEE
Switch to PC12: 0xAA 0xBB 0x03 0x01 0x0C 0xEE
Switch to PC13: 0xAA 0xBB 0x03 0x01 0x0D 0xEE
Switch to PC14: 0xAA 0xBB 0x03 0x01 0x0E 0xEE
Switch to PC15: 0xAA 0xBB 0x03 0x01 0x0F 0xEE
Switch to PC16: 0xAA 0xBB 0x03 0x01 0x10 0xEE
EOP
}
set_led () {
cat <<'EOLED'
2) LED timeout setting:
10S time out: 0xAA 0xBB 0x03 0x03 0x0A 0xEE
30S time out: 0xAA 0xBB 0x03 0x03 0x1E 0xEE
Never time out: 0xAA 0xBB 0x03 0x03 0x00 0xEE
EOLED
}
set_buzzer () {
cat <<'EOB'
3) Mute buzzer: 0xAA 0xBB 0x03 0x02 0x00 0xEE
4) Unmute buzzer: 0xAA 0xBB 0x03 0x02 0x01 0xEE
EOB
}
get_active_port () {
cat <<'EOAP'
5) Read current active input port:
0xAA 0xBB 0x03 0x10 0x00 0xEE
6) Feedback current active input port (From switch to PC)
0xAA 0xBB 0x03 0x11 0xXX 0xEE
Note: 0xXX indicates current active input port of the switch, 0x00->PC1, 0x01->PC2,
0x02->PC3...0x0F->PC16
EOAP
}
send_command () {
: ${TARGET_IP:='192.168.1.10'} \
${TARGET_PORT:='5000'} \
${PREAMBLE:='\xAA\xBB\x03'} \
${TERMINATOR:='\xEE'} \
${FUNCTION:='\x01'} \
${FUNCTION_ARG:='\x01'}
# function map is:
# change port \x01
# function_arg for port is \x01 - \x10 (for 16)
# change buzzer \x02
# change LED is \x03
# Could use decimal to hex conversion to accept port 10 and transmit \x0A or 16 \x10 (they didn't start at zero for the index which makes the port and value match)
echo -n -e "${PREAMBLE}\x01\x02${TERMINATOR}" | nc -w1 ${DEBUG:+'-v'} $TARGET_IP $TARGET_PORT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment