Implement check of firmware version and flash format procedure
Newer versions of the firmware are weirdly interpreting previous flash storage data with the wrong IDs. This is creating new components in the platform. Currently, the rootcause is not understood and not logic, but upon testing on various devices it's a consistent issue.
As a precaution, we should implement a firmware check based on a flag on EEPROM for the current flash information firmware. This would mean that the kit would check its new configuration against it and it would potentially flash the memory in case of inconsistency.
UPDATE: the rootcause is now clear.
The way the flash memory management stores the sensor IDs is via a static cast of the SensorType enum here:
https://github.com/fablabbcn/smartcitizen-kit-2x/blob/cf73c8ea1831e253b2822cbd5466a4cd98ab7c85/lib/Sensors/Sensors.h#L79
This was never considered to change, but it did in two commits for SCK2.1:
https://github.com/fablabbcn/smartcitizen-kit-2x/commit/01b42f20c4409d5ce4f8f07bf7456ba0e637fa2c https://github.com/fablabbcn/smartcitizen-kit-2x/commit/4f4713a422030d18f32d08336473c032a01c0fe5
With these changes, the ENUM casting also changes, and previous mappings done in the flash memory no longer match to those originally stored. Reverting this commit would provoke all devices currently deployed with newer firmware versions to suffer from the same problem once there is a firmware upgrade.
Therefore, the only "clean" option is to perform a flash format in case there is no agreement in terms of firmware versions with the current version and the one that the flash memory has stored its data with.
Check https://github.com/fablabbcn/smartcitizen-kit-2x/issues/50 if working on flash issues.