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

gatts/sd: [WIP] allow placing attribute values in user RAM #105

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

dmlambea
Copy link

This PR targets issue #104

This PR is Work in Progress: still need to find a platform-compatible way of determining
whether an attribute value must be located in stack or in user RAM for SoftDevice targets.

Currently, the algorithm works this way: if a characteristics' config
has an attribute value with length greater than zero, the value is set
to be placed in user RAM; otherwise, in stack.

This is a breaking change, since previous software written with non-zero
lengths attrib. values will not be aware that using user RAM instead of
the stack forces them to lock that RAM, i.e., the memory must be reserved
for the lifetime of the attribute. There should be an option for specifying
what attribute will go to RAM and what will go to stack, defaulting to stack,
but introducing new members in the CharacteristicsConfig struct will make
the source incompatible with targets other than SoftDevice.

WIP: still need to find a platform-compatible way of determining whether
an attribute value must be located in stack or in user RAM for SoftDevice
targets.

Currently, the algorithm works this way: if a characteristics' config
has an attribute value with length greater than zero, the value is set
to be placed in user RAM; otherwise, in stack.

This is a breaking change, since previous software written with non-zero
lengths attrib. values will not be aware that using user RAM instead of
the stack forces them to lock that RAM, i.e., the memory must be reserved
for the lifetime of the attribute. There should be an option for specifying
what attribute will go to RAM and what will go to stack, defaulting to stack,
but introducing new members in the CharacteristicsConfig struct will make
the source incompatible with targets other than SoftDevice.
@dmlambea
Copy link
Author

Thinking about making this PR backwards-compatible, we could extend the public API with a kind of "platform-specific" configuration block. For example, adding a map[string]interface{} for defining extra parameters with significance only to the platform able to read it.

...
cfg := bluetooth.CharacteristicConfig{
   Handle: ... ,
   Value: ... ,
   Params: make(map[string]interface{}),
}
cfg.Params["nrfValueLocation"] = "stack"
...

The gatts_sd would interpret that parameter while other modules would ignore it. All current and previous software (which are not defining the Params map) would work, since the special parameters would come empty (nil).

Params is a tentative name, so feel free to propose a better one if you like this enhancement proposal.

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.

None yet

1 participant