Re: Bluetooth: about using of NVS & setting Layer in single App
laczenJMS
Hi Vikrant,
toggle quoted messageShow quoted text
The dts changes you propose might work, but there are some disadvantages with it: if you are overlapping the scratch area with NVS you will loose the data in NVS persistent storage after FOTA. I guess this is related to your problem on using persistent storage with btmesh. According to me the best way to use persistent storage in combination with "btsettings" is to use "btsettings" to store and retrieve your persistent variables. I don't have the time at the moment to write a complete example but I can give you some guidelines: Suppose we need to store a variable named: VID, and its value is VID_VALUE. The values will be stored under "bt/ps". We will need to define routines to apply the data at startup from flash: this is a set routine. Other routines that we could define are export (to save the data) and commit (to apply the data). For simplicity I will only describe the case where there is only a set routine and storage will be done directly. Registering the routines is done by: BT_SETTINGS_DEFINE(ps, ps_set, NULL, NULL): this will define a routine ps_set that will be called if a variable is found under "bt/ps" (e.g. "bt/ps/VID"). The routine ps_set itself is something like: static int ps_set(int argc, char **argv, char *val) { if (argc!=1) { return -EINVAL; } if (strcmp(argv[0],"VID")==0) { len = sizeof(VID_VALUE); err = settings_bytes_from_str(val, VID_VALUE, &len); } } This routine will be called at startup and when VID is found under "bt/ps" its value will be used to update VID_VALUE. To store the variable you have to call two routines : str = settings_str_from_bytes(&VID_VALUE, sizeof(VID_VALUE), buf, sizeof(buf)); settings_save_one("bt/ps/VID", str); The used buffer is a char array that can be defined as: char buf[BT_SETTINGS_SIZE(sizeof(VID_VALUE))]; Op ma 24 sep. 2018 om 10:36 schreef Vikrant More <vikrant8051@...>:
|
|