ngx-kel-agent 0.4.10 → 0.5.0
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.
- package/esm2020/lib/agent-message.service.mjs +18 -0
- package/esm2020/lib/agent.service.mjs +89 -196
- package/esm2020/lib/hamlib-messages.mjs +2 -0
- package/esm2020/lib/hamlib.service.mjs +48 -0
- package/esm2020/lib/wsjtx-messages.mjs +2 -0
- package/esm2020/lib/wsjtx.service.mjs +196 -0
- package/esm2020/public-api.mjs +6 -2
- package/fesm2015/ngx-kel-agent.mjs +300 -169
- package/fesm2015/ngx-kel-agent.mjs.map +1 -1
- package/fesm2020/ngx-kel-agent.mjs +299 -161
- package/fesm2020/ngx-kel-agent.mjs.map +1 -1
- package/lib/agent-message.service.d.ts +9 -0
- package/lib/agent.service.d.ts +112 -29
- package/lib/hamlib-messages.d.ts +10 -0
- package/lib/hamlib.service.d.ts +16 -0
- package/lib/{messages.d.ts → wsjtx-messages.d.ts} +0 -10
- package/lib/wsjtx.service.d.ts +51 -0
- package/package.json +3 -3
- package/public-api.d.ts +5 -1
- package/esm2020/lib/messages.mjs +0 -2
|
@@ -1,244 +1,162 @@
|
|
|
1
|
+
import { Subject, BehaviorSubject, ReplaySubject } from 'rxjs';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
3
|
import { Injectable } from '@angular/core';
|
|
3
|
-
import { BehaviorSubject, ReplaySubject, Subject } from 'rxjs';
|
|
4
4
|
import { debounceTime, retryWhen, tap, delay } from 'rxjs/operators';
|
|
5
5
|
import { webSocket } from 'rxjs/webSocket';
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class AgentMessageService {
|
|
8
8
|
constructor() {
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
|
|
9
|
+
this.rxMessage$ = new Subject();
|
|
10
|
+
this.txMessage$ = new Subject();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
AgentMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AgentMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
14
|
+
AgentMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AgentMessageService, providedIn: 'root' });
|
|
15
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AgentMessageService, decorators: [{
|
|
16
|
+
type: Injectable,
|
|
17
|
+
args: [{
|
|
18
|
+
providedIn: 'root',
|
|
19
|
+
}]
|
|
20
|
+
}], ctorParameters: function () { return []; } });
|
|
21
|
+
|
|
22
|
+
class WsjtxService {
|
|
23
|
+
constructor(messages) {
|
|
24
|
+
this.messages = messages;
|
|
12
25
|
/** Whether we're getting any messages from WSJT-X. */
|
|
13
|
-
this.
|
|
26
|
+
this.connected$ = new BehaviorSubject(false);
|
|
14
27
|
/** Subject for listening to WSJT-X "Heartbeat" messages. */
|
|
15
|
-
this.
|
|
28
|
+
this.heartbeat$ = new ReplaySubject(1);
|
|
16
29
|
/** Subject for listening to WSJT-X "Status" messages. */
|
|
17
|
-
this.
|
|
30
|
+
this.status$ = new ReplaySubject(1);
|
|
18
31
|
/** Subject for listening to WSJT-X "Decode" messages. */
|
|
19
|
-
this.
|
|
32
|
+
this.decode$ = new Subject();
|
|
20
33
|
/** Subject for listening to WSJT-X "Clear" messages. */
|
|
21
|
-
this.
|
|
34
|
+
this.clear$ = new Subject();
|
|
22
35
|
/** Subject for listening to WSJT-X "QsoLogged" messages. */
|
|
23
|
-
this.
|
|
36
|
+
this.qsoLogged$ = new Subject();
|
|
24
37
|
/** Subject for listening to WSJT-X "Close" messages. */
|
|
25
|
-
this.
|
|
38
|
+
this.close$ = new Subject();
|
|
26
39
|
/** Subject for listening to WSJT-X "WsprDecode" messages. */
|
|
27
|
-
this.
|
|
40
|
+
this.wsprDecode$ = new Subject();
|
|
28
41
|
/** Subject for listening to WSJT-X "LoggedAdif" messages. */
|
|
29
|
-
this.
|
|
30
|
-
/* Hamlib */
|
|
31
|
-
/** Whether we're getting any messages from Hamlib. */
|
|
32
|
-
this.hamlibState$ = new BehaviorSubject(false);
|
|
33
|
-
/** Subject for listening to Hamlib "RigState" messages. */
|
|
34
|
-
this.hamlibRigState$ = new BehaviorSubject(null);
|
|
35
|
-
this.defaultAgentHost = 'localhost';
|
|
36
|
-
this.defaultAgentPort = 8081;
|
|
37
|
-
this.localStorageHostKey = 'agent-host';
|
|
38
|
-
this.localStoragePortKey = 'agent-port';
|
|
39
|
-
this.agentHost = this.defaultAgentHost;
|
|
40
|
-
this.agentPort = this.defaultAgentPort;
|
|
41
|
-
this.agentWebSocketSubject = null;
|
|
42
|
-
this.agentWebsocketSubscription = null;
|
|
42
|
+
this.loggedAdif$ = new Subject();
|
|
43
43
|
this.wsjtxId = 'WSJT-X';
|
|
44
|
+
this.setupBehaviors();
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
this.agentPort = this.getPort();
|
|
48
|
-
this.setupWsjtxBehaviors();
|
|
49
|
-
this.setupHamlibBehaviors();
|
|
50
|
-
this.connect();
|
|
51
|
-
}
|
|
52
|
-
setupWsjtxBehaviors() {
|
|
46
|
+
setupBehaviors() {
|
|
47
|
+
this.messages.rxMessage$.subscribe((msg) => this.handleMessage(msg));
|
|
53
48
|
// if we haven't heard from WSJT-X in 15 seconds, consider it "down"
|
|
54
|
-
this.
|
|
49
|
+
this.connected$
|
|
55
50
|
.pipe(debounceTime(15000))
|
|
56
|
-
.subscribe(() => this.
|
|
51
|
+
.subscribe(() => this.connected$.next(false));
|
|
57
52
|
// When WSJT-X announces it's closing, set it to "down" immediately
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
53
|
+
this.close$.subscribe(() => {
|
|
54
|
+
this.connected$.next(false);
|
|
60
55
|
});
|
|
61
56
|
// When WSJT-X goes down, clear its persistent message subjects
|
|
62
|
-
this.
|
|
57
|
+
this.connected$.subscribe((isUp) => {
|
|
63
58
|
if (!isUp) {
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
59
|
+
this.heartbeat$.next(null);
|
|
60
|
+
this.status$.next(null);
|
|
66
61
|
}
|
|
67
62
|
});
|
|
68
63
|
}
|
|
69
|
-
setupHamlibBehaviors() {
|
|
70
|
-
// if we haven't heard from Hamlib in 15 seconds, consider it down
|
|
71
|
-
this.hamlibState$.pipe(debounceTime(15000)).subscribe(() => {
|
|
72
|
-
this.hamlibState$.next(false);
|
|
73
|
-
});
|
|
74
|
-
// When Hamlib goes down, clear its persistent message subjects
|
|
75
|
-
this.hamlibState$.subscribe((isUp) => {
|
|
76
|
-
if (!isUp) {
|
|
77
|
-
this.hamlibRigState$.next(null);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/** Connect (or reconnect) the websocket to the kel-agent server. */
|
|
82
|
-
connect() {
|
|
83
|
-
if (this.agentWebsocketSubscription) {
|
|
84
|
-
this.agentWebsocketSubscription.unsubscribe();
|
|
85
|
-
}
|
|
86
|
-
this.agentHost = this.getHost();
|
|
87
|
-
this.agentPort = this.getPort();
|
|
88
|
-
const protocol = this.agentHost === 'localhost' ? 'ws://' : 'wss://';
|
|
89
|
-
this.agentWebSocketSubject = webSocket({
|
|
90
|
-
url: protocol + this.agentHost + ':' + this.agentPort + '/websocket',
|
|
91
|
-
});
|
|
92
|
-
this.connectedState$.next(true);
|
|
93
|
-
this.agentWebsocketSubscription = this.agentWebSocketSubject
|
|
94
|
-
.pipe(retryWhen((errors) =>
|
|
95
|
-
// retry the websocket connection after 10 seconds
|
|
96
|
-
errors.pipe(tap(() => this.connectedState$.next(false)), delay(10000))))
|
|
97
|
-
.subscribe({
|
|
98
|
-
next: (msg) => {
|
|
99
|
-
this.connectedState$.next(true);
|
|
100
|
-
this.handleMessage(msg);
|
|
101
|
-
},
|
|
102
|
-
error: () => this.connectedState$.next(false),
|
|
103
|
-
complete: () => this.connectedState$.next(false),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
64
|
handleMessage(msg) {
|
|
107
|
-
if (msg.wsjtx
|
|
108
|
-
|
|
109
|
-
this.wsjtxId = msg.wsjtx.payload.id;
|
|
110
|
-
switch (msg.wsjtx.type) {
|
|
111
|
-
case 'HeartbeatMessage':
|
|
112
|
-
this.wsjtxHeartbeat$.next(msg.wsjtx.payload);
|
|
113
|
-
return;
|
|
114
|
-
case 'StatusMessage':
|
|
115
|
-
this.wsjtxStatus$.next(msg.wsjtx.payload);
|
|
116
|
-
return;
|
|
117
|
-
case 'DecodeMessage':
|
|
118
|
-
this.wsjtxDecode$.next(msg.wsjtx.payload);
|
|
119
|
-
return;
|
|
120
|
-
case 'ClearMessage':
|
|
121
|
-
this.wsjtxClear$.next(msg.wsjtx.payload);
|
|
122
|
-
return;
|
|
123
|
-
case 'QsoLoggedMessage':
|
|
124
|
-
this.wsjtxQsoLogged$.next(msg.wsjtx.payload);
|
|
125
|
-
return;
|
|
126
|
-
case 'CloseMessage':
|
|
127
|
-
this.wsjtxClose$.next(msg.wsjtx.payload);
|
|
128
|
-
return;
|
|
129
|
-
case 'WSPRDecodeMessage':
|
|
130
|
-
this.wsjtxWsprDecode$.next(msg.wsjtx.payload);
|
|
131
|
-
return;
|
|
132
|
-
case 'LoggedAdifMessage':
|
|
133
|
-
this.wsjtxLoggedAdif$.next(msg.wsjtx.payload);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (msg.hamlib !== null) {
|
|
138
|
-
this.hamlibState$.next(true);
|
|
139
|
-
switch (msg.hamlib.type) {
|
|
140
|
-
case 'RigState':
|
|
141
|
-
this.hamlibRigState$.next(msg.hamlib.payload);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/** Get the currently configured kel-agent host. */
|
|
147
|
-
getHost() {
|
|
148
|
-
return localStorage.getItem(this.localStorageHostKey) || this.defaultAgentHost;
|
|
149
|
-
}
|
|
150
|
-
/** Get the currently configured kel-agent port. */
|
|
151
|
-
getPort() {
|
|
152
|
-
let portStr = localStorage.getItem(this.localStoragePortKey);
|
|
153
|
-
if (portStr == null) {
|
|
154
|
-
return this.defaultAgentPort;
|
|
65
|
+
if (!msg.wsjtx) {
|
|
66
|
+
return;
|
|
155
67
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
68
|
+
this.connected$.next(true);
|
|
69
|
+
this.wsjtxId = msg.wsjtx.payload.id;
|
|
70
|
+
switch (msg.wsjtx.type) {
|
|
71
|
+
case 'HeartbeatMessage':
|
|
72
|
+
this.heartbeat$.next(msg.wsjtx.payload);
|
|
73
|
+
return;
|
|
74
|
+
case 'StatusMessage':
|
|
75
|
+
this.status$.next(msg.wsjtx.payload);
|
|
76
|
+
return;
|
|
77
|
+
case 'DecodeMessage':
|
|
78
|
+
this.decode$.next(msg.wsjtx.payload);
|
|
79
|
+
return;
|
|
80
|
+
case 'ClearMessage':
|
|
81
|
+
this.clear$.next(msg.wsjtx.payload);
|
|
82
|
+
return;
|
|
83
|
+
case 'QsoLoggedMessage':
|
|
84
|
+
this.qsoLogged$.next(msg.wsjtx.payload);
|
|
85
|
+
return;
|
|
86
|
+
case 'CloseMessage':
|
|
87
|
+
this.close$.next(msg.wsjtx.payload);
|
|
88
|
+
return;
|
|
89
|
+
case 'WSPRDecodeMessage':
|
|
90
|
+
this.wsprDecode$.next(msg.wsjtx.payload);
|
|
91
|
+
return;
|
|
92
|
+
case 'LoggedAdifMessage':
|
|
93
|
+
this.loggedAdif$.next(msg.wsjtx.payload);
|
|
94
|
+
return;
|
|
159
95
|
}
|
|
160
|
-
return portNum;
|
|
161
|
-
}
|
|
162
|
-
/** Set the kel-agent host. */
|
|
163
|
-
setHost(host) {
|
|
164
|
-
localStorage.setItem(this.localStorageHostKey, host);
|
|
165
|
-
this.connect();
|
|
166
|
-
}
|
|
167
|
-
/** Set the kel-agent port. */
|
|
168
|
-
setPort(port) {
|
|
169
|
-
localStorage.setItem(this.localStoragePortKey, String(port));
|
|
170
|
-
this.connect();
|
|
171
96
|
}
|
|
172
97
|
/** Send a command to WSJT-X to clear the Band Activity window. */
|
|
173
|
-
|
|
174
|
-
var _a;
|
|
98
|
+
clearBandActivity() {
|
|
175
99
|
const wsMsg = {
|
|
176
100
|
wsjtx: {
|
|
177
101
|
type: 'ClearMessage',
|
|
178
102
|
payload: { id: this.wsjtxId, window: 0 },
|
|
179
103
|
},
|
|
180
104
|
};
|
|
181
|
-
|
|
105
|
+
this.messages.txMessage$.next(wsMsg);
|
|
182
106
|
}
|
|
183
107
|
/** Send a command to WSJT-X to clear the Rx Frequency window. */
|
|
184
|
-
|
|
185
|
-
var _a;
|
|
108
|
+
clearRxFreqWindow() {
|
|
186
109
|
const wsMsg = {
|
|
187
110
|
wsjtx: {
|
|
188
111
|
type: 'ClearMessage',
|
|
189
112
|
payload: { id: this.wsjtxId, window: 1 },
|
|
190
113
|
},
|
|
191
114
|
};
|
|
192
|
-
|
|
115
|
+
this.messages.txMessage$.next(wsMsg);
|
|
193
116
|
}
|
|
194
117
|
/** Send a command to WSJT-X to clear the Band Activity and Rx Frequency windows. */
|
|
195
|
-
|
|
196
|
-
var _a;
|
|
118
|
+
clearAll() {
|
|
197
119
|
const wsMsg = {
|
|
198
120
|
wsjtx: {
|
|
199
121
|
type: 'ClearMessage',
|
|
200
122
|
payload: { id: this.wsjtxId, window: 2 },
|
|
201
123
|
},
|
|
202
124
|
};
|
|
203
|
-
|
|
125
|
+
this.messages.txMessage$.next(wsMsg);
|
|
204
126
|
}
|
|
205
127
|
/** Send a command to WSJT-X to replay messages. Useful for a fresh client that wants to hear
|
|
206
128
|
* previous WSJT-X decodes. */
|
|
207
|
-
|
|
208
|
-
var _a;
|
|
129
|
+
replay() {
|
|
209
130
|
const wsMsg = {
|
|
210
131
|
wsjtx: {
|
|
211
132
|
type: 'ReplayMessage',
|
|
212
133
|
payload: { id: this.wsjtxId },
|
|
213
134
|
},
|
|
214
135
|
};
|
|
215
|
-
|
|
136
|
+
this.messages.txMessage$.next(wsMsg);
|
|
216
137
|
}
|
|
217
138
|
/** Send a command to WSJT-X to halt any transmissions immediately. */
|
|
218
|
-
|
|
219
|
-
var _a;
|
|
139
|
+
haltTxNow() {
|
|
220
140
|
const wsMsg = {
|
|
221
141
|
wsjtx: {
|
|
222
142
|
type: 'HaltTxMessage',
|
|
223
143
|
payload: { id: this.wsjtxId, autoTxOnly: false },
|
|
224
144
|
},
|
|
225
145
|
};
|
|
226
|
-
|
|
146
|
+
this.messages.txMessage$.next(wsMsg);
|
|
227
147
|
}
|
|
228
148
|
/** Send a command to WSJT-X to stop auto-transmitting after finishing the current round. */
|
|
229
|
-
|
|
230
|
-
var _a;
|
|
149
|
+
haltTxAfterCurrent() {
|
|
231
150
|
const wsMsg = {
|
|
232
151
|
wsjtx: {
|
|
233
152
|
type: 'HaltTxMessage',
|
|
234
153
|
payload: { id: this.wsjtxId, autoTxOnly: true },
|
|
235
154
|
},
|
|
236
155
|
};
|
|
237
|
-
|
|
156
|
+
this.messages.txMessage$.next(wsMsg);
|
|
238
157
|
}
|
|
239
158
|
/** Send a command to WSJT-X to reply to the given decode. The message must include CQ or QRZ. */
|
|
240
|
-
|
|
241
|
-
var _a;
|
|
159
|
+
reply(decode) {
|
|
242
160
|
const wsMsg = {
|
|
243
161
|
wsjtx: {
|
|
244
162
|
type: 'ReplyMessage',
|
|
@@ -254,11 +172,10 @@ class AgentService {
|
|
|
254
172
|
},
|
|
255
173
|
},
|
|
256
174
|
};
|
|
257
|
-
|
|
175
|
+
this.messages.txMessage$.next(wsMsg);
|
|
258
176
|
}
|
|
259
177
|
/** Send a command to WSJT-X to reply to the given decode. The message must include CQ or QRZ. */
|
|
260
|
-
|
|
261
|
-
var _a;
|
|
178
|
+
highlightCallsign(highlightMsg) {
|
|
262
179
|
highlightMsg.id = this.wsjtxId;
|
|
263
180
|
const wsMsg = {
|
|
264
181
|
wsjtx: {
|
|
@@ -266,7 +183,7 @@ class AgentService {
|
|
|
266
183
|
payload: highlightMsg,
|
|
267
184
|
},
|
|
268
185
|
};
|
|
269
|
-
|
|
186
|
+
this.messages.txMessage$.next(wsMsg);
|
|
270
187
|
}
|
|
271
188
|
/** Given a decode message, format a string the same way as displayed in the WSJT-X Band
|
|
272
189
|
* Activity/Rx Frequency windows. */
|
|
@@ -284,14 +201,228 @@ class AgentService {
|
|
|
284
201
|
.padStart(4)} ${msg.deltaFrequency.toString().padStart(4)} ~ ${msg.message}`;
|
|
285
202
|
}
|
|
286
203
|
}
|
|
287
|
-
|
|
204
|
+
WsjtxService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: WsjtxService, deps: [{ token: AgentMessageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
205
|
+
WsjtxService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: WsjtxService, providedIn: 'root' });
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: WsjtxService, decorators: [{
|
|
207
|
+
type: Injectable,
|
|
208
|
+
args: [{
|
|
209
|
+
providedIn: 'root',
|
|
210
|
+
}]
|
|
211
|
+
}], ctorParameters: function () { return [{ type: AgentMessageService }]; } });
|
|
212
|
+
|
|
213
|
+
class HamlibService {
|
|
214
|
+
constructor(messages) {
|
|
215
|
+
this.messages = messages;
|
|
216
|
+
/** Whether we're getting any messages from Hamlib. */
|
|
217
|
+
this.connected$ = new BehaviorSubject(false);
|
|
218
|
+
/** Subject for listening to Hamlib "RigState" messages. */
|
|
219
|
+
this.rigState$ = new BehaviorSubject(null);
|
|
220
|
+
this.setupBehaviors();
|
|
221
|
+
}
|
|
222
|
+
setupBehaviors() {
|
|
223
|
+
this.messages.rxMessage$.subscribe((msg) => this.handleMessage(msg));
|
|
224
|
+
// if we haven't heard from Hamlib in 15 seconds, consider it down
|
|
225
|
+
this.connected$.pipe(debounceTime(15000)).subscribe(() => {
|
|
226
|
+
this.connected$.next(false);
|
|
227
|
+
});
|
|
228
|
+
// When Hamlib goes down, clear its persistent message subjects
|
|
229
|
+
this.connected$.subscribe((isUp) => {
|
|
230
|
+
if (!isUp) {
|
|
231
|
+
this.rigState$.next(null);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
handleMessage(msg) {
|
|
236
|
+
if (!msg.hamlib) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.connected$.next(true);
|
|
240
|
+
switch (msg.hamlib.type) {
|
|
241
|
+
case 'RigState':
|
|
242
|
+
this.rigState$.next(msg.hamlib.payload);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
HamlibService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: HamlibService, deps: [{ token: AgentMessageService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
248
|
+
HamlibService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: HamlibService, providedIn: 'root' });
|
|
249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: HamlibService, decorators: [{
|
|
250
|
+
type: Injectable,
|
|
251
|
+
args: [{
|
|
252
|
+
providedIn: 'root',
|
|
253
|
+
}]
|
|
254
|
+
}], ctorParameters: function () { return [{ type: AgentMessageService }]; } });
|
|
255
|
+
|
|
256
|
+
class AgentService {
|
|
257
|
+
constructor(messages, hamlibService, wsjtxService) {
|
|
258
|
+
this.messages = messages;
|
|
259
|
+
this.hamlibService = hamlibService;
|
|
260
|
+
this.wsjtxService = wsjtxService;
|
|
261
|
+
/** Whether we're connected to the agent. */
|
|
262
|
+
this.connectedState$ = new BehaviorSubject(false);
|
|
263
|
+
this.defaultAgentHost = 'localhost';
|
|
264
|
+
this.defaultAgentPort = 8081;
|
|
265
|
+
this.localStorageHostKey = 'agent-host';
|
|
266
|
+
this.localStoragePortKey = 'agent-port';
|
|
267
|
+
this.agentHost = this.defaultAgentHost;
|
|
268
|
+
this.agentPort = this.defaultAgentPort;
|
|
269
|
+
this.agentWebSocketSubject = null;
|
|
270
|
+
this.agentWebsocketSubscription = null;
|
|
271
|
+
this.hamlibState$ = this.hamlibService.connected$;
|
|
272
|
+
this.hamlibRigState$ = this.hamlibService.rigState$;
|
|
273
|
+
this.wsjtxState$ = this.wsjtxService.connected$;
|
|
274
|
+
this.wsjtxHeartbeat$ = this.wsjtxService.heartbeat$;
|
|
275
|
+
this.wsjtxStatus$ = this.wsjtxService.status$;
|
|
276
|
+
this.wsjtxDecode$ = this.wsjtxService.decode$;
|
|
277
|
+
this.wsjtxClear$ = this.wsjtxService.clear$;
|
|
278
|
+
this.wsjtxQsoLogged$ = this.wsjtxService.qsoLogged$;
|
|
279
|
+
this.wsjtxClose$ = this.wsjtxService.close$;
|
|
280
|
+
this.wsjtxWsprDecode$ = this.wsjtxService.wsprDecode$;
|
|
281
|
+
this.wsjtxLoggedAdif$ = this.wsjtxService.loggedAdif$;
|
|
282
|
+
}
|
|
283
|
+
init() {
|
|
284
|
+
this.messages.txMessage$.subscribe((msg) => this.send(msg));
|
|
285
|
+
this.agentHost = this.getHost();
|
|
286
|
+
this.agentPort = this.getPort();
|
|
287
|
+
this.connect();
|
|
288
|
+
}
|
|
289
|
+
/** Connect (or reconnect) the websocket to the kel-agent server. */
|
|
290
|
+
connect() {
|
|
291
|
+
if (this.agentWebsocketSubscription) {
|
|
292
|
+
this.agentWebsocketSubscription.unsubscribe();
|
|
293
|
+
}
|
|
294
|
+
this.agentHost = this.getHost();
|
|
295
|
+
this.agentPort = this.getPort();
|
|
296
|
+
const protocol = this.agentHost === 'localhost' ? 'ws://' : 'wss://';
|
|
297
|
+
this.agentWebSocketSubject = webSocket({
|
|
298
|
+
url: protocol + this.agentHost + ':' + this.agentPort + '/websocket',
|
|
299
|
+
});
|
|
300
|
+
this.connectedState$.next(true);
|
|
301
|
+
this.agentWebsocketSubscription = this.agentWebSocketSubject
|
|
302
|
+
.pipe(retryWhen((errors) =>
|
|
303
|
+
// retry the websocket connection after 10 seconds
|
|
304
|
+
errors.pipe(tap(() => this.connectedState$.next(false)), delay(10000))))
|
|
305
|
+
.subscribe({
|
|
306
|
+
next: (msg) => {
|
|
307
|
+
this.connectedState$.next(true);
|
|
308
|
+
this.messages.rxMessage$.next(msg);
|
|
309
|
+
},
|
|
310
|
+
error: () => this.connectedState$.next(false),
|
|
311
|
+
complete: () => this.connectedState$.next(false),
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/** Get the currently configured kel-agent host. */
|
|
315
|
+
getHost() {
|
|
316
|
+
return (localStorage.getItem(this.localStorageHostKey) || this.defaultAgentHost);
|
|
317
|
+
}
|
|
318
|
+
/** Get the currently configured kel-agent port. */
|
|
319
|
+
getPort() {
|
|
320
|
+
let portStr = localStorage.getItem(this.localStoragePortKey);
|
|
321
|
+
if (portStr == null) {
|
|
322
|
+
return this.defaultAgentPort;
|
|
323
|
+
}
|
|
324
|
+
let portNum = parseInt(portStr, 10);
|
|
325
|
+
if (isNaN(portNum)) {
|
|
326
|
+
return this.defaultAgentPort;
|
|
327
|
+
}
|
|
328
|
+
return portNum;
|
|
329
|
+
}
|
|
330
|
+
/** Set the kel-agent host. */
|
|
331
|
+
setHost(host) {
|
|
332
|
+
localStorage.setItem(this.localStorageHostKey, host);
|
|
333
|
+
this.connect();
|
|
334
|
+
}
|
|
335
|
+
/** Set the kel-agent port. */
|
|
336
|
+
setPort(port) {
|
|
337
|
+
localStorage.setItem(this.localStoragePortKey, String(port));
|
|
338
|
+
this.connect();
|
|
339
|
+
}
|
|
340
|
+
send(wsMsg) {
|
|
341
|
+
var _a;
|
|
342
|
+
(_a = this.agentWebSocketSubject) === null || _a === void 0 ? void 0 : _a.next(wsMsg);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Send a command to WSJT-X to clear the Band Activity window.
|
|
346
|
+
*
|
|
347
|
+
* @deprecated Use {@link WsjtxService.clearBandActivity} instead.
|
|
348
|
+
*/
|
|
349
|
+
sendWsjtxClearBandActivity() {
|
|
350
|
+
this.wsjtxService.clearBandActivity();
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Send a command to WSJT-X to clear the Rx Frequency window.
|
|
354
|
+
*
|
|
355
|
+
* @deprecated Use {@link WsjtxService.clearRxFreqWindow} instead.
|
|
356
|
+
*/
|
|
357
|
+
sendWsjtxClearRxFreqWindow() {
|
|
358
|
+
this.wsjtxService.clearRxFreqWindow();
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Send a command to WSJT-X to clear the Band Activity and Rx Frequency windows.
|
|
362
|
+
*
|
|
363
|
+
* @deprecated Use {@link WsjtxService.clearAll} instead.
|
|
364
|
+
*/
|
|
365
|
+
sendWsjtxClearAll() {
|
|
366
|
+
this.wsjtxService.clearAll();
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Send a command to WSJT-X to replay messages. Useful for a fresh client that wants to hear
|
|
370
|
+
* previous WSJT-X decodes.
|
|
371
|
+
*
|
|
372
|
+
* @deprecated Use {@link WsjtxService.replay} instead.
|
|
373
|
+
*/
|
|
374
|
+
sendWsjtxReplay() {
|
|
375
|
+
this.wsjtxService.replay();
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Send a command to WSJT-X to halt any transmissions immediately.
|
|
379
|
+
*
|
|
380
|
+
* @deprecated Use {@link WsjtxService.haltTxNow} instead.
|
|
381
|
+
*/
|
|
382
|
+
sendWsjtxHaltTxNow() {
|
|
383
|
+
this.wsjtxService.haltTxNow();
|
|
384
|
+
}
|
|
385
|
+
/** Send a command to WSJT-X to stop auto-transmitting after finishing the current round.
|
|
386
|
+
*
|
|
387
|
+
* @deprecated Use {@link WsjtxService.haltTxAfterCurrent} instead.
|
|
388
|
+
*/
|
|
389
|
+
sendWsjtxHaltTxAfterCurrent() {
|
|
390
|
+
this.wsjtxService.haltTxAfterCurrent();
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Send a command to WSJT-X to reply to the given decode. The message must include CQ or QRZ.
|
|
394
|
+
*
|
|
395
|
+
* @deprecated Use {@link WsjtxService.reply} instead.
|
|
396
|
+
*/
|
|
397
|
+
sendWsjtxReply(decode) {
|
|
398
|
+
this.wsjtxService.reply(decode);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Send a command to WSJT-X to reply to the given decode. The message must include CQ or QRZ.
|
|
402
|
+
*
|
|
403
|
+
* @deprecated Use {@link WsjtxService.highlightCallsign} instead.
|
|
404
|
+
*/
|
|
405
|
+
sendWsjtxHighlightCallsign(highlightMsg) {
|
|
406
|
+
this.wsjtxService.highlightCallsign(highlightMsg);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Given a decode message, format a string the same way as displayed in the WSJT-X Band
|
|
410
|
+
* Activity/Rx Frequency windows.
|
|
411
|
+
*
|
|
412
|
+
* @deprecated Use {@link WsjtxService.formatDecode} instead.
|
|
413
|
+
*/
|
|
414
|
+
static formatDecode(msg) {
|
|
415
|
+
return WsjtxService.formatDecode(msg);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
AgentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AgentService, deps: [{ token: AgentMessageService }, { token: HamlibService }, { token: WsjtxService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
288
419
|
AgentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AgentService, providedIn: 'root' });
|
|
289
420
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: AgentService, decorators: [{
|
|
290
421
|
type: Injectable,
|
|
291
422
|
args: [{
|
|
292
|
-
providedIn: 'root'
|
|
423
|
+
providedIn: 'root',
|
|
293
424
|
}]
|
|
294
|
-
}], ctorParameters: function () { return []; } });
|
|
425
|
+
}], ctorParameters: function () { return [{ type: AgentMessageService }, { type: HamlibService }, { type: WsjtxService }]; } });
|
|
295
426
|
|
|
296
427
|
/*
|
|
297
428
|
* Public API Surface of ngx-kel-agent
|
|
@@ -303,5 +434,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
303
434
|
* Generated bundle index. Do not edit.
|
|
304
435
|
*/
|
|
305
436
|
|
|
306
|
-
export { AgentService };
|
|
437
|
+
export { AgentMessageService, AgentService, HamlibService, WsjtxService };
|
|
307
438
|
//# sourceMappingURL=ngx-kel-agent.mjs.map
|