Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Commit 06aa94a

Browse files
committed
refactor: rename A-GPS to A-GNSS
Fixes #134 BREAKING CHANGE: this renames exported members
1 parent 43ab3b9 commit 06aa94a

10 files changed

Lines changed: 72 additions & 65 deletions

File tree

.github/workflows/api-tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ on:
99
env:
1010
API_HOST: ${{ secrets.API_HOST }}
1111
TEAM_ID: ${{ secrets.TEAM_ID }}
12-
AGPS_SERVICE_KEY: ${{ secrets.AGPS_SERVICE_KEY }}
12+
AGNSS_SERVICE_KEY: ${{ secrets.AGNSS_SERVICE_KEY }}
1313
PGPS_SERVICE_KEY: ${{ secrets.PGPS_SERVICE_KEY }}
1414
GROUNDFIX_SERVICE_KEY: ${{ secrets.GROUNDFIX_SERVICE_KEY }}
1515
API_KEY: ${{ secrets.API_KEY }}
1616
EVALUATION_TOKEN: ${{ secrets.EVALUATION_TOKEN }}
1717

1818
jobs:
19-
agps:
20-
name: A-GPS Service API verification tests
19+
agnss:
20+
name: A-GNSS Service API verification tests
2121
runs-on: ubuntu-22.04
2222
steps:
2323
- uses: actions/setup-node@v4
2424
with:
2525
node-version: "20.x"
2626
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
2727
- run: npm ci
28-
- run: npx tsx --test ./api-verification/agps.spec.ts
28+
- run: npx tsx --test ./api-verification/agnss.spec.ts
2929
pgps:
3030
name: P-GPS Service API verification tests
3131
runs-on: ubuntu-22.04

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Configure these environment variables:
1515

1616
- `API_HOST` (optional, endpoint to run the tests against)
1717
- `TEAM_ID`
18-
- `AGPS_SERVICE_KEY`
18+
- `AGNSS_SERVICE_KEY`
1919
- `PGPS_SERVICE_KEY`
2020
- `GROUNDFIX_SERVICE_KEY`
2121

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
import { AGPSMessage, SCHEMA_VERSION, verify } from '../src/verify-agps-data.js'
1+
import {
2+
AGNSSMessage,
3+
SCHEMA_VERSION,
4+
verify,
5+
} from '../src/verify-agnss-data.js'
26
import { apiClient, tokenAuthorization } from './api-client.js'
37
import { describe, it } from 'node:test'
48
import assert from 'node:assert/strict'
59

610
const { getBinary, head } = apiClient({
711
endpoint: process.env.API_HOST,
812
authorizationToken: tokenAuthorization({
9-
tokenKey: process.env.AGPS_SERVICE_KEY ?? '',
13+
tokenKey: process.env.AGNSS_SERVICE_KEY ?? '',
1014
tokenPayload: {
1115
aud: process.env.TEAM_ID,
1216
},
1317
}),
1418
})
1519

16-
void describe('AGPS', () => {
20+
void describe('AGNSS', () => {
1721
void describe('chunking', () => {
1822
void describe('use HEAD request to get response size', () => {
19-
const agpsReq = {
23+
const agnssReq = {
2024
deviceIdentifier: 'TestClient',
2125
mcc: 242,
2226
mnc: 2,
@@ -26,17 +30,20 @@ void describe('AGPS', () => {
2630
}
2731
let chunkSize: number
2832

29-
void it('should describe length of A-GPS data', async () => {
30-
const res = await head({ resource: 'location/agps', payload: agpsReq })
33+
void it('should describe length of A-GNSS data', async () => {
34+
const res = await head({
35+
resource: 'location/agnss',
36+
payload: agnssReq,
37+
})
3138
chunkSize = parseInt(res.get('content-length') ?? '0', 10)
3239
assert.equal(chunkSize > 0, true)
3340
})
3441

35-
void it('should return A-GPS data', async () => {
42+
void it('should return A-GNSS data', async () => {
3643
assert.equal(chunkSize > 0, true) // chunk size should have been set
3744
const res = await getBinary({
38-
resource: 'location/agps',
39-
payload: agpsReq,
45+
resource: 'location/agnss',
46+
payload: agnssReq,
4047
headers: {
4148
'Content-Type': 'application/octet-stream',
4249
Range: `bytes=0-${chunkSize}`,
@@ -47,12 +54,12 @@ void describe('AGPS', () => {
4754
// Verify response
4855
const verified = verify(res)
4956
assert.equal('error' in verified, false)
50-
assert.equal((verified as AGPSMessage).schemaVersion, SCHEMA_VERSION)
57+
assert.equal((verified as AGNSSMessage).schemaVersion, SCHEMA_VERSION)
5158
})
5259

5360
void it('should chunk large responses', async () => {
5461
const res = await getBinary({
55-
resource: 'location/agps',
62+
resource: 'location/agnss',
5663
payload: {
5764
mcc: 242,
5865
mnc: 2,
@@ -71,18 +78,18 @@ void describe('AGPS', () => {
7178
// Verify response
7279
const verified = verify(res)
7380
assert.equal('error' in verified, false)
74-
assert.equal((verified as AGPSMessage).schemaVersion, SCHEMA_VERSION)
75-
assert.equal((verified as AGPSMessage).entries.length, 1)
76-
assert.equal((verified as AGPSMessage).entries[0].type, 2)
77-
assert.equal((verified as AGPSMessage).entries[0].items > 0, true)
81+
assert.equal((verified as AGNSSMessage).schemaVersion, SCHEMA_VERSION)
82+
assert.equal((verified as AGNSSMessage).entries.length, 1)
83+
assert.equal((verified as AGNSSMessage).entries[0].type, 2)
84+
assert.equal((verified as AGNSSMessage).entries[0].items > 0, true)
7885
})
7986
})
8087
})
8188

8289
void describe('should support 8 types', () => {
8390
for (const type of [1, 2, 3, 4, 6, 7, 8, 9]) {
8491
void it(`should resolve custom type ${type}`, async () => {
85-
const agpsReq = {
92+
const agnssReq = {
8693
mcc: 242,
8794
mnc: 2,
8895
eci: 33703712,
@@ -92,15 +99,15 @@ void describe('AGPS', () => {
9299
}
93100

94101
const headRes = await head({
95-
resource: 'location/agps',
96-
payload: agpsReq,
102+
resource: 'location/agnss',
103+
payload: agnssReq,
97104
})
98105
const chunkSize = parseInt(headRes.get('content-length') ?? '0', 10)
99106
assert.equal(chunkSize > 0, true)
100107

101108
const res = await getBinary({
102-
resource: 'location/agps',
103-
payload: agpsReq,
109+
resource: 'location/agnss',
110+
payload: agnssReq,
104111
headers: {
105112
'Content-Type': 'application/octet-stream',
106113
Range: `bytes=0-${chunkSize}`,
@@ -111,17 +118,17 @@ void describe('AGPS', () => {
111118
// Verify response
112119
const verified = verify(res)
113120
assert.equal('error' in verified, false)
114-
assert.equal((verified as AGPSMessage).schemaVersion, SCHEMA_VERSION)
115-
assert.equal((verified as AGPSMessage).entries.length, 1)
116-
assert.equal((verified as AGPSMessage).entries[0].type, type)
117-
assert.equal((verified as AGPSMessage).entries[0].items > 0, true)
121+
assert.equal((verified as AGNSSMessage).schemaVersion, SCHEMA_VERSION)
122+
assert.equal((verified as AGNSSMessage).entries.length, 1)
123+
assert.equal((verified as AGNSSMessage).entries[0].type, type)
124+
assert.equal((verified as AGNSSMessage).entries[0].items > 0, true)
118125
})
119126
}
120127
})
121128

122129
void it('should combine types', async () => {
123130
const types = new Set([1, 3, 4, 6, 7, 8, 9])
124-
const agpsReq = {
131+
const agnssReq = {
125132
mcc: 242,
126133
mnc: 2,
127134
eci: 33703712,
@@ -131,15 +138,15 @@ void describe('AGPS', () => {
131138
}
132139

133140
const headRes = await head({
134-
resource: 'location/agps',
135-
payload: agpsReq,
141+
resource: 'location/agnss',
142+
payload: agnssReq,
136143
})
137144
const chunkSize = parseInt(headRes.get('content-length') ?? '0', 10)
138145
assert.equal(chunkSize > 0, true)
139146

140147
const res = await getBinary({
141-
resource: 'location/agps',
142-
payload: agpsReq,
148+
resource: 'location/agnss',
149+
payload: agnssReq,
143150
headers: {
144151
'Content-Type': 'application/octet-stream',
145152
Range: `bytes=0-${chunkSize}`,
@@ -150,10 +157,10 @@ void describe('AGPS', () => {
150157
// Verify response
151158
const verified = verify(res)
152159
assert.equal('error' in verified, false)
153-
assert.equal((verified as AGPSMessage).schemaVersion, SCHEMA_VERSION)
154-
assert.equal((verified as AGPSMessage).entries.length, 7)
160+
assert.equal((verified as AGNSSMessage).schemaVersion, SCHEMA_VERSION)
161+
assert.equal((verified as AGNSSMessage).entries.length, 7)
155162
assert.deepEqual(
156-
new Set((verified as AGPSMessage).entries.map(({ type }) => type)),
163+
new Set((verified as AGNSSMessage).entries.map(({ type }) => type)),
157164
types,
158165
)
159166
})

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './verify-agps-data.js'
1+
export * from './verify-agnss-data.js'
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
33
import {
4-
AGPSType,
4+
AGNSSType,
55
DataGram,
66
SCHEMA_VERSION,
77
verify,
8-
} from './verify-agps-data.js'
8+
} from './verify-agnss-data.js'
99
import { describe, it } from 'node:test'
1010
import assert from 'node:assert/strict'
1111

1212
void describe('verify', () => {
1313
for (const [file, expected] of [
1414
[
15-
'nrfc_agpspayload1.bin',
15+
'nrfc_agnsspayload1.bin',
1616
{
1717
schemaVersion: SCHEMA_VERSION,
1818
entries: [
1919
{
20-
type: AGPSType.Ephemerides,
20+
type: AGNSSType.Ephemerides,
2121
items: 30,
2222
},
2323
],
2424
},
2525
],
2626
[
27-
'nrfc_agpspayload2.bin',
27+
'nrfc_agnsspayload2.bin',
2828
{
2929
schemaVersion: SCHEMA_VERSION,
3030
entries: [
31-
{ type: AGPSType.Almanac, items: 31 },
32-
{ type: AGPSType['GPS time of week'], items: 30 },
33-
{ type: AGPSType['GPS system clock and time of week'], items: 1 },
34-
{ type: AGPSType['Approximate location'], items: 1 },
35-
{ type: AGPSType['UTC parameters'], items: 1 },
31+
{ type: AGNSSType.Almanac, items: 31 },
32+
{ type: AGNSSType['GPS time of week'], items: 30 },
33+
{ type: AGNSSType['GPS system clock and time of week'], items: 1 },
34+
{ type: AGNSSType['Approximate location'], items: 1 },
35+
{ type: AGNSSType['UTC parameters'], items: 1 },
3636
{
37-
type: AGPSType['Klobuchar ionospheric correction parameters'],
37+
type: AGNSSType['Klobuchar ionospheric correction parameters'],
3838
items: 1,
3939
},
40-
{ type: AGPSType['Satellite integrity data'], items: 1 },
40+
{ type: AGNSSType['Satellite integrity data'], items: 1 },
4141
],
4242
},
4343
],
4444
] as [string, Record<string, unknown>][]) {
45-
void it(`should verify the A-GPS message ${file} to contain ${JSON.stringify(
45+
void it(`should verify the A-GNSS message ${file} to contain ${JSON.stringify(
4646
expected,
4747
)}`, () => {
4848
const res = verify(
@@ -59,7 +59,7 @@ void describe('verify', () => {
5959
})
6060
}
6161

62-
for (const file of ['agpspayload1.bin', 'agpspayload2.bin']) {
62+
for (const file of ['agnsspayload1.bin', 'agnsspayload2.bin']) {
6363
void it(`should not verify ${file}`, () => {
6464
const res = verify(
6565
fs.readFileSync(path.join(process.cwd(), 'test-data', file)),
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const SCHEMA_VERSION = 1
22

3-
export enum AGPSType {
3+
export enum AGNSSType {
44
'UTC parameters' = 1,
55
'Ephemerides' = 2,
66
'Almanac' = 3,
@@ -12,17 +12,17 @@ export enum AGPSType {
1212
}
1313

1414
export const datagramLength: { [type: number]: number } = {
15-
[AGPSType['UTC parameters']]: 14,
16-
[AGPSType.Ephemerides]: 62,
17-
[AGPSType.Almanac]: 31,
18-
[AGPSType['Klobuchar ionospheric correction parameters']]: 8,
19-
[AGPSType['GPS time of week']]: 4,
20-
[AGPSType['GPS system clock and time of week']]: 16,
21-
[AGPSType['Approximate location']]: 15,
22-
[AGPSType['Satellite integrity data']]: 4,
15+
[AGNSSType['UTC parameters']]: 14,
16+
[AGNSSType.Ephemerides]: 62,
17+
[AGNSSType.Almanac]: 31,
18+
[AGNSSType['Klobuchar ionospheric correction parameters']]: 8,
19+
[AGNSSType['GPS time of week']]: 4,
20+
[AGNSSType['GPS system clock and time of week']]: 16,
21+
[AGNSSType['Approximate location']]: 15,
22+
[AGNSSType['Satellite integrity data']]: 4,
2323
}
2424

25-
export type AGPSMessage = {
25+
export type AGNSSMessage = {
2626
schemaVersion: number
2727
entries: DataGram[]
2828
}
@@ -35,7 +35,7 @@ export type DataGram = {
3535
export const verify = (
3636
buf: Buffer,
3737
debug?: (message?: any, ...optionalParams: any[]) => void,
38-
): { error: Error } | AGPSMessage => {
38+
): { error: Error } | AGNSSMessage => {
3939
// First byte is schemaVersion
4040
const schemaVersion = buf.readUInt8(0)
4141

@@ -53,7 +53,7 @@ export const verify = (
5353
while (offset <= buf.length) {
5454
const type = buf.readUInt8(offset)
5555
debug?.(`Read type ${type} at ${offset}`)
56-
if (AGPSType[type] === undefined)
56+
if (AGNSSType[type] === undefined)
5757
return {
5858
error: new Error(`Encountered unsupported datagram type: ${type}`),
5959
}
@@ -68,7 +68,7 @@ export const verify = (
6868
error: new Error(
6969
`Datagram is ${
7070
offset - buf.length
71-
} bytes too short to contain ${numItems} items of ${AGPSType[type]}`,
71+
} bytes too short to contain ${numItems} items of ${AGNSSType[type]}`,
7272
),
7373
}
7474

0 commit comments

Comments
 (0)