node-red-contrib-antenna-genius 0.3.1 → 0.3.2-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ main ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ main ]
20
+ schedule:
21
+ - cron: '30 9 * * 6'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'javascript' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v2
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
@@ -0,0 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+
6
+ # This workflow integrates njsscan with GitHub's Code Scanning feature
7
+ # nodejsscan is a static security code scanner that finds insecure code patterns in your Node.js applications
8
+
9
+ name: njsscan sarif
10
+
11
+ on:
12
+ push:
13
+ branches: [ main ]
14
+ pull_request:
15
+ # The branches below must be a subset of the branches above
16
+ branches: [ main ]
17
+ schedule:
18
+ - cron: '26 7 * * 3'
19
+
20
+ jobs:
21
+ njsscan:
22
+ runs-on: ubuntu-latest
23
+ name: njsscan code scanning
24
+ steps:
25
+ - name: Checkout the code
26
+ uses: actions/checkout@v2
27
+ - name: nodejsscan scan
28
+ id: njsscan
29
+ uses: ajinabraham/njsscan-action@7237412fdd36af517e2745077cedbf9d6900d711
30
+ with:
31
+ args: '. --sarif --output results.sarif || true'
32
+ - name: Upload njsscan report
33
+ uses: github/codeql-action/upload-sarif@v1
34
+ with:
35
+ sarif_file: results.sarif
@@ -8,6 +8,8 @@ on:
8
8
  branches: [ main ]
9
9
  pull_request:
10
10
  branches: [ main ]
11
+ schedule:
12
+ - cron: '42 0 * * *'
11
13
 
12
14
  jobs:
13
15
  build:
@@ -28,6 +28,7 @@ jobs:
28
28
  node-version: 16
29
29
  registry-url: https://registry.npmjs.org/
30
30
  - run: npm ci
31
+ - run: npx auto-dist-tag --write
31
32
  - run: npm publish
32
33
  env:
33
34
  NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -169,3 +169,4 @@ const decode412 = (data) => {
169
169
 
170
170
  exports.encode = encode;
171
171
  exports.decode = decode;
172
+ exports.decodeheader = decodeheader;
package/README.md CHANGED
@@ -59,7 +59,7 @@ Port 2: Status for Radio A antenna.
59
59
 
60
60
  ### Details
61
61
 
62
- A typical workflow is to feed each output to a `button` and then map `payload.name` to the button`s `label`, and `payload.background` to the button`s `background`. Set the buttons `payload` to `true` and `Topic` to `msg.topic` when clicked and everything is setup to directly feed an `activate-antenna` node.
62
+ A typical workflow is to feed each output to a `button` and then map `payload.name` to the button's `label`, and `payload.background` to the button's `background`. Set the buttons `payload` to `true` and `Topic` to `msg.topic` when clicked and everything is setup to directly feed an `activate-antenna` node.
63
63
 
64
64
  ## antenna-genius-activate-antenna
65
65
 
@@ -1,4 +1,4 @@
1
- const Utils = require("./Utils");
1
+ const Utils = require("./GeniusUtils");
2
2
 
3
3
  module.exports = (RED) => {
4
4
  class AntennaGeniusActivateAntenna {
@@ -1,7 +1,7 @@
1
1
  const Net = require("net");
2
2
  const { PromiseSocket } = require("promise-socket");
3
3
  const EventEmitter = require("events");
4
- const Utils = require("./Utils");
4
+ const Utils = require("./GeniusUtils");
5
5
 
6
6
  class UpdatesEventEmitter extends EventEmitter {}
7
7
 
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "node-red-contrib-antenna-genius",
3
- "version": "0.3.1",
3
+ "version": "0.3.2-beta.4",
4
4
  "description": "Antenna Genius Control and Monitoring Nodes",
5
5
  "keywords": [
6
6
  "node-red"
7
7
  ],
8
8
  "scripts": {
9
- "test": "jest",
9
+ "test": "jest --coverage",
10
10
  "watch": "jest --watch",
11
11
  "start": "node ./node_modules/node-red/red.js -v -u C:/Users/dahlj.GREATSTONE/.node-red ",
12
- "debug": "node --nolazy ./node_modules/node-red/red.js -v -u C:/Users/dahlj.GREATSTONE/.node-red"
12
+ "debug": "node --nolazy ./node_modules/node-red/red.js -v -u C:/Users/dahlj.GREATSTONE/.node-red",
13
+ "preversion": "npm test"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -22,7 +23,6 @@
22
23
  },
23
24
  "homepage": "https://github.com/sm6srw/node-red-contrib-antenna-genius#readme",
24
25
  "node-red": {
25
- "version": ">=2.0.0",
26
26
  "nodes": {
27
27
  "antenna-genius-server": "antenna-genius-server.js",
28
28
  "antenna-genius-band-labels": "antenna-genius-band-labels.js",
@@ -34,11 +34,15 @@
34
34
  "promise-socket": "^7.0.0"
35
35
  },
36
36
  "devDependencies": {
37
+ "auto-dist-tag": "^2.1.1",
37
38
  "jest": "^27.4.7",
38
39
  "node-red": "^2.1.4",
39
40
  "node-red-node-test-helper": "^0.2.7"
40
41
  },
41
42
  "jest": {
42
43
  "verbose": true
44
+ },
45
+ "publishConfig": {
46
+ "tag": "beta"
43
47
  }
44
48
  }
@@ -0,0 +1,90 @@
1
+ const net = require("net");
2
+ const { PromiseSocket } = require("promise-socket");
3
+ const { encode, decodeheader } = require("../GeniusUtils.js");
4
+
5
+ var server;
6
+
7
+ const bands = [
8
+ "0;None;0;0",
9
+ "1;160m;1600000;2200000",
10
+ "2;80m;3300000;4000000",
11
+ "3;40m;6800000;7400000",
12
+ "4;30m;9900000;10350000",
13
+ "5;20m;13800000;14550000",
14
+ "6;17m;17868000;18368000",
15
+ "7;15m;20800000;21650000",
16
+ "8;12m;24690000;25190000",
17
+ "9;10m;27800000;29900000",
18
+ "0;6m;49800000;54200000",
19
+ "11;60m;5000000;6000000",
20
+ "12;2m;144000000;148000000",
21
+ "13;70cm;432000000;436000000",
22
+ "14;Custom 3;0;0",
23
+ "15;Custom 4;0;0",
24
+ ];
25
+
26
+ const antennas = [
27
+ "1;Antenna1;3;FFFF",
28
+ "2;Antenna2;3;FFFF",
29
+ "3;Antenna3;3;FFFF",
30
+ "4;Antenna4;3;FFFF",
31
+ "5;Antenna5;3;FFFF",
32
+ "6;Antenna6;3;FFFF",
33
+ "7;Antenna7;3;FFFF",
34
+ "8;Antenna8;3;FFFF",
35
+ ];
36
+
37
+ const start = () => {
38
+ server = net.createServer();
39
+ server.on("connection", (conn) => {
40
+ let connection = new PromiseSocket(conn);
41
+
42
+ connection.setEncoding("utf8");
43
+
44
+ conn.on("data", async (data) => {
45
+ let command = decodeheader(data);
46
+ const params = command.payload.split(";");
47
+
48
+ switch (command.command) {
49
+ case 24:
50
+ command.payload = "1;2;TestGenius";
51
+ break;
52
+ case 82:
53
+ {
54
+ let index = parseInt(params[0]);
55
+ command.payload = bands[index];
56
+ }
57
+ break;
58
+ case 401:
59
+ command.payload = "3;1;0;2;0;0;3;2;0;4;0;0;1";
60
+ break;
61
+ case 412:
62
+ {
63
+ let index = parseInt(params[0]);
64
+ command.payload = antennas[index - 1];
65
+ }
66
+ break;
67
+ }
68
+ let ret = encode(
69
+ command.protocol,
70
+ command.method,
71
+ command.command,
72
+ command.revision,
73
+ command.payload
74
+ );
75
+ await connection.write(ret);
76
+ });
77
+ });
78
+ return new Promise((resolve) => {
79
+ server.listen(0, "localhost", () => {
80
+ return resolve(server.address().port);
81
+ });
82
+ });
83
+ };
84
+
85
+ const stop = () => {
86
+ server.unref();
87
+ };
88
+
89
+ exports.start = start;
90
+ exports.stop = stop;
@@ -0,0 +1,414 @@
1
+ const Net = require("net");
2
+ const { PromiseSocket } = require("promise-socket");
3
+ const testServer = require("./GeniusTestServer.js");
4
+ const { encode, decode } = require("../GeniusUtils.js");
5
+
6
+ describe("Antenna Genius Test Server", () => {
7
+ var port;
8
+ var client;
9
+
10
+ beforeEach(async () => {
11
+ port = await testServer.start();
12
+ client = new PromiseSocket(new Net.Socket());
13
+ await client.connect(port, "localhost");
14
+ });
15
+
16
+ afterEach(async () => {
17
+ await client.end();
18
+ testServer.stop();
19
+ });
20
+
21
+ it("should load", async () => {});
22
+
23
+ it("should respond to command 24 correctly", async () => {
24
+ let command = encode(0, 0, 24, 0, "");
25
+ await client.write(command);
26
+ let response = await client.read();
27
+ let data = decode(response);
28
+ expect(data).toBeDefined();
29
+ expect(data).toStrictEqual({
30
+ command: 24,
31
+ error: 0,
32
+ length: "0015",
33
+ method: 0,
34
+ payload: "1;2;TestGenius",
35
+ protocol: 0,
36
+ revision: 0,
37
+ identification: 1,
38
+ group: 2,
39
+ name: "TestGenius",
40
+ });
41
+ });
42
+
43
+ it("should respond to command 82 correctly", async () => {
44
+ let bands = [];
45
+
46
+ for (let i = 0; i < 16; i++) {
47
+ let command = encode(0, 0, 82, 0, i.toString());
48
+ await client.write(command);
49
+ let response = await client.read();
50
+ let data = decode(response);
51
+ expect(data).toBeDefined();
52
+ bands.push(data);
53
+ }
54
+ expect(bands).toStrictEqual([
55
+ {
56
+ command: 82,
57
+ cutoff_lower: 0,
58
+ cutoff_upper: 0,
59
+ error: 0,
60
+ index: 0,
61
+ length: "0011",
62
+ method: 0,
63
+ name: "None",
64
+ payload: "0;None;0;0",
65
+ protocol: 0,
66
+ revision: 0,
67
+ },
68
+ {
69
+ command: 82,
70
+ cutoff_lower: 1600000,
71
+ cutoff_upper: 2200000,
72
+ error: 0,
73
+ index: 1,
74
+ length: "001d",
75
+ method: 0,
76
+ name: "160m",
77
+ payload: "1;160m;1600000;2200000",
78
+ protocol: 0,
79
+ revision: 0,
80
+ },
81
+ {
82
+ command: 82,
83
+ cutoff_lower: 3300000,
84
+ cutoff_upper: 4000000,
85
+ error: 0,
86
+ index: 2,
87
+ length: "001c",
88
+ method: 0,
89
+ name: "80m",
90
+ payload: "2;80m;3300000;4000000",
91
+ protocol: 0,
92
+ revision: 0,
93
+ },
94
+ {
95
+ command: 82,
96
+ cutoff_lower: 6800000,
97
+ cutoff_upper: 7400000,
98
+ error: 0,
99
+ index: 3,
100
+ length: "001c",
101
+ method: 0,
102
+ name: "40m",
103
+ payload: "3;40m;6800000;7400000",
104
+ protocol: 0,
105
+ revision: 0,
106
+ },
107
+ {
108
+ command: 82,
109
+ cutoff_lower: 9900000,
110
+ cutoff_upper: 10350000,
111
+ error: 0,
112
+ index: 4,
113
+ length: "001d",
114
+ method: 0,
115
+ name: "30m",
116
+ payload: "4;30m;9900000;10350000",
117
+ protocol: 0,
118
+ revision: 0,
119
+ },
120
+ {
121
+ command: 82,
122
+ cutoff_lower: 13800000,
123
+ cutoff_upper: 14550000,
124
+ error: 0,
125
+ index: 5,
126
+ length: "001e",
127
+ method: 0,
128
+ name: "20m",
129
+ payload: "5;20m;13800000;14550000",
130
+ protocol: 0,
131
+ revision: 0,
132
+ },
133
+ {
134
+ command: 82,
135
+ cutoff_lower: 17868000,
136
+ cutoff_upper: 18368000,
137
+ error: 0,
138
+ index: 6,
139
+ length: "001e",
140
+ method: 0,
141
+ name: "17m",
142
+ payload: "6;17m;17868000;18368000",
143
+ protocol: 0,
144
+ revision: 0,
145
+ },
146
+ {
147
+ command: 82,
148
+ cutoff_lower: 20800000,
149
+ cutoff_upper: 21650000,
150
+ error: 0,
151
+ index: 7,
152
+ length: "001e",
153
+ method: 0,
154
+ name: "15m",
155
+ payload: "7;15m;20800000;21650000",
156
+ protocol: 0,
157
+ revision: 0,
158
+ },
159
+ {
160
+ command: 82,
161
+ cutoff_lower: 24690000,
162
+ cutoff_upper: 25190000,
163
+ error: 0,
164
+ index: 8,
165
+ length: "001e",
166
+ method: 0,
167
+ name: "12m",
168
+ payload: "8;12m;24690000;25190000",
169
+ protocol: 0,
170
+ revision: 0,
171
+ },
172
+ {
173
+ command: 82,
174
+ cutoff_lower: 27800000,
175
+ cutoff_upper: 29900000,
176
+ error: 0,
177
+ index: 9,
178
+ length: "001e",
179
+ method: 0,
180
+ name: "10m",
181
+ payload: "9;10m;27800000;29900000",
182
+ protocol: 0,
183
+ revision: 0,
184
+ },
185
+ {
186
+ command: 82,
187
+ cutoff_lower: 49800000,
188
+ cutoff_upper: 54200000,
189
+ error: 0,
190
+ index: 0,
191
+ length: "001d",
192
+ method: 0,
193
+ name: "6m",
194
+ payload: "0;6m;49800000;54200000",
195
+ protocol: 0,
196
+ revision: 0,
197
+ },
198
+ {
199
+ command: 82,
200
+ cutoff_lower: 5000000,
201
+ cutoff_upper: 6000000,
202
+ error: 0,
203
+ index: 11,
204
+ length: "001d",
205
+ method: 0,
206
+ name: "60m",
207
+ payload: "11;60m;5000000;6000000",
208
+ protocol: 0,
209
+ revision: 0,
210
+ },
211
+ {
212
+ command: 82,
213
+ cutoff_lower: 144000000,
214
+ cutoff_upper: 148000000,
215
+ error: 0,
216
+ index: 12,
217
+ length: "0020",
218
+ method: 0,
219
+ name: "2m",
220
+ payload: "12;2m;144000000;148000000",
221
+ protocol: 0,
222
+ revision: 0,
223
+ },
224
+ {
225
+ command: 82,
226
+ cutoff_lower: 432000000,
227
+ cutoff_upper: 436000000,
228
+ error: 0,
229
+ index: 13,
230
+ length: "0022",
231
+ method: 0,
232
+ name: "70cm",
233
+ payload: "13;70cm;432000000;436000000",
234
+ protocol: 0,
235
+ revision: 0,
236
+ },
237
+ {
238
+ command: 82,
239
+ cutoff_lower: 0,
240
+ cutoff_upper: 0,
241
+ error: 0,
242
+ index: 14,
243
+ length: "0016",
244
+ method: 0,
245
+ name: "Custom 3",
246
+ payload: "14;Custom 3;0;0",
247
+ protocol: 0,
248
+ revision: 0,
249
+ },
250
+ {
251
+ command: 82,
252
+ cutoff_lower: 0,
253
+ cutoff_upper: 0,
254
+ error: 0,
255
+ index: 15,
256
+ length: "0016",
257
+ method: 0,
258
+ name: "Custom 4",
259
+ payload: "15;Custom 4;0;0",
260
+ protocol: 0,
261
+ revision: 0,
262
+ },
263
+ ]);
264
+ });
265
+
266
+ it("should respond to command 412 correctly", async () => {
267
+ let antennas = [];
268
+
269
+ for (let i = 1; i <= 8; i++) {
270
+ let command = encode(0, 0, 412, 0, i.toString());
271
+ await client.write(command);
272
+ let response = await client.read();
273
+ let data = decode(response);
274
+ expect(data).toBeDefined();
275
+ antennas.push(data);
276
+ }
277
+ expect(antennas).toStrictEqual([
278
+ {
279
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
280
+ command: 412,
281
+ error: 0,
282
+ index: 1,
283
+ length: "0018",
284
+ method: 0,
285
+ mode: 3,
286
+ name: "Antenna1",
287
+ payload: "1;Antenna1;3;FFFF",
288
+ protocol: 0,
289
+ revision: 0,
290
+ },
291
+ {
292
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
293
+ command: 412,
294
+ error: 0,
295
+ index: 2,
296
+ length: "0018",
297
+ method: 0,
298
+ mode: 3,
299
+ name: "Antenna2",
300
+ payload: "2;Antenna2;3;FFFF",
301
+ protocol: 0,
302
+ revision: 0,
303
+ },
304
+ {
305
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
306
+ command: 412,
307
+ error: 0,
308
+ index: 3,
309
+ length: "0018",
310
+ method: 0,
311
+ mode: 3,
312
+ name: "Antenna3",
313
+ payload: "3;Antenna3;3;FFFF",
314
+ protocol: 0,
315
+ revision: 0,
316
+ },
317
+ {
318
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
319
+ command: 412,
320
+ error: 0,
321
+ index: 4,
322
+ length: "0018",
323
+ method: 0,
324
+ mode: 3,
325
+ name: "Antenna4",
326
+ payload: "4;Antenna4;3;FFFF",
327
+ protocol: 0,
328
+ revision: 0,
329
+ },
330
+ {
331
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
332
+ command: 412,
333
+ error: 0,
334
+ index: 5,
335
+ length: "0018",
336
+ method: 0,
337
+ mode: 3,
338
+ name: "Antenna5",
339
+ payload: "5;Antenna5;3;FFFF",
340
+ protocol: 0,
341
+ revision: 0,
342
+ },
343
+ {
344
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
345
+ command: 412,
346
+ error: 0,
347
+ index: 6,
348
+ length: "0018",
349
+ method: 0,
350
+ mode: 3,
351
+ name: "Antenna6",
352
+ payload: "6;Antenna6;3;FFFF",
353
+ protocol: 0,
354
+ revision: 0,
355
+ },
356
+ {
357
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
358
+ command: 412,
359
+ error: 0,
360
+ index: 7,
361
+ length: "0018",
362
+ method: 0,
363
+ mode: 3,
364
+ name: "Antenna7",
365
+ payload: "7;Antenna7;3;FFFF",
366
+ protocol: 0,
367
+ revision: 0,
368
+ },
369
+ {
370
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
371
+ command: 412,
372
+ error: 0,
373
+ index: 8,
374
+ length: "0018",
375
+ method: 0,
376
+ mode: 3,
377
+ name: "Antenna8",
378
+ payload: "8;Antenna8;3;FFFF",
379
+ protocol: 0,
380
+ revision: 0,
381
+ },
382
+ ]);
383
+ });
384
+
385
+ it("should respond to command 401 correctly", async () => {
386
+ let command = encode(0, 0, 401, 0, "");
387
+ await client.write(command);
388
+ let response = await client.read();
389
+ let data = decode(response);
390
+ expect(data).toBeDefined();
391
+ expect(data).toStrictEqual({
392
+ command: 401,
393
+ error: 0,
394
+ length: "0020",
395
+ method: 0,
396
+ payload: "3;1;0;2;0;0;3;2;0;4;0;0;1",
397
+ portA_antenna: 2,
398
+ portA_band: 1,
399
+ portA_inhibit: 0,
400
+ portA_mode: 3,
401
+ portA_profile: 0,
402
+ portA_tx: 0,
403
+ portB_antenna: 4,
404
+ portB_band: 2,
405
+ portB_inhibit: 0,
406
+ portB_mode: 3,
407
+ portB_profile: 0,
408
+ portB_tx: 0,
409
+ protocol: 0,
410
+ revision: 0,
411
+ stackReach: 1,
412
+ });
413
+ });
414
+ });
@@ -1,4 +1,4 @@
1
- const { encode, decode } = require("../Utils.js");
1
+ const { encode, decode } = require("../GeniusUtils.js");
2
2
 
3
3
  describe("Utils", () => {
4
4
  it("should encode null input gracefully", (done) => {
@@ -1,16 +1,30 @@
1
1
  const helper = require("node-red-node-test-helper");
2
2
  const antennaStatusNode = require("../antenna-genius-antenna-status.js");
3
3
  const serverNode = require("../antenna-genius-server.js");
4
+ const testServer = require("./GeniusTestServer.js");
4
5
 
5
6
  const nodes = [antennaStatusNode, serverNode];
6
7
 
7
8
  describe("antenna-genius-antenna-status Node", () => {
9
+ var port;
10
+
11
+ beforeEach(async () => {
12
+ port = await testServer.start();
13
+ });
14
+
15
+ afterEach(async () => {
16
+ testServer.stop();
17
+ helper.unload();
18
+ flow[0].port = 9007;
19
+ flow[0].autoConnect = false;
20
+ });
21
+
8
22
  const flow = [
9
23
  {
10
24
  id: "n1",
11
25
  type: "antenna-genius-server",
12
26
  name: "test name",
13
- hostname: "localhost",
27
+ host: "localhost",
14
28
  port: 9007,
15
29
  disabledColor: "Black",
16
30
  activeColor: "Green",
@@ -29,10 +43,6 @@ describe("antenna-genius-antenna-status Node", () => {
29
43
  { id: "n4", type: "helper" },
30
44
  ];
31
45
 
32
- afterEach(() => {
33
- helper.unload();
34
- });
35
-
36
46
  it("should be loaded", (done) => {
37
47
  helper.load(nodes, flow, () => {
38
48
  let n2 = helper.getNode("n2");
@@ -176,4 +186,54 @@ describe("antenna-genius-antenna-status Node", () => {
176
186
  });
177
187
  });
178
188
  });
189
+
190
+ it("should provide A port output when connected to server", (done) => {
191
+ flow[0].port = port;
192
+ flow[0].autoConnect = true;
193
+ helper.load(nodes, flow, () => {
194
+ let n3 = helper.getNode("n3");
195
+ n3.on("input", (msg) => {
196
+ try {
197
+ expect(msg).toMatchObject({
198
+ enabled: true,
199
+ payload: {
200
+ background: "Blue",
201
+ enabled: true,
202
+ name: "Antenna2",
203
+ selected: true,
204
+ },
205
+ topic: "1;2",
206
+ });
207
+ done();
208
+ } catch (err) {
209
+ done(err);
210
+ }
211
+ });
212
+ });
213
+ });
214
+
215
+ it("should provide B port output when connected to server", (done) => {
216
+ flow[0].port = port;
217
+ flow[0].autoConnect = true;
218
+ helper.load(nodes, flow, () => {
219
+ let n4 = helper.getNode("n4");
220
+ n4.on("input", (msg) => {
221
+ try {
222
+ expect(msg).toMatchObject({
223
+ enabled: true,
224
+ payload: {
225
+ background: "Green",
226
+ enabled: true,
227
+ name: "Antenna2",
228
+ selected: false,
229
+ },
230
+ topic: "2;2",
231
+ });
232
+ done();
233
+ } catch (err) {
234
+ done(err);
235
+ }
236
+ });
237
+ });
238
+ });
179
239
  });
@@ -1,16 +1,30 @@
1
1
  const helper = require("node-red-node-test-helper");
2
2
  const bandLabelsNode = require("../antenna-genius-band-labels.js");
3
3
  const serverNode = require("../antenna-genius-server.js");
4
+ const testServer = require("./GeniusTestServer.js");
4
5
 
5
6
  const nodes = [bandLabelsNode, serverNode];
6
7
 
7
8
  describe("antenna-genius-band-labels Node", () => {
9
+ var port;
10
+
11
+ beforeEach(async () => {
12
+ port = await testServer.start();
13
+ });
14
+
15
+ afterEach(async () => {
16
+ testServer.stop();
17
+ helper.unload();
18
+ flow[0].port = 9007;
19
+ flow[0].autoConnect = false;
20
+ });
21
+
8
22
  const flow = [
9
23
  {
10
24
  id: "n1",
11
25
  type: "antenna-genius-server",
12
26
  name: "test name",
13
- hostname: "localhost",
27
+ host: "localhost",
14
28
  port: 9007,
15
29
  disabledColor: "Black",
16
30
  activeColor: "Green",
@@ -27,12 +41,6 @@ describe("antenna-genius-band-labels Node", () => {
27
41
  { id: "n3", type: "helper" },
28
42
  ];
29
43
 
30
- beforeEach(() => {});
31
-
32
- afterEach(() => {
33
- helper.unload();
34
- });
35
-
36
44
  it("should be loaded", (done) => {
37
45
  helper.load(nodes, flow, () => {
38
46
  let n2 = helper.getNode("n2");
@@ -140,4 +148,22 @@ describe("antenna-genius-band-labels Node", () => {
140
148
  done();
141
149
  });
142
150
  });
151
+
152
+ it("should connect with test server and provide valid output", (done) => {
153
+ flow[0].port = port;
154
+ flow[0].autoConnect = true;
155
+ helper.load(nodes, flow, () => {
156
+ let n3 = helper.getNode("n3");
157
+ n3.on("input", (msg) => {
158
+ try {
159
+ expect(msg).toMatchObject({
160
+ payload: { bandLabelA: "160m", bandLabelB: "80m" },
161
+ });
162
+ done();
163
+ } catch (err) {
164
+ done(err);
165
+ }
166
+ });
167
+ });
168
+ });
143
169
  });
@@ -1,8 +1,16 @@
1
1
  const helper = require("node-red-node-test-helper");
2
2
  const serverNode = require("../antenna-genius-server.js");
3
+ const testServer = require("./GeniusTestServer.js");
3
4
 
4
5
  describe("antenna-genius-server Node", () => {
5
- afterEach(() => {
6
+ var port;
7
+
8
+ beforeEach(async () => {
9
+ port = await testServer.start();
10
+ });
11
+
12
+ afterEach(async () => {
13
+ testServer.stop();
6
14
  helper.unload();
7
15
  });
8
16
 
@@ -13,11 +21,11 @@ describe("antenna-genius-server Node", () => {
13
21
  type: "antenna-genius-server",
14
22
  name: "test name",
15
23
  host: "localhost",
16
- port: 9007,
24
+ port: port,
17
25
  disabledColor: "Black",
18
26
  activeColor: "Green",
19
27
  selectedColor: "Blue",
20
- autoConnect: false,
28
+ autoConnect: true,
21
29
  },
22
30
  ];
23
31
  helper.load(serverNode, flow, () => {
@@ -34,23 +42,385 @@ describe("antenna-genius-server Node", () => {
34
42
  type: "antenna-genius-server",
35
43
  name: "test name",
36
44
  host: "localhost",
37
- port: 9007,
45
+ port: port,
38
46
  disabledColor: "Black",
39
47
  activeColor: "Green",
40
48
  selectedColor: "Blue",
41
- autoConnect: false,
49
+ autoConnect: true,
42
50
  },
43
51
  ];
44
52
  helper.load(serverNode, flow, () => {
45
53
  let n1 = helper.getNode("n1");
46
54
  expect(n1).toHaveProperty("name", "test name");
47
55
  expect(n1).toHaveProperty("host", "localhost");
48
- expect(n1).toHaveProperty("port", 9007);
56
+ expect(n1).toHaveProperty("port", port);
49
57
  expect(n1).toHaveProperty("disabledColor", "Black");
50
58
  expect(n1).toHaveProperty("activeColor", "Green");
51
59
  expect(n1).toHaveProperty("selectedColor", "Blue");
52
- expect(n1).toHaveProperty("autoConnect", false);
60
+ expect(n1).toHaveProperty("autoConnect", true);
53
61
  done();
54
62
  });
55
63
  });
64
+
65
+ it("can connect", (done) => {
66
+ let flow = [
67
+ {
68
+ id: "n1",
69
+ type: "antenna-genius-server",
70
+ name: "test name",
71
+ host: "localhost",
72
+ port: port,
73
+ disabledColor: "Black",
74
+ activeColor: "Green",
75
+ selectedColor: "Blue",
76
+ autoConnect: true,
77
+ },
78
+ ];
79
+ helper.load(serverNode, flow, () => {
80
+ let n1 = helper.getNode("n1");
81
+ n1.updatesEventEmitter.on("connected", () => {
82
+ expect(n1.connected).toBeTruthy();
83
+ expect(n1.status).toStrictEqual({
84
+ command: 401,
85
+ error: 0,
86
+ length: "0020",
87
+ method: 0,
88
+ payload: "3;1;0;2;0;0;3;2;0;4;0;0;1",
89
+ portA_antenna: 2,
90
+ portA_band: 1,
91
+ portA_inhibit: 0,
92
+ portA_mode: 3,
93
+ portA_profile: 0,
94
+ portA_tx: 0,
95
+ portB_antenna: 4,
96
+ portB_band: 2,
97
+ portB_inhibit: 0,
98
+ portB_mode: 3,
99
+ portB_profile: 0,
100
+ portB_tx: 0,
101
+ protocol: 0,
102
+ revision: 0,
103
+ stackReach: 1,
104
+ });
105
+ expect(n1.bands).toStrictEqual([
106
+ {
107
+ command: 82,
108
+ cutoff_lower: 0,
109
+ cutoff_upper: 0,
110
+ error: 0,
111
+ index: 0,
112
+ length: "0011",
113
+ method: 0,
114
+ name: "None",
115
+ payload: "0;None;0;0",
116
+ protocol: 0,
117
+ revision: 0,
118
+ },
119
+ {
120
+ command: 82,
121
+ cutoff_lower: 1600000,
122
+ cutoff_upper: 2200000,
123
+ error: 0,
124
+ index: 1,
125
+ length: "001d",
126
+ method: 0,
127
+ name: "160m",
128
+ payload: "1;160m;1600000;2200000",
129
+ protocol: 0,
130
+ revision: 0,
131
+ },
132
+ {
133
+ command: 82,
134
+ cutoff_lower: 3300000,
135
+ cutoff_upper: 4000000,
136
+ error: 0,
137
+ index: 2,
138
+ length: "001c",
139
+ method: 0,
140
+ name: "80m",
141
+ payload: "2;80m;3300000;4000000",
142
+ protocol: 0,
143
+ revision: 0,
144
+ },
145
+ {
146
+ command: 82,
147
+ cutoff_lower: 6800000,
148
+ cutoff_upper: 7400000,
149
+ error: 0,
150
+ index: 3,
151
+ length: "001c",
152
+ method: 0,
153
+ name: "40m",
154
+ payload: "3;40m;6800000;7400000",
155
+ protocol: 0,
156
+ revision: 0,
157
+ },
158
+ {
159
+ command: 82,
160
+ cutoff_lower: 9900000,
161
+ cutoff_upper: 10350000,
162
+ error: 0,
163
+ index: 4,
164
+ length: "001d",
165
+ method: 0,
166
+ name: "30m",
167
+ payload: "4;30m;9900000;10350000",
168
+ protocol: 0,
169
+ revision: 0,
170
+ },
171
+ {
172
+ command: 82,
173
+ cutoff_lower: 13800000,
174
+ cutoff_upper: 14550000,
175
+ error: 0,
176
+ index: 5,
177
+ length: "001e",
178
+ method: 0,
179
+ name: "20m",
180
+ payload: "5;20m;13800000;14550000",
181
+ protocol: 0,
182
+ revision: 0,
183
+ },
184
+ {
185
+ command: 82,
186
+ cutoff_lower: 17868000,
187
+ cutoff_upper: 18368000,
188
+ error: 0,
189
+ index: 6,
190
+ length: "001e",
191
+ method: 0,
192
+ name: "17m",
193
+ payload: "6;17m;17868000;18368000",
194
+ protocol: 0,
195
+ revision: 0,
196
+ },
197
+ {
198
+ command: 82,
199
+ cutoff_lower: 20800000,
200
+ cutoff_upper: 21650000,
201
+ error: 0,
202
+ index: 7,
203
+ length: "001e",
204
+ method: 0,
205
+ name: "15m",
206
+ payload: "7;15m;20800000;21650000",
207
+ protocol: 0,
208
+ revision: 0,
209
+ },
210
+ {
211
+ command: 82,
212
+ cutoff_lower: 24690000,
213
+ cutoff_upper: 25190000,
214
+ error: 0,
215
+ index: 8,
216
+ length: "001e",
217
+ method: 0,
218
+ name: "12m",
219
+ payload: "8;12m;24690000;25190000",
220
+ protocol: 0,
221
+ revision: 0,
222
+ },
223
+ {
224
+ command: 82,
225
+ cutoff_lower: 27800000,
226
+ cutoff_upper: 29900000,
227
+ error: 0,
228
+ index: 9,
229
+ length: "001e",
230
+ method: 0,
231
+ name: "10m",
232
+ payload: "9;10m;27800000;29900000",
233
+ protocol: 0,
234
+ revision: 0,
235
+ },
236
+ {
237
+ command: 82,
238
+ cutoff_lower: 49800000,
239
+ cutoff_upper: 54200000,
240
+ error: 0,
241
+ index: 0,
242
+ length: "001d",
243
+ method: 0,
244
+ name: "6m",
245
+ payload: "0;6m;49800000;54200000",
246
+ protocol: 0,
247
+ revision: 0,
248
+ },
249
+ {
250
+ command: 82,
251
+ cutoff_lower: 5000000,
252
+ cutoff_upper: 6000000,
253
+ error: 0,
254
+ index: 11,
255
+ length: "001d",
256
+ method: 0,
257
+ name: "60m",
258
+ payload: "11;60m;5000000;6000000",
259
+ protocol: 0,
260
+ revision: 0,
261
+ },
262
+ {
263
+ command: 82,
264
+ cutoff_lower: 144000000,
265
+ cutoff_upper: 148000000,
266
+ error: 0,
267
+ index: 12,
268
+ length: "0020",
269
+ method: 0,
270
+ name: "2m",
271
+ payload: "12;2m;144000000;148000000",
272
+ protocol: 0,
273
+ revision: 0,
274
+ },
275
+ {
276
+ command: 82,
277
+ cutoff_lower: 432000000,
278
+ cutoff_upper: 436000000,
279
+ error: 0,
280
+ index: 13,
281
+ length: "0022",
282
+ method: 0,
283
+ name: "70cm",
284
+ payload: "13;70cm;432000000;436000000",
285
+ protocol: 0,
286
+ revision: 0,
287
+ },
288
+ {
289
+ command: 82,
290
+ cutoff_lower: 0,
291
+ cutoff_upper: 0,
292
+ error: 0,
293
+ index: 14,
294
+ length: "0016",
295
+ method: 0,
296
+ name: "Custom 3",
297
+ payload: "14;Custom 3;0;0",
298
+ protocol: 0,
299
+ revision: 0,
300
+ },
301
+ {
302
+ command: 82,
303
+ cutoff_lower: 0,
304
+ cutoff_upper: 0,
305
+ error: 0,
306
+ index: 15,
307
+ length: "0016",
308
+ method: 0,
309
+ name: "Custom 4",
310
+ payload: "15;Custom 4;0;0",
311
+ protocol: 0,
312
+ revision: 0,
313
+ },
314
+ ]);
315
+ expect(n1.antennas).toStrictEqual([
316
+ {
317
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
318
+ command: 412,
319
+ error: 0,
320
+ index: 1,
321
+ length: "0018",
322
+ method: 0,
323
+ mode: 3,
324
+ name: "Antenna1",
325
+ payload: "1;Antenna1;3;FFFF",
326
+ protocol: 0,
327
+ revision: 0,
328
+ },
329
+ {
330
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
331
+ command: 412,
332
+ error: 0,
333
+ index: 2,
334
+ length: "0018",
335
+ method: 0,
336
+ mode: 3,
337
+ name: "Antenna2",
338
+ payload: "2;Antenna2;3;FFFF",
339
+ protocol: 0,
340
+ revision: 0,
341
+ },
342
+ {
343
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
344
+ command: 412,
345
+ error: 0,
346
+ index: 3,
347
+ length: "0018",
348
+ method: 0,
349
+ mode: 3,
350
+ name: "Antenna3",
351
+ payload: "3;Antenna3;3;FFFF",
352
+ protocol: 0,
353
+ revision: 0,
354
+ },
355
+ {
356
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
357
+ command: 412,
358
+ error: 0,
359
+ index: 4,
360
+ length: "0018",
361
+ method: 0,
362
+ mode: 3,
363
+ name: "Antenna4",
364
+ payload: "4;Antenna4;3;FFFF",
365
+ protocol: 0,
366
+ revision: 0,
367
+ },
368
+ {
369
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
370
+ command: 412,
371
+ error: 0,
372
+ index: 5,
373
+ length: "0018",
374
+ method: 0,
375
+ mode: 3,
376
+ name: "Antenna5",
377
+ payload: "5;Antenna5;3;FFFF",
378
+ protocol: 0,
379
+ revision: 0,
380
+ },
381
+ {
382
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
383
+ command: 412,
384
+ error: 0,
385
+ index: 6,
386
+ length: "0018",
387
+ method: 0,
388
+ mode: 3,
389
+ name: "Antenna6",
390
+ payload: "6;Antenna6;3;FFFF",
391
+ protocol: 0,
392
+ revision: 0,
393
+ },
394
+ {
395
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
396
+ command: 412,
397
+ error: 0,
398
+ index: 7,
399
+ length: "0018",
400
+ method: 0,
401
+ mode: 3,
402
+ name: "Antenna7",
403
+ payload: "7;Antenna7;3;FFFF",
404
+ protocol: 0,
405
+ revision: 0,
406
+ },
407
+ {
408
+ bands: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
409
+ command: 412,
410
+ error: 0,
411
+ index: 8,
412
+ length: "0018",
413
+ method: 0,
414
+ mode: 3,
415
+ name: "Antenna8",
416
+ payload: "8;Antenna8;3;FFFF",
417
+ protocol: 0,
418
+ revision: 0,
419
+ },
420
+ ]);
421
+ done();
422
+ });
423
+ n1.connect();
424
+ });
425
+ });
56
426
  });