Skip to content

Feature/add escape handling for devjson#1430

Merged
ndorin merged 3 commits into
mainfrom
feature/add-escape-handling-for-devjson
Jun 12, 2026
Merged

Feature/add escape handling for devjson#1430
ndorin merged 3 commits into
mainfrom
feature/add-escape-handling-for-devjson

Conversation

@ndorin

@ndorin ndorin commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces enhancements to both device API data handling and the debug websocket server. The most significant changes are improved handling of escape sequences for string and byte array conversions in the device JSON API, and the addition of automatic port forwarding management for the debug websocket server to support connectivity on the CS LAN adapter.

Device JSON API improvements:

  • Added the UnescapeString method in DeviceJsonApi.cs to process escape sequences (like \r, \n, \t, and \xHH) when converting values to string or byte[], ensuring that non-printable ASCII characters are handled correctly during type conversion. [1] [2]
  • Updated ConvertType to use UnescapeString for string and byte[] conversions, improving robustness when handling JSON input with escape sequences.

Debug websocket server enhancements:

  • In DebugSessionRequestHandler.cs, added logic to automatically forward the debug websocket port to the CS LAN adapter when starting the server, improving accessibility for debugging sessions. Handles cases where the CS LAN adapter is not present or errors occur during forwarding.
  • Added corresponding logic to remove the port forwarding entry when stopping the debug websocket server, ensuring clean-up and avoiding lingering port forwards.

@ndorin ndorin self-assigned this Jun 12, 2026
Copilot AI review requested due to automatic review settings June 12, 2026 17:21
@ndorin ndorin added the enhancement New feature or request label Jun 12, 2026
@ndorin ndorin requested a review from jkdevito June 12, 2026 17:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Essentials’ developer tooling by (1) improving DeviceJsonApi type conversion to better handle escaped sequences in string/byte-array parameters, and (2) extending the debug websocket session handler to automatically manage CS LAN port forwarding for easier connectivity.

Changes:

  • Added UnescapeString and updated ConvertType to support escape-sequence processing when converting JSON-provided parameters to string and byte[].
  • Added automatic CS LAN port-forward creation/removal when starting/stopping the debug websocket server.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/PepperDash.Essentials.Core/Web/RequestHandlers/DebugSessionRequestHandler.cs Automatically adds/removes CS LAN port forwarding when debug websocket starts/stops.
src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs Adds escape-sequence processing for parameter conversion to string/byte[].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs
Comment thread src/PepperDash.Essentials.Core/Web/RequestHandlers/DebugSessionRequestHandler.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ndorin ndorin merged commit 72a4c63 into main Jun 12, 2026
2 checks passed
@ndorin ndorin deleted the feature/add-escape-handling-for-devjson branch June 12, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants