I confirmed that the code below works correction on 0.4.7 but stopped working with 0.4.9. It appears that 0.4.9 has affected the way retained variables work
I had been using the back up ram via retained variables on a photon running successfully for a week. Then today I flashed the photon and now retained variables are no longer working. No matter what I try the values are no longer retained...
I simplified the code to:
STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));
retained int value;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(value);
Spark.publish("message-1",String(value),60,PRIVATE); delay(1000);
value = 20;
Serial.println(value);
Spark.publish("message-2",String(value),60,PRIVATE); delay(5000);
delay(1000); // Give the serial TX buffer a chance to empty
System.sleep(SLEEP_MODE_DEEP, 10);
}
Thanks for reporting this. We’ve identified and resolved the issue. Please recompile and flash your application to get the fix. The fix does not affect system firmware - only the application code needs to be flashed.
Yes, there was a bug introduced in 0.4.8 that was fixed for 0.4.9, so I believe this is what’s causing the issue on the electron, which is based on 0.4.8. We will be posting a new release in a few weeks, if not sooner.
In the meantime,you could try building using the local toolchain.
sorry, had some issues compiling the firmware. When uploading user-firmware.bin or application.bin, the electron goes into magenta-breathing recovery mode,…
flashed the same binaries (system-part1.bin, system-part2.bin and application.bin) again over serial and voila! Backup RAM works now! (using F/W 0.4.9)