Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key store manager+FileSystem.h simulator #55

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

deuxksix
Copy link
Contributor

@deuxksix deuxksix commented Dec 2, 2024

This PR does two things:

  1. add support of src/system/physical/fileSystem.h in simulator
  2. add abstraction to give everyone access to the common key-value store

Users may discover new static methods in their mode context:

2024-12-02_17-31


There are pointers to the KeyProxy class which describes a typical use case:

2024-12-02_17-32


Others may discover these functionnalities through the basic mode documentation:

2024-12-02_17-33

Note: intentionally, we try to orient users into using the custom ramp & index, more basic & less error-prone!


Other ways to discover direct access to the key-value store system is through its namespace:

2024-12-02_17-34
2024-12-02_17-35


Several remarks:

  1. accessing key / values by "name" hashes the key name on the 31 lower-significant bits, prone to collisions
  2. all other keys starts with a one, with the next 15 bits partitioning the key space in way to avoid collisions
  3. the manager, each group and each mode have all their own uint16_t key space, indexed with enumerations
  4. each space has a storeId serial, used to detect when groups / modes changes, dropping "obsolete" keys
  5. values up to 64 bytes in size are transparently stored on several keys, only when using indexed key spaces

And as a bonus, at last, the lamp now remembers what was its last mode, its ramp value, other favorites, etc

Draft: I still need to validate that everything works on real hardware!

@deuxksix deuxksix changed the title Draft: Key store manager+FileSystem.h simulator Key store manager+FileSystem.h simulator Dec 2, 2024
@deuxksix
Copy link
Contributor Author

deuxksix commented Dec 2, 2024

draft status removed

now tested with a couple issues solved

src/modes/include/hardware/keystore.hpp Outdated Show resolved Hide resolved
src/modes/include/hardware/keystore.hpp Outdated Show resolved Hide resolved
src/modes/include/hardware/keystore.hpp Outdated Show resolved Hide resolved
@BaptisteHudyma
Copy link
Owner

Looks awesome thanks!!!
I will test it on several hardware before merge

@deuxksix
Copy link
Contributor Author

deuxksix commented Dec 3, 2024

rebased +also fixed a bug

Note: it could be cool at some point to have explicit enter_mode / quit_mode / enter_group / quit_group handlers because right now, as there are several ways to enter / quit things (turn on, turn off, next group, next mode, favorite, etc) it's easy to forget to load / save something when writing bugs (see save_ramps called in three distinct places)

@BaptisteHudyma
Copy link
Owner

Tested and approved, congrats <3

@BaptisteHudyma BaptisteHudyma merged commit 501bc1a into BaptisteHudyma:main Dec 3, 2024
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