Refactor device reset logic and improve disconnect handling - #256
Merged
Conversation
Extract repeated channel reset code into ResetAllChannelsToZero methods in JieStarBase, MKBaseByte, and MKBaseNibble. Simplify InitDevice and DisconnectDevice to use the new method. Ensure DisconnectDevice is called during BluetoothAdvertisingDevice disconnect. Fix minor comment typos.
Author
|
My suggestion to fix #255 |
vicocz
approved these changes
Jul 30, 2026
Owner
There was a problem hiding this comment.
Pull request overview
Refactors Bluetooth-advertising device implementations to centralize “reset all channels to zero” logic and ensures device-specific disconnect cleanup is invoked during disconnect, improving consistency of channel reset behavior across device types.
Changes:
- Extracts repeated channel-reset loops into
ResetAllChannelsToZero()inJieStarBase,MKBaseByte, andMKBaseNibble, and uses it fromInitDevice()/DisconnectDevice(). - Updates
BluetoothAdvertisingDevicedisconnect flow to callDisconnectDevice()and fixes a disconnect comment typo. - Adjusts MouldKing byte-based reset to also reset telegram channel bytes as part of the new reset helper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| BrickController2/BrickController2/DeviceManagement/MouldKing/MKBaseNibble.cs | Refactors init/disconnect channel reset into a shared helper. |
| BrickController2/BrickController2/DeviceManagement/MouldKing/MKBaseByte.cs | Refactors init/disconnect reset into a helper and resets base telegram channel bytes. |
| BrickController2/BrickController2/DeviceManagement/JieStar/JieStarBase.cs | Refactors init/disconnect channel reset into a shared helper. |
| BrickController2/BrickController2/DeviceManagement/BluetoothAdvertisingDevice.cs | Calls DisconnectDevice() during disconnect and fixes a typo in a comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Moved DisconnectDevice() call before awaiting StopOutputTaskAsync and TryDisconnectAsync. Removed explicit assignment of DeviceState = Disconnected; to improve disconnection sequence and state management.
Author
|
Thank you :) |
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.
Extract repeated channel reset code into ResetAllChannelsToZero methods in JieStarBase, MKBaseByte, and MKBaseNibble. Simplify InitDevice and DisconnectDevice to use the new method. Ensure DisconnectDevice is called during BluetoothAdvertisingDevice disconnect. Fix minor comment typos.