@robdobsn/raftjs 1.7.2 → 1.7.3

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.
Files changed (188) hide show
  1. package/dist/web/RaftAttributeHandler.js +5 -5
  2. package/dist/web/RaftAttributeHandler.js.map +1 -1
  3. package/package.json +5 -2
  4. package/.editorconfig +0 -14
  5. package/.gitattributes +0 -11
  6. package/.nvmrc +0 -1
  7. package/TODO.md +0 -1
  8. package/dist/react-native/RaftAttributeHandler.d.ts +0 -12
  9. package/dist/react-native/RaftAttributeHandler.js +0 -249
  10. package/dist/react-native/RaftAttributeHandler.js.map +0 -1
  11. package/dist/react-native/RaftChannel.d.ts +0 -20
  12. package/dist/react-native/RaftChannel.js +0 -12
  13. package/dist/react-native/RaftChannel.js.map +0 -1
  14. package/dist/react-native/RaftChannelBLE.native.d.ts +0 -95
  15. package/dist/react-native/RaftChannelBLE.native.js +0 -482
  16. package/dist/react-native/RaftChannelBLE.native.js.map +0 -1
  17. package/dist/react-native/RaftChannelBLE.web.d.ts +0 -40
  18. package/dist/react-native/RaftChannelBLE.web.js +0 -300
  19. package/dist/react-native/RaftChannelBLE.web.js.map +0 -1
  20. package/dist/react-native/RaftChannelBLEFactory.d.ts +0 -10
  21. package/dist/react-native/RaftChannelBLEFactory.js +0 -17
  22. package/dist/react-native/RaftChannelBLEFactory.js.map +0 -1
  23. package/dist/react-native/RaftChannelBLEScanner.native.d.ts +0 -18
  24. package/dist/react-native/RaftChannelBLEScanner.native.js +0 -138
  25. package/dist/react-native/RaftChannelBLEScanner.native.js.map +0 -1
  26. package/dist/react-native/RaftChannelSimulated.d.ts +0 -32
  27. package/dist/react-native/RaftChannelSimulated.js +0 -418
  28. package/dist/react-native/RaftChannelSimulated.js.map +0 -1
  29. package/dist/react-native/RaftChannelWebSerial.d.ts +0 -39
  30. package/dist/react-native/RaftChannelWebSerial.js +0 -329
  31. package/dist/react-native/RaftChannelWebSerial.js.map +0 -1
  32. package/dist/react-native/RaftChannelWebSocket.d.ts +0 -30
  33. package/dist/react-native/RaftChannelWebSocket.js +0 -207
  34. package/dist/react-native/RaftChannelWebSocket.js.map +0 -1
  35. package/dist/react-native/RaftCommsStats.d.ts +0 -39
  36. package/dist/react-native/RaftCommsStats.js +0 -128
  37. package/dist/react-native/RaftCommsStats.js.map +0 -1
  38. package/dist/react-native/RaftConnEvents.d.ts +0 -39
  39. package/dist/react-native/RaftConnEvents.js +0 -54
  40. package/dist/react-native/RaftConnEvents.js.map +0 -1
  41. package/dist/react-native/RaftConnector.d.ts +0 -245
  42. package/dist/react-native/RaftConnector.js +0 -621
  43. package/dist/react-native/RaftConnector.js.map +0 -1
  44. package/dist/react-native/RaftCustomAttrHandler.d.ts +0 -4
  45. package/dist/react-native/RaftCustomAttrHandler.js +0 -50
  46. package/dist/react-native/RaftCustomAttrHandler.js.map +0 -1
  47. package/dist/react-native/RaftDeviceInfo.d.ts +0 -63
  48. package/dist/react-native/RaftDeviceInfo.js +0 -36
  49. package/dist/react-native/RaftDeviceInfo.js.map +0 -1
  50. package/dist/react-native/RaftDeviceManager.d.ts +0 -40
  51. package/dist/react-native/RaftDeviceManager.js +0 -499
  52. package/dist/react-native/RaftDeviceManager.js.map +0 -1
  53. package/dist/react-native/RaftDeviceMgrIF.d.ts +0 -15
  54. package/dist/react-native/RaftDeviceMgrIF.js +0 -11
  55. package/dist/react-native/RaftDeviceMgrIF.js.map +0 -1
  56. package/dist/react-native/RaftDeviceMsg.d.ts +0 -9
  57. package/dist/react-native/RaftDeviceMsg.js +0 -11
  58. package/dist/react-native/RaftDeviceMsg.js.map +0 -1
  59. package/dist/react-native/RaftDeviceStates.d.ts +0 -37
  60. package/dist/react-native/RaftDeviceStates.js +0 -60
  61. package/dist/react-native/RaftDeviceStates.js.map +0 -1
  62. package/dist/react-native/RaftFileHandler.d.ts +0 -52
  63. package/dist/react-native/RaftFileHandler.js +0 -502
  64. package/dist/react-native/RaftFileHandler.js.map +0 -1
  65. package/dist/react-native/RaftLog.d.ts +0 -22
  66. package/dist/react-native/RaftLog.js +0 -63
  67. package/dist/react-native/RaftLog.js.map +0 -1
  68. package/dist/react-native/RaftMiniHDLC.d.ts +0 -18
  69. package/dist/react-native/RaftMiniHDLC.js +0 -383
  70. package/dist/react-native/RaftMiniHDLC.js.map +0 -1
  71. package/dist/react-native/RaftMsgHandler.d.ts +0 -62
  72. package/dist/react-native/RaftMsgHandler.js +0 -511
  73. package/dist/react-native/RaftMsgHandler.js.map +0 -1
  74. package/dist/react-native/RaftMsgTrackInfo.d.ts +0 -17
  75. package/dist/react-native/RaftMsgTrackInfo.js +0 -42
  76. package/dist/react-native/RaftMsgTrackInfo.js.map +0 -1
  77. package/dist/react-native/RaftProtocolDefs.d.ts +0 -30
  78. package/dist/react-native/RaftProtocolDefs.js +0 -48
  79. package/dist/react-native/RaftProtocolDefs.js.map +0 -1
  80. package/dist/react-native/RaftStreamHandler.d.ts +0 -38
  81. package/dist/react-native/RaftStreamHandler.js +0 -257
  82. package/dist/react-native/RaftStreamHandler.js.map +0 -1
  83. package/dist/react-native/RaftStruct.d.ts +0 -3
  84. package/dist/react-native/RaftStruct.js +0 -208
  85. package/dist/react-native/RaftStruct.js.map +0 -1
  86. package/dist/react-native/RaftSysTypeManager.d.ts +0 -14
  87. package/dist/react-native/RaftSysTypeManager.js +0 -53
  88. package/dist/react-native/RaftSysTypeManager.js.map +0 -1
  89. package/dist/react-native/RaftSystemType.d.ts +0 -28
  90. package/dist/react-native/RaftSystemType.js +0 -3
  91. package/dist/react-native/RaftSystemType.js.map +0 -1
  92. package/dist/react-native/RaftSystemUtils.d.ts +0 -136
  93. package/dist/react-native/RaftSystemUtils.js +0 -410
  94. package/dist/react-native/RaftSystemUtils.js.map +0 -1
  95. package/dist/react-native/RaftTypes.d.ts +0 -194
  96. package/dist/react-native/RaftTypes.js +0 -153
  97. package/dist/react-native/RaftTypes.js.map +0 -1
  98. package/dist/react-native/RaftUpdateEvents.d.ts +0 -33
  99. package/dist/react-native/RaftUpdateEvents.js +0 -46
  100. package/dist/react-native/RaftUpdateEvents.js.map +0 -1
  101. package/dist/react-native/RaftUpdateManager.d.ts +0 -61
  102. package/dist/react-native/RaftUpdateManager.js +0 -621
  103. package/dist/react-native/RaftUpdateManager.js.map +0 -1
  104. package/dist/react-native/RaftUtils.d.ts +0 -126
  105. package/dist/react-native/RaftUtils.js +0 -467
  106. package/dist/react-native/RaftUtils.js.map +0 -1
  107. package/dist/react-native/RaftWifiTypes.d.ts +0 -23
  108. package/dist/react-native/RaftWifiTypes.js +0 -43
  109. package/dist/react-native/RaftWifiTypes.js.map +0 -1
  110. package/dist/react-native/main.d.ts +0 -25
  111. package/dist/react-native/main.js +0 -51
  112. package/dist/react-native/main.js.map +0 -1
  113. package/eslint.config.mjs +0 -33
  114. package/examples/dashboard/package.json +0 -36
  115. package/examples/dashboard/src/CommandPanel.tsx +0 -147
  116. package/examples/dashboard/src/ConnManager.ts +0 -164
  117. package/examples/dashboard/src/DeviceActionsForm.tsx +0 -133
  118. package/examples/dashboard/src/DeviceAttrsForm.tsx +0 -49
  119. package/examples/dashboard/src/DeviceLineChart.tsx +0 -163
  120. package/examples/dashboard/src/DevicePanel.tsx +0 -166
  121. package/examples/dashboard/src/DevicesPanel.tsx +0 -58
  122. package/examples/dashboard/src/DispLedGrid.tsx +0 -110
  123. package/examples/dashboard/src/DispOneLed.tsx +0 -20
  124. package/examples/dashboard/src/LatencyTest.ts +0 -130
  125. package/examples/dashboard/src/LatencyTestPanel.tsx +0 -92
  126. package/examples/dashboard/src/Main.tsx +0 -234
  127. package/examples/dashboard/src/SettingsManager.ts +0 -67
  128. package/examples/dashboard/src/SettingsScreen.tsx +0 -174
  129. package/examples/dashboard/src/StatusPanel.tsx +0 -71
  130. package/examples/dashboard/src/SystemTypeCog/CogStateInfo.ts +0 -163
  131. package/examples/dashboard/src/SystemTypeCog/SystemTypeCog.ts +0 -91
  132. package/examples/dashboard/src/SystemTypeGeneric/StateInfoGeneric.ts +0 -30
  133. package/examples/dashboard/src/SystemTypeGeneric/SystemTypeGeneric.ts +0 -91
  134. package/examples/dashboard/src/SystemTypeMarty/RICAddOn.ts +0 -70
  135. package/examples/dashboard/src/SystemTypeMarty/RICAddOnBase.ts +0 -33
  136. package/examples/dashboard/src/SystemTypeMarty/RICAddOnManager.ts +0 -342
  137. package/examples/dashboard/src/SystemTypeMarty/RICCommsStats.ts +0 -170
  138. package/examples/dashboard/src/SystemTypeMarty/RICHWElem.ts +0 -123
  139. package/examples/dashboard/src/SystemTypeMarty/RICLEDPatternChecker.ts +0 -207
  140. package/examples/dashboard/src/SystemTypeMarty/RICROSSerial.ts +0 -464
  141. package/examples/dashboard/src/SystemTypeMarty/RICServoFaultDetector.ts +0 -146
  142. package/examples/dashboard/src/SystemTypeMarty/RICStateInfo.ts +0 -97
  143. package/examples/dashboard/src/SystemTypeMarty/RICSystemUtils.ts +0 -371
  144. package/examples/dashboard/src/SystemTypeMarty/RICTypes.ts +0 -20
  145. package/examples/dashboard/src/SystemTypeMarty/SystemTypeMarty.ts +0 -119
  146. package/examples/dashboard/src/index.html +0 -15
  147. package/examples/dashboard/src/index.tsx +0 -13
  148. package/examples/dashboard/src/styles.css +0 -408
  149. package/examples/dashboard/tsconfig.json +0 -18
  150. package/jest.config.js +0 -11
  151. package/src/RaftAttributeHandler.ts +0 -298
  152. package/src/RaftChannel.ts +0 -32
  153. package/src/RaftChannelBLE.native.ts +0 -616
  154. package/src/RaftChannelBLE.web.ts +0 -372
  155. package/src/RaftChannelBLEFactory.ts +0 -13
  156. package/src/RaftChannelBLEScanner.native.ts +0 -184
  157. package/src/RaftChannelSimulated.ts +0 -482
  158. package/src/RaftChannelWebSerial.ts +0 -420
  159. package/src/RaftChannelWebSocket.ts +0 -258
  160. package/src/RaftCommsStats.ts +0 -142
  161. package/src/RaftConnEvents.ts +0 -58
  162. package/src/RaftConnector.ts +0 -743
  163. package/src/RaftCustomAttrHandler.ts +0 -54
  164. package/src/RaftDeviceInfo.ts +0 -102
  165. package/src/RaftDeviceManager.ts +0 -607
  166. package/src/RaftDeviceMgrIF.ts +0 -33
  167. package/src/RaftDeviceMsg.ts +0 -20
  168. package/src/RaftDeviceStates.ts +0 -92
  169. package/src/RaftFileHandler.ts +0 -668
  170. package/src/RaftLog.ts +0 -70
  171. package/src/RaftMiniHDLC.ts +0 -396
  172. package/src/RaftMsgHandler.ts +0 -813
  173. package/src/RaftMsgTrackInfo.ts +0 -51
  174. package/src/RaftProtocolDefs.ts +0 -46
  175. package/src/RaftStreamHandler.ts +0 -328
  176. package/src/RaftStruct.ts +0 -209
  177. package/src/RaftSysTypeManager.ts +0 -60
  178. package/src/RaftSystemType.ts +0 -32
  179. package/src/RaftSystemUtils.ts +0 -487
  180. package/src/RaftTypes.ts +0 -278
  181. package/src/RaftUpdateEvents.ts +0 -48
  182. package/src/RaftUpdateManager.ts +0 -781
  183. package/src/RaftUtils.ts +0 -494
  184. package/src/RaftWifiTypes.ts +0 -36
  185. package/src/main.ts +0 -38
  186. package/testdata/TestDeviceTypeRecs.json +0 -492
  187. package/tsconfig.json +0 -30
  188. package/tsconfig.react-native.json +0 -29
