Add ability to choose connection protocol (TCP/UDP) #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature: Protocol Selection
This pull request introduces the ability for users to choose the connection protocol (TCP or UDP) when using the ZKLib package. This enhancement provides greater flexibility and control over device communication.
Changes Made:
ZKLibconstructor to accept an optionalprotocolparameter.preferredProtocolproperty to store the user's protocol preference.setProtocolmethod to allow changing the protocol after instantiation.createSocketmethod to respect thepreferredProtocolsetting.New Functionality:
Users can now specify their preferred protocol in three ways:
Example usage:
Testing:
Tested TCP-only, UDP-only, and auto modes with a compatible device.
Verified that the setProtocol method correctly updates the preferred protocol.
Ensured backwards compatibility with existing usage patterns.
Potential Impacts:
This change is backwards compatible and should not affect existing implementations.
Users who explicitly want to use TCP or UDP can now do so without modifying the package internals.
Documentation:
TODO: Update README.md to include information about the new protocol selection feature.
Next Steps:
If approved, we should update the package documentation to reflect this new feature.
Consider adding more comprehensive tests for different protocol scenarios.
I welcome any feedback or suggestions for improvement on this implementation.