@robdobsn/raftjs 1.10.7 → 1.11.6

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 (89) hide show
  1. package/dist/react-native/RaftAttributeHandler.js +11 -9
  2. package/dist/react-native/RaftAttributeHandler.js.map +1 -1
  3. package/dist/react-native/RaftChannelSimulated.js +4 -3
  4. package/dist/react-native/RaftChannelSimulated.js.map +1 -1
  5. package/dist/react-native/RaftConnector.d.ts +10 -1
  6. package/dist/react-native/RaftConnector.js +23 -10
  7. package/dist/react-native/RaftConnector.js.map +1 -1
  8. package/dist/react-native/RaftDeviceManager.d.ts +14 -2
  9. package/dist/react-native/RaftDeviceManager.js +224 -77
  10. package/dist/react-native/RaftDeviceManager.js.map +1 -1
  11. package/dist/react-native/RaftDeviceMgrIF.d.ts +5 -1
  12. package/dist/react-native/RaftDeviceStates.d.ts +21 -3
  13. package/dist/react-native/RaftDeviceStates.js +31 -6
  14. package/dist/react-native/RaftDeviceStates.js.map +1 -1
  15. package/dist/react-native/RaftPublish.d.ts +2 -0
  16. package/dist/react-native/RaftPublish.js +81 -0
  17. package/dist/react-native/RaftPublish.js.map +1 -0
  18. package/dist/react-native/RaftStreamHandler.d.ts +11 -0
  19. package/dist/react-native/RaftStreamHandler.js +66 -0
  20. package/dist/react-native/RaftStreamHandler.js.map +1 -1
  21. package/dist/react-native/RaftStruct.d.ts +2 -2
  22. package/dist/react-native/RaftStruct.js +97 -26
  23. package/dist/react-native/RaftStruct.js.map +1 -1
  24. package/dist/react-native/RaftSystemUtils.d.ts +17 -1
  25. package/dist/react-native/RaftSystemUtils.js +51 -0
  26. package/dist/react-native/RaftSystemUtils.js.map +1 -1
  27. package/dist/react-native/RaftTypes.d.ts +21 -0
  28. package/dist/react-native/RaftTypes.js.map +1 -1
  29. package/dist/react-native/main.d.ts +1 -0
  30. package/dist/react-native/main.js +1 -0
  31. package/dist/react-native/main.js.map +1 -1
  32. package/dist/web/RaftAttributeHandler.js +11 -9
  33. package/dist/web/RaftAttributeHandler.js.map +1 -1
  34. package/dist/web/RaftChannelSimulated.js +4 -3
  35. package/dist/web/RaftChannelSimulated.js.map +1 -1
  36. package/dist/web/RaftConnector.d.ts +10 -1
  37. package/dist/web/RaftConnector.js +23 -10
  38. package/dist/web/RaftConnector.js.map +1 -1
  39. package/dist/web/RaftDeviceManager.d.ts +14 -2
  40. package/dist/web/RaftDeviceManager.js +224 -77
  41. package/dist/web/RaftDeviceManager.js.map +1 -1
  42. package/dist/web/RaftDeviceMgrIF.d.ts +5 -1
  43. package/dist/web/RaftDeviceStates.d.ts +21 -3
  44. package/dist/web/RaftDeviceStates.js +31 -6
  45. package/dist/web/RaftDeviceStates.js.map +1 -1
  46. package/dist/web/RaftPublish.d.ts +2 -0
  47. package/dist/web/RaftPublish.js +81 -0
  48. package/dist/web/RaftPublish.js.map +1 -0
  49. package/dist/web/RaftStreamHandler.d.ts +11 -0
  50. package/dist/web/RaftStreamHandler.js +66 -0
  51. package/dist/web/RaftStreamHandler.js.map +1 -1
  52. package/dist/web/RaftStruct.d.ts +2 -2
  53. package/dist/web/RaftStruct.js +97 -26
  54. package/dist/web/RaftStruct.js.map +1 -1
  55. package/dist/web/RaftSystemUtils.d.ts +17 -1
  56. package/dist/web/RaftSystemUtils.js +51 -0
  57. package/dist/web/RaftSystemUtils.js.map +1 -1
  58. package/dist/web/RaftTypes.d.ts +21 -0
  59. package/dist/web/RaftTypes.js.map +1 -1
  60. package/dist/web/main.d.ts +1 -0
  61. package/dist/web/main.js +1 -0
  62. package/dist/web/main.js.map +1 -1
  63. package/examples/dashboard/package.json +1 -1
  64. package/examples/dashboard/src/DeviceActionsForm.tsx +2 -2
  65. package/examples/dashboard/src/DeviceLineChart.tsx +16 -3
  66. package/examples/dashboard/src/DevicePanel.tsx +79 -3
  67. package/examples/dashboard/src/DeviceStatsPanel.tsx +76 -0
  68. package/examples/dashboard/src/DevicesPanel.tsx +11 -0
  69. package/examples/dashboard/src/SettingsScreen.tsx +9 -4
  70. package/examples/dashboard/src/SystemTypeCog/CogStateInfo.ts +10 -2
  71. package/examples/dashboard/src/SystemTypeCog/SystemTypeCog.ts +37 -3
  72. package/examples/dashboard/src/SystemTypeGeneric/StateInfoGeneric.ts +10 -2
  73. package/examples/dashboard/src/SystemTypeGeneric/SystemTypeGeneric.ts +38 -4
  74. package/examples/dashboard/src/SystemTypeMarty/RICStateInfo.ts +10 -2
  75. package/examples/dashboard/src/styles.css +162 -0
  76. package/package.json +52 -49
  77. package/src/RaftAttributeHandler.ts +25 -22
  78. package/src/RaftChannelSimulated.ts +4 -3
  79. package/src/RaftConnector.ts +34 -13
  80. package/src/RaftDeviceManager.ts +253 -83
  81. package/src/RaftDeviceMgrIF.ts +5 -1
  82. package/src/RaftDeviceStates.ts +42 -8
  83. package/src/RaftPublish.ts +92 -0
  84. package/src/RaftStreamHandler.ts +84 -1
  85. package/src/RaftStruct.test.ts +229 -0
  86. package/src/RaftStruct.ts +101 -37
  87. package/src/RaftSystemUtils.ts +59 -0
  88. package/src/RaftTypes.ts +27 -0
  89. package/src/main.ts +1 -0
@@ -14,7 +14,7 @@ import RaftChannelWebSocket from "./RaftChannelWebSocket";
14
14
  import RaftChannelWebSerial from "./RaftChannelWebSerial";
15
15
  import RaftChannelSimulated from "./RaftChannelSimulated";
16
16
  import RaftCommsStats from "./RaftCommsStats";
17
- import { RaftEventFn, RaftOKFail, RaftFileSendType, RaftFileDownloadResult, RaftProgressCBType, RaftBridgeSetupResp, RaftFileDownloadFn, RaftReportMsg } from "./RaftTypes";
17
+ import { RaftEventFn, RaftOKFail, RaftFileSendType, RaftFileDownloadResult, RaftProgressCBType, RaftStreamDataProgressCBType, RaftBridgeSetupResp, RaftFileDownloadFn, RaftReportMsg } from "./RaftTypes";
18
18
  import RaftSystemUtils from "./RaftSystemUtils";
19
19
  import RaftFileHandler from "./RaftFileHandler";
20
20
  import RaftStreamHandler from "./RaftStreamHandler";
@@ -282,18 +282,7 @@ export default class RaftConnector {
282
282
  // Store locator
283
283
  this._channelConnLocator = locator;
284
284
 
285
- // Get system type
286
- if (this._getSystemTypeCB) {
287
- // Get system type
288
- this._systemType = await this._getSystemTypeCB(this._raftSystemUtils);
289
-
290
- // Set defaults
291
- if (this._systemType && this._systemType.defaultWiFiHostname) {
292
- this._raftSystemUtils.setDefaultWiFiHostname(this._systemType.defaultWiFiHostname);
293
- }
294
- }
295
-
296
- // Connect
285
+ // Connect channel first (system type resolution needs a live connection)
297
286
  let connOk = false;
298
287
  try {
299
288
  // Event
@@ -307,6 +296,16 @@ export default class RaftConnector {
307
296
 
308
297
  if (connOk) {
309
298
 
299
+ // Resolve system type now that the channel is connected
300
+ if (this._getSystemTypeCB) {
301
+ this._systemType = await this._getSystemTypeCB(this._raftSystemUtils);
302
+
303
+ // Set defaults
304
+ if (this._systemType && this._systemType.defaultWiFiHostname) {
305
+ this._raftSystemUtils.setDefaultWiFiHostname(this._systemType.defaultWiFiHostname);
306
+ }
307
+ }
308
+
310
309
  // Setup system type
311
310
  if (this._systemType) {
312
311
  this._systemType.setup(this._raftSystemUtils, this._onEventFn);
@@ -478,6 +477,28 @@ export default class RaftConnector {
478
477
 
479
478
  // Mark: Streaming --------------------------------------------------------------------------------
480
479
 
480
+ /**
481
+ * streamData - stream arbitrary data to a named firmware endpoint using the RT_STREAM protocol.
482
+ * @param streamContents data to stream
483
+ * @param fileName logical filename sent in ufStart (e.g. "pattern.thr")
484
+ * @param targetEndpoint REST API endpoint name on the firmware (e.g. "streampattern")
485
+ * @param progressCallback optional (sent, total, progress) callback
486
+ * @returns Promise<boolean> true on success
487
+ */
488
+ async streamData(
489
+ streamContents: Uint8Array,
490
+ fileName: string,
491
+ targetEndpoint: string,
492
+ progressCallback?: RaftStreamDataProgressCBType,
493
+ ): Promise<boolean> {
494
+ if (this._raftStreamHandler && this.isConnected()) {
495
+ return this._raftStreamHandler.streamData(
496
+ streamContents, fileName, targetEndpoint, progressCallback,
497
+ );
498
+ }
499
+ return false;
500
+ }
501
+
481
502
  /**
482
503
  * streamAudio - stream audio
483
504
  * @param streamContents audio data