I just noticed that when I just programmed the 20736S I'm using now, the return value of bleprofile_ReadNVRAM() is 0. I get the same value if some form of read error occurred. Now I have the problem that I have to be able to detect the read error and act differently compared to the case where NVRAM has not been written yet.
One avenue I'm thinking about is using some battery buffered register to store the configuration state. There are some RTCs out there in the wild that offer that possibility and you have this most intriguing set of functions called mia_xyzKeepstateN(). Please let me know whether I can use them for this purpose or whether they serve some different function.
mia_xyzKeepstateN() only provides 32 bits (of which keep state 0, bit 0 is reserved, leaving the app 31 bits) of storage in deep sleep/hid-off. Anything stored here will be lost on power cycle (unlike with a real NV store). So you can do something like this:
void app_enter_deep_sleep(UINT 8 keep_this)
// Store value in keep state 1 and ender deep sleep.
// Enter deep sleep here using your favorite mechanism.
// Do some app init here.
// Then read keep state register to see what was stored before entering deep sleep and
// do something.
// Do something if 1 was stored by app_enter_deep_sleep before entering deep sleep last time.