Skip to content

Refactor device reset logic and improve disconnect handling - #256

Merged
vicocz merged 2 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/FixDisconnectDevice
Aug 1, 2026
Merged

Refactor device reset logic and improve disconnect handling#256
vicocz merged 2 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/FixDisconnectDevice

Conversation

@J0EK3R

@J0EK3R J0EK3R commented Jul 30, 2026

Copy link
Copy Markdown

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.

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.
@J0EK3R

J0EK3R commented Jul 30, 2026

Copy link
Copy Markdown
Author

My suggestion to fix #255

@vicocz

vicocz commented Jul 30, 2026

Copy link
Copy Markdown
Owner

My suggestion to fix #255

That's exactly what I meant by my comment in #240

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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() in JieStarBase, MKBaseByte, and MKBaseNibble, and uses it from InitDevice() / DisconnectDevice().
  • Updates BluetoothAdvertisingDevice disconnect flow to call DisconnectDevice() 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.

Comment thread BrickController2/BrickController2/DeviceManagement/BluetoothAdvertisingDevice.cs Outdated
Moved DisconnectDevice() call before awaiting StopOutputTaskAsync and TryDisconnectAsync. Removed explicit assignment of DeviceState = Disconnected; to improve disconnection sequence and state management.
@vicocz
vicocz merged commit 9e6bf28 into vicocz:default Aug 1, 2026
2 of 4 checks passed
@J0EK3R

J0EK3R commented Aug 1, 2026

Copy link
Copy Markdown
Author

Thank you :)

@J0EK3R
J0EK3R deleted the merge/vicocz/FixDisconnectDevice branch August 1, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants