You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Pritish Gandhi <pr...@aylanetworks.com> on 2017/04/14 16:24:49 UTC

Question regarding config system in myNewt OS

Hi All,
Probably a dumb question, but is there a way to delete or remove config
name-value pairs from config?
I'm using conf_save_one() to save single name-value pairs to config. But I
couldn't find a similar function to remove them. I wonder whether, since
I'm using the append only fcb system, I would have to write another special
name-value pair to mark it deleted. I would've assumed config_fcb to handle
that for me.

I also noticed that conf_save_one() retains the old value if I save a
STRING name-value pair with the strlen(value) == 0. The way I'm working
around this is to set the value string to "(null)" and when I read a
"(null)" from the config system I just memset my string to 0x0s.

Comments on these are much appreciated.
Thanks,
Pritish

Re: Question regarding config system in myNewt OS

Posted by Pritish Gandhi <pr...@aylanetworks.com>.
Hey Marko,
No I was literally setting it to a string "(null)". I will try what you
recommend and just set the value ptr I pass in to NULL.
Thanks for the quick reply,
Pritish

On Fri, Apr 14, 2017 at 11:32 AM, marko kiiskila <ma...@runtime.io> wrote:

> Hi Pritish,
>
> not a dumb question! Delete is meant to happen if you pass NULL as the
> value.
> When reading the config back, seeing NULL means that value was deleted.
> I.e. the ‘workaround' is exactly how your config handler should behave :)
>
> Alas, I was meant to write documentation about this, but never ended
> up finishing it.
>
> > On Apr 14, 2017, at 9:24 AM, Pritish Gandhi <pr...@aylanetworks.com>
> wrote:
> >
> > Hi All,
> > Probably a dumb question, but is there a way to delete or remove config
> > name-value pairs from config?
> > I'm using conf_save_one() to save single name-value pairs to config. But
> I
> > couldn't find a similar function to remove them. I wonder whether, since
> > I'm using the append only fcb system, I would have to write another
> special
> > name-value pair to mark it deleted. I would've assumed config_fcb to
> handle
> > that for me.
> >
> > I also noticed that conf_save_one() retains the old value if I save a
> > STRING name-value pair with the strlen(value) == 0. The way I'm working
> > around this is to set the value string to "(null)" and when I read a
> > "(null)" from the config system I just memset my string to 0x0s.
> >
> > Comments on these are much appreciated.
> > Thanks,
> > Pritish
>
>

Re: Question regarding config system in myNewt OS

Posted by marko kiiskila <ma...@runtime.io>.
Hi Pritish,

not a dumb question! Delete is meant to happen if you pass NULL as the value.
When reading the config back, seeing NULL means that value was deleted.
I.e. the ‘workaround' is exactly how your config handler should behave :)

Alas, I was meant to write documentation about this, but never ended
up finishing it.

> On Apr 14, 2017, at 9:24 AM, Pritish Gandhi <pr...@aylanetworks.com> wrote:
> 
> Hi All,
> Probably a dumb question, but is there a way to delete or remove config
> name-value pairs from config?
> I'm using conf_save_one() to save single name-value pairs to config. But I
> couldn't find a similar function to remove them. I wonder whether, since
> I'm using the append only fcb system, I would have to write another special
> name-value pair to mark it deleted. I would've assumed config_fcb to handle
> that for me.
> 
> I also noticed that conf_save_one() retains the old value if I save a
> STRING name-value pair with the strlen(value) == 0. The way I'm working
> around this is to set the value string to "(null)" and when I read a
> "(null)" from the config system I just memset my string to 0x0s.
> 
> Comments on these are much appreciated.
> Thanks,
> Pritish