Class: PostRunner::EPO_Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/postrunner/EPO_Downloader.rb

Overview

This class can download the current set of Extended Prediction Orbit data for GPS satellites and store them in the EPO.BIN file format. Some Garmin devices pick up this file under GARMIN/GARMIN/REMOTESW/EPO.BIN.

Constant Summary collapse

@@URI =
URI('https://omt.garmin.com/Rce/ProtobufApi/EphemerisService/GetEphemerisData')
@@POST_DATA =

This is the payload of the POST request. It was taken from www.kluenter.de/garmin-ephemeris-files-and-linux/. It may contain a product ID or serial number.

"\n-\n\aexpress\u0012\u0005de_DE\u001A\aWindows\"\u0012601 Service Pack 1\u0012\n\b\x8C\xB4\x93\xB8\u000E\u0012\u0000\u0018\u0000\u0018\u001C\"\u0000"
@@HEADER =
{
  'Garmin-Client-Name' => 'CoreService',
  'Content-Type' => 'application/octet-stream',
  'Content-Length' => '63'
}

Instance Method Summary collapse

Constructor Details

#initializeEPO_Downloader

Create an EPO_Downloader object.



36
37
38
39
40
41
# File 'lib/postrunner/EPO_Downloader.rb', line 36

def initialize
  @https = Net::HTTP.new(@@URI.host, @@URI.port)
  @https.use_ssl = true
  @request = Net::HTTP::Post.new(@@URI.path, initheader = @@HEADER)
  @request.body = @@POST_DATA
end

Instance Method Details

#download(output_file) ⇒ Object

Download the current EPO data from the Garmin server and write it into the specified output file.

Parameters:

  • output_file (String)

    The name of the output file. Usually this is ‘EPO.BIN’.



47
48
49
50
51
52
53
54
55
56
# File 'lib/postrunner/EPO_Downloader.rb', line 47

def download(output_file)
  return false unless (epo = get_epo_from_server)
  return false unless (epo = fix(epo))
  return false unless check_epo_data(epo)
  write_file(output_file, epo)
  Log.info "Extended Prediction Orbit (EPO) data has been downloaded " +
           "from Garmin site."

  true
end