Skip to content

Add a global AppIdService to the application architecture#231

Open
J0EK3R wants to merge 9 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/AppIdService
Open

Add a global AppIdService to the application architecture#231
J0EK3R wants to merge 9 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/AppIdService

Conversation

@J0EK3R

@J0EK3R J0EK3R commented Jun 11, 2026

Copy link
Copy Markdown

As I discovered while reverse‑engineering the JIESTAR devices, the bytes at positions [1, 2] in their datagrams represent an ApplicationIdentifier.

Since JIESTAR and MouldKing devices share the same datagram structure, MouldKing also uses these two bytes as an ApplicationIdentifier.

With this PR, I introduced a global AppIdService, which generates a random ApplicationID on first use and persists it via the PreferencesService.

CaDA, MouldKing, and JIESTAR now all rely on this shared AppIdService.

@J0EK3R J0EK3R force-pushed the merge/vicocz/AppIdService branch from 77a6abc to 2d562db Compare June 11, 2026 10:20
@J0EK3R J0EK3R marked this pull request as ready for review June 11, 2026 11:58
@vicocz vicocz requested review from Copilot and vicocz June 12, 2026 20:19

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

This PR introduces a single, app-global Application Identifier service that is persisted via PreferencesService, and wires CaDA, MouldKing, and JIESTAR to use this shared AppId source (instead of vendor-specific persistence/logic).

Changes:

  • Added IAppIdentifierService + AppIdentifierService that generates/persists a random app identifier and can serve variable-length prefixes.
  • Refactored CaDA and JIESTAR device managers to pull their AppID from the shared service.
  • Updated MouldKing architecture so devices can receive an app-wide AppID (via IMouldKingDeviceManager) and patch telegram bytes [1] and [2]; updated/added tests accordingly.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
BrickController2/BrickController2/UI/Services/AppIdentifier/IAppIdentifierService.cs New interface for requesting an AppID prefix of a given length.
BrickController2/BrickController2/UI/Services/AppIdentifier/AppIdentifierService.cs New global AppID implementation backed by IPreferencesService.
BrickController2/BrickController2/UI/DI/UiModule.cs Registers AppIdentifierService as a singleton in UI DI.
BrickController2/BrickController2/DeviceManagement/CaDA/CaDADeviceManager.cs Switches CaDA to use the shared AppID and removes vendor-specific persistence.
BrickController2/BrickController2/DeviceManagement/JieStar/JieStarDeviceManager.cs Switches JIESTAR to use the shared AppID and removes vendor-specific persistence.
BrickController2/BrickController2/DeviceManagement/MouldKing/IMouldKingDeviceManager.cs New interface to expose the MouldKing AppID to devices.
BrickController2/BrickController2/DeviceManagement/MouldKing/MouldKingDeviceManager.cs Uses shared AppID and exposes it via IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MouldKing.cs Registers MouldKing device manager as IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MKBaseNibble.cs Patches appId bytes into connect/base telegrams via IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MKBaseByte.cs Patches appId bytes into connect/base telegrams via IMouldKingDeviceManager.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK3_8.cs Updates ctor signature to pass IMouldKingDeviceManager to base.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK4.cs Updates ctor signature to pass IMouldKingDeviceManager to base.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK5.cs Updates ctor signature to pass IMouldKingDeviceManager to base.
BrickController2/BrickController2/DeviceManagement/MouldKing/MK6.cs Updates ctor signature to pass IMouldKingDeviceManager to base.
BrickController2/BrickController2.Tests/DeviceManagement/CaDA/CaDADeviceManagerTests.cs Updates tests to use shared AppID preferences key + service.
BrickController2/BrickController2.Tests/DeviceManagement/MouldKing/MouldKingDeviceManagerTests.cs Updates tests for new DI requirements and adds AppID assertion.
BrickController2/BrickController2.Tests/DeviceManagement/JieStar/JieStarDeviceManagerTests.cs New test verifying JIESTAR uses the shared AppID.
BrickController2/BrickController2.Tests/DeviceManagement/DI/VendorBuilderTests.cs Extends DI tests to register new required manager interfaces for device construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

J0EK3R and others added 2 commits June 13, 2026 05:39
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants