Tuesday, April 22, 2014

A Trusted QSL library for Java

As long time blog readers are no doubt familiar, I do quite a bit of tinkering with Android. Ham Finder is written in Android. I have wanted for some time to have a way of uploading QSLs to Logbook of the World from Ham Finder, mostly because it makes mobile logging for LOTW go from extremely difficult to a snap.

For your information, here's what I've had to do to make this work in the past:

1. Divide up my QSOs by location where they were made.
2. Sign each of these with a custom created Station identification with Trusted QSL.
3. Upload each of them.

This was a royal pain, and I want to make all of this seamless, using Ham Finder. I think I've almost got all of the pieces figured out, and so here I present them:

  1. The key piece to make this all work is a java library that runs Trusted QSL. I'm making this open sources, the code I have so far is available at GitHub.
  2. Right now Ham Finder doesn't provide ITU zones, nor CQ Zones. I'm working on adding those features. It will be most difficult for those countries (Outside of the US) which have multiple CQ/ITU zones, but I'll get something to work most of the time for now.
  3. Upload them to LOTW as needed, including corrections. This should be easy enough to manage, as all of the contacts are stored in a database already. It just involves making sure they are only sent once.
Trusted QSL is an open source bit of software written in C++. I wanted a natively coded bit of software, for a number of reasons, mostly because it's easier to maintain. I don't care about a lot of the functionality provided by Trusted QSL either, I just want to sign and upload them.

Through reading documentation, reverse engineering the TQ8 files, and even emailing the Trusted Qsl staff, I've learned a number of things. First of all, TQ8 files are GZipped files of the Global Amateur Interchange (GAbbI) file format. The latest specifications on LOTW can be found at Rick Murphy's website. In fact, there are a few key differences from the web site specification and what is actually used. The key differences are as follows:

  1. All of the data for signing is upper case.
  2. The order of fields for the signed data is: CA_PROVINCE, CQZ, GRIDSQUARE, IOTA, ITUZ, US_COUNTY, US_STATE, BAND, BAND_RX, CALL, FREQ, FREQ_RX, MODE, PROP_MODE, QSO_DATE, QSO_TIME, SAT_NAME. Note that station comes first, then QSO data. 
  3. There are several undocumented fields, including CA_PROVINCE, US_STATE, SIGNDATA, and SIGN_LOTW_V1.0. SIGNDATA is the data signed for the LOTW signature, SIGN_LOTW_V1.0 is the LOTW signature itself. CA__PROVINCE and US_STATE are the Canadian Province and US state.
  4. SIGN_LOTW_V1.0 has a :6 after the number of digits. I can't actually figure out what this means...
  5. The max space per row is actually 64, not 72 as specified.
  6. The character count includes line breaks, and if there is any line breaks, it also counts the last line break. For a single line, it doesn't count the final line break.
  7. The signature format is SHA1withRSA.
As of right now, I have the library published, have had Logbook of the World accept it, and am working on integrating the library into Ham Finder. Hopefully it will work great!