Skip to content

Commit

Permalink
2022 12 build position (#268)
Browse files Browse the repository at this point in the history
* Ability to build compressed or normal position packet bodies.
* Cleanup
* Updates.
* Rename packetFactory.ts to PacketFactory.ts
* Condensing code
* Updating pipelines.
  • Loading branch information
KD0NKS committed Dec 23, 2022
1 parent 6bd60a8 commit 9b5467a
Show file tree
Hide file tree
Showing 15 changed files with 1,278 additions and 789 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
interval: weekly
open-pull-requests-limit: 10
versioning-strategy: increase
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
node-version: 18
check-latest: true
registry-url: 'https://registry.npmjs.org'

Expand Down
12 changes: 9 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { AbstractBuilderModel } from './src/AbstractBuilderModel'
import { BuildPositionModel } from './src/BuildPositionModel'
import aprsPacket from './src/aprsPacket'
import aprsParser from './src/parser'
import { ConversionConstantEnum } from './src/ConversionConstantEnum'
import { ConversionUtil } from './src/ConversionUtil'
import digipeater from './src/digipeater'
import { KissUtil } from './src/KissUtil'
import { PacketFactory } from './src/packetFactory'
import { PacketTypeEnum } from './src/PacketTypeEnum'
import digipeater from './src/digipeater'
import telemetry from './src/telemetry'
import { ConversionUtil } from './src/ConversionUtil'
import wx from './src/wx'

export {
aprsPacket
AbstractBuilderModel
, aprsPacket
, aprsParser
, BuildPositionModel
, ConversionConstantEnum
, ConversionUtil
, digipeater
, KissUtil
, PacketTypeEnum
, PacketFactory
, telemetry
, wx
}
47 changes: 24 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "afairhurst",
"license": "ISC",
"name": "js-aprs-fap",
"version": "1.1.8",
"version": "1.2.0",
"homepage": "https://github.com/KD0NKS/js-aprs-fap",
"description": "NodeJs library for parsing APRS packets.",
"repository": {
Expand Down Expand Up @@ -35,13 +35,13 @@
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.11",
"@types/node": "^18.11.15",
"chai": "^4.3.7",
"coveralls": "^3.1.1",
"mocha": "^10.1.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
"typescript": "^4.9.4"
}
}
125 changes: 125 additions & 0 deletions src/AbstractBuilderModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
export abstract class AbstractBuilderModel {
/**
* In decimal degrees.
*/
public latitude: number

/**
* In decimal degrees.
*/
public longitude: number

/**
* APRS symbol to use, first table/overlay and then code (two bytes).
* If string length is zero (""), uses default.
*/
public symbols: string = ""

/**
* Speed in km/h, -1 == don't include.
* NOTE! Ignored if course is null.
*/
public speed?: number = null

/**
* Course in degrees, -1 == don't include. zero == unknown course, 360 == North.
* NOTE: Ignored if speed is null.
*/
public course?: number = null

/**
* Altitude in meters above mean sea level.
* NOTE: Ignored -10000 or under is
*/
public altitude?: number = null

/**
* True if compressed format should be used.
*/
public isUseCompression: boolean = false

/**
* Unix timestamp to include in the generated packet, 0 for current time.
* Autoswitches from HMS to DHM when the timestamp is over 23 hours old
* and causes failure (returns undef) after 28 days because the timestamp
* would become ambiguous.
* Also fails if the timestamp is over 1 hour into the future
*/
public timestamp?: number = null

/**
* Comment to add to packet
*/
public comment?: string = null

/**
* Use amount (0..4) of position ambiguity.
* NOTE: Position ambiguity and compression can't be used at the same time.
*/
public ambiguity?: 1 | 2 | 3 | 4 | null = null

/**
* Use !DAO! extension for improved precision.
* Note: Ignored with compressed positions.
*/
public isUseDao: boolean = false

protected isBoolean(val: any): boolean {
return 'boolean' === typeof val;
}

constructor(options?: any) {
if(options && options != null) {
if(options["latitude"] != null && isNaN(Number(options["latitude"])) == false) {
this.latitude = Number(options["latitude"])
}

if(options["longitude"] != null && isNaN(Number(options["longitude"])) == false) {
this.longitude = Number(options["longitude"])
}

if(options["speed"] != null && isNaN(Number(options["speed"])) == false) {
this.speed = Number(options["speed"])
}

if(options["course"] != null && isNaN(Number(options["course"])) == false) {
this.course = Number(options["course"])
}

if(options["altitude"] != null && isNaN(Number(options["altitude"])) == false) {
this.altitude = Number(options["altitude"])
}

if(options["timestamp"] != null && isNaN(Number(options["timestamp"])) == false) {
this.timestamp = Number(options["timestamp"])
}

if(options["ambiguity"] != null && isNaN(Number(options["ambiguity"])) == false
&& (
Number(options["ambiguity"]) == 0
|| Number(options["ambiguity"]) == 1
|| Number(options["ambiguity"]) == 2
|| Number(options["ambiguity"]) == 3
|| Number(options["ambiguity"]) == 4
)) {
this.ambiguity = options["ambiguity"]
}

if(options["symbols"] && options["symbols"] != null) {
this.symbols = String(options["symbols"])
}

if(options["comment"] && options["comment"] != null) {
this.comment = String(options["comment"])
}

if(options["isUseCompression"] && options["isUseCompression"] != null && this.isBoolean(options["isUseCompression"])) {
this.isUseCompression = options["isUseCompression"]
}

if(options["isUseDao"] && options["isUseDao"] != null && this.isBoolean(options["isUseDao"])) {
this.isUseDao = options["isUseDao"]
}
}
}
}
20 changes: 20 additions & 0 deletions src/BuildPositionModel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AbstractBuilderModel } from './AbstractBuilderModel'

export class BuildPositionModel extends AbstractBuilderModel {
/**
* True to signal messaging capability, 0 for no messaging capability (default)
*/
public isMessagingEnabled = false

constructor(options?: any) {
if(options && options != null) {
super(options)

if(options["isMessagingEnabled"] && options["isMessagingEnabled"] != null && this.isBoolean(options["isMessagingEnabled"])) {
this.isMessagingEnabled = options["isMessagingEnabled"]
}
} else {
super()
}
}
}
10 changes: 10 additions & 0 deletions src/CompressionOriginEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum CompressionOriginEnum {
COMPRESSED = "000"
, TNC_BTEXT = "001"
, SOFTWARE = "010"
, TBD = "011"
, KPC3 = "100"
, PICO = "101"
, OTHER = "110"
, DIGIPEATER_CONVERSION = "111"
}
6 changes: 6 additions & 0 deletions src/NmeaSourceEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum NmeaSourceEnum {
OTHER = "00"
, GLL = "01"
, GGA = "10"
, RMC = "11"
}
Loading

0 comments on commit 9b5467a

Please sign in to comment.