motion-master-client 0.0.246 → 0.0.248

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.
@@ -2057,7 +2057,7 @@ class MotionMasterReqResClient {
2057
2057
  * @param deviceRef The reference to the device on which the command will be executed.
2058
2058
  * @param command The command to be executed, represented as a Uint8Array.
2059
2059
  * @param commandTimeout The maximum time allowed for the command to complete.
2060
- * @param responsePollingInterval The interval (in milliseconds) for polling the command response. Defaults to 1000ms.
2060
+ * @param responsePollingInterval The interval (in milliseconds) for polling the command response.
2061
2061
  * @param osCommandMode Specifies whether the next OS command should run immediately after the current one or abort the current command. Sets the OS Command Mode. Defaults to false.
2062
2062
  * @param fsBufferContent If true, the content of the fs-buffer will be read and assigned to the `fsBuffer` property of {@link OsCommandResponse}. If a Uint8Array is provided, the content will be written to the fs-buffer file. If undefined, only the OS command will be executed, and its response will be read and parsed.
2063
2063
  * @returns An observable of type T, which extends {@link OsCommandResponse}, representing the result of the command execution.
@@ -2081,7 +2081,7 @@ class MotionMasterReqResClient {
2081
2081
  ? rxjs_1.EMPTY
2082
2082
  : (0, rxjs_1.timer)(responsePollingInterval),
2083
2083
  }))).pipe((0, operators_1.takeUntil)((0, rxjs_1.timer)(commandTimeout).pipe((0, operators_1.mergeMap)(() => (0, rxjs_1.throwError)(() => new Error(`A timeout has occurred for the OS command ${JSON.stringify(command)} on device ${deviceRef}.`))))), (0, operators_1.filter)(os_command_1.isOsCommandResponse), (0, operators_1.mergeMap)((response) => {
2084
- if (fsBufferContent === true) {
2084
+ if (response.request === 'succeeded' && fsBufferContent === true) {
2085
2085
  return this.getFile(deviceRef, 'fs-buffer', 20000).pipe((0, operators_1.map)((value) => {
2086
2086
  response.fsBuffer = value;
2087
2087
  return response;
@@ -2512,12 +2512,12 @@ class MotionMasterReqResClient {
2512
2512
  * @param deviceRef - The reference to the device to which the command will be sent.
2513
2513
  * @param index - The index of the SMM parameter to read.
2514
2514
  * @param subindex - The subindex of the SMM parameter to read. Defaults to 0.
2515
- * @param commandTimeout - The timeout for the command in milliseconds. Defaults to 10,000 ms (10 seconds).
2516
- * @param responsePollingInterval - The interval between polling attempts for a response in milliseconds. Defaults to 100 ms.
2515
+ * @param commandTimeout - The timeout for the command in milliseconds.
2516
+ * @param responsePollingInterval - The interval between polling attempts for a response in milliseconds.
2517
2517
  *
2518
2518
  * @returns An observable that emits the response from the command once it is received.
2519
2519
  */
2520
- readSmmParameter(deviceRef, index, subindex = 0, commandTimeout = 10000, responsePollingInterval = 100) {
2520
+ readSmmParameter(deviceRef, index, subindex = 0, commandTimeout = 5000, responsePollingInterval = 500) {
2521
2521
  const command = (0, os_command_1.createSmmAcyclicHandlerReadSmmParameterOsCommand)(index, subindex);
2522
2522
  return this.runOsCommandAndReadFsBuffer(deviceRef, command, commandTimeout, responsePollingInterval, os_command_1.OsCommandMode.EXECUTE_THE_NEXT_COMMAND_IMMEDIATELY);
2523
2523
  }
@@ -2592,7 +2592,7 @@ class MotionMasterReqResClient {
2592
2592
  }));
2593
2593
  }
2594
2594
  /**
2595
- * Reads the SMM firmware version from a device.
2595
+ * Reads the SMM firmware version from a device as an array of bytes.
2596
2596
  *
2597
2597
  * This method reads the firmware version (MCU Software Version 0x0001:00) of the device as an array of numbers.
2598
2598
  * The first byte represents the minor version, and the second byte represents the major version.
@@ -2604,6 +2604,43 @@ class MotionMasterReqResClient {
2604
2604
  readSmmFirmareVersion(deviceRef) {
2605
2605
  return this.readSmmParameterArrayValue(deviceRef, 0x0001, 0);
2606
2606
  }
2607
+ /**
2608
+ * Reads the SMM firmware version from a device as a number.
2609
+ *
2610
+ * This function retrieves a specific parameter from the device's SMM memory
2611
+ * and interprets the result as a 16-bit version number.
2612
+ *
2613
+ * @param deviceRef - A reference to the target device.
2614
+ * @returns An `Observable<number>` emitting the firmware version, represented as an integer.
2615
+ */
2616
+ readSmmFirmareVersionAsNumber(deviceRef) {
2617
+ return this.readSmmFirmareVersion(deviceRef).pipe((0, operators_1.map)((bytes) => (bytes[1] << 8) | bytes[0]));
2618
+ }
2619
+ /**
2620
+ * Resolves the SMM parameter structure version for the specified device based on its firmware version.
2621
+ *
2622
+ * @param deviceRef - The reference to the target device.
2623
+ *
2624
+ * @returns An Observable that emits the appropriate SMM parameter structure version:
2625
+ * - 0x0041 for firmware versions below 2.3 (0x0203).
2626
+ * - 0x0203 for firmware versions 2.3 (0x0203) and above.
2627
+ *
2628
+ * @remarks
2629
+ * - The function first reads the firmware version of the device.
2630
+ * - Based on the firmware version, it returns the corresponding parameter structure version:
2631
+ * - If the firmware version is less than 0x0203, the parameter structure version is 0x0041.
2632
+ * - If the firmware version is 0x0203 or greater, the parameter structure version is 0x0203.
2633
+ */
2634
+ resolveSmmParameterStructureVersion(deviceRef) {
2635
+ return this.readSmmFirmareVersionAsNumber(deviceRef).pipe((0, operators_1.map)((version) => {
2636
+ if (version < 0x0203) {
2637
+ return 0x0041;
2638
+ }
2639
+ else {
2640
+ return 0x0203;
2641
+ }
2642
+ }));
2643
+ }
2607
2644
  /**
2608
2645
  * Reads the SMM serial number from a device.
2609
2646
  *
@@ -2668,16 +2705,18 @@ class MotionMasterReqResClient {
2668
2705
  * @param deviceRef - The reference to the device to which the login command will be sent.
2669
2706
  * @param username - The optional username used for logging in to the SMM. If not provided, it will be treated as an empty string.
2670
2707
  * @param password - The password used for logging in to the SMM.
2708
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2709
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2671
2710
  *
2672
2711
  * @returns An observable that emits a boolean value indicating whether the login attempt succeeded.
2673
2712
  *
2674
2713
  * @remarks
2675
2714
  * If the device is already logged in, the next login attempt will fail unless the user logs out first.
2676
2715
  */
2677
- loginToSmmForParameterDownload(deviceRef, username, password) {
2716
+ loginToSmmForParameterDownload(deviceRef, username, password, commandTimeout = 5000, responsePollingInterval = 500) {
2678
2717
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.PARAMETER_DOWNLOAD_LOGIN);
2679
2718
  const content = (0, smm_1.packSmmCredentials)(username, password);
2680
- return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2719
+ return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2681
2720
  }
2682
2721
  /**
2683
2722
  * Logs into the SMM for software update with the provided credentials.
@@ -2689,16 +2728,18 @@ class MotionMasterReqResClient {
2689
2728
  * @param deviceRef - The reference to the device to which the login command will be sent.
2690
2729
  * @param username - The optional username used for logging in to the SMM. If not provided, it will be treated as an empty string.
2691
2730
  * @param password - The password used for logging in to the SMM.
2731
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2732
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2692
2733
  *
2693
2734
  * @returns An observable that emits a boolean value indicating whether the login attempt succeeded.
2694
2735
  *
2695
2736
  * @remarks
2696
2737
  * If the device is already logged in, the next login attempt will fail unless the user logs out first.
2697
2738
  */
2698
- loginToSmmForSoftwareUpdate(deviceRef, username, password) {
2739
+ loginToSmmForSoftwareUpdate(deviceRef, username, password, commandTimeout = 5000, responsePollingInterval = 500) {
2699
2740
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.SOFTWARE_UPDATE_LOGIN);
2700
2741
  const content = (0, smm_1.packSmmCredentials)(username, password);
2701
- return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2742
+ return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2702
2743
  }
2703
2744
  /**
2704
2745
  * Logs out from the SMM.
@@ -2707,12 +2748,14 @@ class MotionMasterReqResClient {
2707
2748
  * is successful and `false` otherwise. The command times out after 10 seconds if no response is received.
2708
2749
  *
2709
2750
  * @param deviceRef - The reference to the device to which the logout command will be sent.
2751
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2752
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2710
2753
  *
2711
2754
  * @returns An observable that emits a boolean value indicating whether the logout attempt succeeded.
2712
2755
  */
2713
- logoutFromSmm(deviceRef) {
2756
+ logoutFromSmm(deviceRef, commandTimeout = 5000, responsePollingInterval = 500) {
2714
2757
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.LOGOUT);
2715
- return this.runOsCommand(deviceRef, command, 10000, 100).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2758
+ return this.runOsCommand(deviceRef, command, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2716
2759
  }
2717
2760
  /**
2718
2761
  * Logs out from the SMM and then logs back in with the provided credentials for parameter download.
@@ -2724,16 +2767,36 @@ class MotionMasterReqResClient {
2724
2767
  * @param deviceRef - The reference to the device to which the logout and login commands will be sent.
2725
2768
  * @param username - The username used for logging in to the SMM.
2726
2769
  * @param password - The password used for logging in to the SMM.
2770
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2771
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2727
2772
  *
2728
2773
  * @returns An observable that emits a boolean value indicating whether the relogin attempt succeeded.
2729
2774
  */
2730
- reloginToSmmForParameterDownload(deviceRef, username, password) {
2731
- return (0, rxjs_1.concat)(this.logoutFromSmm(deviceRef), this.loginToSmmForParameterDownload(deviceRef, username, password)).pipe((0, operators_1.last)());
2775
+ reloginToSmmForParameterDownload(deviceRef, username, password, commandTimeout = 5000, responsePollingInterval = 500) {
2776
+ return this.logoutFromSmm(deviceRef, commandTimeout, responsePollingInterval).pipe((0, operators_1.mergeMap)((succeeded) => succeeded
2777
+ ? this.loginToSmmForParameterDownload(deviceRef, username, password, commandTimeout, responsePollingInterval)
2778
+ : (0, rxjs_1.of)(false)));
2732
2779
  }
2733
- changeSmmPassword(deviceRef, oldPassword, newPassword) {
2780
+ /**
2781
+ * Changes the SMM password for the specified device.
2782
+ *
2783
+ * @param deviceRef - A reference to the target device.
2784
+ * @param oldPassword - The current SMM password.
2785
+ * @param newPassword - The new password to set for the SMM.
2786
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2787
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2788
+ * @returns An Observable that emits `true` if the password change and SMM restart succeed, otherwise `false`.
2789
+ *
2790
+ * @remarks
2791
+ * A prior successful login is required before changing the password.
2792
+ * The new password must be at least 4 characters long.
2793
+ *
2794
+ * This function sends an acyclic command to update the password. If successful, it triggers an SMM restart.
2795
+ */
2796
+ changeSmmPassword(deviceRef, oldPassword, newPassword, commandTimeout = 5000, responsePollingInterval = 500) {
2734
2797
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.CHANGE_PASSWORD);
2735
2798
  const content = (0, smm_1.packSmmChangePassword)(newPassword, oldPassword);
2736
- return (0, rxjs_1.concat)((0, rxjs_1.defer)(() => this.runOsCommandAndWriteFsBuffer(deviceRef, command, content).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'))), (0, rxjs_1.defer)(() => this.triggerSmmRestart(deviceRef))).pipe((0, operators_1.last)());
2799
+ return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'), (0, operators_1.mergeMap)((succeeded) => (succeeded ? this.triggerSmmRestart(deviceRef) : (0, rxjs_1.of)(false))));
2737
2800
  }
2738
2801
  /**
2739
2802
  * Triggers a restart for the specified device.
@@ -2742,12 +2805,12 @@ class MotionMasterReqResClient {
2742
2805
  * The method will return `true` if the restart was successful, otherwise `false`.
2743
2806
  *
2744
2807
  * @param deviceRef - The reference to the device to restart.
2745
- * @param commandTimeout - The timeout in milliseconds for the command to complete. Default is 10000ms (10 seconds).
2746
- * @param responsePollingInterval - The interval in milliseconds between polling for the response. Default is 100ms.
2808
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2809
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2747
2810
  *
2748
2811
  * @returns An Observable that emits `true` if the restart was successful, or `false` otherwise.
2749
2812
  */
2750
- triggerSmmRestart(deviceRef, commandTimeout = 10000, responsePollingInterval = 100) {
2813
+ triggerSmmRestart(deviceRef, commandTimeout = 5000, responsePollingInterval = 500) {
2751
2814
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.TRIGGER_RESTART);
2752
2815
  return this.runOsCommand(deviceRef, command, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2753
2816
  }
@@ -2758,12 +2821,12 @@ class MotionMasterReqResClient {
2758
2821
  * The method will return `true` if the acknowledgment was successful, otherwise `false`.
2759
2822
  *
2760
2823
  * @param deviceRef - The reference to the device to acknowledge the I/O failure on.
2761
- * @param commandTimeout - The timeout in milliseconds for the command to complete. Default is 10000ms (10 seconds).
2762
- * @param responsePollingInterval - The interval in milliseconds between polling for the response. Default is 100ms.
2824
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2825
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2763
2826
  *
2764
2827
  * @returns An Observable that emits `true` if the acknowledgment was successful, or `false` otherwise.
2765
2828
  */
2766
- acknowledgeIoFailureOnSmm(deviceRef, commandTimeout = 10000, responsePollingInterval = 100) {
2829
+ acknowledgeIoFailureOnSmm(deviceRef, commandTimeout = 5000, responsePollingInterval = 500) {
2767
2830
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.IO_FAILURE_ACKNOWLEDGE);
2768
2831
  return this.runOsCommand(deviceRef, command, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2769
2832
  }
@@ -2790,41 +2853,164 @@ class MotionMasterReqResClient {
2790
2853
  observables.push((0, rxjs_1.defer)(() => this.runOsCommandAndWriteFsBuffer(deviceRef, finalizeSoftwareUpdateCommand, packedCrc).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'))), (0, rxjs_1.defer)(() => this.triggerSmmRestart(deviceRef)));
2791
2854
  return (0, rxjs_1.concat)(...observables);
2792
2855
  }
2793
- transmitSmmParameters(deviceRef, parameters, version = 0x0041) {
2794
- const values = parameters.map((p) => p.value);
2856
+ /**
2857
+ * Transmits SMM parameters to the specified device.
2858
+ *
2859
+ * @param deviceRef - The reference to the target device.
2860
+ * @param values - An array of data values to transmit.
2861
+ * @param parameterStructureVersion - The version of the parameter structure (default: 0x0041).
2862
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2863
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2864
+ *
2865
+ * @returns An Observable that emits `true` if the operation succeeds, or `false` if it fails, the `values` array is empty.
2866
+ *
2867
+ * @remarks
2868
+ * - If the `values` array is empty, the function immediately returns `false`.
2869
+ * - The `version` is prepended to the values array before packing.
2870
+ * - The function constructs an OS command for transmitting the parameters and writes the packed buffer to the fs-buffer file.
2871
+ */
2872
+ transmitSmmParameters(deviceRef, values, parameterStructureVersion = 0x0041, commandTimeout = 5000, responsePollingInterval = 500) {
2873
+ if (values.length === 0) {
2874
+ return (0, rxjs_1.of)(false);
2875
+ }
2795
2876
  // usedParameterStructVersion: 1st byte is major version, 2nd byte is minor version (0x0028 -> 0.40)
2796
- values.unshift(version);
2877
+ values.unshift(parameterStructureVersion);
2797
2878
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.TRANSMIT_PARAMETERS);
2798
2879
  const { buffer: content } = (0, smm_1.packSmmParameterValues)(values);
2799
- return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2880
+ return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2800
2881
  }
2801
- loadSmmParametersForVerification(deviceRef) {
2882
+ /**
2883
+ * Loads the SMM parameters for verification on the specified device.
2884
+ *
2885
+ * This method sends a command to the device to load the SMM parameters for verification and waits for the response.
2886
+ * The device returns a buffer with all bits inverted. The OS command will invert the bits and reconstruct the buffer
2887
+ * into valid parameter values, which are then returned in sequence within the OS command response.
2888
+ *
2889
+ * @param deviceRef - The reference to the device from which the parameters should be loaded.
2890
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2891
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2892
+ * @returns An Observable that emits the response from the device, containing the valid parameter values for verification
2893
+ * after the buffer is processed and reconstructed.
2894
+ *
2895
+ * @throws Will throw an error if the command fails or times out.
2896
+ */
2897
+ loadSmmParametersForVerification(deviceRef, commandTimeout = 5000, responsePollingInterval = 500) {
2802
2898
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.LOAD_PARAMETERS_FOR_VERIFICATION);
2803
- return this.runOsCommandAndReadFsBuffer(deviceRef, command, 5000, 1000);
2899
+ return this.runOsCommandAndReadFsBuffer(deviceRef, command, commandTimeout, responsePollingInterval);
2804
2900
  }
2805
- loadSmmParametersForVerificationAndUnpack(deviceRef) {
2806
- return this.loadSmmParametersForVerification(deviceRef).pipe((0, operators_1.map)((response) => {
2807
- if (!response.fsBuffer) {
2808
- throw new Error('Reading loading SMM parameters for verification. The response buffer is empty.');
2809
- }
2810
- const values = Uint8Array.from(response.fsBuffer).map((byte) => byte ^ 0xff);
2811
- return (0, smm_1.unpackSmmParameterValues)(values);
2812
- }));
2813
- }
2814
- verifySmmParameters(deviceRef, parameters, groupOrdinal) {
2815
- const values = parameters.map((p) => p.value);
2816
- const { buffer: content } = (0, smm_1.calcSmmBitmask)(values, groupOrdinal);
2901
+ /**
2902
+ * Verifies a group of SMM parameters for the specified device.
2903
+ *
2904
+ * This function calculates a bitmask from the provided values and group ordinal,
2905
+ * then sends an SMM OS command (subcommand VERIFY_PARAMETERS) along with the bitmask content
2906
+ * via `fs-buffer` to the device for verification.
2907
+ *
2908
+ * @param deviceRef - A reference to the target device.
2909
+ * @param values - An array of parameter values to verify.
2910
+ * @param groupIndex - The verification group index used for bitmask calculation.
2911
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2912
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2913
+ * @returns An `Observable<boolean>` that emits `true` if the verification succeeded, or `false` otherwise.
2914
+ *
2915
+ * @remarks
2916
+ * This function requires parameters to be previously loaded for verification to succeed. If parameters are not preloaded, the verification will fail.
2917
+ * The same group can be verified multiple times without causing an error.
2918
+ */
2919
+ verifySmmParameters(deviceRef, values, groupIndex, commandTimeout = 5000, responsePollingInterval = 500) {
2920
+ const { buffer: content } = (0, smm_1.packSmmParameterValuesForVerification)(values, groupIndex);
2817
2921
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.VERIFY_PARAMETERS);
2818
- return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2922
+ return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2819
2923
  }
2820
- loadSmmValidationFile(deviceRef) {
2924
+ /**
2925
+ * Loads the SMM validation file on the specified device.
2926
+ *
2927
+ * @param deviceRef - A reference to the target device.
2928
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2929
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2930
+ * @returns An Observable emitting the OS command response.
2931
+ *
2932
+ * @remarks
2933
+ * This function should only be called **after all parameter groups have been successfully verified**.
2934
+ */
2935
+ loadSmmValidationFile(deviceRef, commandTimeout = 5000, responsePollingInterval = 500) {
2821
2936
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.LOAD_VALIDATION_FILE);
2822
- return this.runOsCommand(deviceRef, command, 5000, 100);
2937
+ return this.runOsCommand(deviceRef, command, commandTimeout, responsePollingInterval);
2823
2938
  }
2824
- validateSmmConfiguration(deviceRef, report, date, username, password) {
2939
+ /**
2940
+ * Loads the SMM validation file and then retrieves the safety parameters report file.
2941
+ *
2942
+ * @param deviceRef - A reference to the target device.
2943
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2944
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2945
+ * @returns An Observable emitting the decoded content of the `.safety_parameters_report` file.
2946
+ *
2947
+ * @throws An error if loading the validation file fails.
2948
+ *
2949
+ * @remarks
2950
+ * This function should only be called **after all parameter groups have been successfully verified**.
2951
+ */
2952
+ loadSmmValidationFileAndReadSafetyParametersReportFile(deviceRef, commandTimeout = 5000, responsePollingInterval = 500) {
2953
+ return this.loadSmmValidationFile(deviceRef, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.mergeMap)((response) => {
2954
+ if (response.request !== 'succeeded') {
2955
+ throw new Error('Failed to load the validation file.');
2956
+ }
2957
+ return this.getDecodedFile(deviceRef, '.safety_parameters_report');
2958
+ }));
2959
+ }
2960
+ /**
2961
+ * Validates the SMM configuration on the specified device.
2962
+ *
2963
+ * @param deviceRef - The reference to the target device.
2964
+ * @param report - A `Uint8Array` representing the validation report data.
2965
+ * @param date - The date associated with the validation.
2966
+ * @param username - The username used for authentication.
2967
+ * @param password - The password used for authentication.
2968
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2969
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2970
+ *
2971
+ * @returns An Observable that emits `true` if the configuration validation succeeds, or `false` if it fails.
2972
+ *
2973
+ * @remarks
2974
+ * - Packs the validation report, date, username, and password into a buffer.
2975
+ * - Constructs an OS command using the `VALIDATE_CONFIGURATION` subcommand.
2976
+ * - Sends the command to the device and writes the packed buffer to the fs-buffer file.
2977
+ * - **Important:** Once the configuration is successfully validated, subsequent calls to this function will fail. To revalidate, the user must go through the verification process again.
2978
+ */
2979
+ validateSmmConfiguration(deviceRef, report, date, username, password, commandTimeout = 5000, responsePollingInterval = 500) {
2825
2980
  const { buffer: content } = (0, smm_1.packSmmValidationReport)(report, date, username, password);
2826
2981
  const command = (0, os_command_1.createSmmAcyclicHandlerOsCommand)(os_command_1.SmmAcyclicHandlerSubcommandId.VALIDATE_CONFIGURATION);
2827
- return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2982
+ return this.runOsCommandAndWriteFsBuffer(deviceRef, command, content, commandTimeout, responsePollingInterval).pipe((0, operators_1.last)(), (0, operators_1.map)((response) => response.request === 'succeeded'));
2983
+ }
2984
+ /**
2985
+ * Reads the safety parameters report from the device and validates the SMM configuration.
2986
+ *
2987
+ * @param deviceRef - The reference to the target device.
2988
+ * @param date - The date associated with the validation.
2989
+ * @param username - The username used for authentication.
2990
+ * @param password - The password used for authentication.
2991
+ * @param commandTimeout - The timeout in milliseconds for the command to complete.
2992
+ * @param responsePollingInterval - The interval in milliseconds between polling for the response.
2993
+ *
2994
+ * @returns An Observable that emits `true` if the SMM configuration is successfully validated, or `false` if validation fails.
2995
+ *
2996
+ * @throws An error if the `.safety_parameters_report` file is missing.
2997
+ *
2998
+ * @remarks
2999
+ * - The function attempts to retrieve the `.safety_parameters_report` file from the device.
3000
+ * - If the file is missing, an error is thrown.
3001
+ * - The file content is read into a `Uint8Array` and passed to `validateSmmConfiguration`.
3002
+ * - The SMM configuration validation follows the same behavior as `validateSmmConfiguration`:
3003
+ * - If validation succeeds, subsequent calls to this function will fail.
3004
+ * - To revalidate, the user must repeat the verification process.
3005
+ */
3006
+ readSafetyParametersReportAndValidateSmmConfiguration(deviceRef, date, username, password, commandTimeout = 5000, responsePollingInterval = 500) {
3007
+ return this.getFile(deviceRef, '.safety_parameters_report').pipe((0, operators_1.last)(), (0, operators_1.mergeMap)((file) => {
3008
+ if (!file) {
3009
+ throw new Error("The '.safety_parameters_report' file is missing.");
3010
+ }
3011
+ const report = new Uint8Array(file);
3012
+ return this.validateSmmConfiguration(deviceRef, report, date, username, password, commandTimeout, responsePollingInterval);
3013
+ }));
2828
3014
  }
2829
3015
  }
2830
3016
  exports.MotionMasterReqResClient = MotionMasterReqResClient;