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

Refactor get/set/del/hasSetting #2048

Merged
merged 34 commits into from
Jan 20, 2020
Merged

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Dec 9, 2019

  • change...Setting(key, index, default) ->...Setting({key, index}, default) via helper struct. Normal ...Setting without index works the same
  • getSetting will deduce return type from defaultValue. Empty default will return String, special treatment for const char*. bool is no longer .toInt() == 1, but getSetting("key", false). getSetting("key") does not specialize.
    The general idea for this approach is to have conversion functions specialised in a single place.
  • continue with configuration prototypes, move WIFI1_..., WIFI2_... etc. into methods (preserving flash-string status)
  • directly use defined wifi settings. webui now knows about built-in settings and wont allow deletion (since the setting will come back anyway. previously, on boot. now, right after reload callback)
  • cleanup type narrowing in for-loops

Migrate part is still a tricky one, since modules will know better about which types of settings are used and which ones are not. Keeping in mind that defines are still there, module itself can generate current configuration and provide it to user, so it is not required to overwrite any settings like that.

Latest update also adds conversion template struct override to provide custom conversion functions.
One way is to specialise existing settings_convert_t based on settings_internals.h examples. Another one is to provide a second argument to getSetting<..., TConvert> template. Not sure that the last option is strictly needed right now, but I wonder if some special conversions can be covered by that. For example, wifi sleep or secure client settings.

@mcspr
Copy link
Collaborator Author

mcspr commented Jan 17, 2020

It feels like migrate configuration block needs to go completely. It is easier to track settings recording per-module instead of per-board and it will manage defaults without having each board duplicate getSetting({blah, index}, _default(index))

Also added wifi management without overwriting settings:
https://gitter.im/tinkerman-cat/espurna?at=5e1c26270aba1f0d80263391

@mcspr mcspr changed the title WIP: refactor get/set/del/hasSetting Refactor get/set/del/hasSetting Jan 20, 2020
@mcspr mcspr merged commit 298ce8c into xoseperez:dev Jan 20, 2020
@mcspr mcspr deleted the settings/typed-defauts branch January 20, 2020 13:39
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.

1 participant