Make Serial and TCP interfaces more closely respect connectNow when false#857
Open
Travis-L-R wants to merge 7 commits intomeshtastic:masterfrom
Open
Make Serial and TCP interfaces more closely respect connectNow when false#857Travis-L-R wants to merge 7 commits intomeshtastic:masterfrom
Travis-L-R wants to merge 7 commits intomeshtastic:masterfrom
Conversation
added 6 commits
November 11, 2025 18:57
Contributor
|
I think this looks good as long as pylint etc. can be made happy. Thanks for the PR! |
Author
|
Thanks, pylint is complaining here over the use of type() instead of isinstance(), but using isinstance() would defeat the purpose of checking that it's a StreamInterface object and not a class that inherits from it. So I've added a pylint disable flag in 1214d50 Ideally StreamInterface would be made a proper abstract class, but that'd need a more significant refactor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
When the connectNow parameter to StreamInterface's init() method is True, it will also call connect() during init(). Then connect() starts a thread for receiving data and starts the process of pulling config info from the node.
The issue
When using classes that inherit from StreamInterface it should be possible to instantiate an interface but not "connectNow" and then later call connect() to create a connection.
Currently, when connectNow is false:
Commit 2245ac8 moves the connection parts of SerialInterface's init() method out into a separate connect() method that does its bit and then calls connect() from StreamInterface (and which won't be called during init() if connectNow is false).
Commit 76418b8 similarly adds a connect() method that calls TCPInterface's myConnect() first before calling connect() from StreamInterface.
The other commits are incidental cleanups. f3f17a7 and 3be73b4 get rid of some variables that are already better declared elsewhere. 79334e8 and 040f332 tidy up the way that the use of StreamInterface in a non-abstract way is blocked, by changing how that is checked for and issuing a RuntimeError instead of a generic exception (with a corresponding test case change).
These changes shouldn't break anything, except perhaps if anyone is already using a workaround for the issue in separate apps.