Lost connection to MySQL server at 'reading initial communication packet', system error: 111Lost connection to MySQL server at 'reading initial communication packet', system error: 111Lost connection to MySQL server at 'reading initial communication packet', system error: 111 OpenAPRS - Direct Client Connection Documentation
Links: [OpenAPRS]

OpenAPRS - Direct Client Connections

Introducing a new concept: Direct Client Connections to OpenAPRS

Ever wish your smart phone (Blackberry / iPhone) could easily send your position over the APRS-IS network? Or even better beacon your position just like an APRS capable radio? Think of the possibilities! Ever wish you could send or receive APRS messages from your embeded device (smart phone, PDA etc)? Is it annoying that you have to link your APRS software to an APRS-IS server and wait for minutes before you get a partial feed and begin seeing stations in your area? Wouldn't it be amazing if your APRS software on your computer could query a centeralized database based on your current map view and display all of the current stations within the view area like OpenAPRS does with Google Maps? Wouldn't it be nice to be able to get a telemetry or position history for a stations even though you just turned on your machine and opened up your APRS software?

If you've answered yes to any of these questions, perhaps OpenAPRS's NEW Direct Client Connection (DCC) interface is the answer. The concept behind DCC is fairly simple, in order to store a history for a station or know instantly where a station is, someone has to store that data in realtime via a database, typically an SQL server. Conveniently OpenAPRS already does this, but up until this point besides using our free XML interface this doesn't help the common software developer. XML is clunky and takes a lot more time to parse and process than our new DCC interface.

So what's the catch?

The catch is, though we've spent countless hours developing an interface to make client->server queries for embeded devices and PC software simpler, no software supports the interface yet and to the best of my knowledge no software has been written to add realtime APRS positioning support to Blackberry's or iPhones. My next step is to write a simple program for the iPhone to allow it to send it's GPS position using OpenAPRS's new DCC interface and then expand the program enabling full messaging support.

What can I do to help this interface gain support?

That's easy, drop your favorite APRS software developer a note and ask them to add support for the OpenAPRS DCC interface. Or, even better, if you're a Blackberry or iPhone software developer consider starting a project to write realtime APRS position and messaging support, I'd be happy to help you along with the DCC interface to get the program up and running.

Below is the documentation for the new DCC interface:

Connecting, Authenticating and Simple Queries Using OpenAPRS DCC

Connecting to DCC is fairly simple, make a TCP connection to "dcc.openaprs.net" port 2620 and send your login string. You must have an account at OpenAPRS which requires an active email address. To send position, objects or messages your license must be verified through OpenAPRS's license verification system. Once you've setup your account on our main page www.openaprs.net (under the Options icon) you can login to DCC. For this example I'll use "user@gmail.com" and "logmein" as the password. The client field is totally optional, however we request software developers use this field to tell us what client is using DCC. Every reply from the DCC server has a reply number to make parsing data from the server an easy task.


telnet dcc.openaprs.net 2620
Connected to localhost.
Escape character is '^]'.
001 MS:I am a OpenAPRS v1.01.02.
002 MS:Please login by typing ``.LN <email> <password> [client]''
.LN user@gmail.com logmein
100 MS:Login successful.
109 CL:NV6G
106 MS:Ping?
500 MS:OK!


Periodically the server will send a "PING" message to the client (once every 90 seconds), this is reply number "106", in order to stay connected the client must immediately (within 180 seconds) reply with the "PONG" message command ".PN".

What is the "MS:" portion before the reply message?

All communications to or from the server with the exception of the login command use a special format in the form of:

<field name>:<field value>|<field name>:<field value>|<field name>:<field value>|...

The field name "MS:" stands for message, therefore any time you get a reply from the server you know that the field "MS:" is the message of the reply from the server. There is a list of field names below and what these fields represent. When a query is made to the database and a list of fields is returned like in the example below the fields can be returned in ANY order and will be escaped by the backslash character (\). The only characters that are escaped are the pipe (|) character and the backslash (\) character itself.


500 MS:OK!
304 AT:-18|CR:170|CT:1222701074|LA:38.270833|LN:-122.272100|NM:|SR:NV6G-2|CD:k|TB:/|TY:P
305 RS:1|MH:1|SW:0.0000|MS:1 of 1 matches returned (0.0000 seconds).