@@ -1,813 +0,0 @@
1
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
- //
3
- // RaftMsgHandler
4
- // Part of RaftJS
5
- //
6
- // Rob Dobson & Chris Greening 2020-2024
7
- // (C) 2020-2024 All rights reserved
8
- //
9
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10
-
11
- import RaftCommsStats from './RaftCommsStats';
12
- import { RaftMsgTrackInfo } from './RaftMsgTrackInfo';
13
- import RaftLog from './RaftLog';
14
- import RaftUtils from './RaftUtils';
15
- import {
16
- RICSERIAL_MSG_NUM_POS,
17
- RICSERIAL_PAYLOAD_POS,
18
- RICSERIAL_PROTOCOL_POS,
19
- RICREST_REST_ELEM_CODE_POS,
20
- RICREST_HEADER_PAYLOAD_POS,
21
- RICREST_FILEBLOCK_FILEPOS_POS,
22
- RICREST_FILEBLOCK_PAYLOAD_POS,
23
- RICREST_BRIDGE_PAYLOAD_POS,
24
- RICREST_BRIDGE_ID_POS,
25
- RICRESTElemCode,
26
- RaftCommsMsgProtocol,
27
- RaftCommsMsgTypeCode,
28
- } from './RaftProtocolDefs';
29
- import RaftMiniHDLC from './RaftMiniHDLC';
30
- import { RaftBridgeSetupResp, RaftReportMsg } from './RaftTypes';
31
-
32
- // Message results
33
- export enum RaftMsgResultCode {
34
- MESSAGE_RESULT_TIMEOUT,
35
- MESSAGE_RESULT_OK,
36
- MESSAGE_RESULT_FAIL,
37
- MESSAGE_RESULT_UNKNOWN,
38
- }
39
-
40
- export interface RaftMessageResult {
41
- onRxReply(
42
- msgHandle: number,
43
- msgRsltCode: RaftMsgResultCode,
44
- msgRsltJsonObj: object | null,
45
- ): void;
46
- onRxUnnumberedMsg(msgRsltJsonObj: object): void;
47
- onRxFileBlock(
48
- filePos: number,
49
- fileBlockData: Uint8Array
50
- ): void;
51
- onRxOtherMsgType(payload: Uint8Array, frameTimeMs: number): void;
52
- }
53
-
54
- export interface RaftMessageSender {
55
- sendTxMsg(
56
- msg: Uint8Array,
57
- sendWithResponse: boolean,
58
- ): Promise<boolean>;
59
- sendTxMsgNoAwait(
60
- msg: Uint8Array,
61
- sendWithResponse: boolean,
62
- ): Promise<boolean>;
63
- sendTxMsgRaw(msg: string): boolean;
64
- sendTxMsgRawAndWaitForReply<T>(msgPayload: Uint8Array): T;
65
- }
66
-
67
- export default class RaftMsgHandler {
68
- // Message numbering and tracking
69
- private _currentMsgNumber = 1;
70
- private _currentMsgHandle = 1;
71
- private _msgTrackInfos: Array<RaftMsgTrackInfo> = new Array<RaftMsgTrackInfo>(
72
- RaftMsgTrackInfo.MAX_MSG_NUM + 1,
73
- );
74
- private _msgTrackTimerMs = 50;
75
- private _msgTrackLastCheckIdx = 0;
76
-
77
- // report message callback dictionary. Add a callback to subscribe to report messages
78
- private _reportMsgCallbacks = new Map<string, (report: RaftReportMsg) => void>();
79
-
80
- // Interface to inform of message results
81
- private _msgResultHandler: RaftMessageResult | null = null;
82
-
83
- // Interface to send messages
84
- private _msgSender: RaftMessageSender | null = null;
85
-
86
- // Comms stats
87
- private _commsStats: RaftCommsStats;
88
-
89
- // RaftMiniHDLC - handles part of RICSerial protocol
90
- private _miniHDLC: RaftMiniHDLC;
91
-
92
- // Raw message mode
93
- private _rawMsgMode = false;
94
-
95
- // Constructor
96
- constructor(commsStats: RaftCommsStats) {
97
- this._commsStats = commsStats;
98
- RaftLog.debug('RaftMsgHandler constructor');
99
-
100
- // Message tracking
101
- for (let i = 0; i < this._msgTrackInfos.length; i++) {
102
- this._msgTrackInfos[i] = new RaftMsgTrackInfo();
103
- }
104
-
105
- // Timer for checking messages
106
- setTimeout(async () => {
107
- this._onMsgTrackTimer(true);
108
- }, this._msgTrackTimerMs);
109
-
110
- // HDLC used to encode/decode the RICREST protocol
111
- this._miniHDLC = new RaftMiniHDLC();
112
- this._miniHDLC.setOnRxFrame(this._onHDLCFrameDecode.bind(this));
113
- }
114
-
115
- registerForResults(msgResultHandler: RaftMessageResult) {
116
- this._msgResultHandler = msgResultHandler;
117
- }
118
-
119
- registerMsgSender(RaftMessageSender: RaftMessageSender) {
120
- this._msgSender = RaftMessageSender;
121
- }
122
-
123
- handleNewRxMsg(rxMsg: Uint8Array): void {
124
- this._miniHDLC.addRxBytes(rxMsg);
125
- // RaftLog.verbose(`handleNewRxMsg len ${rxMsg.length} ${RaftUtils.bufferToHex(rxMsg)}`)
126
- }
127
-
128
- // This is currently only for testing and simulated channels
129
- handleNewRxMsgRaw(rxMsg: Uint8Array, rxMsgType: RaftCommsMsgTypeCode, rxMsgNum: number, rxMsgTimeMs: number): void {
130
- // Check message types
131
- if (rxMsgType == RaftCommsMsgTypeCode.MSG_TYPE_RESPONSE) {
132
- // Convert raw Uint8Array to string assuming UTF-8
133
- const restStr = new TextDecoder('utf-8').decode(rxMsg);
134
- this._handleResponseMessages(restStr, rxMsgNum);
135
- } else if (rxMsgType == RaftCommsMsgTypeCode.MSG_TYPE_REPORT) {
136
- // Convert raw Uint8Array to string assuming UTF-8
137
- const restStr = new TextDecoder('utf-8').decode(rxMsg);
138
- this._handleReportMessages(restStr);
139
- } else {
140
- this._msgResultHandler?.onRxOtherMsgType(rxMsg, rxMsgTimeMs);
141
- }
142
- }
143
-
144
- reportMsgCallbacksSet(callbackName: string, callback: (report: RaftReportMsg) => void): void {
145
- this._reportMsgCallbacks.set(callbackName, callback);
146
- }
147
-
148
- reportMsgCallbacksDelete(callbackName: string) {
149
- this._reportMsgCallbacks.delete(callbackName);
150
- }
151
-
152
- setRawMsgMode(isRawMode: boolean): void {
153
- this._rawMsgMode = isRawMode;
154
- RaftLog.debug(`setRawMsgMode ${isRawMode}`);
155
- }
156
-
157
- _onHDLCFrameDecode(rxMsg: Uint8Array, frameTimeMs: number): void {
158
- // Add to stats
159
- this._commsStats.msgRx();
160
-
161
- // Validity
162
- if (rxMsg.length < RICSERIAL_PAYLOAD_POS) {
163
- this._commsStats.msgTooShort();
164
- return;
165
- }
166
-
167
- // RaftLog.verbose(`_onHDLCFrameDecode len ${rxMsg.length}`);
168
-
169
- // Decode the RICFrame header
170
- let rxMsgNum = rxMsg[RICSERIAL_MSG_NUM_POS] & 0xff;
171
- let rxProtocol = rxMsg[RICSERIAL_PROTOCOL_POS] & 0x3f;
172
- let rxMsgType = (rxMsg[RICSERIAL_PROTOCOL_POS] >> 6) & 0x03;
173
-
174
- // Check for RICREST bridging protocol
175
- if (rxProtocol == RaftCommsMsgProtocol.MSG_PROTOCOL_BRIDGE_RICREST) {
176
-
177
- // Debug
178
- const bridgeID = rxMsg.length > RICREST_BRIDGE_ID_POS ? rxMsg[RICREST_BRIDGE_ID_POS] : 0;
179
- RaftLog.info(
180
- `_onHDLCFrameDecode RICREST bridge rx bridgeID ${bridgeID} len ${rxMsg.length}`
181
- );
182
-
183
- // Simply remove the wrapper
184
- rxMsg = rxMsg.slice(RICREST_BRIDGE_PAYLOAD_POS);
185
-
186
- // Get the message info from the unwrapped message
187
- rxMsgNum = rxMsg[RICSERIAL_MSG_NUM_POS] & 0xff;
188
- rxProtocol = rxMsg[RICSERIAL_PROTOCOL_POS] & 0x3f;
189
- rxMsgType = (rxMsg[RICSERIAL_PROTOCOL_POS] >> 6) & 0x03;
190
- }
191
-
192
- // Check for RICREST protocol
193
- if (rxProtocol == RaftCommsMsgProtocol.MSG_PROTOCOL_RICREST) {
194
- RaftLog.verbose(
195
- `_onHDLCFrameDecode RICREST rx msgNum ${rxMsgNum} msgDirn ${rxMsgType} ${RaftUtils.bufferToHex(
196
- rxMsg,
197
- )}`,
198
- );
199
- // Extract payload
200
- const ricRestElemCode =
201
- rxMsg[RICSERIAL_PAYLOAD_POS + RICREST_REST_ELEM_CODE_POS] & 0xff;
202
- if (
203
- ricRestElemCode == RICRESTElemCode.RICREST_ELEM_CODE_URL ||
204
- ricRestElemCode == RICRESTElemCode.RICREST_ELEM_CODE_CMDRESPJSON ||
205
- ricRestElemCode == RICRESTElemCode.RICREST_ELEM_CODE_COMMAND_FRAME
206
- ) {
207
- // These are all text-based messages
208
- const restStr = RaftUtils.getStringFromBuffer(
209
- rxMsg,
210
- RICSERIAL_PAYLOAD_POS + RICREST_HEADER_PAYLOAD_POS,
211
- rxMsg.length - RICSERIAL_PAYLOAD_POS - RICREST_HEADER_PAYLOAD_POS - 1,
212
- );
213
- RaftLog.verbose(
214
- `_onHDLCFrameDecode RICREST rx elemCode ${ricRestElemCode} ${restStr}`,
215
- );
216
-
217
- // Check message types
218
- if (rxMsgType == RaftCommsMsgTypeCode.MSG_TYPE_RESPONSE) {
219
-
220
- // Handle response messages
221
- this._handleResponseMessages(restStr, rxMsgNum);
222
-
223
- } else if (rxMsgType == RaftCommsMsgTypeCode.MSG_TYPE_REPORT) {
224
-
225
- // Handle report messages
226
- this._handleReportMessages(restStr);
227
-
228
- }
229
-
230
- } else {
231
- const binMsgLen = rxMsg.length - RICSERIAL_PAYLOAD_POS - RICREST_HEADER_PAYLOAD_POS;
232
- RaftLog.verbose(
233
- `_onHDLCFrameDecode RICREST rx binary message elemCode ${ricRestElemCode} len ${binMsgLen} data ${RaftUtils.bufferToHex(rxMsg)}`,
234
- );
235
- if (ricRestElemCode == RICRESTElemCode.RICREST_ELEM_CODE_FILEBLOCK) {
236
- const filePos = RaftUtils.getBEUint32FromBuf(rxMsg, RICSERIAL_PAYLOAD_POS + RICREST_HEADER_PAYLOAD_POS + RICREST_FILEBLOCK_FILEPOS_POS);
237
- this._msgResultHandler?.onRxFileBlock(
238
- filePos,
239
- rxMsg.slice(RICSERIAL_PAYLOAD_POS + RICREST_HEADER_PAYLOAD_POS + RICREST_FILEBLOCK_PAYLOAD_POS, rxMsg.length));
240
- }
241
- }
242
-
243
- // Other message types
244
- } else {
245
- this._msgResultHandler?.onRxOtherMsgType(rxMsg, frameTimeMs);
246
- }
247
- }
248
-
249
- _handleResponseMessages(restStr: string, rxMsgNum: number): void {
250
- try {
251
- let msgRsltCode = RaftMsgResultCode.MESSAGE_RESULT_UNKNOWN;
252
- const msgRsltJsonObj = JSON.parse(restStr);
253
- if ('rslt' in msgRsltJsonObj) {
254
- const rsltStr = msgRsltJsonObj.rslt.toLowerCase();
255
- if (rsltStr === 'ok') {
256
- RaftLog.verbose(
257
- `_handleResponseMessages RICREST rslt Ok ${rxMsgNum == 0 ? "unnumbered" : "msgNum " + rxMsgNum.toString()} resp ${msgRsltJsonObj.rslt}`,
258
- );
259
- msgRsltCode = RaftMsgResultCode.MESSAGE_RESULT_OK;
260
- } else if (rsltStr === 'fail') {
261
- msgRsltCode = RaftMsgResultCode.MESSAGE_RESULT_FAIL;
262
- RaftLog.warn(
263
- `_handleResponseMessages RICREST rslt fail ${rxMsgNum == 0 ? "unnumbered" : "msgNum " + rxMsgNum.toString()} resp ${restStr}`,
264
- );
265
- } else {
266
- RaftLog.warn(
267
- `_handleResponseMessages RICREST rslt not recognized ${rxMsgNum == 0 ? "unnumbered" : "msgNum " + rxMsgNum.toString()}resp ${restStr}`,
268
- );
269
- }
270
-
271
- } else {
272
- RaftLog.warn(
273
- `_handleResponseMessages RICREST response doesn't contain rslt ${rxMsgNum == 0 ? "unnumbered" : "msgNum " + rxMsgNum.toString()}resp ${restStr}`,
274
- );
275
- }
276
-
277
- // Handle matching of request and response
278
- this.msgTrackingRxRespMsg(rxMsgNum, msgRsltCode, msgRsltJsonObj);
279
-
280
- } catch (excp: unknown) {
281
- if (excp instanceof Error) {
282
- RaftLog.warn(
283
- `_handleResponseMessages Failed to parse JSON ${rxMsgNum == 0 ? "unnumbered" : "msgNum " + rxMsgNum.toString()} JSON STR ${restStr} resp ${excp.toString()}`,
284
- );
285
- }
286
- }
287
-
288
- }
289
-
290
- _handleReportMessages(restStr: string): void {
291
- try {
292
- const reportMsg: RaftReportMsg = JSON.parse(restStr);
293
- reportMsg.timeReceived = Date.now();
294
- RaftLog.debug(`_handleReportMessages ${JSON.stringify(reportMsg)}`);
295
- this._reportMsgCallbacks.forEach((callback) => callback(reportMsg));
296
- } catch (excp: unknown) {
297
- if (excp instanceof Error) {
298
- RaftLog.warn(
299
- `_handleReportMessages Failed to parse JSON report ${excp.toString()}`,
300
- );
301
- }
302
- }
303
- }
304
-
305
- async sendRICRESTURL<T>(
306
- cmdStr: string,
307
- bridgeID: number | undefined = undefined,
308
- msgTimeoutMs: number | undefined = undefined,
309
- ): Promise<T> {
310
- // Send
311
- return this.sendRICREST(
312
- cmdStr,
313
- RICRESTElemCode.RICREST_ELEM_CODE_URL,
314
- bridgeID,
315
- msgTimeoutMs,
316
- );
317
- }
318
-
319
- async sendRICRESTCmdFrame<T>(
320
- cmdStr: string,
321
- bridgeID: number | undefined = undefined,
322
- msgTimeoutMs: number | undefined = undefined,
323
- ): Promise<T> {
324
- // Send
325
- return this.sendRICREST(
326
- cmdStr,
327
- RICRESTElemCode.RICREST_ELEM_CODE_COMMAND_FRAME,
328
- bridgeID,
329
- msgTimeoutMs,
330
- );
331
- }
332
-
333
- async sendRICREST<T>(
334
- cmdStr: string,
335
- ricRESTElemCode: RICRESTElemCode,
336
- bridgeID: number | undefined = undefined,
337
- msgTimeoutMs: number | undefined = undefined,
338
- ): Promise<T> {
339
- // Put cmdStr into buffer
340
- const cmdStrTerm = new Uint8Array(cmdStr.length + 1);
341
- RaftUtils.addStringToBuffer(cmdStrTerm, cmdStr, 0);
342
- cmdStrTerm[cmdStrTerm.length - 1] = 0;
343
-
344
- // Send
345
- return this.sendRICRESTBytes(
346
- cmdStrTerm,
347
- ricRESTElemCode,
348
- true,
349
- bridgeID,
350
- msgTimeoutMs,
351
- );
352
- }
353
-
354
- async sendRICRESTNoResp(
355
- cmdStr: string,
356
- ricRESTElemCode: RICRESTElemCode,
357
- bridgeID: number | undefined = undefined,
358
- ): Promise<boolean> {
359
-
360
- // Check there is a sender
361
- if (!this._msgSender) {
362
- return false;
363
- }
364
-
365
- // Check for raw message mode (used for testing and simulated channels)
366
- if (this._rawMsgMode) {
367
- return this._msgSender.sendTxMsgRaw(cmdStr);
368
- }
369
-
370
- // Put cmdStr into buffer
371
- const cmdBytes = new Uint8Array(cmdStr.length + 1);
372
- RaftUtils.addStringToBuffer(cmdBytes, cmdStr, 0);
373
- cmdBytes[cmdBytes.length - 1] = 0;
374
-
375
- // Form message
376
- const cmdMsg = new Uint8Array(cmdBytes.length + RICREST_HEADER_PAYLOAD_POS);
377
- cmdMsg[RICREST_REST_ELEM_CODE_POS] = ricRESTElemCode;
378
- cmdMsg.set(cmdBytes, RICREST_HEADER_PAYLOAD_POS);
379
-
380
- // Frame the message
381
- let framedMsg = this.frameCommsMsg(cmdMsg,
382
- RaftCommsMsgTypeCode.MSG_TYPE_COMMAND,
383
- RaftCommsMsgProtocol.MSG_PROTOCOL_RICREST,
384
- true);
385
-
386
- // Wrap if bridged
387
- if (bridgeID !== undefined) {
388
- framedMsg = this.bridgeCommsMsg(framedMsg, bridgeID);
389
- }
390
-
391
- // Encode like HDLC
392
- const encodedMsg = this._miniHDLC.encode(framedMsg);
393
-
394
- // Send
395
- if (!await this._msgSender.sendTxMsg(encodedMsg, false)) {
396
- RaftLog.warn(`sendRICRESTNoResp failed to send message`);
397
- this._commsStats.recordMsgNoConnection();
398
- }
399
-
400
- return true;
401
- }
402
-
403
- async sendRICRESTBytes<T>(
404
- cmdBytes: Uint8Array,
405
- ricRESTElemCode: RICRESTElemCode,
406
- withResponse: boolean,
407
- bridgeID: number | undefined = undefined,
408
- msgTimeoutMs: number | undefined = undefined,
409
- ): Promise<T> {
410
- // Form message
411
- const cmdMsg = new Uint8Array(cmdBytes.length + RICREST_HEADER_PAYLOAD_POS);
412
- cmdMsg[RICREST_REST_ELEM_CODE_POS] = ricRESTElemCode;
413
- cmdMsg.set(cmdBytes, RICREST_HEADER_PAYLOAD_POS);
414
-
415
- // Send
416
- return this.sendMsgAndWaitForReply<T>(
417
- cmdMsg,
418
- RaftCommsMsgTypeCode.MSG_TYPE_COMMAND,
419
- RaftCommsMsgProtocol.MSG_PROTOCOL_RICREST,
420
- withResponse,
421
- bridgeID,
422
- msgTimeoutMs,
423
- );
424
- }
425
-
426
- async sendMsgAndWaitForReply<T>(
427
- msgPayload: Uint8Array,
428
- msgDirection: RaftCommsMsgTypeCode,
429
- msgProtocol: RaftCommsMsgProtocol,
430
- withResponse: boolean,
431
- bridgeID: number | undefined = undefined,
432
- msgTimeoutMs: number | undefined,
433
- ): Promise<T> {
434
-
435
- // Check there is a sender
436
- if (!this._msgSender) {
437
- throw new Error('sendMsgAndWaitForReply failed no sender');
438
- }
439
-
440
- // Check for raw message mode (used for testing and simulated channels)
441
- if (this._rawMsgMode) {
442
- return this._msgSender.sendTxMsgRawAndWaitForReply(msgPayload);
443
- }
444
-
445
- // Frame the message
446
- let framedMsg = this.frameCommsMsg(msgPayload, msgDirection, msgProtocol, true);
447
-
448
- // Wrap if bridged
449
- if (bridgeID !== undefined) {
450
- framedMsg = this.bridgeCommsMsg(framedMsg, bridgeID);
451
- // RaftLog.debug(`sendMsgAndWaitForReply - bridged idx ${bridgeID}`)
452
- } else {
453
- // RaftLog.debug(`sendMsgAndWaitForReply - not bridged`)
454
- }
455
-
456
- // Encode like HDLC
457
- const encodedMsg = this._miniHDLC.encode(framedMsg);
458
-
459
- // Debug
460
- // RaftLog.debug(
461
- // `sendMsgAndWaitForReply ${RaftUtils.bufferToHex(encodedMsg)}`,
462
- // );
463
-
464
- // Return a promise that will be resolved when a reply is received or timeout occurs
465
- const promise = new Promise<T>((resolve, reject) => {
466
-
467
- // Update message tracking
468
- this.msgTrackingTxCmdMsg<T>(
469
- encodedMsg,
470
- withResponse,
471
- bridgeID,
472
- msgTimeoutMs,
473
- resolve,
474
- reject,
475
- );
476
- this._currentMsgHandle++;
477
- });
478
-
479
- return promise;
480
- }
481
-
482
- frameCommsMsg(
483
- msgPayload: Uint8Array,
484
- msgDirection: RaftCommsMsgTypeCode,
485
- msgProtocol: RaftCommsMsgProtocol,
486
- isNumbered: boolean,
487
- ): Uint8Array {
488
- // Header
489
- const msgBuf = new Uint8Array(
490
- msgPayload.length + RICSERIAL_PAYLOAD_POS,
491
- );
492
- msgBuf[RICSERIAL_MSG_NUM_POS] = isNumbered ? this._currentMsgNumber & 0xff : 0;
493
- msgBuf[RICSERIAL_PROTOCOL_POS] = (msgDirection << 6) + msgProtocol;
494
-
495
- // Payload
496
- msgBuf.set(msgPayload, RICSERIAL_PAYLOAD_POS);
497
-
498
- // Return framed message
499
- return msgBuf;
500
- }
501
-
502
- bridgeCommsMsg(
503
- msgBuf: Uint8Array,
504
- bridgeID: number
505
- ) {
506
- //
507
- const bridgedMsg = new Uint8Array(msgBuf.length + RICREST_BRIDGE_PAYLOAD_POS);
508
-
509
- // Bridged messages are unnumbered (msgNum == 0)
510
- bridgedMsg[RICSERIAL_MSG_NUM_POS] = 0;
511
- bridgedMsg[RICSERIAL_PROTOCOL_POS] = (RaftCommsMsgTypeCode.MSG_TYPE_COMMAND << 6) + RaftCommsMsgProtocol.MSG_PROTOCOL_BRIDGE_RICREST;
512
- bridgedMsg[RICREST_BRIDGE_ID_POS] = bridgeID;
513
- bridgedMsg.set(msgBuf, RICREST_BRIDGE_PAYLOAD_POS);
514
- return bridgedMsg;
515
- }
516
-
517
- msgTrackingTxCmdMsg<T>(
518
- msgFrame: Uint8Array,
519
- withResponse: boolean,
520
- bridgeID: number | undefined = undefined,
521
- msgTimeoutMs: number | undefined,
522
- resolve: (arg: T) => void,
523
- reject: (reason: Error) => void,
524
- ): void {
525
- // Record message re-use of number
526
- if (this._msgTrackInfos[this._currentMsgNumber].msgOutstanding) {
527
- this._commsStats.recordMsgNumCollision();
528
- }
529
- // Set tracking info
530
- this._msgTrackInfos[this._currentMsgNumber].set(
531
- true,
532
- msgFrame,
533
- withResponse,
534
- bridgeID,
535
- this._currentMsgHandle,
536
- msgTimeoutMs,
537
- resolve,
538
- reject,
539
- );
540
-
541
- // Debug
542
- RaftLog.debug(
543
- `msgTrackingTxCmdMsg msgNum ${this._currentMsgNumber} bridgeID ${bridgeID} msg ${
544
- RaftUtils.bufferToHex(msgFrame)} msgOutstanding ${this._msgTrackInfos[this._currentMsgNumber].msgOutstanding
545
- }`,
546
- );
547
-
548
- // Stats
549
- this._commsStats.msgTx();
550
-
551
- // Bump msg number
552
- if (this._currentMsgNumber == RaftMsgTrackInfo.MAX_MSG_NUM) {
553
- this._currentMsgNumber = 1;
554
- } else {
555
- this._currentMsgNumber++;
556
- }
557
- }
558
-
559
- msgTrackingRxRespMsg(
560
- msgNum: number,
561
- msgRsltCode: RaftMsgResultCode,
562
- msgRsltJsonObj: object,
563
- ) {
564
- // Check message number
565
- if (msgNum == 0) {
566
- // Callback on unnumbered message
567
- if (this._msgResultHandler !== null)
568
- this._msgResultHandler.onRxUnnumberedMsg(msgRsltJsonObj);
569
- return;
570
- }
571
- if (msgNum > RaftMsgTrackInfo.MAX_MSG_NUM) {
572
- RaftLog.warn('msgTrackingRxRespMsg msgNum > 255');
573
- return;
574
- }
575
- if (!this._msgTrackInfos[msgNum].msgOutstanding) {
576
- RaftLog.warn(`msgTrackingRxRespMsg unmatched msgNum ${msgNum}`);
577
- this._commsStats.recordMsgNumUnmatched();
578
- return;
579
- }
580
-
581
- // Handle message
582
- RaftLog.verbose(
583
- `msgTrackingRxRespMsg Message response received msgNum ${msgNum}`,
584
- );
585
- this._commsStats.recordMsgResp(
586
- Date.now() - this._msgTrackInfos[msgNum].msgSentMs,
587
- );
588
- this._msgCompleted(msgNum, msgRsltCode, msgRsltJsonObj);
589
- }
590
-
591
- _msgCompleted(
592
- msgNum: number,
593
- msgRsltCode: RaftMsgResultCode,
594
- msgRsltObj: object | null,
595
- ) {
596
-
597
- // Lookup message in tracking
598
- const msgHandle = this._msgTrackInfos[msgNum].msgHandle;
599
- this._msgTrackInfos[msgNum].msgOutstanding = false;
600
-
601
- // Check if message result handler should be informed
602
- if (this._msgResultHandler !== null) {
603
- this._msgResultHandler.onRxReply(msgHandle, msgRsltCode, msgRsltObj);
604
- }
605
-
606
- // Handle reply
607
- // if (msgRsltCode === RaftMsgResultCode.MESSAGE_RESULT_OK) {
608
- const resolve = this._msgTrackInfos[msgNum].resolve;
609
- if (resolve) {
610
- RaftLog.verbose(`_msgCompleted msgNum ${msgNum} result ${msgRsltCode.toString()} ${JSON.stringify(msgRsltObj)}`);
611
- (resolve as ((arg: object | null) => void))(msgRsltObj);
612
- }
613
- // } else {
614
- // const reject = this._msgTrackInfos[msgNum].reject;
615
- // if (reject) {
616
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any
617
- // try {
618
- // RaftLog.debug(`_msgCompleted reject rsltCode ${msgRsltCode}`);
619
- // // (reject as any)(new Error(`Message failed msgNum ${msgNum} rslt ${msgRsltCode}`));
620
- // } catch (excp: unknown) {
621
- // RaftLog.warn(`_msgCompleted reject ${excp}`);
622
- // }
623
- // }
624
- // }
625
-
626
- // No longer waiting for reply
627
- this._msgTrackInfos[msgNum].resolve = null;
628
- this._msgTrackInfos[msgNum].reject = null;
629
- }
630
-
631
- // Check message timeouts
632
- async _onMsgTrackTimer(chainRecall: boolean): Promise<void> {
633
-
634
- if (this._msgSender !== null) {
635
- // Handle message tracking
636
- for (let loopIdx = 0; loopIdx < this._msgTrackInfos.length; loopIdx++) {
637
-
638
- // Index to check
639
- const checkIdx = this._msgTrackLastCheckIdx;
640
- this._msgTrackLastCheckIdx = (checkIdx + 1) % this._msgTrackInfos.length;
641
-
642
- // Check if message is outstanding
643
- if (!this._msgTrackInfos[checkIdx].msgOutstanding) continue;
644
-
645
- // Get message timeout and ensure valid
646
- let msgTimeoutMs = this._msgTrackInfos[checkIdx].msgTimeoutMs;
647
- if (msgTimeoutMs === undefined) {
648
- msgTimeoutMs = RaftMsgTrackInfo.MSG_RESPONSE_TIMEOUT_MS;
649
- }
650
-
651
- // Check for timeout (or never sent)
652
- if ((this._msgTrackInfos[checkIdx].retryCount === 0) || (Date.now() > this._msgTrackInfos[checkIdx].msgSentMs + (msgTimeoutMs * (this._msgTrackInfos[checkIdx].retryCount)))) {
653
-
654
- // Debug
655
- RaftLog.verbose(`msgTrackTimer msgNum ${checkIdx} ${this._msgTrackInfos[checkIdx].retryCount === 0 ? 'first send' : 'timeout - retrying'} ${RaftUtils.bufferToHex(this._msgTrackInfos[checkIdx].msgFrame)}`);
656
- // RaftLog.verbose(`msgTrackTimer msg ${RaftUtils.bufferToHex(this._msgTrackInfos[i].msgFrame)}`);
657
-
658
- // Handle timeout (or first send)
659
- if (this._msgTrackInfos[checkIdx].retryCount < RaftMsgTrackInfo.MSG_RETRY_COUNT) {
660
- this._msgTrackInfos[checkIdx].retryCount++;
661
- try {
662
-
663
- // Send the message
664
- if (!await this._msgSender.sendTxMsg(
665
- this._msgTrackInfos[checkIdx].msgFrame,
666
- this._msgTrackInfos[checkIdx].withResponse)) {
667
- RaftLog.warn(`msgTrackTimer Message send failed msgNum ${checkIdx} ${RaftUtils.bufferToHex(this._msgTrackInfos[checkIdx].msgFrame)}`);
668
- this._msgCompleted(checkIdx, RaftMsgResultCode.MESSAGE_RESULT_FAIL, null);
669
- this._commsStats.recordMsgNoConnection();
670
- }
671
-
672
- // Message sent ok so break here
673
- break;
674
-
675
- } catch (error: unknown) {
676
- RaftLog.warn(`Retry message failed ${error}`);
677
- }
678
- this._commsStats.recordMsgRetry();
679
- this._msgTrackInfos[checkIdx].msgSentMs = Date.now();
680
- } else {
681
- RaftLog.warn(
682
- `msgTrackTimer TIMEOUT msgNum ${checkIdx} after ${RaftMsgTrackInfo.MSG_RETRY_COUNT} retries ${RaftUtils.bufferToHex(this._msgTrackInfos[checkIdx].msgFrame)}`,
683
- );
684
- this._msgCompleted(checkIdx, RaftMsgResultCode.MESSAGE_RESULT_TIMEOUT, null);
685
- this._commsStats.recordMsgTimeout();
686
- }
687
- }
688
- }
689
- }
690
-
691
- // Call again if required
692
- if (chainRecall) {
693
- setTimeout(async () => {
694
- this._onMsgTrackTimer(true);
695
- }, this._msgTrackTimerMs);
696
- }
697
- }
698
-
699
- encodeFileStreamBlock(blockContents: Uint8Array,
700
- blockStart: number,
701
- streamID: number): Uint8Array {
702
- // Create entire message buffer (including protocol wrappers)
703
- const msgBuf = new Uint8Array(
704
- blockContents.length + 4 + RICREST_HEADER_PAYLOAD_POS + RICSERIAL_PAYLOAD_POS,
705
- );
706
- let msgBufPos = 0;
707
-
708
- // RICSERIAL protocol
709
- msgBuf[msgBufPos++] = 0; // not numbered
710
- msgBuf[msgBufPos++] =
711
- (RaftCommsMsgTypeCode.MSG_TYPE_COMMAND << 6) +
712
- RaftCommsMsgProtocol.MSG_PROTOCOL_RICREST;
713
-
714
- // RICREST protocol
715
- msgBuf[msgBufPos++] = RICRESTElemCode.RICREST_ELEM_CODE_FILEBLOCK;
716
-
717
- // Header
718
- msgBuf[msgBufPos++] = streamID & 0xff;
719
- msgBuf[msgBufPos++] = (blockStart >> 16) & 0xff;
720
- msgBuf[msgBufPos++] = (blockStart >> 8) & 0xff;
721
- msgBuf[msgBufPos++] = blockStart & 0xff;
722
-
723
- // Copy block info
724
- msgBuf.set(blockContents, msgBufPos);
725
- return msgBuf;
726
- }
727
-
728
- async sendFileBlock(
729
- blockContents: Uint8Array,
730
- blockStart: number
731
- ): Promise<boolean> {
732
- const msgBuf = this.encodeFileStreamBlock(blockContents, blockStart, 0);
733
-
734
- // // Debug
735
- // RaftLog.debug(
736
- // `sendFileBlock frameLen ${msgBuf.length} start ${blockStart} end ${blockEnd} len ${blockLen}`,
737
- // );
738
-
739
- // Send
740
- try {
741
- // Send
742
- if (this._msgSender) {
743
-
744
- // Wrap into HDLC
745
- const framedMsg = this._miniHDLC.encode(msgBuf);
746
-
747
- // Send
748
- return this._msgSender.sendTxMsg(
749
- framedMsg,
750
- true,
751
- // Platform.OS === 'ios',
752
- );
753
- }
754
- } catch (error: unknown) {
755
- RaftLog.warn(`RaftMsgHandler sendFileBlock error${error}`);
756
- }
757
- return false;
758
- }
759
-
760
- async sendStreamBlock(
761
- blockContents: Uint8Array,
762
- blockStart: number,
763
- streamID: number,
764
- ): Promise<boolean> {
765
-
766
- // Ensure any waiting messages are sent first
767
- await this._onMsgTrackTimer(false);
768
-
769
- // Encode message
770
- const msgBuf = this.encodeFileStreamBlock(blockContents, blockStart, streamID);
771
-
772
- // // Debug
773
- // RaftLog.debug(
774
- // `sendStreamBlock frameLen ${msgBuf.length} start ${blockStart} end ${blockEnd} len ${blockLen}`,
775
- // );
776
-
777
- // Send
778
- try {
779
- // Send
780
- if (this._msgSender) {
781
-
782
- // Wrap into HDLC
783
- const framedMsg = this._miniHDLC.encode(msgBuf);
784
-
785
- // Send
786
- return await this._msgSender.sendTxMsg(
787
- framedMsg,
788
- true,
789
- // Platform.OS === 'ios',
790
- );
791
- }
792
- } catch (error: unknown) {
793
- RaftLog.warn(`RaftMsgHandler sendStreamBlock error${error}`);
794
- }
795
- return false;
796
- }
797
-
798
- async createCommsBridge(bridgeSource: string, bridgeName: string, idleCloseSecs = 0): Promise<RaftBridgeSetupResp> {
799
-
800
- // Establish a bridge
801
- return await this.sendRICRESTURL<RaftBridgeSetupResp>(
802
- `commandserial/bridge/setup?port=${bridgeSource}&name=${bridgeName}&idleCloseSecs=${idleCloseSecs}`,
803
- )
804
- }
805
-
806
- async removeCommsBridge(bridgeID: number): Promise<boolean> {
807
-
808
- // Remove a bridge
809
- return await this.sendRICRESTURL<boolean>(
810
- `commandserial/bridge/remove?id=${bridgeID}`,
811
- )
812
- }
813
- }