Skip to content

Instantly share code, notes, and snippets.

@jdawgaz
Last active November 8, 2019 03:40
Show Gist options
  • Save jdawgaz/579e153535d27a79266688af9fd9c06c to your computer and use it in GitHub Desktop.
Save jdawgaz/579e153535d27a79266688af9fd9c06c to your computer and use it in GitHub Desktop.
js8call code
#!/usr/bin/env ruby
# Script to get callsign data
# usage: gcs callsign
#
# this ruby script uses nokogiri
# which must be installed:
# sudo gem install nokogiri
#
# prerequisite for nokogiri is ruby-dev
# install that by: sudo apt-get install ruby-dev
require 'open-uri'
require 'nokogiri'
baseurl = 'https://www.hamqth.com/'
cs = ARGV[0].upcase
url = baseurl + cs
printf "Callsign: %s\n", cs
def mkdata(tr)
itxt = tr.text
data = itxt.lstrip.rstrip.split(':')
end
doc = Nokogiri::HTML(open(url))
data = doc.css('tr')
data.each {|d|
case d.text
when /Name:/
data = mkdata(d)
printf "%-8s : %-20s\n", data[0], data[1]
when /QTH:/
data = mkdata(d)
printf "%-8s : %-20s\n", data[0], data[1]
when /State:/
data = mkdata(d)
printf "%-8s : %-20s\n", data[0], data[1]
when /Country:/
data = mkdata(d)
printf "%-8s : %-20s\n", data[0], data[1]
when /Grid:/
data = mkdata(d)
printf "%-8s : %-20s\n", data[0], data[1]
end
}
puts " "
puts "worked before (JS8):"
exec("awk -F, '{print $1, $5}' $HOME/.local/share/JS8Call/js8call.log | grep -i #{cs}")
#!/usr/bin/env ruby
# NOTE: this script uses the gcs script to get the details of the callsign
# and it EXPECTS the gcs script to be in the "/home/pi/bin" directory
# if you put gcs into another directory, then change the line which
# does the 'exec' statement
# this script interrogates js8call to find out what callsign is currently SELECTED
# and automatically calls gcs, to find out the details.
# this works just fine on the Raspberry Pi
# usage: js8gcs [-n]
require 'socket'
require 'json'
opt = ARGV[0]
host = 'localhost'
port = 2237
s = UDPSocket.new
s.bind(host, port)
jstr = '{"params": {}, "type": "RX.GET_CALL_SELECTED"}'
# js8call is the client. So act as a server ought to and recv connection
# from client
data, client = s.recvfrom(1024)
# now client[1] is the socket of the client
# so send the jstr to client[1]
s.send(jstr, 0, host, client[1])
# now get data from a connection
data, client = s.recvfrom(1024)
# convert to a hash and print the "value"
jdata = JSON.parse(data)
#puts jdata["value"]
s.close
# I have a gcs script that prints out pertinent info
# given a callsign
unless opt
exec("/home/pi/bin/gcs #{jdata['value']}")
else
puts jdata['value']
end
#!/usr/bin/env ruby
if ARGV.empty?
puts <<there
usage: js8rst [sn]
S/N (dB) RST
------------- ---
≤ –19 529
–18 to –13 539
–12 to –7 549
–6 to –1 559
0 to 5 569
6 to 11 579
12 to 17 589
≥ 18 599
there
exit 0
end
snval = ARGV[0].to_i
rstval = case snval
when -1000...-19 # to make case work, I used value of -1000.
529
when -18...-13
539
when -12...-7
549
when -6...-1
559
when 0...5
569
when 6...11
579
when 12...17
589
when 18...1000 # to make the case work, I used max val of 1000.
599
end
puts rstval
#!/usr/bin/env bash
# send aprs message to a callsign
# this uses the following format
# APRS::<callsign padded on the right side with spaces to 9>:message{sequence}
# the above string is sent via JS8Call via @ALLCALL
if [ "$#" == "0" ]; then
echo "usage: js8sendaprsmsg callsign seq-no message"
echo " example: js8sendaprsmsg k7azj 01 hello there"
exit 0
fi
cs=$1
shift
seq=$1
shift
msg="$*"
#echo $addr
#echo $seq
#echo $msg
value=$(printf '\"@ALLCALL APRS::%-9s:%s{%s}\"' ${cs} "${msg}" ${seq})
printf 'sending %s\n' "$value" # beware: can't use echo here
printf '{"params": {}, "type": "TX.SEND_MESSAGE", "value": %s}\n' "${value}" | nc -l -u -w 10 2237
#!/usr/bin/env bash
if [ "$#" == "0" ]; then
echo "usage: js8sendemail2 email@address seq-no message"
echo " example: js8sendemail2 email@address 03 hello"
exit 0
fi
addr=$1
shift
seq=$1
shift
msg="$*"
#echo $addr
#echo $seq
#echo $msg
value="\"@ALLCALL APRS::EMAIL-2 :${addr} ${msg} {${seq}}\""
echo sending $value
printf '{"params": {}, "type": "TX.SEND_MESSAGE", "value": %s}\n' "${value}" | nc -l -u -w 10 2237
#!/usr/bin/env bash
# put your own grid here instead
printf '{"params": {}, "type": "TX.SEND_MESSAGE", "value": "@ALLCALL GRID DM33XI09CF"}\n' | nc -l -u -w 10 2237
#!/usr/bin/env bash
if [ "$#" == "0" ]; then
echo "usage: js8sendsms phone_number message"
echo " example: js8sendsms 1112223456 hello"
exit 0
fi
phone=$1
shift
msg="$*"
value="\"@ALLCALL APRS::SMSGTE :@${phone} ${msg}\""
echo sending $value
printf '{"params": {}, "type": "TX.SEND_MESSAGE", "value": %s}\n' "${value}" | nc -l -u -w 10 2237
Brad Martin (KG5SPR)
send_logs script which uploads adif file to eQSL.cc and LOTW
located here:
https://gitlab.com/emclinux/send-logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment