Giter VIP home page Giter VIP logo

npm-aprs-parser's Introduction

npm-aprs-parser

JavaScript library for parsing APRS packets.

Code Example

    const aprs = require("aprs-parser");
    
    const parser = new aprs.APRSParser();

    console.log(parser.parse("SQ7PFS-10>APRS,TCPIP*,qAC,T2SYDNEY:@085502h4903.50N/07201.75W-PHG5132Hello world/A=001234"));
    console.log();
    console.log(parser.parse("SQ7PFS-10>S32U6T,TCPIP*,qAC,T2SYDNEY:`(_fn\"Oj/>Hellov"));

Output:

    APRSMessage {
      from: Callsign { ssid: '10', call: 'SQ7PFS' },
      to: Callsign { call: 'APRS' },
      via: 
       [ Callsign { call: 'TCPIP*' },
         Callsign { call: 'qAC' },
         Callsign { call: 'T2SYDNEY' } ],
      raw: 'SQ7PFS-10>APRS,TCPIP*,qAC,T2SYDNEY:@085502h4903.50N/07201.75W-PHG5132Hello world/A=001234',
      data: 
       Position {
         latitude: 49.05833333333333,
         longitude: -72.02916666666667,
         symbol: '/-',
         symbolIcon: 'Home',
         extension: PHG { heightFeet: 20, gaindB: 3, directivityDeg: 90, powerWatts: 25 },
         altitude: 376.1232,
         comment: 'Hello world',
         timestamp: Mon Feb 27 2017 09:55:02 GMT+0100 (CET),
         msgEnabled: true } }
    
    APRSMessage {
      from: Callsign { ssid: '10', call: 'SQ7PFS' },
      to: Callsign { call: 'S32U6T' },
      via: 
       [ Callsign { call: 'TCPIP*' },
         Callsign { call: 'qAC' },
         Callsign { call: 'T2SYDNEY' } ],
      raw: 'SQ7PFS-10>S32U6T,TCPIP*,qAC,T2SYDNEY:`(_fn"Oj/>Hellov',
      data: 
       MICEPosition {
         latitude: 33.42733333333334,
         longitude: -12.129,
         mice: 'returning',
         symbol: '/j',
         symbolIcon: 'Jeep',
         extension: CourseSpeed { courseDeg: 251, speedMPerS: 10.28888888 },
         radio: 'Kenwood TH-D7A Mobile',
         comment: 'Hello' } }

Code Example - weather station support

    const aprs = require("aprs-parser");
    
    const parser = new aprs.APRSParser();

    console.log(parser.parse("FW7233>APRS,TCPXX*,qAX,CWOP-2:@231821z5150.13N/01913.68E_239/003g010t042r000p011P011b09969h83L000eMB51"));

Output:

APRSMessage {
  from: Callsign { call: 'FW7233' },
  to: Callsign { call: 'APRS' },
  via: [
    Callsign { call: 'TCPXX*' },
    Callsign { call: 'qAX' },
    Callsign { ssid: '2', call: 'CWOP' }
  ],
  raw: 'FW7233>APRS,TCPXX*,qAX,CWOP-2:@231821z5150.13N/01913.68E_239/003g010t042r000p011P011b09969h83L000eMB51',
  data: Position {
    latitude: 51.8355,
    longitude: 19.228,
    symbol: '/_',
    symbolIcon: 'WX Station',
    extension: CourseSpeed { courseDeg: 239, speedMPerS: 1.543333332 },
    weather: {
      windGust: 4.4704,
      temperature: 5.555555555555555,
      rain1h: 0,
      rain24h: 2.794,
      rainSinceMidnight: 2.794,
      pressure: 996.9,
      humidity: 83,
      luminosity: 0
    },
    comment: 'eMB51',
    timestamp: 2021-01-23T18:21:00.000Z,
    msgEnabled: true
  }

For WX stations with position CourseSpeed extension is used to represent wind speed and direction. Units used in weather report:

  • rain1h, rain24h, rainSinceMidnight - millimeters
  • windGust - meters per second
  • temperature - Celcius
  • pressure - millibars
  • luminosity - watts per square meter
  • snow - centimeters
  • humidity - %

Code Example - APRS Stream

This library also supports connecting to the APRS "firehose". An amateur radio license is required to connect.

    const aprs = require("aprs-parser");
    const stream = new aprs.APRSISConnector;
    stream.connect('YOUR-AMATEUR-RADIO-CALLSIGN');
    
    stream.on('aprs', (event)=>{
        console.log(event)
    });

Installation

$ npm install aprs-parser --save

Supported data types

  • Position
  • Objects
  • Current MIC-E
  • Telemetry
  • Messages
  • Status reports
  • Weather

License

Library is licensed under the GNU Lesser General Public License.

Library by adriann0 with Kris Linquist as an additional contributor.

npm-aprs-parser's People

Contributors

adriann0 avatar dependabot[bot] avatar klinquist avatar tjcoffey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

npm-aprs-parser's Issues

Client side usage

This module seems to work fine on the client side, except that APRSISConnector.js requires some nodejs specific modules (net and readline). Is it possible to only include that file when running on nodejs? I'm currently using Webpack, but would be open to something else if you have another suggestion.

Base91 Telemetry Digital Values

Didn't look closely enough at the existing Telemetry class tests when I wrote the Base91 parser. You're using true/false, mine used 1/0 for the digital values. PR incoming to fix it.
Also realized that adding the telemetry object to both Position and MICEPosition was redundant, so I've removed it from MICEPosition. Wasn't breaking anything, but this is cleaner.

Error when parsing altitude

I was playing around with this package this morning, just trying to capture and parse my own data for a private project I'm working on. Kept running into the Error when parsing altitude error found here

I am using APRSDroid and just sending packets from my phone. What I noticed is that the app is sending my altitude over as /A=-00072. This doesn't appear to work with the regex match: altitudeString.match('^[0-9]{6,6}$'). Seems that it is failing in two places, first being the - character. I am on the coast in a flood zone so my location is actually below sea level, and the second is that the matcher here is looking for exactly 6 digits and my altitude only has 5.

I was able to resolve this by changing the regex to '^-?[0-9]{5,6}$' which makes the - optional and will accept 5 or 6 digits for the altitude. I'm not sure if this is still accurate but it appears to be working. After changing the regex and running my script again I can now see the Position in the parsed message.

Do you think this is a valid fix for this problem? Why does the current implementation require a positive altitude of exactly 6 characters? I'll admit, I didn't dive deep enough to see if allowing negative altitudes would cause any other problems in the project. Was just curious if this would be something worth updating?

Add Base91 compressed telemetry support

Add base91 compressed telemetry per the spec found here: http://he.fi/doc/aprs-base91-comment-telemetry.txt

I've started working on this over in my fork here but am unsure of the best way to proceed and could use some advice from those more familiar with this codebase. Here's where I'm at:

After rereading the spec, base91 TM can occur in the comment field of all three position report types (uncompressed, compressed, and MIC-E). I've broken the parser out into its own class instead of shoving it in the MIC-E position parsing. The commit referenced above just adds the new parser to the end of the parser list. When used like that, it ends up replacing the Position object in data with a Telemetry object, which is broken. For example, the previous parser:

N0CALL>APRS,qAR,IGATE:!6304.03NN02739.63E#PHG26303/Siilinjarvi|"p%T'.agff|
APRSMessage {
  from: Callsign { call: 'N0CALL' },
  to: Callsign { call: 'APRS' },
  via: [ Callsign { call: 'qAR' }, Callsign { call: 'IGATE' } ],
  raw:
   'N0CALL>APRS,qAR,IGATE:!6304.03NN02739.63E#PHG26303/Siilinjarvi|"p%T\'.agff|',
  data:
   Position {
     latitude: 63.067166666666665,
     longitude: 27.6605,
     symbol: 'N#',
     extension:
      PHG { heightFeet: 640, gaindB: 3, directivityDeg: 0, powerWatts: 4 },
     comment: '3/Siilinjarvi|"p%T\'.agff|',
     msgEnabled: false } }

With the new parser in the list:

APRSMessage {
  from: Callsign { call: 'N0CALL' },
  to: Callsign { call: 'APRS' },
  via: [ Callsign { call: 'qAR' }, Callsign { call: 'IGATE' } ],
  raw:
   'N0CALL>APRS,qAR,IGATE:!6304.03NN02739.63E#PHG26303/Siilinjarvi|"p%T\'.agff|',
  data:
   Telemetry { id: 170, analog: [ 415, 559, 5894, 6348 ], digital: [] } }

So that was dumb. When I look at this now, I feel like this telemetry makes most sense as a PositionExtension. Those parsers get called on position messages, and work by parsing the extension and removing the string from the comment. As far as I can tell, those parsers are only looking for one extension, though. Base91 can occur alongside some of the position extensions (see the packet above with PHG extension and base91 TM).

Any thoughts on the best place to integrate this?

Unable to parse location

I haven't had a chance to troubleshoot this one yet... but aprs.fi parses this location just fine, but npm-aprs-parser does not (doesn't return a data object):

AF6HO-2>SWRTSY,WIDE2-2,qAR,WA5ZNU-10:'2[^""qj/]"4)}

It can be found on aprs.fi with the timestamp 2017-02-27 12:15:20 CST
http://aprs.fi/?c=raw&call=AF6HO-2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.