In the example above you will see that I requested the last position (.LP command) for any stations with the callsign of "NV6G-2". Again note that I used another field token in my request, "CL:" which stands for "CALLSIGN". The field tokens available along with the command list can be found later in this document. Most field tokens are 2 characters, however, there are some 3 character tokens and there is no length restriction so future revisions may have new field tokens with longer field names. I tried to keep the field tokens to 2-3 characters in order to keep bandwidth to a minimum. The query above also supports wildcards so you can ".LP CL:NV*" which will cause the server to match any last position report with a callsign matching "NV". The hard limit for all results returned is 1000 records, you will notice that in the case of multiple results returned there will always be a last reply from the server containing the number of results returned, the number of total matches (so you can tell in cases of truncation) and the number of seconds (down to milliseconds) the query took to complete.

Here is an example of a C++ routine to parse the field token list with their associated values, this routine automatically removes any escaping as it goes (uncomment the debuging cout statements to see the fields and values parsed):

EXAMPLE C++ Parser

  typedef map<string, string> varMapType;

  const unsigned int Parse(const string &varMe, varMapType &varMap) {
    bool isEscaped;
    string name, field, parseMe;
    unsigned int pos;
    // initialize variables
    parseMe = varMe;

    // format is field:message|field:message|...
    while(parseMe.length()) {      
      // store field name
      name = "";
      for(pos=0; pos < parseMe.length() && parseMe[pos] != ':'; pos++)
        name += parseMe[pos]; 
      parseMe.erase(0, pos+1);
      //cout << "name(" << name << ")" << endl;
      //cout << "parseMe(" << parseMe << ")" << endl;
      // try and get field data
      field = "";
      for(pos=0; pos < parseMe.length(); pos++) {
        if (!isEscaped && parseMe[pos] == '|')
        if (!isEscaped && parseMe[pos] == '\\')
          isEscaped = true;
        else {   
          isEscaped = false;
          field += parseMe[pos];   
        } //else
      } // for  
      parseMe.erase(0, pos+1);
      //cout << "field(" << field << ")" << endl;
      if (name.length() > 0 && field.length() > 0)
        varMap.insert(pair(name, field));
    } // while
    return varMap.size();
  } // Parse

This should be fairly simple to translate to other languages.

Click here for an example PERL script.

Checking Your APRS Messages

Messaging support:

OpenAPRS DCC has full messaging support built in. This means that DCC acts just as your APRS enabled radio would and supports ACK or REPLY-ACKS. Any messages sent through the DCC messaging interface have the potential of being gated to RF so FCC regulations apply and sending a message requires that your license be verified with us first.

The DCC messaging system works very similar to a POP3 email account. You can check and send messages once messaging has been turned on by either your first call to the ".CK" (check messages) command or manually by using the ".MS ON" command.

EXAMPLE Message Session

500 MS:OK!
300 CT:1222712020|SR:NV6G-2|MS:Hello!  How are you?
300 CT:1222711876|SR:NV6G-2|MS:I'm fine to thank you.
300 CT:1222711877|SR:NV6G-2|MS:How's the weather there?
300 CT:1222711796|SR:NV6G-2|MS:Nice.
301 RS:4|MS:4 messages returned.
.CM CL:OpenAPRS|MS:Testing message system!
500 MS:OK!

As you can see above I was able to check for messages sent to me with the ".CK" command and send a message with the ".CM" command. Once you've turned on messaging any new messages will automatically be sent to you in realtime so you do not need to keep using ".CK" in order to check for new messages. Any messages received while you've got the messaging system active will automatically be ACK'ed or REPLY-ACK'ed by OpenAPRS on your behalf. Messages sent from the DCC messaging system will follow the APRS standard decay until they are ACK'ed by the receiving party.

Sending a Position Report

Sending your position:

Sending your current position report to APRS-IS is made simple through OpenAPRS DCC. See the following example:

EXAMPLE Message Session

.CP LA:38|LN:-122|TB:\\|CD:O|SP:5|CR:180
500 MS:OK!

This example creates a position report using the callsign you signed up with at 38 degrees latitude, -122 degrees longitude (both are specified in decimal format) using the \ symbol table, O symbol, moving 5 kilometers per hour due south. See the full syntax of the ".CP" command below for the list of optional arguments that can be added like ambiguity and status. Please note that the backslash (\) charcter used in the symbol table field is escaped (this is as it should be)!

Looking Up Stations by Bounding Box (latitude/longitude square)

Using bounding box to find stations in your area:

To look up stations much in the same way OpenAPRS does, specify a "bounding box" to the ".LB" command. A bounding box is simply a commas separated list of coordinates in the following format:

      BB:<north latitude>,<west longitude>,<south latitude>,<east longitude>

EXAMPLE: Stations Within Bounding Box

.LB BB:38.675326,-122.774799,37.912242,-121.802458
500 MS:OK!
304 AT:282|CT:1222724831|LA:38.492001|LN:-122.698600|NM:|SR:KF6TYS-3|CM:W2,NCAn/Santa Rosa APRS Digi|CD:#|TB:S|TY:P
304 CR:356|CT:1222724669|LA:38.094333|LN:-122.180800|NM:|SR:K6MAH-15|CM:5)}Solano ACS|CD:j|TB:/|TY:P
304 CT:1222724649|LA:38.329166|LN:-122.319000|NM:|SR:AA6AV-10|CM:1|CD:_|TB:/|TY:P
304 CT:1222724530|LA:38.366665|LN:-122.416600|NM:|SR:W6CO-5|CM:W6CO Systems - SARS - Napa|CD:#|TB:N|TY:P
304 CT:1222724454|LA:38.349167|LN:-122.580000|NM:|SR:WB6TMS-5|CM:W2,NCAn/Sonoma Mtn./SMRS|CD:#|TB:S|TY:P
304 CT:1222724396|LA:38.381332|LN:-122.400000|NM:W6CO   B|SR:W6CO-S|CM: 440 Voice 440.050 +5.00|CD:a|TB:D|TY:O
304 CT:1222724332|LA:38.146667|LN:-122.175400|NM:|SR:WB5VUL|CM: {UIV32N}|CD:_|TB:/|TY:P
304 CT:1222723977|LA:38.028332|LN:-122.633300|NM:WB6EOC-10|SR:WINLINK|CM:144.910MHz 1200 R5m RMSPacket Public|CD:a|TB:W|TY:O
304 CT:1222723861|LA:38.361668|LN:-122.300000|NM:KE6O-10|SR:WINLINK|CM:145.030MHz 1200 R5m RMSPacket EMCOMM|CD:a|TB:W|TY:O
304 CT:1222723837|LA:38.278332|LN:-122.633300|NM:KB6YNO-10|SR:WINLINK|CM:144.910MHz 1200 R5m RMSPacket Public|CD:a|TB:W|TY:O
304 CT:1222723815|LA:38.445000|LN:-122.716600|NM:K6ACS-10|SR:WINLINK|CM:144.910MHz 1200 R5m RMSPacket Public|CD:a|TB:W|TY:O
304 CT:1222723696|LA:38.416668|LN:-122.083300|NM:147.195+V|SR:VACA|CM: T123 R60m|CD:r|TB:/|TY:O
304 CT:1222723617|LA:38.283669|LN:-122.445500|NM:|SR:NJ6E-6|CM:Sonoma WX|CD:_|TB:/|TY:P
304 CT:1222722806|LA:38.381332|LN:-122.400000|NM:|SR:W6CO-B|CM: 440 Voice 440.050 +5.00|CD:&|TB:D|TY:P
304 CT:1222721911|LA:38.411999|LN:-122.113600|NM:|SR:VACA|CM:W2,NCAn, WA6TLW, Mt.Vaca, CA A=002756|CD:#|TB:S|TY:P
304 CR:123|CT:1222720109|LA:38.314333|LN:-122.286800|NM:|SR:KJ4GQV|CM:4!}|CD:O|TB:/|TY:P
304 CR:0|CT:1222718626|LA:38.244333|LN:-122.038000|NM:|SR:N6AJR-15|CM:3u}MT AIO|CD:[|TB:/|TY:P
304 CR:0|CT:1222715904|LA:38.244000|LN:-122.017800|NM:|SR:W6VVR-15|CM:3u}|CD:[|TB:/|TY:P
304 AT:34|CR:328|CT:1222714120|LA:38.280833|LN:-122.052500|NM:|SR:N6QGV-5|CM:Kevin's Truck Sonoma CA.|CD:j|TB:/|TY:P
304 AT:-18|CR:170|CT:1222701074|LA:38.270833|LN:-122.272100|NM:|SR:NV6G-2|CD:k|TB:/|TY:P
304 CR:0|CT:1222696591|LA:38.211167|LN:-122.260000|NM:|SR:KG6SYK-2|CM:4-}seaclif@comcast.net|CD:k|TB:/|TY:P
304 AT:27|CR:357|CT:1222692601|LA:38.266333|LN:-122.714300|NM:|SR:KF6CLH-14|CD:k|TB:/|TY:P
304 AT:48|CT:1222653804|LA:38.439167|LN:-122.703600|NM:|SR:KG6JSL|CM:PRSPOINT, Santa Rosa, CA|CD:-|TB:/|TY:P
304 CT:1222645780|LA:38.388832|LN:-122.595300|NM:|SR:KD6FIL|CM:Altitude 1100ft {UIV32N}|CD:-|TB:/|TY:P
304 AT:-8|CR:274|CT:1222630617|LA:38.117333|LN:-122.300100|NM:|SR:KI6LGK|CM:=|CD:>|TB:/|TY:P
304 AT:41|CR:86|CT:1222574458|LA:38.329334|LN:-122.679300|NM:|SR:W6PL-13|CD:>|TB:/|TY:P
304 CT:1222558452|LA:38.329166|LN:-122.319000|NM:|SR:AA6AV|CM:a6av@sonic.net|CD:x|TB:/|TY:P
304 CR:90|CT:1222555614|LA:38.458333|LN:-122.727300|NM:|SR:KG6PEP-3|CM:4E}|CD:j|TB:/|TY:P
304 AT:16|CR:69|CT:1222488268|LA:38.243667|LN:-122.040000|NM:|SR:KE6BEA|CM:Sean's TruckSuisun City CA.|CD:k|TB:/|TY:P
304 CT:1222453642|LA:38.028332|LN:-122.633300|NM:N6BNJ-10|SR:WINLINK|CM:144.910MHz 1200 R5m RMSPacket Public|CD:a|TB:W|TY:O
304 AT:-4|CR:136|CT:1222394028|LA:38.012165|LN:-122.517300|NM:|SR:K6PHD-9|CD:k|TB:/|TY:P
304 CR:267|CT:1222350025|LA:38.020168|LN:-121.913400|NM:|SR:K6BIV|CM:/|CD:>|TB:/|TY:P
304 CR:0|CT:1222315949|LA:38.457500|LN:-122.723500|NM:|SR:KF6TYS-7|CM:Mark's D700 & GPS3+|CD:-|TB:/|TY:P
304 AT:55|CR:199|CT:1222293365|LA:38.285000|LN:-122.443800|NM:|SR:AE6FQ-1|CD:k|TB:/|TY:P
304 AT:8|CR:137|CT:1221950900|LA:38.234833|LN:-122.260300|NM:|SR:N6JGC-7|CD:>|TB:/|TY:P
305 RS:37|MH:37|SW:0.0000|MS:35 of 35 matches returned (0.0000 seconds).

Using the ".WB" command you can also get a list of only weather stations in a given bounding box.

EXAMPLE: Weather Stations Within Bounding Box

.WB BB:38.010230251583245,-122.72964477539062,38.50304202775689,-121.89331054687501
500 MS:OK!
308 BA:1012.80|HU:46|LA:38.329166|LN:-122.319000|RH:0|SR:AA6AV-10|TM:25|WD:152|WS:7
309 RS:1|MH:1|SW:0.0000|MS:1 of 1 matches returned (0.0000 seconds).

To the naked eye these position replies appear to be confusing or difficult to understand but in fact they are very simple to parse out from software and highly expandable. APRS packets over the years have gotten more and more convoluted as new support for different methods to report data are added. The OpenAPRS DCC protocol will always be simple to parse since adding fields in the future won't affect older versions of software written for previous versions of OpenAPRS DCC.

A Note about AG: (age) and ST: (start time):

The ST: (start time) argument seen in most commands that return data from the server is the unix timestamp to begin matching from. Matching from the start time is regressive which means that instead of matching stations newer than the start time it matches all stations from the start time going back in history. To match all stations up to the current time omit the ST: argument. The AG: argument is designed to set a limit to the history of packets matched when querying for data. Omitting ST: and using AG: will match all stations that have reported from the current time back in history to the number of seconds specified as the age. For example to match any stations that have reported in the last 60 seconds omit ST: and specify AG:60. To match any stations that reported within an hour starting from 2 hours ago use ST:7200|AG:3600. Specifying time this way will allow you to look at a specific window in time if needed.

Live Feed + Filters

We've recently added a live feed command with filter support in order to allow client software to receive live updates from the APRS-IS stream in OpenAPRS's DCC format. For clients that need a more up to date feed the live feed is perferrable over using the "window" commands like .LP/.LB/.LC/etc that only give a temporary picture of what stations are where. The live feed command ".LV" acts as a toggle switch but can take arguments to filter out the data.

Send Fields Filter

Many of the "window" commands already have the SF: or "Send Fields" filter. This filter allows you to specify a commas delimited list of field tokens to be displayed when returning the requested results. This field also works with live feeds, as shown in the example below:

EXAMPLE: Send Fields Filter

317 ON:yes|MS:Live set to ON.
318 LA:14.990000|LN:102.07633|SR:HS3LIQ-3
318 LA:37.418835|LN:-122.1325|SR:KD4IDR
318 LA:36.054165|LN:-79.47599|SR:W4RSE

Above you can see that I requested the source, latitude and longitude fields to only be displayed when returning results.

Live Filters

Live filters act differently than simple bounding box or center range "window" commands. In order to create a system powerful enough to grab a wide set of results based on each individuals needs the client software will need to calculate bounding boxes or circle ranges and apply them correctly in a live filter format. With the exception of the SF: field live filters when used with the .LV command can be specified for any returnable field of the live result set. To set a filter on a field in a live result set you use the .LV command and pair it with a field set of arguments just as would be returned from a server, the difference is the set of fields will have associated filters with them separated by commas for each type of filter. The easiest way to explain this is with the following illustrations:

.LV <FIELD>:<filters separated by commands>|...|SF:<field list>

EXAMPLE: Speed Filter

.LV SP:>50,<60|SR:SP,SR
317 ON:yes|MS:Live set to ON.
318 SP:50.004|SR:VE5RWW-3
318 SP:50.00|SR:VA7GV-2
318 SP:51.856|SR:KC7KF-6

What you can see with the above example is that I asked for position reports with a speed advertised greater than 50 and less than 60. I also requested that only the speed and source callsign fields be returned in the results. As you can imagine this is also how you would specify a bounding box using the LA: and LN: fields as is shown below:

EXAMPLE: Bounding Box Filter

.LV LN:<-120,>-122|LA:>37,<38|SF:sr,la,ln
317 ON:yes|MS:Live set to ON.
318 LA:37.682333|LN:-121.1053|SR:KG6OWS-7
318 LA:37.4658|LN:-121.935|SR:NY3E-1
318 LA:37.478500|LN:-121.9403|SR:WA6PWW-7

If you don't want to try and figure out a bounding box set of filters to cover an area you can now also specify a special field, CN: (center/range) which will calculate a bounding box for you based on a center latitude, longitude and range. See the following example for details:

.LV CN:<latitude,longitude,range (in kilometers)>

EXAMPLE: Bounding Box Filter

.LV CN:38.311491,-122.318344,50
317 ON:yes|MS:Live set to ON.
318 AT:725.42|CD:#|CM:W2,NCAn/Rocky Ridge|ID:7abd8faf13e4a04e524f8614b1385bfe|LA:37.815666|LN:-122.0621|SR:W6CX-3|TB:S
318 CD:a|CM: 440 Voice 442.1125 +5.000|ID:e4724f65d7fa64d0f6e2aa8238c4cd93|LA:38.492001|LN:-122.7230|NM:K6ACS  B|SR:K6ACS-S|TB:D
318 CD:a|CM: 2m Voice 145.040 -0.400 Mhz|ID:369eba30f2e9b722ff2017ea9bb2f037|LA:38.492001|LN:-122.7230|NM:K6ACS  C|SR:K6ACS-S|TB:D

I've also added the ability to have the live data stream output as NMEA waypoints with checksums. See this example:

EXAMPLE: NMEA Waypoint Output

317 ON:yes|MS:Live set to ON.
$GPWPL,03549.00,N,10612.88,W,NM5WR  B*17

The last and most powerful way to filter a result set is by using a REGEX or regular expression match. This can be done as with the following example:

EXAMPLE: Bounding Box Filter

.LV SR:@^W6(.*)|SF:SR
317 ON:yes|MS:Live set to ON.
318 SR:W6GPS
318 SR:W6LX
318 SR:W6SLZ-9

Above you see I've filtered for any station begining with "W6" in the callsign.

Filters will always begin with >, <, = or @ to signify "greater than", "less than", "equal to" or REGEX. The greater/less than operators always compare values converted to floating point numbers, the "equal to" operator always compares as a string (no quotes required).

NOTE: When a field has a filter set on it the field MUST exist or the packet will be skipped. So if you set a filter on the SP: (speed) field and a packet comes through with no speed associated with it, the packet will be skipped and not displayed.


Lost connection to MySQL server at 'reading initial communication packet', system error: 111
Cmd Title

Field Tokens

Lost connection to MySQL server at 'reading initial communication packet', system error: 111
Name Title Name Title Name Title

Server Replies

Lost connection to MySQL server at 'reading initial communication packet', system error: 111
Reply Title Reply Title Reply Title