Created
September 22, 2018 17:35
-
-
Save psfleming/b8b440d271404ce50fca0431befdb98a to your computer and use it in GitHub Desktop.
Set FT8Call gps grid using gpsd and api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gpsd_client' | |
require 'maidenhead' | |
require 'socket' | |
require 'json' | |
ft8call_port = 2237 | |
gpsd = GpsdClient::Gpsd.new() | |
gpsd.start() | |
apicmd = {} | |
# get maidenhead if gps is ready | |
if gpsd.started? | |
pos = gpsd.get_position | |
maid = Maidenhead.to_maidenhead(pos[:lat], pos[:lon], precision = 5) | |
puts "lat = #{pos[:lat]}, lon = #{pos[:lon]}, grid = #{maid}" | |
apicmd = {:type => "STATION.SET_GRID", :value => maid} | |
end | |
# send if we have data | |
Socket.udp_server_loop(ft8call_port) { |msg, msg_src| | |
if apicmd.length > 0 then | |
puts "Sending #{apicmd}" | |
msg_src.reply apicmd.to_json | |
break | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment