I don’t know about something official.
But you can try a simple code below.
For example click HERE
#include "mbed.h" //MbedOS 6.9 Nucleo-F303RE
#include "KVStore.h"
#include "kvstore_global_api.h"
#include <string>
/*A serial monitor is required (tested with Termite 3.4)*/
#define DEBUG 1
int main()
{
debug_if(DEBUG, "Hello from Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
thread_sleep_for(500);
char str[5];
char kv_key[] = {"/kv/key"};
char kv_value[5];
kv_info_t info;
while(true){
debug_if(DEBUG, "Please, enter a value! - five-digit \n");
scanf("%5s",str);
debug_if(DEBUG, "Your value is %s!\n", str);
kv_get_info(kv_key, &info);
kv_get(kv_key, kv_value, info.size, 0);
bool check = true;
for(int i=0;str[i]!='\0';i++){
if(str[i]!=kv_value[i]) check = false;
}
if(check){
debug_if(DEBUG, "This value is already stored!\n");
}else{
debug_if(DEBUG, "Saving new value\n");
kv_set(kv_key, str, strlen(str), 0);
}
}
}
BR, Jan