Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue #729 and use Buffer rather than string for CIRAChannel's s… #732

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

orinem
Copy link
Contributor

@orinem orinem commented Nov 17, 2022

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable
  • All commented code has been removed - NOT YET

What are you changing?

Fix issue #729 by ensuring UTF8 encoding isn't lost before going on the wire.
Renders issue #662 moot as Content-Length is used instead of chunked encoding.

Anything the reviewer should know when reviewing this PR?

Work in progress! The is experimental code. It does not appear to have broken anything, though occasionally adding alarm instances fails for unknown reasons with the device reporting invalid xml. A silly level log message has been added to try to catch this case.

Other SendXXX functions in APFProcessor could possibly benefit from building the buffer in place as was required in SendChannelData.

Added "SendPendingData" to replace essentially identical code that appeared in three places.

The fix for decoding UTF8 from the device is very inefficient.

@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #732 (006e72d) into main (2be2aed) will increase coverage by 0.26%.
The diff coverage is 100.00%.

❗ Current head 006e72d differs from pull request most recent head 5d3066c. Consider uploading reports for the commit 5d3066c to get more accurate results

@@            Coverage Diff             @@
##             main     #732      +/-   ##
==========================================
+ Coverage   93.38%   93.65%   +0.26%     
==========================================
  Files          78       78              
  Lines        3295     3293       -2     
  Branches      532      527       -5     
==========================================
+ Hits         3077     3084       +7     
+ Misses        218      209       -9     
Impacted Files Coverage Δ
src/amt/APFProcessor.ts 99.73% <100.00%> (+<0.01%) ⬆️
src/amt/CIRAChannel.ts 94.28% <100.00%> (+10.74%) ⬆️
src/amt/HttpHandler.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@orinem orinem force-pushed the issue_729 branch 2 times, most recently from 4c1d642 to 458c356 Compare November 18, 2022 00:18
@matt-primrose matt-primrose linked an issue Nov 18, 2022 that may be closed by this pull request
@orinem
Copy link
Contributor Author

orinem commented Nov 18, 2022

This does make the construction of the SendChannelData packet inconsistent with the other packets.

However, the change has the advantage that the test's calculation of the expected data is no longer a duplication of the same code as it's still using string functions.

…ng for CIRAChannel's sendBuffer

Added test for CIRAChannel writeData() binary path
Copy link
Member

@matt-primrose matt-primrose left a comment

Choose a reason for hiding this comment

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

Tested on my local setup and buffer changes don't seem to have any issues over the CIRA channel.

@matt-primrose matt-primrose merged commit de565d1 into open-amt-cloud-toolkit:main Nov 22, 2022
@orinem orinem deleted the issue_729 branch November 30, 2022 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants